:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --border: #2a2f3a;
  --text: #e8eaed;
  --text-muted: #9aa0ab;
  --accent: #6c8cff;
  --accent-2: #8b7bff;
  --green: #3ddc84;
  --red: #ff5c5c;
  --amber: #ffb84d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* ---- Login ---- */
#login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 24px;
  text-align: center;
}
.login-card h1 { margin: 0 0 4px; font-size: 1.4rem; }
.login-card .subtitle { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 24px; }
#login-form { display: flex; flex-direction: column; gap: 12px; }
#login-password {
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
}
#login-form button[type="submit"] {
  padding: 14px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
}
.error { color: var(--red); font-size: 0.85rem; margin: 0; }

/* ---- App shell ---- */
#app-view { min-height: 100vh; display: flex; flex-direction: column; padding-bottom: 100px; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}
.progress-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.header-actions { display: flex; flex-wrap: wrap; gap: 2px; justify-content: flex-end; }
.link-btn { background: none; border: none; color: var(--accent); font-size: 0.85rem; padding: 4px; }
.progress-bar { height: 6px; background: var(--surface-2); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.3s; }
.progress-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; font-variant-numeric: tabular-nums; }

.filters-panel {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.filters-panel label { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: var(--text-muted); }
.filters-panel select {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}
#apply-filters,
#save-settings {
  padding: 10px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.filters-panel input[type="text"] {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
}
.hint { font-size: 0.75rem; color: var(--text-muted); margin: 4px 0 0; }

/* ---- Review card ---- */
.review-card { padding: 16px; max-width: 720px; margin: 0 auto; width: 100%; }
.meta-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.badge {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.badge-category { color: var(--accent-2); border-color: var(--accent-2); }
.badge-status { color: var(--amber); border-color: var(--amber); }

.content-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}
.content-block h2 {
  margin: 0 0 8px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.content-block p { margin: 0; white-space: pre-wrap; line-height: 1.5; }

.content-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.content-block-header h2 { margin: 0; }
.copy-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1;
}
.copy-btn:active { background: var(--border); }

/* ---- Regeneration block ---- */
.regen-block textarea,
.regen-block input[type="text"] {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  margin-top: 4px;
  margin-bottom: 12px;
}
.regen-block label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}
.primary-btn {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: var(--green);
  color: #08130d;
  font-weight: 700;
  font-size: 0.95rem;
}
.primary-btn:disabled { opacity: 0.5; }

.version-history-list {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.version-history-entry {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}
.version-history-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.version-history-entry p { margin: 0; white-space: pre-wrap; font-size: 0.85rem; line-height: 1.4; }
.version-history-notes { color: var(--text-muted); margin-top: 6px !important; font-style: italic; }

#translation-block pre {
  white-space: pre-wrap;
  font-family: inherit;
  margin: 0;
  line-height: 1.5;
}

.notes-block { margin-bottom: 12px; }
.notes-block label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }
.notes-block textarea {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
}

.empty-state { text-align: center; padding: 48px 16px; color: var(--text-muted); }

/* ---- Action bar ---- */
.action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4rem;
  padding: 8px 2px;
  border-radius: 10px;
}
.action-btn span { font-size: 0.65rem; color: var(--text-muted); }
.action-btn:active { background: var(--surface-2); }
.action-btn:disabled { opacity: 0.5; }
.action-accept { color: var(--green); }
/* Neutral, not alarming — "keep as-is" is a routine correction, not a
   discard (2026-08-05 semantics fix, see items.py module docstring). */
.action-keep { color: var(--accent-2); }
.action-translate { color: var(--accent); }
.action-reclassify { color: var(--amber); }

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  z-index: 20;
  max-width: 90vw;
  text-align: center;
}
.toast-error { border-color: var(--red); color: var(--red); }

/* ---- Desktop widening ---- */
@media (min-width: 640px) {
  .review-card { padding: 24px; }
  .action-bar {
    max-width: 720px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 16px 16px 0 0;
    bottom: 12px;
  }
}
