/*
  app.css - one stylesheet for every page.

  Mobile-first: the base rules are the phone layout (top bar, one column,
  bottom tab bar). At 900px the tab bar becomes a side rail. There is no
  max-width container anywhere: on a wide screen the grids add columns
  instead of leaving empty margins, so a desktop never looks like a phone
  in the middle of the screen.

  Colours are the old app's tokens.
*/

:root {
  color-scheme: dark;
  --bg:            #0a0c0d;
  --panel:         #111417;
  --panel-alt:     #161a1d;
  --row-hover:     #1a1f22;
  --border:        rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --ink:           #e9e7e0;
  --ink-2:         #9a9d94;
  --ink-3:         #63665f;
  --accent:        #34d399;
  --accent-dim:    rgba(52, 211, 153, 0.14);
  --negative:      #f0715a;
  --negative-dim:  rgba(240, 113, 90, 0.14);
  --warning:       #f2b544;
  --warning-dim:   rgba(242, 181, 68, 0.14);
  --mono: "Cascadia Code", "Cascadia Mono", Consolas, "SFMono-Regular",
    ui-monospace, Menlo, "Liberation Mono", monospace;

  --radius: 10px;
  --side: clamp(12px, 2vw, 32px);
  --gap: clamp(10px, 1.2vw, 18px);
  --topbar-h: 3.25rem;
  --tabbar-h: 3.5rem;
  --rail-w: 13rem;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: clamp(14px, 0.3vw + 12.5px, 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(52, 211, 153, 0.07), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 0%, rgba(240, 113, 90, 0.05), transparent 55%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--mono);
  line-height: 1.55;
}

a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 600; }
p { margin: 0 0 0.6em; }
.muted { color: var(--ink-2); }
.positive { color: var(--accent); }
.negative { color: var(--negative); }

/* ---------- shell ---------- */

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas: "top" "main";
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}

.topbar {
  grid-area: top;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 var(--side);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
}

.brand {
  color: var(--ink);
  text-decoration: none;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.brand-glyph { color: var(--accent); margin-right: 0.35em; }
.brand-cursor { color: var(--accent); animation: blink 1.1s steps(1) infinite; margin-left: 0.1em; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .brand-cursor { animation: none; } }

.topbar-right { display: flex; align-items: center; gap: 14px; color: var(--ink-3); font-size: 0.85rem; }
.topbar-right form { margin: 0; }

/* the model's health: grey when the desktop is simply off (the usual state),
   amber when something between here and the model is broken. On a phone the
   reason drops from the whole top bar; on a wide screen, from the indicator. */
.model-status > summary { list-style: none; cursor: pointer; white-space: nowrap; }
.model-status > summary::-webkit-details-marker { display: none; }
.model-status > summary::before { content: "● "; }
.model-status--up > summary { color: var(--accent); }
.model-status--down > summary { color: var(--ink-3); }
.model-status--fault > summary { color: var(--warning); }
.model-status-detail {
  position: absolute;
  left: var(--side);
  right: var(--side);
  top: calc(100% + 4px);
  z-index: 30;
  margin: 0;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--panel-alt);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
.who { display: none; }

.main {
  grid-area: main;
  min-width: 0;
  padding: var(--gap) var(--side) calc(var(--gap) * 2);
}

.rail { display: none; }

/* phone: bottom tab bar */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.tabbar > a,
.more > summary {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--tabbar-h);
  padding: 0 4px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 0.78rem;
  cursor: pointer;
  list-style: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.more > summary::-webkit-details-marker { display: none; }
.tabbar > a[aria-current="page"] { color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); }
.more { position: relative; }
.more[open] > summary { color: var(--ink); }
.more ul {
  position: absolute;
  right: 6px;
  bottom: calc(100% + 6px);
  min-width: 12rem;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--panel-alt);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
.more li a {
  display: block;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
}
.more li a:hover, .more li a[aria-current="page"] { background: var(--row-hover); color: var(--accent); }

/* wide: side rail, no tab bar */
@media (min-width: 900px) {
  .shell {
    grid-template-columns: var(--rail-w) minmax(0, 1fr);
    grid-template-areas: "top top" "rail main";
    padding-bottom: 0;
  }
  .tabbar { display: none; }
  .who { display: inline; }
  .model-status { position: relative; }
  .model-status-detail { left: auto; right: 0; top: calc(100% + 8px); width: 22rem; }
  .rail {
    grid-area: rail;
    position: sticky;
    top: var(--topbar-h);
    align-self: start;
    display: flex;
    flex-direction: column;
    height: calc(100dvh - var(--topbar-h));
    padding: var(--gap) 10px;
    border-right: 1px solid var(--border);
  }
  .rail ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
  .rail a {
    display: block;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--ink-2);
    text-decoration: none;
  }
  .rail a:hover { background: var(--row-hover); color: var(--ink); }
  .rail a[aria-current="page"] { background: var(--accent-dim); color: var(--accent); }
  .rail a[aria-current="page"]::before { content: "> "; }
  .rail-foot { margin-top: auto; font-size: 0.85rem; }
}

/* ---------- page structure ---------- */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: var(--gap);
}
.page-head h1 { font-size: clamp(1.15rem, 0.8vw + 0.95rem, 1.6rem); }
.eyebrow {
  display: block;
  color: var(--ink-3);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

.section { margin-top: var(--gap); }

/* auto-fit + min(100%, …): one column on a phone, as many as fit on a wide
   screen, and never wider than the viewport on a very narrow one */
.grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
}
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); }
.span-all { grid-column: 1 / -1; }

.panel {
  min-width: 0;
  padding: clamp(12px, 1.1vw, 18px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.panel > h2 {
  margin-bottom: 10px;
  color: var(--ink-2);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.06em;
}

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-label { color: var(--ink-3); font-size: 0.75rem; letter-spacing: 0.06em; }
.stat-value { font-size: clamp(1.15rem, 1vw + 0.85rem, 1.7rem); font-variant-numeric: tabular-nums; }

/* ---------- messages ---------- */

.messages:empty { display: none; }
.messages { display: grid; gap: 8px; margin-bottom: var(--gap); }
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--panel-alt);
}
.alert--error { border-color: var(--negative); background: var(--negative-dim); }
.alert--warning { border-color: var(--warning); background: var(--warning-dim); }
.alert--success { border-color: var(--accent); background: var(--accent-dim); }

/* ---------- forms ---------- */

input, select, textarea, button { font: inherit; color: inherit; }

input[type="text"], input[type="password"], input[type="search"], input[type="number"],
input[type="date"], select, textarea {
  width: 100%;
  min-height: 2.5rem;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.form-stack { display: grid; gap: 14px; }
.form-stack label { display: grid; gap: 4px; }
.form-stack label > span { color: var(--ink-2); font-size: 0.8rem; }
.field-error { color: var(--negative); font-size: 0.8rem; }

.btn {
  min-height: 2.5rem;
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--panel-alt);
  cursor: pointer;
}
.btn:hover { border-color: var(--ink-3); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #062a1d; font-weight: 600; }
.btn--primary:hover { filter: brightness(1.08); }

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-2);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--ink); }

/* ---------- login ---------- */

.bare {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: var(--side);
}
.login { width: min(100%, 24rem); display: grid; gap: 18px; }
.login .brand { font-size: 1.4rem; text-align: center; }

/* htmx marks requests in flight */
.htmx-request { opacity: 0.6; transition: opacity 0.2s; }

/* ---------- small pieces ---------- */

.hint { color: var(--ink-3); font-size: 0.75rem; font-weight: 400; letter-spacing: 0; }
.small { font-size: 0.8rem; }
.empty { color: var(--ink-3); margin: 6px 0; }

.kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.kv:last-child { border-bottom: 0; }
.kv-key { min-width: 0; overflow-wrap: anywhere; }
.kv-value { white-space: nowrap; font-variant-numeric: tabular-nums; }

.badge {
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  white-space: nowrap;
}
.badge--pending { background: var(--warning-dim); color: var(--warning); }
.badge--reversed { background: var(--row-hover); color: var(--ink-2); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.72rem;
  white-space: nowrap;
}
.chip--ignore { background: var(--negative-dim); color: var(--negative); }
.chip-x {
  padding: 0 2px;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  line-height: 1;
}
.chip-x:hover { color: var(--ink); }

/* ---------- toolbars and filters ---------- */

.toolbar { display: grid; gap: 10px; margin-bottom: var(--gap); }

.range { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.range-dates { display: inline-flex; align-items: center; gap: 6px; }
.range-dates input { width: auto; min-height: 2.25rem; }

/* radio buttons drawn as a segmented control: no JavaScript, and the form
   submits them like any other field */
.segmented {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  overflow: hidden;
}
.segmented label { position: relative; }
.segmented input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.segmented span {
  display: block;
  padding: 6px 10px;
  color: var(--ink-2);
  font-size: 0.8rem;
  cursor: pointer;
  border-right: 1px solid var(--border);
}
.segmented label:last-child span { border-right: 0; }
.segmented input:checked + span { background: var(--accent-dim); color: var(--accent); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.segmented span:hover { color: var(--ink); }

.filter-row {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
  align-items: center;
}
.filter-row input[type="search"] { grid-column: 1 / -1; }
@media (min-width: 900px) { .filter-row input[type="search"] { grid-column: span 2; } }

.check { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 0.85rem; cursor: pointer; }

.bulk {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--gap);
}
.bulk input[type="text"] { width: auto; flex: 1 1 10rem; }

.inline-form { display: flex; gap: 6px; margin-top: 6px; }
.inline-form input { min-width: 0; }

.stat-edit summary { color: var(--ink-3); font-size: 0.75rem; cursor: pointer; }
.stat-edit summary:hover { color: var(--ink); }

/* ---------- bars ---------- */

.bar {
  display: block;
  padding: 5px 0;
  color: var(--ink);
  text-decoration: none;
}
.bar-top { display: flex; justify-content: space-between; gap: 12px; font-size: 0.85rem; }
.bar-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-value { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-track { display: block; height: 4px; margin-top: 4px; border-radius: 2px; background: var(--row-hover); }
.bar-fill { display: block; height: 100%; border-radius: 2px; background: var(--negative); }
.bar:hover .bar-name { color: var(--accent); }

/* ---------- chart ---------- */

.flow-chart {
  display: grid;
  grid-template-columns: 3.4rem minmax(0, 1fr);
  grid-template-rows: clamp(170px, 26vw, 300px) auto;
}
.chart-empty { grid-column: 1 / -1; color: var(--ink-3); margin: 24px 0; text-align: center; }
.chart-y { position: relative; }
.chart-y span {
  position: absolute;
  right: 8px;
  transform: translateY(-50%);
  color: var(--ink-3);
  font-size: 0.7rem;
  white-space: nowrap;
}
.chart-plot {
  position: relative;
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  touch-action: pan-y;
  cursor: crosshair;
}
.chart-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.chart-x {
  grid-column: 2;
  display: flex;
  justify-content: space-between;
  padding-top: 4px;
  color: var(--ink-3);
  font-size: 0.7rem;
}
.chart-month { stroke: var(--border); stroke-width: 1; }
.chart-zero { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-area { fill: var(--accent); opacity: 0.16; }
.chart-area--neg { fill: var(--negative); }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart-line--neg { stroke: var(--negative); }
.chart-mark-hit { stroke: transparent; stroke-width: 12; }
.chart-mark-line { stroke: var(--accent); stroke-width: 1; opacity: 0.35; stroke-dasharray: 2 3; }
.chart-mark--neg .chart-mark-line { stroke: var(--negative); }
.chart-mark:hover .chart-mark-line { opacity: 1; }
.chart-month-label {
  position: absolute;
  top: 2px;
  padding-left: 3px;
  color: var(--ink-3);
  font-size: 0.65rem;
  pointer-events: none;
}

/* overlays moved by flow-chart.js; [hidden] must win over their display */
.chart-plot [hidden] { display: none !important; }
.chart-crosshair, .chart-highlight {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  pointer-events: none;
}
.chart-crosshair { border-left: 1px solid var(--ink-2); }
.chart-highlight { border-left: 2px solid var(--warning); }
.chart-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--bg);
  pointer-events: none;
}
.chart-dot.is-negative { background: var(--negative); }
.chart-tip {
  position: absolute;
  top: 8px;
  margin-left: 10px;
  display: grid;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--panel-alt);
  font-size: 0.75rem;
  white-space: nowrap;
  pointer-events: none;
}
.chart-tip.is-left { transform: translateX(-100%); margin-left: -10px; }
.chart-tip-date { color: var(--ink-3); }
.chart-tip-value { color: var(--accent); font-weight: 600; }
.chart-tip-value.negative { color: var(--negative); }

/* ---------- transaction rows ---------- */

.tx-list { padding-top: 4px; padding-bottom: 4px; }
.day-head {
  display: flex;
  justify-content: space-between;
  padding: 12px 4px 4px;
  border-bottom: 1px solid var(--border);
  color: var(--ink-3);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}
.tx-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}
.tx-row:last-child { border-bottom: 0; }
.tx-row:hover { background: var(--row-hover); }
.tx-row.is-ignored { opacity: 0.45; }
.tx-check { margin: 12px 0 0 4px; accent-color: var(--accent); }
.tx-details { flex: 1; min-width: 0; }
.tx-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 4px;
  cursor: pointer;
  list-style: none;
}
.tx-summary::-webkit-details-marker { display: none; }
.tx-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-width: 0; }
.tx-date { color: var(--ink-3); font-size: 0.8rem; white-space: nowrap; }
.tx-desc { overflow-wrap: anywhere; }
.tx-category { color: var(--ink-3); font-size: 0.75rem; }
.tx-tags { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.tx-tags:empty { display: none; }
.tx-amount { white-space: nowrap; font-variant-numeric: tabular-nums; }
.tx-more { padding: 0 4px 12px; }
.tx-detail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: 4px 16px;
  margin: 0 0 10px;
  font-size: 0.8rem;
}
.tx-detail div { display: flex; gap: 8px; min-width: 0; }
.tx-detail dt { color: var(--ink-3); flex: 0 0 6.5rem; }
.tx-detail dd { margin: 0; overflow-wrap: anywhere; }

.tag-editor { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tag-editor form { margin: 0; }
.tag-add input { width: 9rem; min-height: 1.9rem; padding: 3px 8px; font-size: 0.8rem; }

.load-more { display: block; width: 100%; margin-top: 10px; }

/* ---------- imports ---------- */

.dropzone {
  display: grid;
  gap: 10px;
  padding: 22px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone input { justify-self: center; max-width: 100%; }

/* the list page keeps its chart in view on screens with room for both */
@media (min-width: 900px) and (min-height: 760px) {
  .chart-sticky {
    position: sticky;
    top: calc(var(--topbar-h) + 6px);
    z-index: 5;
    box-shadow: 0 10px 18px var(--bg);
  }
  .chart-sticky .flow-chart { grid-template-rows: clamp(150px, 18vh, 220px) auto; }
}

/* ---------- declarations ---------- */

.btn--danger { border-color: var(--negative); color: var(--negative); background: none; }
.btn--danger:hover { background: var(--negative-dim); }
a.btn { display: inline-flex; align-items: center; text-decoration: none; color: inherit; }
a.btn--primary { color: #062a1d; }
.warning-text { color: var(--warning); }

.warning {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.warning:last-of-type { border-bottom: 0; }
.warning-kind {
  flex: 0 0 5.5rem;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  text-align: center;
  background: var(--warning-dim);
  color: var(--warning);
}
.warning--missing .warning-kind, .warning--unlinked .warning-kind { background: var(--negative-dim); color: var(--negative); }
.warning--shifted .warning-kind { background: var(--row-hover); color: var(--ink-2); }
.warning-note { min-width: 0; }

.decl {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  text-decoration: none;
}
.decl:last-of-type { border-bottom: 0; }
a.decl:hover .decl-label { color: var(--accent); }
.decl-main { display: grid; gap: 2px; min-width: 0; }
.decl-label { overflow-wrap: anywhere; }
.decl-side { white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right; }
.decl-actions { display: flex; gap: 6px; flex-shrink: 0; }

.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}
.form-stack label > span .hint { margin-left: 4px; }
.form-actions { display: flex; align-items: center; gap: 14px; }
.decl-form { grid-column: span 2; }
@media (max-width: 899px) { .decl-form { grid-column: auto; } }

/* ---------- insights and reports ---------- */

.segmented a { text-decoration: none; }
.segmented a[aria-current="page"] span { background: var(--accent-dim); color: var(--accent); }
.segmented a:last-child span { border-right: 0; }

a.link-row { color: var(--ink); text-decoration: none; }
a.link-row:hover .kv-key { color: var(--accent); }

.months {
  display: flex;
  align-items: stretch;
  gap: 2px;
  height: clamp(140px, 22vw, 240px);
}
.month-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.month-slot { flex: 1; display: flex; align-items: flex-end; }
.month-bar { width: 100%; border-radius: 2px 2px 0 0; background: var(--ink-3); }
.month-col:hover .month-bar { background: var(--ink-2); }
.month-bar.is-flagged { background: var(--warning); }
.month-bar.is-partial {
  background: repeating-linear-gradient(135deg, var(--ink-3) 0 3px, transparent 3px 6px);
}
.month-label {
  height: 1.4em;
  color: var(--ink-3);
  font-size: 0.65rem;
  white-space: nowrap;
  overflow: visible;
}

.anomaly { padding: 10px 0; border-bottom: 1px solid var(--border); }
.anomaly:last-child { border-bottom: 0; }
.anomaly p { margin: 6px 0; }
.anomaly .kv { border: 0; padding: 2px 0; }
.anomaly--low .kv-value { color: var(--ink-2); }

.narrative-text p { margin: 0 0 0.8em; max-width: 80ch; }

/* htmx's own indicator styles are off (CSP: no injected styles) */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }
.form-actions:has(.htmx-request) .htmx-indicator { display: inline; }
@media (max-width: 599px) { .month-label.wide-only { visibility: hidden; } }

/* ---------- tagging ---------- */

.sug-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.sug-row.is-decided { opacity: 0.55; }
.decided { font-size: 0.75rem; padding: 2px 8px; border-radius: 4px; }
.decided--accepted { background: var(--accent-dim); color: var(--accent); }
.decided--rejected { background: var(--row-hover); color: var(--ink-2); }
.job-start { margin: 10px 0; flex-wrap: wrap; align-items: center; }
.job-start select { width: auto; }
.job { margin-top: 8px; }
.job-state--queued { color: var(--ink-2); }
.job-state--running { color: var(--warning); }
.job-state--done { color: var(--accent); }
.job-state--failed { color: var(--negative); }
.progress { height: 6px; margin: 8px 0 4px; border-radius: 3px; background: var(--row-hover); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); }
@media (max-width: 599px) {
  .sug-row { flex-wrap: wrap; }
  .sug-row > .decl-main { flex: 1 1 100%; }
  .sug-row > .decl-actions { margin-left: auto; }
}

/* ---------- ask ---------- */

.conversation { display: grid; gap: var(--gap); margin: var(--gap) 0; }
.turn { display: grid; gap: 8px; }
.turn-q {
  justify-self: end;
  max-width: min(100%, 60ch);
  margin: 0;
  padding: 8px 12px;
  border-radius: var(--radius) var(--radius) 2px var(--radius);
  background: var(--accent-dim);
}
.turn-a {
  max-width: min(100%, 80ch);
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) var(--radius) 2px;
  background: var(--panel);
}
.turn-a p { margin: 0 0 0.6em; }
.turn-a p:last-child { margin: 0; }
.turn-trace ul { margin: 6px 0 0; padding-left: 1.2em; font-size: 0.8rem; color: var(--ink-2); }
.ask-form {
  position: sticky;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.ask-form input { flex: 1 1 16rem; }
@media (min-width: 900px) { .ask-form { bottom: 12px; } }
