/* Site Helper: dark "Riverside" look. Every colour lives in :root.
   Purple is the only accent and is used for the main button and active states, never for small text.
   Inter is served from /static (the page's security policy only allows our own files). */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap; src: url(inter-latin.woff2) format("woff2"); }
:root {
  --bg: #121212;
  --panel: #1c1c1c;
  --raised: #2f2c2d;
  --raised-2: #3b3738;
  --ink: #f6f3f4;
  --muted: #bbbbbb;
  --dim: #686868;
  --line: #3a3637;
  --field-line: #7a7a7a;
  --accent: #7946f8;
  --accent-hover: #6a38e8;
  --accent-ink: #ffffff;
  --accent-soft: #c9b6ff;
  --focus: #c9b6ff;
  --err: #ffb4b4;
  --err-bg: #2c1a1a;
  --ok-bg: #1b2b22;
  --ok-line: #5bc383;
  --warn: #ffd37a;
  --side-w: 240px;
  --tab-h: 51px;  /* mobile bottom tab bar: 68px x 0.75 */
  /* Button size tokens: every button in the editor chrome reads these. Values are the old ones x 0.75 (18px/52px/22px -> 13.5px/39px/16.5px). */
  --btn-font: .75rem;
  --btn-h-sm: 36px;
  --btn-h: 39px;
  --btn-h-lg: 42px;
  --btn-h-xl: 45px;
  --btn-py: .41rem;
  --btn-px: .83rem;
  --btn-gap: .45rem;
  --btn-ic: 16.5px;
  --btn-r: 9px;
  font-size: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 400 1rem/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3, h4 { font-weight: 700; }
h1 { font-size: 1.5rem; line-height: 1.2; margin: 0; }
label { font-weight: 600; display: block; margin-bottom: .35rem; }
a { color: var(--accent-soft); }
.ic { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

input, textarea, select { font: inherit; color: var(--ink); border: 2px solid var(--field-line); border-radius: 12px; padding: .6rem .75rem; background: var(--bg); width: 100%; min-height: 52px; color-scheme: dark; }
input::placeholder, textarea::placeholder { color: #8f8f8f; opacity: 1; }
input:focus-visible, textarea:focus-visible, select:focus-visible { border-color: var(--focus); }

.btn { font: inherit; font-size: var(--btn-font); font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: var(--btn-gap); min-height: var(--btn-h); padding: var(--btn-py) var(--btn-px); border-radius: var(--btn-r); border: 0; background: var(--raised); color: var(--ink); cursor: pointer; text-decoration: none; }
.btn:hover:not(:disabled) { background: var(--raised-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.big { width: 100%; font-size: calc(var(--btn-font) * 1.1); min-height: var(--btn-h-xl); }
.btn.link { background: none; text-decoration: underline; padding: .375rem; color: var(--ink); }
.btn.link:hover:not(:disabled) { background: none; color: var(--accent-soft); }
.btn:disabled, .btn.primary:disabled { background: var(--raised); color: var(--muted); opacity: .5; cursor: not-allowed; }
.btn.link:disabled { background: none; }
.btn .ic, .nav-item .ic { width: var(--btn-ic); height: var(--btn-ic); }
.msg { min-height: 1.5em; margin: .5rem 0 0; }
.msg.err { color: var(--err); font-weight: 600; }
.msg.work, .log li.work { display: flex; align-items: center; gap: .6rem; }
.spinner { flex: none; width: 1.1rem; height: 1.1rem; border: 3px solid var(--raised-2); border-top-color: var(--accent-soft); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; border-top-color: var(--raised-2); border-left-color: var(--accent-soft); } }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 1.5rem; }
.login-card { background: var(--panel); border-radius: 16px; padding: 2rem; width: min(480px, 100%); }
.login-card h1 { margin-bottom: 1.25rem; font-size: 1.6rem; line-height: 1.25; }
.login-card form { display: grid; gap: .75rem; }
.login-card .btn { width: 100%; font-size: calc(var(--btn-font) * 1.1); min-height: var(--btn-h-lg); }
.code-box { font-size: 1.6rem; letter-spacing: .25em; text-align: center; font-variant-numeric: tabular-nums; min-height: 60px; }

/* shell: fixed sidebar + main column */
.app { height: 100%; display: flex; }
.side { width: var(--side-w); flex: none; background: var(--panel); display: flex; flex-direction: column; gap: 1.25rem; padding: 1rem .75rem; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .6rem; padding: .25rem .35rem; min-height: 52px; }
.logo { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--raised); color: var(--ink); }
.brand-text { display: grid; line-height: 1.25; min-width: 0; }
.brand-sub { color: var(--muted); font-size: 1rem; }
.brand-name { font-weight: 700; overflow-wrap: anywhere; }
.nav { display: grid; gap: .25rem; }
.nav-item { font: inherit; font-size: var(--btn-font); font-weight: 500; display: flex; align-items: center; gap: .56rem; min-height: var(--btn-h); padding: 0 .64rem; border: 0; border-radius: var(--btn-r); background: none; color: var(--ink); text-decoration: none; cursor: pointer; text-align: left; width: 100%; }
.nav-item:hover { background: var(--raised); }
.nav-item[aria-current="page"] { background: var(--raised-2); }
.nav-item[aria-current="page"] .ic { color: var(--accent-soft); }
.account { margin-top: auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: .25rem; }
.switch-link { display: inline-flex; align-items: center; gap: .35rem; align-self: start; width: fit-content; padding: .75rem 0; margin-block: -.5rem -.6rem; font-size: var(--btn-font); font-weight: 500; color: var(--accent-soft); text-decoration: none; }
.switch-link .ic { width: 14px; height: 14px; }
.switch-link:hover { text-decoration: underline; }
.who-row { display: flex; align-items: center; gap: .75rem; padding: .25rem .85rem; min-height: 48px; }
.avatar { flex: none; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--raised-2); }
.who { color: var(--muted); font-size: 1rem; line-height: 1.3; overflow-wrap: anywhere; min-width: 0; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }

.crumbbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1.5rem; min-height: 80px; }
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: .6rem; color: var(--muted); }
.crumbs li + li::before { content: "\203A" / ""; margin-right: .6rem; color: var(--muted); }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; }
.publish-box { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.hint-line { margin: 0; color: var(--muted); }
.publish-box .hint-line { text-align: right; }
#action-msg { margin: 0 1.5rem .5rem; padding: .6rem 1rem; background: var(--raised); border-radius: 12px; }
#action-msg:empty { display: none; }
.pagehead { padding: .25rem 1.5rem 1.25rem; }
.pagehead h1 { margin-bottom: 1rem; }
.quick { display: flex; flex-wrap: wrap; gap: .6rem; }
.quick .btn { gap: .375rem; padding-inline: .675rem; }

.split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(380px, 28%) 1fr; gap: 1rem; padding: 0 1.5rem 1.5rem; }
.chat { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-radius: 12px; padding: .75rem; gap: .75rem; }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.chat-title { font-weight: 700; padding-left: .25rem; }
.chat-head .btn { min-height: 48px; }
.chat-hint { font-size: 1rem; line-height: 1.4; }
.notice { margin: 0; padding: .6rem .8rem; background: var(--raised); border-left: 6px solid var(--warn); border-radius: 10px; }
.log { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: .75rem; min-height: 120px; }
.log li { max-width: 94%; padding: .7rem .9rem; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1.05rem; line-height: 1.45; }
.log li.bot { background: var(--raised); align-self: flex-start; }
.log li.me { background: var(--raised-2); align-self: flex-end; }
.log li.err { background: var(--err-bg); color: var(--err); border-left: 6px solid var(--err); font-weight: 600; }
.log li.ok { background: var(--ok-bg); border-left: 6px solid var(--ok-line); }
.log li.work { color: var(--muted); }
.log .choices { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; white-space: normal; }
.log .choices.stack { flex-direction: column; align-items: stretch; }
.log .choices.stack .btn { justify-content: flex-start; text-align: left; min-height: var(--btn-h-lg); }
.log .btn:not(.primary):not(.link) { background: var(--raised-2); }
.log .btn:not(.primary):not(.link):hover:not(:disabled) { background: #4a4546; }
.log a:not(.btn) { font-weight: 700; }
.log a.btn { margin-top: .6rem; display: inline-flex; color: var(--accent-ink); }
.log li.confirm { background: var(--panel); border: 2px solid var(--accent); max-width: 100%; align-self: stretch; white-space: normal; }
.confirm-head { margin: 0 0 .4rem; font-weight: 700; }
.confirm-list { margin: 0 0 .6rem; padding-left: 1.3rem; }
.confirm-list li { display: list-item; max-width: none; padding: 0 0 .35rem; margin: 0; background: none; border-radius: 0; font-size: inherit; }
.confirm-ask { margin: 0; font-weight: 700; }
.confirm .choices .btn { flex: 1 1 6rem; text-align: center; padding-inline: .3rem; }
.picked { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .25rem .5rem .25rem .8rem; background: var(--raised); border: 2px solid var(--accent); border-radius: 12px; }
.picked-line { margin: 0; overflow-wrap: anywhere; flex: 1; min-width: 0; }
.picked .btn { flex: none; }
.ask-row { display: flex; gap: .5rem; align-items: stretch; }
.ask textarea { resize: vertical; }
.ask .btn { min-width: 4.1rem; }
.actions { display: grid; gap: .4rem; border-top: 1px solid var(--line); padding-top: .75rem; }
.actions-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.actions-row .btn { flex: 1 1 6.75rem; }
.preview { display: flex; flex-direction: column; min-height: 0; border-radius: 12px; overflow: hidden; background: var(--panel); }
.preview-bar { display: flex; align-items: center; gap: .75rem; padding: .5rem .75rem; background: var(--panel); border-bottom: 1px solid var(--line); }
.preview-bar label { margin: 0; }
.preview-bar select { width: auto; min-width: 12rem; background: var(--raised); }
.preview-bar .hint { color: var(--muted); }
#frame { flex: 1; width: 100%; border: 0; background: #fff; }

/* section header with a count, and cards (calendar events, past changes) */
.section-head { font-size: 1.25rem; line-height: 1.3; margin: .5rem 0 0; }
.cards { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 1rem; align-items: start; }
.history { padding: .25rem 1.5rem 2rem; overflow-y: auto; flex: 1; min-height: 0; }
.entry { background: var(--panel); border-radius: 12px; padding: 1rem 1.1rem; min-width: 0; }
.entry p { margin: 0; overflow-wrap: anywhere; }
.entry-what { font-size: 1.15rem; font-weight: 700; line-height: 1.3; }
.entry-meta { color: var(--muted); margin-top: .35rem !important; }
.tag { display: inline-block; background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 0 .7rem; font-size: 1rem; font-weight: 600; white-space: nowrap; }
.entry-what .tag { display: table; margin-top: .5rem; }

/* past sessions: cards that open a read-only chat */
.entry-btn { display: block; width: 100%; font: inherit; color: var(--ink); text-align: left; border: 0; cursor: pointer; min-height: 48px; }
.entry-btn:hover { background: var(--raised); }
.entry-clip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.entry-btn .entry-meta { display: block; }
.entry-btn .tag { display: table; margin-top: .5rem; }
.read-view { max-width: 760px; display: grid; gap: .75rem; align-content: start; }
.read-view > * { min-width: 0; }
.read-bar { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: space-between; }
.read-bar .btn { min-height: 48px; }
.read-view h1 { overflow-wrap: anywhere; }
.read-view h1:focus-visible { outline-offset: 4px; }
.read-view .notice { margin: 0; }
.read-log { flex: none; overflow: visible; }
.read-log li { max-width: 94%; }

/* calendar screen */
.cal { padding: .25rem 1.5rem 2rem; display: grid; gap: 1rem; align-content: start; grid-auto-rows: max-content; flex: 1; min-height: 0; overflow-y: auto; }
.cal > * { min-width: 0; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.cal h2 { font-size: 1.5rem; line-height: 1.2; margin: 0; }
.cal h3 { font-size: 1.25rem; margin: 0; }
.cal-today { margin: 0; color: var(--muted); }
.cal-sub { margin-top: .5rem !important; }
.cal-add-row .btn { width: auto; min-width: 10.5rem; }
.cal-list { margin-top: 0; }
.ev-card { background: var(--panel); border-radius: 12px; padding: 1rem 1.1rem; display: grid; grid-template-columns: 64px 1fr; gap: .3rem 1rem; min-width: 0; }
.ev-card p { margin: 0; overflow-wrap: anywhere; }
.ev-date { width: 64px; height: 64px; border-radius: 12px; background: var(--raised); display: grid; align-content: center; justify-items: center; line-height: 1.1; }
.ev-mon { color: var(--muted); font-weight: 600; text-transform: uppercase; }
.ev-day { font-size: 1.5rem; font-weight: 700; }
.ev-body { display: grid; gap: .2rem; min-width: 0; align-content: start; }
.ev-name { font-size: 1.15rem; line-height: 1.3; font-weight: 700; margin: 0; overflow-wrap: anywhere; }
.ev-when { font-weight: 500; }
.ev-next, .ev-place, .ev-photo { color: var(--muted); }
.ev-thumb { display: block; position: relative; overflow: hidden; border-radius: 10px; background: var(--raised); }
.ev-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ev-thumb.is-loading { animation: ev-pulse 1.2s ease-in-out infinite; }
.ev-thumb.is-loading img { opacity: 0; }
.ev-thumb--card { width: 100%; max-width: 360px; aspect-ratio: 16 / 9; margin-top: .4rem; }
.ev-thumb--form { width: 100%; max-width: 260px; aspect-ratio: 4 / 3; }
.ev-photo-preview { min-width: 0; }
@keyframes ev-pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .ev-thumb.is-loading { animation: none; } }
.ev-card .actions-row { grid-column: 1 / -1; margin-top: .5rem; flex-wrap: nowrap; }
.ev-card .actions-row .btn { flex: 1 1 0; min-width: 0; padding-inline: .375rem; }
.cal-form { background: var(--panel); border: 2px solid var(--accent); border-radius: 12px; padding: 1rem; display: grid; gap: 1rem; max-width: 760px; }
.cal-form fieldset { border: 1px solid var(--line); border-radius: 12px; padding: .75rem 1rem 1rem; margin: 0; display: grid; gap: .5rem; min-width: 0; }
.cal-form legend { font-weight: 700; padding: 0 .35rem; }
.cal-form .field { display: grid; gap: .1rem; }
.cal-form .field label { margin: 0 0 .25rem; }
.cal-form .two { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.cal-form .check, .cal-form .radio { display: flex; align-items: center; gap: .75rem; min-height: 52px; }
.cal-form .check input, .cal-form .radio input { width: 28px; height: 28px; min-height: 0; margin: 0; flex: none; accent-color: var(--accent); }
.cal-form .check label, .cal-form .radio label { margin: 0; font-weight: 600; flex: 1; padding: .6rem 0; cursor: pointer; }
.cal-form .indent { padding-left: 2.6rem; }
.cal-form textarea { resize: vertical; }
.ev-preview { margin: 0; padding: .75rem 1rem; background: var(--raised); border-left: 6px solid var(--accent); border-radius: 10px; font-size: 1.05rem; font-weight: 600; overflow-wrap: anywhere; }
.ev-preview:empty { display: none; }
.cal-form .msg.err:empty { display: none; }
.cal-log { flex: none; overflow: visible; max-width: 760px; }
.cal-log:empty { display: none; }
.cal-log li { max-width: 100%; scroll-margin: 1rem; }
.actions-cal .actions { border: 0; padding: 0; max-width: 300px; }
@media (min-width: 600px) { .cal-form .two { grid-template-columns: 1fr 1fr; } }

/* round help button, bottom right */
.help { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 5; width: var(--btn-h); height: var(--btn-h); border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: #121212; font-weight: 700; font-size: calc(var(--btn-font) * 1.35); text-decoration: none; box-shadow: 0 2px 10px rgba(0, 0, 0, .5); }
.help:hover { background: #fff; }
.help:focus-visible { outline-offset: 3px; }

/* phones: top bar + bottom tab bar; preview on top, chat below. One page scroll, no scroll boxes inside it. */
@media (max-width: 820px) {
  .cal-log li { scroll-margin-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 1rem); }  /* keep the Yes / No buttons clear of the bottom tab bar */
  .app { height: auto; min-height: 100%; flex-direction: column; padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
  .side { width: auto; flex-direction: row; align-items: center; justify-content: space-between; gap: .5rem; padding: .35rem .75rem; overflow: visible; }
  .brand { padding: 0; min-width: 0; }
  .brand-sub { display: none; }
  .account { margin: 0; flex: none; }
  .who-row { display: none; }
  .account .nav-item { width: auto; padding: 0 .56rem; flex-direction: row; gap: .375rem; min-height: var(--btn-h-sm); }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; grid-auto-flow: column; grid-auto-columns: auto; justify-content: space-between; gap: 0; background: var(--panel); border-top: 1px solid var(--line); padding: .35rem calc(var(--btn-h) + 1.1rem) calc(.35rem + env(safe-area-inset-bottom)) .35rem; }
  .nav-item { flex-direction: column; justify-content: center; gap: .075rem; min-height: var(--btn-h-lg); padding: .19rem .45rem; font-size: var(--btn-font); text-align: center; white-space: nowrap; border-radius: var(--btn-r); }
  .crumbbar { padding: .5rem .75rem; min-height: 0; }
  .crumbs, .publish-box .hint-line { display: none; }
  .publish-box { flex: 1; }
  .publish-box .btn { flex: 1; }
  #action-msg { margin: 0 .75rem .5rem; }
  .pagehead { padding: .25rem .75rem .75rem; }
  .pagehead h1 { font-size: 1.3rem; margin-bottom: .6rem; }
  .quick { flex-wrap: nowrap; overflow-x: auto; margin-inline: -.75rem; padding: 0 .75rem .25rem; scrollbar-width: none; }
  .quick .btn { flex: none; white-space: nowrap; }
  .split { display: flex; flex-direction: column; padding: 0 .75rem .75rem; gap: .75rem; }
  .preview { order: 1; height: 48vh; flex: none; }
  .chat { order: 2; flex: none; }
  .log { overflow: visible; flex: none; }
  .log li { max-width: 100%; }
  .preview-bar .hint { display: none; }
  .cal { padding: .25rem .75rem 1.5rem; overflow: visible; flex: none; }
  .history { padding: .25rem .75rem 1.5rem; overflow: visible; flex: none; }
  .read-log li { max-width: 100%; }
  .login-card { padding: 1.5rem; }
  .help { right: .6rem; bottom: calc(.45rem + env(safe-area-inset-bottom)); z-index: 11; }  /* sits at the right end of the tab bar, so it never covers a button */
}

/* client picker (GET /clients, server-rendered in app.py): a centred card with one big link per website */
.picker { max-width: 34rem; margin: 0 auto; min-height: 100%; padding: 3rem 1.5rem; display: flex; flex-direction: column; justify-content: center; gap: 1.25rem; }
.picker h1 { font-size: 1.5rem; }
.picker p { margin: 0; color: var(--muted); }
.client-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.client-list a { display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-height: 56px; padding: .6rem 1rem; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); color: var(--ink); font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.client-list a::after { content: "\203A" / ""; flex: none; color: var(--accent-soft); font-size: 1.5rem; line-height: 1; }
.client-list a:hover { background: var(--raised); border-color: var(--field-line); }
@media (max-width: 820px) { .picker { padding: 1.5rem .75rem; justify-content: flex-start; } }
