/* S1: Design tokens */
:root {
  --bg-base: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #0f172a;
  --border: #334155;
  --border-light: #1e293b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --link: #60a5fa;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-border: #3b82f6;
  --btn-bg: #334155;
  --btn-border: #475569;
  --btn-hover: #475569;
  --success: #166534;
  --error: #991b1b;
  --note: #4ade80;
  --skip-reason: #f97316;
  --skip-bg: #1a1a2e;
  --radius: 4px;
  --radius-lg: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: var(--bg-base); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; line-height: 1.5; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* M8: Skip link */
.skip-link { position: absolute; top: -40px; left: 0; background: var(--primary); color: #fff; padding: 8px 16px; z-index: 200; transition: top 0.2s ease-out; }
.skip-link:focus { top: 0; }

.container { max-width: 1100px; margin: 0 auto; padding: 20px; }
header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; border-bottom: 1px solid var(--border-light); padding-bottom: 16px; }
header h1 { font-size: 20px; font-weight: 600; }
.stats-bar { display: flex; gap: 16px; font-size: 13px; color: var(--text-muted); }
.stats-bar span { background: var(--bg-card); padding: 4px 10px; border-radius: var(--radius); }

/* M5: Mobile header stacking */
@media (max-width: 640px) {
  header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .stats-bar { flex-wrap: wrap; gap: 8px; }
}

.actions-bar { display: flex; gap: 8px; margin-bottom: 16px; align-items: center; }
button { background: var(--btn-bg); color: var(--text); border: 1px solid var(--btn-border); padding: 6px 14px; border-radius: var(--radius); cursor: pointer; font-size: 13px; transition: background 0.15s ease; }
button:hover { background: var(--btn-hover); }
/* S3: Focus visible */
button:focus-visible { outline: 2px solid var(--primary-border); outline-offset: 2px; }
button.primary { background: var(--primary); border-color: var(--primary-border); }
button.primary:hover { background: var(--primary-hover); }

/* Tabs */
.tabs { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tab { background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-muted); padding: 8px 16px; cursor: pointer; font-size: 13px; transition: color 0.15s ease, border-color 0.15s ease; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--primary-border); }

/* S8: Tab content transition */
#candidates { transition: opacity 0.15s ease; }
#candidates.loading { opacity: 0.4; }

/* Cards */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 12px; transition: opacity 0.25s ease; }
/* M3: Card removal animation */
.card.removing { opacity: 0; }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.card-header h3 { font-size: 15px; font-weight: 500; flex: 1; }
/* M2: Keyboard-selected card */
.card.selected { border-color: var(--primary-border); box-shadow: 0 0 0 1px var(--primary-border); }
.meta { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }

/* M1: Question body preview */
.question-body { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; max-height: 60px; overflow: hidden; position: relative; cursor: pointer; padding: 8px; background: rgba(255,255,255,0.02); border-radius: var(--radius); border-left: 2px solid var(--border); }
.question-body.expanded { max-height: none; }
.question-body:not(.expanded)::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 1.5em; background: linear-gradient(transparent, var(--bg-card)); }
.show-more { font-size: 11px; color: var(--text-dim); cursor: pointer; margin-bottom: 4px; }
.show-more:hover { color: var(--text); }

/* S2: Draft text max-height */
.draft-text { background: var(--bg-input); padding: 12px; border-radius: var(--radius); margin: 8px 0; white-space: pre-wrap; font-size: 13px; max-height: 200px; overflow-y: auto; }
.confidence-note { font-size: 12px; color: var(--note); margin-bottom: 8px; font-style: italic; }
.skip-reason { font-size: 12px; color: var(--skip-reason); margin: 8px 0; padding: 8px; background: var(--skip-bg); border-radius: var(--radius); }
.card-actions { display: flex; gap: 8px; margin-top: 12px; }

/* S4: Edit area classes (no inline styles) */
.edit-area { display: none; margin-top: 8px; }
.edit-area.visible { display: block; }
.edit-actions { margin-top: 6px; }

textarea { width: 100%; background: var(--bg-input); color: var(--text); border: 1px solid var(--btn-border); border-radius: var(--radius); padding: 8px; font-family: inherit; font-size: 13px; resize: vertical; min-height: 80px; }
textarea:focus-visible { outline: 2px solid var(--primary-border); outline-offset: -1px; }

.empty { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.loading-placeholder { text-align: center; padding: 40px 20px; color: var(--text-dim); }

/* S7: Toast with animation */
.toast { position: fixed; bottom: 20px; right: 20px; color: #fff; padding: 10px 16px; border-radius: var(--radius-lg); font-size: 13px; z-index: 100; animation: toast-in 0.2s ease-out; }
.toast.success { background: var(--success); }
.toast.error { background: var(--error); }
.toast.fade-out { animation: toast-out 0.3s ease-in forwards; }
@keyframes toast-in { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; } }

.scanning { color: var(--text-muted); font-size: 13px; }

/* M2: Keyboard shortcut hint */
.kbd-hint { font-size: 11px; color: var(--text-dim); margin-left: auto; }
.kbd-hint kbd { background: var(--bg-card); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; font-family: inherit; font-size: 10px; }

/* Inline confirmation */
.confirm-yes { color: #4ade80; font-weight: 600; text-decoration: none; }
.confirm-yes:hover { text-decoration: underline; }
.confirm-cancel { color: var(--text-muted); text-decoration: none; }
.confirm-cancel:hover { text-decoration: underline; }

/* Doc freshness indicators */
.stale-green { color: #4ade80; }
.stale-amber { color: #f59e0b; }
.stale-red { color: #ef4444; }

/* Moderation status */
.mod-pending { color: #f59e0b; font-weight: 600; }

/* Forum badge */
.forum-badge { display: inline-block; font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 3px; text-transform: uppercase; letter-spacing: 0.5px; }
.forum-badge.merchant { background: #1e3a5f; color: #60a5fa; }
.forum-badge.developer { background: #1a3a2a; color: #4ade80; }

/* Inline post error */
.post-error { margin-top: 10px; padding: 10px 12px; background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3); border-radius: var(--radius); color: #fca5a5; font-size: 13px; line-height: 1.5; }
.post-error a { color: var(--link); }
