/* Phone-first. Dark by default because most reading happens at night, with a
   light scheme honoured when the device asks for one. No framework and no build
   step — this file is edited directly in a browser, on a phone. */

:root {
  --bg: #111417;
  --surface: #191d21;
  --surface-2: #22272c;
  --line: #2e353b;
  --text: #e9edf0;
  --muted: #97a2ac;
  --accent: #6aa9ff;
  --pass: #4ec98a;
  --fail: #ef6f6f;
  --warn: #e0b155;
  --radius: 12px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #eef1f4;
    --line: #d9dee4;
    --text: #14181c;
    --muted: #5c6874;
    --accent: #1f6feb;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-text-size-adjust: 100%;
}

.view { max-width: 720px; margin: 0 auto; padding: 16px; }
[hidden] { display: none !important; }

/* Sign in ------------------------------------------------------------------*/
.brand { text-align: center; margin: 12vh 0 24px; }
.brand h1 { font-size: 1.35rem; margin: 0 0 4px; letter-spacing: -0.01em; }
.sub { color: var(--muted); margin: 0; font-size: 0.9rem; }

/* Chrome -------------------------------------------------------------------*/
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0 12px; font-size: 0.95rem;
}
.spacer { flex: 1; }

.tabs {
  display: flex; gap: 4px; margin-bottom: 14px;
  background: var(--surface); padding: 4px; border-radius: var(--radius);
}
.tab {
  flex: 1; padding: 9px 4px; border: 0; border-radius: 9px;
  background: transparent; color: var(--muted);
  font: inherit; font-size: 0.9rem; cursor: pointer;
}
.tab.is-active { background: var(--surface-2); color: var(--text); font-weight: 600; }

.panel { display: none; }
.panel.is-active { display: block; }

/* Cards --------------------------------------------------------------------*/
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

label { display: block; margin-bottom: 12px; font-size: 0.85rem; color: var(--muted); }

input, textarea, select, button {
  font: inherit;
  width: 100%;
  /* 16px keeps iOS Safari from zooming the whole page on focus */
  font-size: 16px;
}

input, textarea, select {
  margin-top: 5px; padding: 11px 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent;
}

button {
  padding: 11px 14px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); cursor: pointer;
  /* comfortable thumb target */
  min-height: 44px;
}
button.primary { background: var(--accent); border-color: transparent; color: #06121f; font-weight: 600; }
button.ghost { background: transparent; color: var(--muted); }
button.chip { width: auto; padding: 6px 11px; min-height: 34px; font-size: 0.82rem; border-radius: 999px; }
button:disabled { opacity: 0.5; cursor: default; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row button { width: auto; flex: 1; min-width: 120px; }

.hint { color: var(--muted); font-size: 0.78rem; margin: -4px 0 12px; }
.msg { font-size: 0.85rem; margin: 10px 0 0; min-height: 1em; }
.msg.err { color: var(--fail); }
.msg.ok { color: var(--pass); }

hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* Lists --------------------------------------------------------------------*/
.list > .item {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
}
.item h3 { margin: 0 0 6px; font-size: 0.98rem; line-height: 1.35; }
.item .meta { color: var(--muted); font-size: 0.8rem; margin: 0 0 10px; }
.item .meta a { color: var(--accent); }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.03em; background: var(--surface-2); color: var(--muted);
}
.badge.pass { background: rgba(78,201,138,0.16); color: var(--pass); }
.badge.fail { background: rgba(239,111,111,0.16); color: var(--fail); }
.badge.insufficient_evidence,
.badge.verifying { background: rgba(224,177,85,0.16); color: var(--warn); }

/* The evidence trail -------------------------------------------------------*/
.trail {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 0.85rem;
}
.trail .reasoning { color: var(--text); margin: 0 0 10px; }
.trail .cite {
  border-left: 2px solid var(--line); padding: 2px 0 2px 10px;
  margin: 8px 0; color: var(--muted);
}
.trail .cite blockquote {
  margin: 4px 0 0; color: var(--text); font-style: italic;
}
.trail .fabrication {
  background: rgba(239,111,111,0.1); border: 1px solid var(--fail);
  border-radius: 9px; padding: 10px; color: var(--fail); font-size: 0.82rem;
}

.empty { color: var(--muted); text-align: center; padding: 32px 16px; font-size: 0.9rem; }

/* Vault sheet --------------------------------------------------------------*/
.sheet {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50;
}
.sheet-inner {
  width: 100%; max-width: 720px; margin: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  max-height: 88vh; overflow-y: auto;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.sheet h2 { margin: 0 0 8px; font-size: 1.05rem; }

/* Toast --------------------------------------------------------------------*/
.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 999px; font-size: 0.85rem;
  z-index: 60; max-width: 90vw;
}

/* Manual entry ------------------------------------------------------------*/
#manual-card summary {
  cursor: pointer; font-weight: 600; font-size: 0.95rem;
  /* the whole row is the tap target, not just the word */
  margin: -16px; padding: 16px; list-style-position: inside;
}
#manual-card[open] summary { margin-bottom: 4px; }

.req { color: var(--warn); font-weight: 500; }
.hint-inline { color: var(--muted); font-weight: 400; }

/* Who translated it and which edition — the difference between a citation and
   an assertion, so it is shown on the source, not buried in a detail view. */
.apparatus {
  color: var(--muted); font-size: 0.8rem; font-style: italic;
  margin: -6px 0 10px;
}
