@font-face { font-family: 'Playfair Display'; src: url('/web/static/fonts/PlayfairDisplay.ttf') format('truetype'); font-weight: 400 900; }
@font-face { font-family: 'Playfair Display'; src: url('/web/static/fonts/PlayfairDisplay-Italic.ttf') format('truetype'); font-style: italic; font-weight: 400 900; }

:root {
  --paper: #FBFAF6;
  --ink: #16140F;
  --coral: #C94D42;
  --coral-bright: #FF7A6E;
  --hairline: rgba(22,20,15,0.14);
  --muted: rgba(22,20,15,0.55);
}
@media (prefers-color-scheme: dark) {
  :root { --paper: #16140F; --ink: #F5F3EE; --coral: #E0685C; --coral-bright: #FF8F84; --hairline: rgba(245,243,238,0.16); --muted: rgba(245,243,238,0.55); }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  display: flex;
  flex-direction: column;
}
h1, h2, h3, .display { font-family: 'Playfair Display', Georgia, serif; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.02em; }

.hidden { display: none !important; }

/* ---- login ---- */
#login-screen {
  flex: 1; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 1.25rem;
}
#login-screen h1 { font-size: 2rem; margin: 0; }
#login-form { display: flex; flex-direction: column; gap: 0.75rem; width: min(320px, 84vw); }
input[type="password"], input[type="text"] {
  background: transparent; border: 1px solid var(--hairline); color: var(--ink);
  padding: 0.75rem 0.9rem; font-size: 1rem; border-radius: 2px;
}
button {
  background: var(--coral); color: #FBFAF6; border: none; padding: 0.75rem 1rem;
  font-size: 0.95rem; border-radius: 2px; cursor: pointer; font-weight: 600;
}
button:hover { background: var(--coral-bright); }
button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--hairline); }
#login-error { color: var(--coral); font-size: 0.85rem; min-height: 1.2em; }

/* ---- app shell ---- */
#app-shell { flex: 1; display: none; flex-direction: column; height: 100vh; }
#app-shell.active { display: flex; }

header.masthead {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 0.9rem 1.25rem; border-bottom: 1px solid var(--hairline);
}
header.masthead h1 { font-size: 1.3rem; margin: 0; }
nav.tabs { display: flex; gap: 1.5rem; padding: 0 1.25rem; border-bottom: 1px solid var(--hairline); }
nav.tabs button {
  background: none; border: none; color: var(--muted); font-family: inherit; font-weight: 600;
  padding: 0.75rem 0; border-bottom: 2px solid transparent; border-radius: 0; font-size: 0.9rem;
}
nav.tabs button.active { color: var(--ink); border-bottom-color: var(--coral); }
nav.tabs button:hover { background: none; color: var(--ink); }

main.view { flex: 1; overflow-y: auto; padding: 1.25rem; }
.view-panel { display: none; max-width: 720px; margin: 0 auto; }
.view-panel.active { display: block; }

.section-num { color: var(--coral); font-weight: 700; margin-right: 0.5em; }
.hairline { border: none; border-top: 1px solid var(--hairline); margin: 1.25rem 0; }
.muted { color: var(--muted); font-size: 0.85rem; }

/* ---- chat ---- */
/* NOTE: this must be #chat-panel.active, not #chat-panel — an ID selector
   without .active beats the generic ".view-panel { display: none }" rule on
   specificity alone, which kept chat visible underneath every other tab. */
#chat-panel.active { display: flex; flex-direction: column; height: 100%; max-width: 720px; }
#chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 0.6rem; padding-bottom: 1rem; }
.msg { max-width: 80%; padding: 0.6rem 0.85rem; border-radius: 3px; line-height: 1.4; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--coral); color: #FBFAF6; }
.msg.assistant { align-self: flex-start; background: transparent; border: 1px solid var(--hairline); }
.msg .ts { display: block; font-size: 0.7rem; opacity: 0.6; margin-top: 0.25rem; }
#thinking-indicator { padding: 0.3rem 0.1rem; font-style: italic; }
#thinking-indicator.hidden { display: none; }
#chat-input-row { display: flex; gap: 0.5rem; padding-top: 0.75rem; border-top: 1px solid var(--hairline); align-items: flex-end; }
#chat-input-row textarea {
  flex: 1; resize: none; overflow-y: auto; max-height: 8.5rem; line-height: 1.4;
  background: transparent; border: 1px solid var(--hairline); color: var(--ink);
  padding: 0.6rem 0.85rem; font-size: 1rem; font-family: inherit; border-radius: 2px;
}
#chat-input-row button { flex-shrink: 0; }

/* ---- today / tasks ---- */
.event-row, .task-row { display: flex; justify-content: space-between; align-items: baseline; padding: 0.6rem 0; border-bottom: 1px solid var(--hairline); gap: 1rem; }
.event-row .time, .task-row .due { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.task-row .domain { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--coral); }
.counts-row { display: flex; gap: 1.5rem; margin-bottom: 1rem; }
.counts-row .stat { text-align: center; }
.counts-row .stat .n { font-size: 1.6rem; font-family: 'Playfair Display', serif; }
.counts-row .stat .l { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; }

/* ---- system ---- */
#system-status { margin-bottom: 0.75rem; }
#system-extra { line-height: 1.6; margin-bottom: 0.5rem; }
.account-row { display: flex; gap: 0.6rem; margin-bottom: 0.4rem; }
.account-row button.active-account { background: var(--coral); color: #FBFAF6; }
.account-row button.inactive-account { background: transparent; border: 1px solid var(--hairline); color: var(--ink); }
#account-note { margin-bottom: 0; }
#system-stats { gap: 1.5rem; }
.gauge { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; }
.gauge-track { fill: none; stroke: var(--hairline); stroke-width: 6; }
.gauge-fill {
  fill: none; stroke-width: 6; stroke-linecap: round;
  transform-origin: 32px 32px; transform: rotate(-90deg);
  transition: stroke-dashoffset 0.4s ease, stroke 0.4s ease;
}
.gauge-num { font-family: 'Playfair Display', serif; font-size: 0.85rem; fill: var(--ink); }
.gauge .l { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.gauge-sub { font-size: 0.65rem; }
.job-row { display: flex; justify-content: space-between; padding: 0.4rem 0; border-bottom: 1px solid var(--hairline); font-size: 0.85rem; }
.file-row { display: flex; justify-content: space-between; padding: 0.45rem 0; border-bottom: 1px solid var(--hairline); cursor: pointer; font-size: 0.9rem; }
.file-row:hover { color: var(--coral); }
.file-row .size { color: var(--muted); font-size: 0.75rem; }
#files-crumb { margin-bottom: 0.5rem; font-size: 0.85rem; }
#files-crumb button { background: none; border: none; color: var(--coral); padding: 0; font-size: 0.85rem; font-weight: 600; }
#file-preview { white-space: pre-wrap; font-size: 0.8rem; background: rgba(128,128,128,0.08); padding: 0.75rem; border-radius: 3px; max-height: 50vh; overflow: auto; }
#clean-result { margin-top: 0.75rem; font-size: 0.85rem; }
