/*
 * Voice of Pheme's look, in ONE place. Adapted from Eye of Sauron's
 * interface (header, menu, tiles, panels, chips, sign-in card, light and
 * dark mode, bigger targets on a computer, the same header on every page).
 *
 * COLOURS: LAUREL GOLD, after the golden trumpet of Fame (Pheme), chosen
 * by Khai on 9 Nov 2026 from three palettes shown side by side. Warm cream
 * page, white cards, warm dark text, antique-gold accent. Pages use only the
 * variables below, never colour codes, so a change is made here once.
 *
 * CONTRAST, MEASURED (WCAG; 4.5 is the floor for small text). Light: text
 * 15.0, muted 5.9, accent 5.4 (white on accent 5.4). Dark, on its cards:
 * text 12.9, muted 6.3, accent 7.6 (dark text on accent 8.3). Warnings use
 * amber-orange so they never blur with the gold accent.
 *
 * Inter is served from /static/fonts, never a font CDN (SIL Open Font
 * Licence, alongside the files).
 */

@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('/static/fonts/inter-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('/static/fonts/inter-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('/static/fonts/inter-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('/static/fonts/inter-latin-700-normal.woff2') format('woff2'); }

:root {
  /* Surfaces: warm cream page, white cards */
  --bg: #f7f4ee;
  --surface: #ffffff;
  --surface-hover: #f0ebe1;
  --border: #e6dfd2;

  /* Text */
  --text: #2a2620;
  --text-muted: #6b6355;

  /* Accent: laurel gold (the trumpet) */
  --accent: #8a6418;
  --accent-dim: #6e4f12;
  --accent-soft: rgba(138, 100, 24, 0.10);
  --on-accent: #ffffff;

  /* States */
  --error: #b3261e;
  --error-soft: rgba(179, 38, 30, 0.08);
  --success: #2f7d4a;
  --success-soft: rgba(47, 125, 74, 0.10);
  --warn: #a14b00;
  --warn-soft: rgba(161, 75, 0, 0.10);
  --info: #3b6fc4;
  --info-soft: rgba(59, 111, 196, 0.10);

  --hairline: rgba(42, 38, 32, 0.08);
  --shadow: 0 6px 24px rgba(42, 38, 32, 0.10);
  --radius: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

/* Dark: follows the device, and the moon button overrides it per browser
   (pheme.theme). The script at the top of every page sets data-theme before
   anything draws, so there is never a flash of the wrong one. */
:root[data-theme="dark"] {
  --bg: #1b1916;
  --surface: #24211d;
  --surface-hover: #2f2b26;
  --border: #3d3832;
  --text: #ece6da;
  --text-muted: #aaa193;
  --accent: #d9ab55;
  --accent-dim: #c4943c;
  --accent-soft: rgba(217, 171, 85, 0.14);
  --on-accent: #1b1916;
  --error: #f2877c;
  --error-soft: rgba(242, 135, 124, 0.12);
  --success: #74c48d;
  --success-soft: rgba(116, 196, 141, 0.12);
  --warn: #f0a35e;
  --warn-soft: rgba(240, 163, 94, 0.12);
  --info: #86adf0;
  --info-soft: rgba(134, 173, 240, 0.12);
  --hairline: rgba(255, 255, 255, 0.08);
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--accent); }
a:hover { color: var(--accent-dim); }
h1, h2, h3 { line-height: 1.3; }
h2 { font-size: 17px; font-weight: 600; margin: 28px 0 10px; }
h3 { font-size: 15px; font-weight: 600; margin: 18px 0 8px; }
code { font-size: 0.9em; background: var(--surface-hover); padding: 1px 5px; border-radius: 5px; }
pre { white-space: pre-wrap; background: var(--surface-hover); padding: 10px 12px; border-radius: 8px; font-size: 13px; overflow-x: auto; }
.muted { color: var(--text-muted); font-size: 14px; }
main { max-width: 860px; margin: 0 auto; padding: 18px 16px 48px; }
.page-title { font-size: 22px; font-weight: 600; margin: 6px 0 16px; }

/* ---------- Header and menu (the same on every page) ---------- */
header.site-header { display: flex; align-items: center; gap: 12px; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
header.site-header .logo { width: 32px; height: 32px; flex-shrink: 0; border-radius: 9px; background: var(--accent); color: var(--on-accent); display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
header.site-header .logo svg { width: 22px; height: 22px; }
header.site-header .titles { flex: 1 1 0; min-width: 0; }
header.site-header .titles strong { display: block; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header.site-header .titles span { display: block; font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
nav.site-nav { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 2px 4px; }
nav.site-nav a { color: var(--text-muted); text-decoration: none; padding: 6px 9px; border-radius: 8px; white-space: nowrap; transition: background-color .12s; }
nav.site-nav a.active { color: var(--accent); }
nav.site-nav a:hover { background: var(--surface-hover); color: var(--text); }
nav.site-nav .icon-btn, button.theme-toggle, .theme-toggle { margin-top: 0; margin-bottom: 0; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; min-height: 0; padding: 0; margin-left: 2px; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--text-muted); cursor: pointer; }
nav.site-nav .icon-btn.active { color: var(--accent); border-color: var(--accent); }
nav.site-nav .icon-btn svg, .theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
.signout { margin: 0; display: inline; }
.signout button { background: none; border: 0; color: var(--text-muted); padding: 6px 9px; min-height: 0; margin: 0; cursor: pointer; font: inherit; border-radius: 8px; }
.signout button:hover { background: var(--surface-hover); color: var(--text); }
.who { font-size: 13px; color: var(--text-muted); margin-left: 6px; white-space: nowrap; }
@media (max-width: 860px) {
  header.site-header { flex-wrap: wrap; row-gap: 6px; padding: 10px 14px; }
  header.site-header .titles span { display: none; }
  nav.site-nav { display: contents; }
  nav.site-nav > * { order: 4; }
  nav.site-nav > .icon-btn, nav.site-nav > .theme-toggle, nav.site-nav > .signout { order: 2; }
  nav.site-nav > a:not(.icon-btn) { padding: 6px 12px 6px 0; }
  nav.site-nav > .who { display: none; }
  header.site-header::after { content: ''; order: 3; flex: 0 0 100%; height: 0; }
}

/* ---------- Brand switcher (chips) ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 14px; }
.chip { padding: 6px 13px; border-radius: 999px; font-size: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); text-decoration: none; }
.chip:hover { background: var(--surface-hover); color: var(--text); }
.chip.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---------- Tiles (headline numbers) ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin: 0 0 18px; }
.tile { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; color: inherit; text-decoration: none; }
a.tile:hover { border-color: var(--accent); }
.tile .label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.tile .value { font-size: 26px; font-weight: 600; line-height: 1.25; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .hint { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.tile.attention .value { color: var(--accent); }

/* ---------- Panels, cards and tables ---------- */
.panel, .box { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin: 10px 0; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.item { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 8px 0; }
.item .title { font-weight: 600; }
.item .meta { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 600; font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.pill { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 999px; background: var(--surface-hover); color: var(--text-muted); margin-left: 6px; vertical-align: 1px; }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.good { background: var(--success-soft); color: var(--success); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .cols { grid-template-columns: 1fr; } }

/* ---------- Messages ---------- */
.ok, .warn, .err, .info { padding: 10px 14px; border-radius: 10px; margin: 10px 0; font-size: 14px; }
.ok { background: var(--success-soft); color: var(--text); border: 1px solid transparent; border-left: 3px solid var(--success); }
.warn { background: var(--warn-soft); color: var(--text); border-left: 3px solid var(--warn); }
.err { background: var(--error-soft); color: var(--text); border-left: 3px solid var(--error); }
.info { background: var(--info-soft); color: var(--text); border-left: 3px solid var(--info); }

/* ---------- Forms and buttons ---------- */
label { display: block; font-size: 14px; font-weight: 500; color: var(--text-muted); margin: 14px 0 5px; }
input[type=text], input[type=email], input[type=password], input[type=datetime-local], input[type=number], textarea, select {
  width: 100%; font: inherit; font-size: 15px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 9px 12px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 6rem; resize: vertical; }
textarea.body { min-height: 28rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
input[disabled], textarea[disabled], select[disabled] { opacity: .7; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; color: var(--text); }
label.check input { width: auto; }
button, .btn { font: inherit; font-weight: 600; font-size: 15px; padding: 9px 16px; margin: 12px 6px 0 0; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
button:hover, .btn:hover { background: var(--surface-hover); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.primary:hover, .btn.primary:hover { background: var(--accent-dim); }
button[disabled] { opacity: .5; cursor: not-allowed; }
@media (hover: hover) and (pointer: fine) {
  :where(button, .btn) { min-height: 40px; }
  :where(select) { min-height: 38px; }
}

/* Show / hide on a password box (/static/app.js). */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 48px !important; }
.pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; min-height: 0; padding: 0; margin: 0; border: 0; border-radius: 8px; background: none; color: var(--text-muted); cursor: pointer; }
.pw-eye:hover { color: var(--text); background: none; }
.pw-eye svg { width: 20px; height: 20px; }

/* ---------- Sign-in card ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px 30px; box-shadow: var(--shadow); }
.auth-card .mark { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 18px; background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center; }
.auth-card .mark svg { width: 42px; height: 42px; }
.auth-card h1 { text-align: center; font-size: 22px; margin: 0; }
.auth-card .sub { text-align: center; color: var(--text-muted); margin: 2px 0 18px; }
.auth-card button.primary { width: 100%; margin: 18px 0 0; }
.auth-card .alt { text-align: center; font-size: 14px; margin-top: 16px; }
.auth-card details { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.auth-card summary { cursor: pointer; color: var(--text-muted); font-size: 14px; text-align: center; list-style: none; }
.auth-card summary::-webkit-details-marker { display: none; }
.corner { position: fixed; top: 14px; right: 14px; z-index: 5; }

/* ---------- Draft preview ---------- */
.preview { border-top: 1px dashed var(--border); margin-top: 24px; padding-top: 10px; }
.preview img { max-width: 100%; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.thumbs label { margin: 0; font-weight: 400; color: var(--text); }
.thumbs img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 8px; display: block; margin: 4px 0; }
