* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--tg-theme-bg-color, #ffffff);
  color: var(--tg-theme-text-color, #000000);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex: 1;
  padding: 24px 16px 80px;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

h1 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 20px;
}

.input-group {
  margin-bottom: 12px;
}

.input-group input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  border: 1px solid var(--tg-theme-hint-color, #999999);
  border-radius: 12px;
  background-color: var(--tg-theme-secondary-bg-color, #f0f0f0);
  color: var(--tg-theme-text-color, #000000);
  outline: none;
  transition: border-color 0.2s;
}

.input-group input::placeholder {
  color: var(--tg-theme-hint-color, #999999);
}

.input-group input:focus {
  border-color: var(--tg-theme-button-color, #3390ec);
}

.hint {
  font-size: 13px;
  color: var(--tg-theme-hint-color, #999999);
  line-height: 1.4;
  margin-bottom: 20px;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  background-color: var(--tg-theme-button-color, #3390ec);
  color: var(--tg-theme-button-text-color, #ffffff);
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-primary:active {
  opacity: 0.7;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary .spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--tg-theme-button-text-color, #ffffff);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Result messages */
.result-message {
  display: none;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  margin-top: 16px;
  transition: opacity 0.3s;
}

.result-message.visible {
  display: block;
}

.result-message.success {
  background-color: rgba(52, 199, 89, 0.15);
  color: #34c759;
}

.result-message.pending {
  background-color: rgba(255, 204, 0, 0.15);
  color: #cc8800;
}

.result-message.error {
  background-color: rgba(255, 59, 48, 0.15);
  color: #ff3b30;
}

/* Bottom navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background-color: var(--tg-theme-secondary-bg-color, #f0f0f0);
  border-top: 1px solid var(--tg-theme-hint-color, #cccccc);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  font-size: 12px;
  color: var(--tg-theme-hint-color, #999999);
  text-decoration: none;
  transition: color 0.2s;
}

.nav-tab.active {
  color: var(--tg-theme-button-color, #3390ec);
}

.nav-tab svg {
  width: 24px;
  height: 24px;
  margin-bottom: 4px;
}

/* Auth error overlay */
.auth-error {
  display: none;
  flex: 1;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 24px;
  color: var(--tg-theme-hint-color, #999999);
  font-size: 16px;
}

.auth-error.visible {
  display: flex;
}

/* Stub screen */
.stub-message {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: var(--tg-theme-hint-color, #999999);
  font-size: 16px;
}

/* My Sites screen */
.sites-loading {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.sites-loading .spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--tg-theme-hint-color, #999999);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.sites-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: var(--tg-theme-hint-color, #999999);
  font-size: 16px;
  line-height: 1.6;
}

.link-add {
  color: var(--tg-theme-link-color, #3390ec);
  text-decoration: none;
  font-weight: 600;
}

.sites-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.site-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background-color: var(--tg-theme-secondary-bg-color, #f0f0f0);
  border-radius: 12px;
}

.site-info {
  flex: 1;
  min-width: 0;
}

.site-domain {
  font-size: 15px;
  font-weight: 500;
  color: var(--tg-theme-text-color, #000000);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-status {
  font-size: 13px;
  color: var(--tg-theme-hint-color, #999999);
  margin-top: 2px;
}

.status-icon {
  font-size: 11px;
}

.btn-remove {
  margin-left: 12px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--tg-theme-destructive-text-color, #ff3b30);
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s;
}

.btn-remove:active {
  opacity: 0.6;
}

.btn-remove:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Debug mode */
#debug-indicator {
  position: fixed;
  top: 8px;
  right: 8px;
  background-color: rgba(255, 204, 0, 0.9);
  color: #333;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 8px;
  z-index: 9999;
  pointer-events: none;
}

#debug-export {
  position: fixed;
  bottom: 70px;
  right: 12px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background-color: rgba(255, 204, 0, 0.9);
  color: #333;
  cursor: pointer;
  z-index: 9999;
  transition: opacity 0.2s;
}

#debug-export:active {
  opacity: 0.7;
}

#debug-export:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
