/* PolyWorker.com — dark only. Jobs are coloured lanes; everything else stays quiet. */
:root {
  color-scheme: dark;
  --bg: #141826;
  --surface: #1C2133;
  --raised: #252B40;
  --line: #343B55;
  --line-soft: #2A3047;
  --text: #E4E7F1;
  --muted: #9AA2BD;
  --faint: #6C7491;
  --signal: #82A8FF;
  --signal-ink: #0F1630;
  --amber: #F2B356;
  --coral: #F07A78;
  --mint: #7FD1A8;
  --lane: var(--signal);
  --radius-s: 6px;
  --radius-m: 10px;
  --font: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  --font-mono: "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
  --step--1: 0.8125rem;
  --step-0: 0.9375rem;
  --step-1: 1.125rem;
  --step-2: 1.4rem;
  --step-3: 1.85rem;
  --hover: rgb(255 255 255 / .04);
  --shadow: rgb(0 0 0 / .35);
}

/* Light mode, chosen in Settings. Same roles, light values: every text colour keeps at least 4.5:1 contrast on
   the surfaces it sits on, and white text on the --signal buttons does too. */
[data-theme="light"] {
  color-scheme: light;
  --bg: #F3F4F8;
  --surface: #FFFFFF;
  --raised: #ECEEF4;
  --line: #CDD2DF;
  --line-soft: #E2E5EE;
  --text: #1B2033;
  --muted: #545D78;
  --faint: #636B86;
  --signal: #2F5FD0;
  --signal-ink: #FFFFFF;
  --amber: #9A5B00;
  --coral: #C2353A;
  --mint: #18794E;
  --hover: rgb(0 0 0 / .04);
  --shadow: rgb(27 32 51 / .16);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
/* Auth screens opt out: iPhone browsers (Brave included) treat 100vh as taller
   than the visible page, so a 100%-tall body plus a 100vh card sits low. */
html:has(.auth-wrap), html:has(.legal),
html:has(.auth-wrap) body, html:has(.legal) body { height: auto; min-height: 100vh; min-height: 100svh; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 var(--step-0)/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--signal); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-1); }
h3 { font-size: var(--step-0); }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: var(--step--1); }
.num { font-variant-numeric: tabular-nums; }
.pre { white-space: pre-wrap; word-break: break-word; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--line-soft); margin: 1.5rem 0; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side {
  background: var(--surface);
  border-right: 1px solid var(--line-soft);
  padding: 1.1rem .8rem;
  display: flex; flex-direction: column; gap: 1.1rem;
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 650; font-size: 1.05rem; color: var(--text); padding: 0 .5rem; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-flex; gap: 2px; }
.brand-mark i { width: 4px; height: 18px; border-radius: 2px; display: block; }
.brand-mark i:nth-child(1) { background: #82A8FF; }
.brand-mark i:nth-child(2) { background: #F2B356; height: 14px; margin-top: 4px; }
.brand-mark i:nth-child(3) { background: #7FD1A8; height: 10px; margin-top: 8px; }
.brand-name { line-height: 1; }
.brand small { color: var(--faint); font-weight: 400; font-size: .8em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  color: var(--muted); padding: .42rem .6rem; border-radius: var(--radius-s);
  display: flex; justify-content: space-between; align-items: center;
}
.nav a:hover { background: var(--raised); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--raised); color: var(--text); }
.nav-group-title { color: var(--faint); font-size: var(--step--1); padding: 0 .6rem .2rem; }
.nav .lane-link { border-left: 3px solid var(--lane); border-radius: 0 var(--radius-s) var(--radius-s) 0; padding-left: .55rem; }
.nav .lane-link .live { width: 7px; height: 7px; border-radius: 50%; background: var(--lane); box-shadow: 0 0 0 3px color-mix(in srgb, var(--lane) 25%, transparent); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }

.timer {
  border: 1px solid var(--line); border-left: 4px solid var(--lane);
  border-radius: var(--radius-s); padding: .6rem .7rem; background: var(--bg);
}
.timer .t { font: 600 1.25rem/1.1 var(--font-mono); font-variant-numeric: tabular-nums; }
.timer .who { font-size: var(--step--1); color: var(--muted); margin-bottom: .2rem; }
.timer form { display: inline; }
.timer .row { display: flex; gap: .4rem; margin-top: .45rem; }

.main { padding: 1.8rem 2.2rem 4rem; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin-top: .3rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.btn.menu-toggle { display: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem; justify-content: center;
  font: 500 var(--step--1)/1 var(--font); color: var(--text);
  background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: .55rem .85rem; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--signal); color: var(--signal-ink); border-color: var(--signal); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--coral); }
.btn.danger:hover { border-color: var(--coral); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--line); }
.btn.sm { padding: .35rem .6rem; }
.btn.block { width: 100%; }
.linkbtn { background: none; border: 0; color: var(--signal); cursor: pointer; padding: 0; font: inherit; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; }
.field label { font-size: var(--step--1); color: var(--muted); }
.field .help { font-size: var(--step--1); color: var(--faint); }
.field .err { font-size: var(--step--1); color: var(--coral); }
.field.check { flex-direction: row; align-items: center; gap: .5rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], input[type=search], input:not([type]), select, textarea {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: .55rem .65rem; font: inherit; font-size: var(--step-0);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--signal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--signal) 18%, transparent); }
textarea { min-height: 7rem; resize: vertical; line-height: 1.5; }
input[type=color] { width: 3rem; height: 2.3rem; padding: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-s); }
.color-pair { display: flex; align-items: center; gap: .5rem; }
.color-pair input[type="color"] { flex: none; }
.color-pair input[type="text"] { flex: 1; width: auto; min-width: 0; }
input[type=checkbox] { accent-color: var(--signal); width: 1rem; height: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 1.1rem; }
.form-grid .wide { grid-column: 1 / -1; }
fieldset { border: 0; border-top: 1px solid var(--line-soft); padding: 1.1rem 0 0; margin: 0 0 1rem; }
legend { color: var(--text); font-weight: 600; padding-right: .6rem; }
.inline-form { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin: 0; }
.inline-form .grow { flex: 1 1 220px; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.filters select, .filters input { width: auto; min-width: 9rem; }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius-m); padding: 1.1rem 1.2rem; }
.panel + .panel { margin-top: 1rem; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; margin-bottom: .7rem; }
.panel-head h2 { margin: 0; }
.cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1.2rem; align-items: start; }
.stack > * + * { margin-top: 1rem; }

/* ---------- lanes (the signature element) ---------- */
.lanes { display: flex; flex-direction: column; gap: .55rem; }
.lane {
  display: grid; grid-template-columns: 6px minmax(140px, 1.1fr) minmax(170px, 1fr) minmax(0, 2fr) auto;
  gap: 1rem; align-items: center;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius-m);
  padding: .85rem 1rem .85rem 0; overflow: hidden;
}
.lane.is-live { border-color: color-mix(in srgb, var(--lane) 55%, var(--line)); }
.lane-bar { align-self: stretch; background: var(--lane); margin: -.85rem 0; }
.lane-name { font-weight: 600; }
.lane-name a { color: var(--text); }
.lane-meta { font-size: var(--step--1); color: var(--muted); }
.lane-ctx { font-size: var(--step--1); color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.lane-ctx em { color: var(--faint); font-style: normal; }
.hours { display: flex; flex-direction: column; gap: .3rem; }
.hours-track { height: 6px; background: var(--raised); border-radius: 3px; position: relative; overflow: hidden; }
.hours-fill { position: absolute; inset: 0 auto 0 0; background: var(--lane); border-radius: 3px; }
.hours-fill.over { background: repeating-linear-gradient(-45deg, var(--lane), var(--lane) 4px, var(--amber) 4px, var(--amber) 8px); }
.core { display: inline-flex; align-items: center; gap: .3rem; }
.core::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.core.in::before { background: var(--mint); }

.capacity { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.capacity .big { font-size: var(--step-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.capacity-track { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--raised); margin: .6rem 0 .2rem; }
.capacity-track span { display: block; height: 100%; background: var(--lane); }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: .6rem 0; border-top: 1px solid var(--line-soft); display: flex; gap: .7rem; align-items: flex-start; }
.list > li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { color: var(--text); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--lane); flex: none; margin-top: .45rem; }
.tag { display: inline-block; font-size: .75rem; padding: .08rem .45rem; border-radius: 999px; background: var(--raised); color: var(--muted); border: 1px solid var(--line-soft); }
.tag.job { border-color: color-mix(in srgb, var(--lane) 50%, transparent); color: var(--text); }
.tag.job::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--lane); margin-right: .35rem; vertical-align: 1px; }
.tag.urgent, .tag.overdue { color: var(--coral); border-color: color-mix(in srgb, var(--coral) 40%, transparent); }
.tag.high { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 40%, transparent); }
.tag.blocked { color: var(--amber); }
.tag.done { color: var(--mint); }
.tag.ai { color: var(--signal); border-color: color-mix(in srgb, var(--signal) 40%, transparent); }
.status-form select {
  width: auto; min-width: 6.6rem; padding: .2rem .15rem; font-size: var(--step--1);
  background: transparent; border-color: transparent; color: var(--muted); cursor: pointer;
}
.status-form select:hover, .status-form select:focus { background: var(--bg); border-color: var(--line); color: var(--text); }

.list > li.task { align-items: center; gap: .85rem; padding-left: .7rem; border-left: 3px solid var(--lane); }
.task .meta { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .5rem; margin-top: .12rem; color: var(--faint); font-size: var(--step--1); }
.task .who, .log .who { color: var(--muted); }
.task .ref { color: var(--faint); }
.task .facts {
  display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: .05rem;
  min-width: 7.4rem; text-align: right; font-size: var(--step--1); line-height: 1.35;
  font-variant-numeric: tabular-nums; color: var(--muted);
}
.task .facts .overdue { color: var(--coral); }
.task .facts .when:empty { min-height: 1.2em; }
.task .facts .est { color: var(--faint); }

.dayhead {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  margin: 1.25rem 0 .15rem; font-size: var(--step-0); font-weight: 600; color: var(--text);
}
h2 + .dayhead { margin-top: .15rem; }
.dayhead .total { color: var(--muted); font-weight: 500; }
.log { list-style: none; margin: 0; padding: 0; }
.log > li {
  position: relative;
  display: grid; grid-template-columns: 7.6rem 4.8rem minmax(0, 1fr);
  gap: .25rem .8rem; align-items: start;
  padding: .55rem .15rem .55rem .7rem; border-top: 1px solid var(--line-soft); border-left: 3px solid var(--lane);
}
.log > li:first-child { border-top: 0; }
.log .when { color: var(--muted); padding-top: .08rem; }
.log .dur { font-weight: 600; padding-top: .08rem; }
.log .what { min-width: 0; }
.log .line { display: flex; gap: .75rem; align-items: baseline; min-width: 0; }
.log .work { min-width: 0; }
.log .note { color: var(--faint); font-size: var(--step--1); }
.log .who { margin-left: auto; flex: none; font-size: var(--step--1); white-space: nowrap; }
.log form {
  position: absolute; right: .15rem; top: .4rem; opacity: 0; pointer-events: none;
  background: var(--surface); padding-left: .45rem;
}
.log > li:hover form, .log > li:focus-within form { opacity: 1; pointer-events: auto; }

table.table { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
.table th { text-align: left; color: var(--faint); font-weight: 500; padding: .5rem .6rem; border-bottom: 1px solid var(--line); }
.table td { padding: .55rem .6rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table-wrap { overflow-x: auto; }

/* ---------- schedule ---------- */
/* Wide screens: the calendar fills the window and scrolls inside it, with the day and hour labels pinned.
   100dvh is the height actually visible; 100vh (the fallback for older browsers) can be taller on phones. */
.page-schedule { overflow: hidden; }
.page-schedule .shell,
.page-schedule .main { height: 100vh; height: 100dvh; }
.page-schedule .main {
  display: flex; flex-direction: column; min-height: 0; overflow: hidden; padding-bottom: 1.2rem;
}
.page-schedule .main > * { flex: none; }
.page-schedule .cal { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.cal { border: 1px solid var(--line-soft); border-radius: var(--radius-m); background: var(--surface); }
.cal-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; }
.cal-head, .cal-body { display: grid; grid-template-columns: 3.6rem repeat(7, minmax(8.25rem, 1fr)); min-width: 62rem; }
.cal-head { position: sticky; top: 0; z-index: 4; background: var(--surface); border-bottom: 1px solid var(--line); }
.cal-gutter, .cal-times { position: sticky; left: 0; z-index: 3; background: var(--surface); }
.cal-gutter { z-index: 5; }
.cal-dayhead { text-align: center; padding: .45rem .25rem .55rem; border-left: 1px solid var(--line-soft); }
.cal-dayhead .dow { display: block; color: var(--muted); font-size: .72rem; font-weight: 500; }
.cal-dayhead .dom { display: inline-flex; align-items: center; justify-content: center; min-width: 1.7rem; height: 1.7rem; margin-top: .1rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.cal-dayhead.today .dow { color: var(--signal); }
.cal-dayhead.today .dom { color: var(--signal-ink); background: var(--signal); border-radius: 999px; }
.cal-col { position: relative; border-left: 1px solid var(--line-soft); }
.cal-col.today { background: color-mix(in srgb, var(--signal) 8%, transparent); }
.cal-slot { border-top: 1px solid var(--line-soft); box-sizing: border-box; }
.cal-hour { box-sizing: border-box; border-top: 1px solid transparent; color: var(--faint); font-size: .68rem; text-align: right; padding: .15rem .4rem 0 0; font-variant-numeric: tabular-nums; }
.cal-ev { position: absolute; z-index: 1; overflow: hidden; box-sizing: border-box; background: var(--lane); border-radius: 4px; padding: 2px 5px; font-size: .72rem; line-height: 1.25; }
.cal-ev:hover { text-decoration: none; filter: brightness(1.08); }
.cal-ev .t { display: block; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-ev .m, .cal-ev .why { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; }
.cal-ev.hard { outline: 2px solid var(--coral); outline-offset: -2px; }
.cal-ev.soft { outline: 1px solid var(--amber); outline-offset: -1px; }
.cal-now { position: absolute; left: 0; right: 0; z-index: 2; height: 2px; background: var(--coral); pointer-events: none; }
.cal-now::before { content: ""; position: absolute; left: -1px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--coral); }
/* Phones and small tablets: the heading and buttons wrap and take much of the screen, so don't lock the page.
   The page scrolls normally, and the calendar is a window one screen tall: scroll the page until it fills the
   screen, then scroll inside it. When it reaches the top or bottom, scrolling carries on to the page. */
@media (max-width: 820px) {
  .page-schedule { overflow: visible; }
  .page-schedule .shell, .page-schedule .main { height: auto; }
  .page-schedule .main { display: block; overflow: visible; padding-bottom: 1.5rem; }
  .page-schedule .cal { display: block; }
  .page-schedule .cal-scroll { height: calc(100vh - 1.5rem - 2px); height: calc(100svh - 1.5rem - 2px); }  /* 2px: the frame's border */
}
.agenda .when { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 6.5rem; font-size: var(--step--1); padding-top: .1rem; }
.clash-text { color: var(--coral); font-size: var(--step--1); }
.clash-text.soft { color: var(--amber); }

.dayboard-scale, .dayrow { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: .6rem; align-items: center; }
.dayboard-scale { margin-bottom: .15rem; }
.dayboard-scale .scale { position: relative; height: 1rem; }
.dayboard-scale .scale span { position: absolute; top: 0; color: var(--faint); font-size: .7rem; font-variant-numeric: tabular-nums; transform: translateX(-50%); }
.dayboard-scale .scale span:first-child { transform: none; }
.dayrow { margin: .3rem 0; }
.dayrow .name { color: var(--text); font-size: var(--step--1); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dayrow .track { position: relative; height: 1.75rem; background: var(--bg); border-radius: 4px; }
.dayrow .coreband { position: absolute; top: 0; bottom: 0; background: var(--raised); border-radius: 3px; }
.dayrow .block { position: absolute; top: 3px; bottom: 3px; z-index: 1; overflow: hidden; white-space: nowrap; color: var(--text); font-size: .7rem; line-height: 1.35rem; padding: 0 .35rem; border-radius: 3px; border-left: 3px solid var(--lane); background: color-mix(in srgb, var(--lane) 42%, var(--bg)); }
.dayrow .block.hard { outline: 1px solid var(--coral); }
.dayrow .block.soft { outline: 1px solid var(--amber); }
.dayrow .block:hover { text-decoration: none; }
.dayrow .now { position: absolute; top: 0; bottom: 0; z-index: 2; width: 1px; background: var(--text); }
.switch-card { border-left: 4px solid var(--lane); background: var(--bg); border-radius: var(--radius-s); padding: .75rem .9rem; margin-bottom: 1rem; }
.switch-facts { margin: .4rem 0 0; padding-left: 1.1rem; color: var(--muted); font-size: var(--step--1); }
.switch-facts li + li { margin-top: .15rem; }

/* ---------- flashes ---------- */
.flashes { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.2rem; }
.flash { padding: .65rem .9rem; border-radius: var(--radius-s); background: var(--surface); border: 1px solid var(--line); border-left-width: 4px; }
.flash.success { border-left-color: var(--mint); }
.flash.error { border-left-color: var(--coral); }
.flash.warning { border-left-color: var(--amber); }
.flash.info { border-left-color: var(--signal); }

.empty { color: var(--muted); padding: 1.2rem 0; }
.empty a { font-weight: 500; }

/* ---------- auth & landing ---------- */
.auth-wrap {
  min-height: 100vh;
  min-height: 100svh; /* visible height while the mobile toolbar is open; 100vh includes it */
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
}
.auth { width: 100%; max-width: 400px; margin-block: auto; }
.auth .brand { justify-content: center; margin-bottom: 1.5rem; font-size: 1.25rem; }
.auth .panel { padding: 1.6rem; }
.auth h1 { font-size: var(--step-2); }
.auth-foot { text-align: center; margin-top: 1rem; color: var(--muted); font-size: var(--step--1); }

.landing { max-width: 1080px; margin: 0 auto; padding: 1.5rem 1.5rem 5rem; }
.landing-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4.5rem; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 3rem; align-items: center; }
.hero h1 { font-size: clamp(2.2rem, 4.6vw, 3.4rem); line-height: 1.05; letter-spacing: -0.025em; margin-bottom: 1.1rem; }
.hero p { color: var(--muted); font-size: var(--step-1); }
.hero-demo { display: flex; flex-direction: column; gap: .5rem; }
.demo-lane { display: grid; grid-template-columns: 6px 1fr auto; gap: .9rem; align-items: center; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius-m); padding: .75rem 1rem .75rem 0; overflow: hidden; }
.demo-lane .lane-bar { margin: -.75rem 0; }
.demo-lane .t { font-variant-numeric: tabular-nums; color: var(--muted); font-size: var(--step--1); }
.demo-clash { color: var(--coral); font-size: var(--step--1); padding-left: 1.2rem; }
.features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2rem 2.5rem; margin-top: 5rem; }
.features h3 { font-size: var(--step-1); margin-bottom: .4rem; }
.features p { color: var(--muted); }

/* ---------- chat ---------- */
.chat-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1.2rem; height: calc(100vh - 3.6rem); }
.chat-list { overflow-y: auto; }
.chat-list a { display: block; padding: .45rem .6rem; border-radius: var(--radius-s); color: var(--muted); font-size: var(--step--1); border-left: 3px solid var(--lane); margin-bottom: 2px; }
.chat-list a.btn { border-left: 1px solid var(--line); color: var(--text); margin-bottom: .8rem; }
.chat-list a.on, .chat-list a:not(.btn):hover { background: var(--surface); color: var(--text); text-decoration: none; }
.chat-main { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius-m); }
.chat-top { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: .8rem 1rem; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.chat-top .scope { display: flex; align-items: center; gap: .55rem; font-weight: 600; }
.chat-top .scope .dot { margin: 0; }
.chat-top form { display: flex; gap: .4rem; align-items: center; }
.chat-top select { width: auto; padding: .35rem .5rem; font-size: var(--step--1); }
.messages { flex: 1; overflow-y: auto; padding: 1.2rem 1rem; display: flex; flex-direction: column; gap: 1rem; }
.msg { max-width: 760px; }
.msg.user { align-self: flex-end; background: var(--raised); padding: .65rem .9rem; border-radius: var(--radius-m) var(--radius-m) 2px var(--radius-m); }
.msg.assistant { align-self: flex-start; }
.msg .body { white-space: pre-wrap; word-break: break-word; }
.msg .body code { font-family: var(--font-mono); font-size: .88em; background: var(--bg); padding: .05rem .3rem; border-radius: 4px; }
.msg .acts { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }
.act { font-size: .75rem; padding: .12rem .5rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.act.write { color: var(--signal); border-color: color-mix(in srgb, var(--signal) 45%, transparent); }
.act.fail { color: var(--coral); border-color: color-mix(in srgb, var(--coral) 45%, transparent); }
.msg.pending .body { color: var(--faint); }
.composer { border-top: 1px solid var(--line-soft); padding: .8rem; display: flex; gap: .6rem; align-items: flex-end; }
.composer textarea { min-height: 2.8rem; max-height: 12rem; }
.suggest { display: flex; flex-wrap: wrap; gap: .4rem; }
.suggest button { font: inherit; font-size: var(--step--1); color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: .35rem .75rem; cursor: pointer; }
.suggest button:hover { color: var(--text); border-color: var(--muted); }
.chat-empty { margin: auto; text-align: center; max-width: 460px; color: var(--muted); }
.chat-empty .suggest { justify-content: center; margin-top: 1rem; }
.chat-nav { display: none; gap: .3rem; }
.chat-list-head { display: none; font-size: var(--step--1); color: var(--muted); font-weight: 600; margin: .4rem 0 .6rem; }

/* Wide screens: a conversation fills the window and the page itself doesn't scroll. Messages scroll in the middle
   and the message box stays at the bottom. */
@media (min-width: 821px) {
  .page-chat { overflow: hidden; }
  .page-chat .shell { height: 100vh; height: 100dvh; }
  .page-chat .main { height: 100%; display: flex; flex-direction: column; overflow: hidden; padding-bottom: 1.8rem; }
  .page-chat .chat-layout { flex: 1; min-height: 0; height: auto; }
}

/* Phones: the chat is pinned to the edges of the screen (position: fixed; inset: 0) and only the messages scroll,
   like a chat app. Pinned edges are placed by the browser itself, so this doesn't rely on its reported screen
   height (100vh, 100dvh, visualViewport), which some iPhone browsers, Brave among them, get wrong until the page
   is scrolled. The page underneath is given no height, so there's nothing to scroll and nothing slides under the
   browser's toolbars. Notices (the plan banner, flashes) sit above the chat. */
@media (max-width: 820px) {
  .page-chat { background: var(--surface); }
  .page-chat .shell { min-height: 0; }
  .page-chat .main { position: fixed; inset: 0; display: flex; flex-direction: column; padding: 0; overflow: hidden; }
  .page-chat .main > .menu-toggle { display: none; }
  .page-chat .main > .flashes { flex: none; margin: .5rem .6rem 0; }
  .page-chat .chat-layout { flex: 1; min-height: 0; height: auto; display: flex; flex-direction: column; gap: 0; }
  .page-chat .chat-list { display: none; }
  .page-chat .chat-main { flex: 1; min-height: 0; border: 0; border-radius: 0; }
  .page-chat .chat-top { flex: none; padding: .45rem .6rem; gap: .35rem .5rem; }
  .page-chat .chat-nav { display: flex; }
  .page-chat .chat-top .actions { margin-left: auto; }
  .page-chat .chat-top select { max-width: 9.5rem; }
  .page-chat .chat-top .scope { order: 3; flex: 1 0 100%; min-width: 0; font-size: var(--step--1); }
  .page-chat #chat-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .page-chat .messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: .9rem .8rem; }
  .page-chat .msg.user { max-width: 88%; }
  .page-chat .composer { flex: none; padding: .5rem .6rem calc(.5rem + env(safe-area-inset-bottom)); }
  .page-chat .composer textarea { font-size: 16px; min-height: 2.6rem; resize: none; }   /* 16px stops iPhones zooming in */
}

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .cols { grid-template-columns: 1fr; }
  .lane { grid-template-columns: 6px 1fr 1fr; }
  .lane-ctx { grid-column: 2 / -1; }
  .lane .actions { grid-column: 2 / -1; }
  .hero { grid-template-columns: 1fr; }
  .features { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  /* The menu drawer runs from the top to the bottom of what's visible (not 100vh, which on phones includes the
     area behind the browser's toolbar), and scrolls if it doesn't fit, so Settings and Sign out are reachable. */
  .side { position: fixed; inset: 0 auto 0 0; height: auto; width: 260px; z-index: 20; transform: translateX(-100%); transition: transform .2s ease;
          overscroll-behavior: contain; padding-bottom: calc(1.1rem + env(safe-area-inset-bottom)); }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgb(0 0 0 / .45); }
  .btn.menu-toggle { display: inline-flex; margin-bottom: 1rem; }
  .main { padding: 1.1rem 1rem 3rem; }
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .chat-layout > .chat-list { order: 2; overflow: visible; }      /* Assistant page: conversations under the form */
  .chat-layout > .chat-list > a.btn { display: none; }             /* "New conversation" is the form above */
  .chat-list-head { display: block; }
  .lane { grid-template-columns: 6px 1fr; }
  .lane > :not(.lane-bar) { grid-column: 2; }
  .list > li.task { flex-wrap: wrap; }
  .task .grow { flex: 1 1 calc(100% - 1rem); }
  .task .facts { flex-direction: row; gap: .7rem; min-width: 0; align-items: center; }
  .status-form { margin-left: auto; }
  .log > li { grid-template-columns: 6.8rem 4.4rem minmax(0, 1fr); }
  .log .line { flex-wrap: wrap; }
  .log .who { margin-left: 0; }
  .log form { position: static; opacity: 1; pointer-events: auto; grid-column: 1 / -1; justify-self: start; background: none; padding-left: 0; }
  .features { grid-template-columns: 1fr; }
}
@media (hover: none) {
  .log form {
    position: static; opacity: 1; pointer-events: auto; background: none;
    grid-column: 1 / -1; justify-self: start; padding-left: 0;
  }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.cols > .panel + .panel { margin-top: 0; }


/* ---------- legal pages and footer ---------- */
.legal { max-width: 820px; margin: 0 auto; padding: 1.5rem 1.5rem 3rem; }
.legal-nav { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 2.5rem; }
.legal-tabs { display: flex; gap: .25rem; }
.legal-tabs a { color: var(--muted); padding: .4rem .7rem; border-radius: var(--radius-s); font-size: var(--step--1); }
.legal-tabs a:hover { background: var(--raised); color: var(--text); text-decoration: none; }
.legal-tabs a.on { background: var(--raised); color: var(--text); }
.legal-doc h1 { margin-bottom: .3rem; }
.legal-doc h2 { margin-top: 2.2rem; padding-top: 1.2rem; border-top: 1px solid var(--line-soft); scroll-margin-top: 1rem; }
.legal-doc h3 { margin-top: 1.4rem; }
.legal-doc .lead { font-size: var(--step-1); color: var(--text); margin: 1.2rem 0 0; }
.legal-doc ul { padding-left: 1.2rem; margin: 0 0 1em; }
.legal-doc li { margin-bottom: .4rem; }
.legal-doc code { font-family: var(--font-mono); font-size: .9em; background: var(--raised); padding: .05rem .35rem; border-radius: 4px; }
.legal-table { width: 100%; border-collapse: collapse; margin: 0 0 1.2rem; font-size: var(--step--1); }
.legal-table th, .legal-table td { text-align: left; vertical-align: top; padding: .6rem .7rem; border-top: 1px solid var(--line-soft); }
.legal-table th { color: var(--muted); font-weight: 500; border-top: 0; border-bottom: 1px solid var(--line); }
.legal-table td:first-child { min-width: 9rem; }
@media (max-width: 640px) { .legal-table { display: block; overflow-x: auto; } }
.legal-foot { margin-top: 3.5rem; padding-top: 1.2rem; border-top: 1px solid var(--line-soft); }
.legal-foot p { margin: .6rem 0 0; }
.legal-links { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; font-size: var(--step--1); }
.landing .legal-foot { margin-top: 4rem; }
.auth .legal-foot { margin-top: 2rem; border-top: 0; text-align: center; padding-top: 0; }
.auth .legal-links { justify-content: center; }
.auth .legal-foot p { margin-inline: auto; }
.side-legal { display: flex; flex-wrap: wrap; gap: .1rem .7rem; padding: .5rem .6rem 0; font-size: .75rem; }
.side-legal a { color: var(--faint); }
.side-legal a:hover { color: var(--muted); }
.field.check.terms { align-items: flex-start; }
.field.check.terms input { margin-top: .25rem; flex: none; }
.field.check.terms label { line-height: 1.45; }

/* ---------- captcha and contact ---------- */
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.captcha-box { display: flex; align-items: center; min-height: 70px; }
.captcha-box img { display: block; border-radius: var(--radius-s); border: 1px solid var(--line); background: #F4F5FA; max-width: 100%; height: auto; }
.captcha-q { margin: 0; padding: .7rem .8rem; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-s); color: var(--text); }
.contact-form { max-width: 560px; margin-top: 1.4rem; }
.contact-form textarea { min-height: 9rem; }

/* ---------- two-step sign-in and passkeys ---------- */
.or { display: flex; align-items: center; gap: .8rem; color: var(--faint); font-size: var(--step--1); margin: 1rem 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line-soft); }
.err-line { color: var(--coral); margin: .6rem 0 0; }
.steps { padding-left: 1.2rem; margin: 0 0 1rem; }
.steps > li { margin-bottom: 1.4rem; padding-left: .3rem; }
.qr { display: block; width: max-content; max-width: 100%; margin: .8rem 0 .6rem; padding: .6rem; background: #fff; border-radius: var(--radius-s); line-height: 0; }
.qr img { display: block; }
code.secret { font-family: var(--font-mono); font-size: var(--step-0); letter-spacing: .05em; background: var(--bg); border: 1px solid var(--line); padding: .35rem .6rem; border-radius: var(--radius-s); user-select: all; word-break: break-all; }
pre.codes { font-family: var(--font-mono); font-size: var(--step-1); line-height: 1.9; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-s); padding: .8rem 1rem; columns: 2; margin: 1rem 0; user-select: all; }
.inline-pw { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline-pw input { flex: 1 1 10rem; width: auto; min-width: 0; }

/* ---------- Security page: one stacked column ---------- */
/* minmax(0, 1fr): a plain grid column grows to fit its widest content (a table, a long URL), which pushed
   pages such as Administration > Billing wider than a phone screen. Tables scroll sideways in .table-wrap. */
.sec-stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; max-width: 760px; }
.sec-stack code { overflow-wrap: anywhere; }
.sec-stack > .panel { margin: 0; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: .45rem; }
.sec-head h2 { margin: 0; }
.sec-desc { color: var(--muted); font-size: var(--step--1); margin: 0 0 1rem; }
.sec-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.sec-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; padding: .75rem 0; border-top: 1px solid var(--line-soft); }
.sec-row:last-child { border-bottom: 1px solid var(--line-soft); }
.sec-row-main { min-width: 0; }
.sec-row details[open] { flex: 1 1 100%; }
details.reveal > summary { list-style: none; cursor: pointer; }
details.reveal > summary::-webkit-details-marker { display: none; }
details.reveal[open] > summary { margin-bottom: .7rem; }
details.reveal .inline-pw { margin: 0; }
.passkey-add { margin-top: 1.2rem; }
.passkey-add h3 { margin-bottom: .6rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }
.codes-box { margin-top: 1.2rem; padding-top: 1.2rem; border-top: 1px solid var(--line-soft); }
.support-code { font-family: var(--font-mono); font-size: 2.2rem; letter-spacing: .2em; text-align: center; padding: .7rem 1rem .7rem 1.2rem; max-width: 18rem; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-m); margin: 0 0 .7rem; user-select: all; }
.sec .actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .6rem; }

/* ---------- Administration > Models ---------- */
.admin-section { margin-bottom: 2.2rem; }
.section-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: .3rem 1rem; margin-bottom: .9rem; }
.section-head h2 { margin: 0; }
.section-head p { margin: 0; }
.prov-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; align-items: stretch; }
.prov-grid > .prov { display: flex; flex-direction: column; margin: 0; }
.prov .panel-head { align-items: center; margin-bottom: 1rem; min-height: 2.4rem; }
.prov .panel-head h3 { margin: 0; font-size: var(--step-1); }
.prov-help { margin: -.3rem 0 0; min-height: 2.6em; }
.prov-actions { margin-top: auto; padding-top: 1rem; display: flex; gap: .5rem; }
.models-table td { vertical-align: middle; }
.add-model { margin-top: 1rem; }
.add-model > summary { cursor: pointer; font-weight: 600; list-style: none; }
.add-model > summary::-webkit-details-marker { display: none; }
.add-model > summary::before { content: "+"; display: inline-block; width: 1.1rem; color: var(--muted); font-weight: 400; }
.add-model[open] > summary::before { content: "\2212"; }
.add-model[open] > summary { margin-bottom: 1.1rem; }
.add-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1.4fr); gap: 0 1rem; }
.add-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .6rem 1rem; }
.add-foot .field { margin: 0; }
@media (max-width: 760px) { .add-grid { grid-template-columns: 1fr; } }

/* A button that stays in place but can't be used right now. */
.btn.is-disabled { opacity: .4; cursor: default; pointer-events: none; user-select: none; }

/* ---------- Calendars ---------- */
.feed-facts { display: grid; gap: .4rem 1.5rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin: 0 0 1rem; }
.feed-facts dt { color: var(--faint); font-size: var(--step--1); }
.feed-facts dd { margin: 0; }
.sec-notes { margin: 0; padding-left: 1.2rem; color: var(--muted); font-size: var(--step--1); }
.sec-notes li { margin-bottom: .5rem; }
.sec-notes strong { color: var(--text); font-weight: 600; }
details.howto { margin-top: 1.1rem; font-size: var(--step--1); }
details.howto > summary { cursor: pointer; color: var(--muted); }
details.howto ul { margin: .7rem 0 0; padding-left: 1.2rem; color: var(--muted); }
details.howto li { margin-bottom: .5rem; }
.feed-facts + .err-line { margin: -.2rem 0 1rem; }

/* ---------- Billing ---------- */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; }
.plan-card { display: flex; flex-direction: column; gap: .35rem; padding: 1.1rem; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-m); }
.plan-card .btn { margin-top: auto; }
.plan-name { font-size: var(--step-1); font-weight: 650; }
.plan-days { color: var(--muted); font-size: var(--step--1); }
.plan-price { margin: .5rem 0 .1rem; }
.price-now { font-size: 1.7rem; font-weight: 700; }
.price-old { color: var(--faint); text-decoration: line-through; }
.plans-table input { min-width: 0; }
.plans-table td { vertical-align: middle; }

/* ---------- Administration > Usage ---------- */
.usage { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.usage-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem .8rem; }
.usage-filters label { display: flex; flex-direction: column; gap: .25rem; font-size: var(--step--1); color: var(--muted); }
.usage-filters input, .usage-filters select { width: auto; max-width: 12rem; padding: .35rem .5rem; font-size: var(--step--1); }
.usage-presets { display: flex; gap: .3rem; margin-right: .4rem; }
.usage-where { margin: 0; color: var(--muted); }
.usage-where strong { color: var(--text); }
.usage-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; }
.usage-tile { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius-m); padding: .8rem 1rem; }
.usage-tile .k { font-size: var(--step--1); color: var(--muted); }
.usage-tile .v { font-size: 1.6rem; font-weight: 600; margin-top: .15rem; }
.usage-legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; list-style: none; padding: 0; margin: 0 0 .6rem; font-size: var(--step--1); color: var(--muted); }
.usage .sw { display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; margin-right: .4rem; vertical-align: -.05rem; }
.usage-chart-wrap { position: relative; overflow-x: auto; }
.usage-chart { display: block; width: 100%; min-width: 600px; height: auto; }
.usage-chart .grid { stroke: var(--line-soft); stroke-width: 1; }
.usage-chart .grid.base { stroke: var(--line); }
.usage-chart .tick { fill: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.usage-chart .hit { fill: transparent; }
.usage-chart .ubar.on .hit { fill: var(--hover); }
.usage-chart .ubar:focus-visible .hit { fill: color-mix(in srgb, var(--text) 8%, transparent); }
.usage-tip { position: absolute; z-index: 5; pointer-events: none; white-space: pre; background: var(--raised); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-s); padding: .45rem .6rem; font-size: var(--step--1);
  font-variant-numeric: tabular-nums; box-shadow: 0 6px 20px var(--shadow); }
.usage-table th.r, .usage-table td.r { text-align: right; }
.usage-table td:first-child { white-space: nowrap; }
@media (max-width: 820px) {
  .usage-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .usage-tile .v { font-size: 1.3rem; }
}
