:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --border: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --error: #ef4444;
  --success: #22c55e;
  --radius: 8px;
  --youtube: #ef4444;
  --x-post: #a1a1aa;
  --webpage: #3b82f6;
}

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

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.screen-header h1 {
  font-size: 18px;
  font-weight: 600;
}

.screen-content {
  flex: 1;
  padding: 20px;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
}

.screen-content.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
}

.screen-content h1 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--muted);
  margin-bottom: 24px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="url"],
input[type="password"],
input[type="text"] {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  outline: none;
  -webkit-appearance: none;
}

input:focus {
  border-color: var(--primary);
}

input::placeholder {
  color: var(--muted);
}

textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  resize: vertical;
  outline: none;
  -webkit-appearance: none;
}

textarea:focus {
  border-color: var(--primary);
}

textarea::placeholder {
  color: var(--muted);
}

.url-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.url-row input {
  flex: 1;
  background: none;
  border: none;
  padding: 0;
  min-width: 0;
}

.url-row input:focus {
  border-color: transparent;
}

.source-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.source-icon.youtube { color: var(--youtube); }
.source-icon.x-post { color: var(--x-post); }
.source-icon.webpage { color: var(--webpage); }

.token-row {
  display: flex;
  gap: 8px;
}

.token-row input {
  flex: 1;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover, .btn-primary:active {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover, .btn-secondary:active {
  background: var(--border);
}

.btn-ghost {
  background: none;
  color: var(--muted);
}

.btn-ghost:hover, .btn-ghost:active {
  color: var(--text);
}

.btn-icon {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px;
  font-size: 18px;
  line-height: 1;
}

.btn-icon:hover, .btn-icon:active {
  background: var(--border);
}

.btn-full {
  width: 100%;
}

.btn-large {
  padding: 16px 20px;
  font-size: 18px;
  min-height: 56px;
}

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

.error {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius);
  color: var(--error);
  font-size: 14px;
}

.success-text {
  color: var(--success);
  font-size: 24px;
  font-weight: 600;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Safe area for notched devices */
@supports (padding: env(safe-area-inset-top)) {
  .screen-header {
    padding-top: calc(16px + env(safe-area-inset-top));
  }
  .screen-content {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
}
