/* Copyright (c) 2026 Mike Smith / Hardcase / jyukumite@gmail.com / mike@hardcase.biz. All rights reserved. */

:root {
  /* house palette (dark slate) */
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-rgb: 30 41 59;
  --border: #334155;
  --border-rgb: 51 65 85;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --faint: #475569;
  --accent: #3b82f6;
  --accent-soft: #60a5fa;
  --accent-rgb: 59 130 246;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --bad: #dc2626;
  /* style-guide aliases; the gantt and chat use these names */
  --card: var(--panel);
  --line: var(--border);
  --fg: var(--text);
  /* gantt */
  --bar: #3b82f6;
  --bar-done: #1d4ed8;
  --group: #94a3b8;
  --milestone: #e2e8f0;
  --mount: #8b5cf6;
  --mount-rgb: 139 92 246;
  --today: #d97706;
  --weekend: rgb(var(--panel-rgb) / 0.5);
  --float: rgb(var(--border-rgb) / 0.6);
  /* resource load */
  --load-low: #16a34a;
  --load-full: #d97706;
  --load-over: #dc2626;
  /* layout */
  --chat-w: 33%;
  /* grid columns; gantt.js overrides these on #gantt-scroll from localStorage 'divide.cols' */
  --col-task: 220px;
  --col-start: 96px;
  --col-finish: 96px;
  --col-dur: 48px;
  --col-pct: 48px;
  --col-status: 80px;
  --col-who: 140px;
  --col-spent: 88px;
  --col-left: 88px;
  --grid-cols: var(--col-task) var(--col-start) var(--col-finish) var(--col-dur) var(--col-pct) var(--col-status) var(--col-who) var(--col-spent) var(--col-left);
  --grid-w: 669px;
  --row-h: 28px;
  --hdr-h: 44px;
  --nav-h: 48px;
  --toolbar-h: 40px;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: var(--font-mono);
}

.footer-version {
  position: fixed;
  bottom: 6px;
  left: 10px;
  font-size: 11px;
  color: var(--faint);
  pointer-events: none;
}

/* ---- navbar ---- */

.navbar {
  background: var(--panel) !important;
  border-bottom: 1px solid var(--border);
  min-height: var(--nav-h);
  padding-top: 0;
  padding-bottom: 0;
  flex: 0 0 auto;
}

.brand {
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Lockup: "divide" in --fg at 600, ".works" secondary (--muted, 400); never the other way. */
.brand-name {
  color: var(--fg);
}

.brand-tld {
  color: var(--muted);
  font-weight: 400;
}

.login-wordmark {
  display: block;
  width: auto;
  max-width: 100%;
}

#nav-crumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

#nav-crumbs .crumb {
  background: none;
  border: 0;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 6px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#nav-crumbs .crumb:hover {
  color: var(--text);
  background: var(--border);
}

#nav-crumbs .crumb.current {
  color: var(--text);
  font-weight: 500;
}

#nav-crumbs .sep {
  color: var(--faint);
}

.ws-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 2px var(--panel);
}

.ws-dot.online { background: var(--ok); }
.ws-dot.connecting, .ws-dot.reconnecting { background: var(--warn); }
.ws-dot.offline { background: var(--danger); }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 6px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
}

.btn-icon:hover:not(:disabled) {
  background: var(--border);
  color: var(--text);
}

.btn-icon:disabled {
  opacity: 0.4;
}

.btn-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-icon.active {
  border-color: var(--accent);
  color: var(--accent-soft);
}

/* ---- main grid ---- */

#main {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--chat-w, 33%) 6px 1fr;
  grid-template-rows: minmax(0, 1fr);
}

#chat {
  min-width: 0;
  min-height: 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-right: 1px solid var(--border);
  overflow: hidden; /* only the message log scrolls */
}

#split-v {
  background: var(--panel);
  cursor: col-resize;
  touch-action: none;
}

#split-v:hover, #split-v.dragging {
  background: var(--accent);
}

body.resizing {
  cursor: col-resize;
  user-select: none;
}

#right {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: var(--toolbar-h) minmax(0, 1fr) auto auto;
  /* minmax(0, ...): the resources pane holds content-wide rows; an auto column would grow to
     their width and the gantt scroller with it, leaving nothing to scroll. */
  grid-template-columns: minmax(0, 1fr);
}

/* ---- toolbar ---- */

#gantt-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

#gantt-toolbar .sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
  flex: 0 0 auto;
}

#gantt-toolbar .btn-icon {
  flex: 0 0 auto;
}

#gantt-toolbar .grow-space {
  flex: 1 1 auto;
}

/* ---- the one scroller ---- */

#gantt-scroll {
  /* Re-declared here: a var() inside a custom property resolves where it is declared, so the
     :root copy would keep the default widths and ignore gantt.js's per-column overrides. */
  --grid-cols: var(--col-task) var(--col-start) var(--col-finish) var(--col-dur) var(--col-pct) var(--col-status) var(--col-who) var(--col-spent) var(--col-left);
  position: relative;
  overflow: auto;
  background: var(--bg);
  overscroll-behavior: contain;
}

/* Both rows must be as wide as their content: a sticky child cannot leave its parent's box,
   so a viewport-wide row lets the left grid scroll away once scrollLeft passes its width. */
#gantt-header {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  width: max-content;
  min-width: 100%;
  height: var(--hdr-h);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.hdr-grid {
  position: sticky;
  left: 0;
  z-index: 5;
  flex: 0 0 var(--grid-w, 669px);
  width: var(--grid-w, 669px);
  display: grid;
  grid-template-columns: var(--grid-cols);
  align-items: end;
  background: var(--panel);
  border-right: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.hdr-grid > div {
  position: relative;
  padding: 0 6px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* column resize: 6 px handle on each header cell's right edge, shown on header hover */
.col-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
  opacity: 0;
  transition: opacity 120ms var(--ease);
}

.col-handle::after {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  right: 2px;
  width: 2px;
  border-radius: 1px;
  background: var(--border);
}

.hdr-grid:hover .col-handle, .hdr-grid.col-resizing .col-handle {
  opacity: 1;
}

.col-handle:hover::after, .hdr-grid.col-resizing .col-handle::after {
  background: var(--accent);
}

.hdr-axis {
  position: relative;
  flex: 0 0 auto;
  height: var(--hdr-h);
  overflow: hidden;
  font-size: 12px;
  color: var(--muted);
}

.tier {
  position: absolute;
  left: 0;
  right: 0;
  height: 22px;
  overflow: hidden;
}

.tier-top {
  top: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tier-bot {
  top: 22px;
  border-top: 1px solid var(--border);
}

.tier .cell {
  position: absolute;
  top: 0;
  left: 0;
  height: 22px;
  line-height: 22px;
  padding-left: 4px;
  border-left: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
}

.today-tag {
  position: absolute;
  top: 0;
  left: 0;
  padding: 0 4px;
  height: 22px;
  line-height: 22px;
  font-size: 11px;
  color: var(--warn);
  font-weight: 500;
  pointer-events: none;
}

#gantt-body {
  display: flex;
  align-items: flex-start;
  position: relative;
  width: max-content;
  min-width: 100%;
}

/* ---- grid (sticky left) ---- */

#grid {
  position: sticky;
  left: 0;
  z-index: 3;
  flex: 0 0 var(--grid-w, 669px);
  width: var(--grid-w, 669px);
  background: var(--bg);
  border-right: 1px solid var(--border);
  font-size: 12px;
  overflow: hidden;
}

.grow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--row-h, 28px);
  display: grid;
  grid-template-columns: var(--grid-cols);
  align-items: center;
  border-bottom: 1px solid var(--border);
  box-sizing: border-box;
  cursor: default;
  user-select: none;
  will-change: transform;
}

.grow.odd {
  background: rgb(var(--panel-rgb) / 0.35);
}

.grow:hover {
  background: rgb(var(--border-rgb) / 0.35);
}

.grow.selected {
  background: var(--border);
}

.grow.pending {
  opacity: 0.7;
  pointer-events: none;
}

.grow.via-mount, .grow.is-mount {
  border-left: 2px solid var(--mount);
}

/* Every cell fills the row height: under align-items: center an EMPTY cell collapsed to zero
   height, so a click on a blank Status or Who cell hit the row and opened no editor. */
.grow > div {
  align-self: stretch;
  line-height: calc(var(--row-h, 28px) - 1px);
  padding: 0 6px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.grow .c-name {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.grow .c-start, .grow .c-finish, .grow .c-dur, .grow .c-pct {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}

/* Effort that cannot fit in the task's days with its people: amber, the tooltip says by how much. */
.grow .c-dur.effort-short {
  color: var(--warn);
  font-weight: 600;
}
.grow .c-dur.effort-short::after {
  content: " !";
}

.grow .c-status {
  font-size: 11px;
  color: var(--muted);
}

/* effort- or time-derived percent: muted with a trailing dot (no italics, see style guide) */
.grow .c-pct.derived {
  color: var(--muted);
}

.grow .c-pct.derived::after {
  content: " .";
  color: var(--faint);
}

/* Six-dot grip: a 5 px dot pattern clipped to a 10 x 15 content box = exactly 2 x 3 dots,
   with padding around it as a bigger hit area. */
.grow .grip {
  flex: 0 0 16px;
  box-sizing: border-box;
  width: 16px;
  height: 21px;
  padding: 3px;
  color: var(--muted);
  background-image: radial-gradient(circle, currentColor 1.2px, transparent 1.6px);
  background-size: 5px 5px;
  background-origin: content-box;
  background-clip: content-box;
  border-radius: 3px;
  cursor: grab;
  visibility: hidden;
  opacity: 0.7;
  transition: opacity 120ms, color 120ms;
}

.grow:hover .grip, .grow.selected .grip {
  visibility: visible;
}

.grow .grip:hover {
  opacity: 1;
  color: var(--fg);
  /* Second layer: a tile behind the dots, filling the whole padded box. */
  background-image:
    radial-gradient(circle, currentColor 1.2px, transparent 1.6px),
    linear-gradient(rgb(var(--border-rgb) / 0.7), rgb(var(--border-rgb) / 0.7));
  background-size: 5px 5px, auto;
  background-origin: content-box, border-box;
  background-clip: content-box, border-box;
}

@media (prefers-reduced-motion: reduce) {
  .grow .grip {
    transition: none;
  }
}

.grow.read-only .grip {
  visibility: hidden;
}

.grow.read-only .title {
  color: var(--muted);
}

.grow.drag-source {
  opacity: 0.5;
}

.grow.drop-before {
  box-shadow: inset 0 2px 0 var(--accent);
}

.grow.drop-after {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.grow.drop-into {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.grow.drop-refused {
  cursor: not-allowed;
}

.grow.is-group .c-name, .grow.is-mount .c-name {
  font-weight: 500;
}

.grow .title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grow .crit-flag {
  color: var(--bad);
  font-weight: 600;
}

/* Notes / assistant's context present: small marks after the title. */
.grow .row-mark {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  color: var(--faint);
  cursor: pointer;
}

.grow .row-mark[hidden] {
  display: none;
}

.grow .row-mark svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.1;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.grow .ai-mark svg {
  fill: currentColor;
  stroke: none;
}

.grow .row-mark:hover {
  color: var(--accent-soft);
}

/* expand/collapse chevron: 12 px inline SVG, down when expanded, rotated right when collapsed */
.grow .caret {
  flex: 0 0 12px;
  width: 12px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0;
  border-radius: 3px;
  line-height: 1;
}

.grow .caret:hover {
  color: var(--text);
  background: var(--border);
}

.grow .caret[hidden] {
  display: none;
}

.caret-svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 120ms var(--ease);
}

.caret.collapsed .caret-svg {
  transform: rotate(-90deg);
}

/* leaf rows: empty slot where the chevron would be, so titles line up with siblings */
.caret-spacer {
  flex: 0 0 12px;
  width: 12px;
  height: 16px;
}

.caret-spacer[hidden] {
  display: none;
}

.graft {
  flex: 0 0 auto;
  color: var(--mount);
  font-weight: 600;
}

/* ---- timeline svg ---- */

#timeline {
  display: block;
  flex: 0 0 auto;
  font-size: 12px;
}

.row-stripe {
  fill: transparent;
  stroke: var(--border);
  stroke-width: 1;
}

.row-stripe.selected {
  fill: rgb(var(--border-rgb) / 0.5);
}

.weekend {
  fill: var(--weekend);
}

.today-line {
  stroke: var(--today);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.bar {
  fill: rgb(var(--accent-rgb) / 0.55);
  stroke: none;
  rx: 3;
}

.bar-progress {
  fill: var(--accent);
  rx: 3;
}

.bar-summary {
  fill: var(--muted);
  stroke: none;
}

.bar-milestone {
  fill: var(--milestone);
  stroke: none;
}

.bar-g.bar-critical .bar, .bar-g.bar-critical .bar-summary, .bar-g.bar-critical .bar-milestone {
  stroke: var(--bad);
  stroke-width: 1.5;
}

.bar-mount {
  fill: var(--mount);
}

.bar-label {
  fill: var(--text);
  font-size: 12px;
  pointer-events: none;
}

.float-rect {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
  stroke-dasharray: 4 3;
  opacity: 0.6;
}

.mount-band {
  fill: rgb(var(--mount-rgb) / 0.12);
}

.bar-g.selected .bar,
.bar-g.selected .bar-summary,
.bar-g.selected .bar-milestone {
  stroke: var(--fg);
  stroke-width: 2;
}

.bar-g:hover .bar {
  fill: rgb(var(--accent-rgb) / 0.7);
}

.bar-g.pending {
  opacity: 0.7;
  pointer-events: none;
}

.bar-g .bar, .bar-g .bar-progress, .bar-g .bar-summary, .bar-g .bar-milestone {
  transition: x 180ms var(--ease), width 180ms var(--ease);
}

.link {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.2;
}

.link.selected {
  stroke: var(--accent-soft);
  stroke-width: 2;
}

.link.link-critical {
  stroke: var(--bad);
}

.link-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 8;
  cursor: pointer;
}

.link.picked {
  stroke-width: 2.5;
}

.mk path { fill: var(--muted); }
.mk-sel path { fill: var(--accent-soft); }
.mk-crit path { fill: var(--bad); }

.ghost {
  fill: none;
  stroke: var(--ghost, var(--accent-soft));
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  opacity: 0.6;
}

.ghost-tag {
  fill: var(--ghost, var(--accent-soft));
  font-size: 11px;
}

.layer-ghosts {
  pointer-events: none;
}

/* interaction handles: connector dots at both ends, percent triangle under the bar */
.dot {
  fill: var(--panel);
  stroke: var(--accent-soft);
  stroke-width: 1.5;
  cursor: crosshair;
}

.dot:hover {
  fill: var(--accent-soft);
}

.pct-handle {
  fill: var(--text);
  stroke: var(--bg);
  stroke-width: 1;
  cursor: ew-resize;
}

.bar-g .bar {
  cursor: grab;
}

.drag-label {
  position: fixed;
  z-index: 60;
  padding: 2px 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  pointer-events: none;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);
}

/* ---- resources pane (below the gantt, its own splitter) ---- */

/* A pane of its own, not a row of the gantt: its own vertical scroll, and a horizontal scroll
   driven from #gantt-scroll (resources.js copies scrollLeft) so its bars stay under the tasks'
   bars. The content is content-wide so the sticky-left labels can follow that scroll. */
#res-split {
  height: 5px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  cursor: row-resize;
  touch-action: none;
}
#res-split:hover,
#res-split.dragging,
#res-split:focus-visible {
  background: var(--accent);
  outline: none;
}
#res-split.collapsed {
  display: none;
}
body.resizing-rows {
  cursor: row-resize;
  user-select: none;
}
#resources {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: var(--res-pane-h, 200px);
  background: var(--panel);
}
#resources.collapsed {
  height: auto;
  border-top: 1px solid var(--border);
}
.res-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
#resources.collapsed .res-scroll {
  display: none;
}
.res-content {
  display: flex;
  align-items: flex-start;
  width: max-content;
  min-width: 100%;
}
.res-left {
  position: sticky;
  left: 0;
  z-index: 2;
  flex: 0 0 var(--grid-w, 669px);
  width: var(--grid-w, 669px);
  background: var(--panel);
  border-right: 1px solid var(--border);
}
.res-right {
  flex: 0 0 auto;
}
.res-head {
  flex: 0 0 auto;
  height: var(--res-head-h, 26px);
}
.res-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  font-size: 12px;
  color: var(--muted);
}
.res-title {
  flex: 1 1 auto;
  font-weight: 500;
}
.res-toggle .caret-svg {
  transition: transform 120ms cubic-bezier(.2, .8, .2, 1);
}
/* The pane opens upwards from the bottom: collapsed points up (open it), open points down. */
.res-toggle.collapsed .caret-svg {
  transform: rotate(180deg);
}
button.res-member.res-edit {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}
button.res-member.res-edit:hover {
  text-decoration: underline;
}
.res-link {
  padding: 0 8px;
  font-size: 11px;
}
.res-label {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 8px;
  overflow: hidden;
  white-space: nowrap;
  border-top: 1px solid var(--border);
}
.res-label.has-conflict {
  box-shadow: inset 3px 0 0 var(--bad);
}
.res-member {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}
.res-home {
  color: var(--muted);
  margin-left: -4px;
}
.res-member + .res-member::before {
  content: "=";
  color: var(--muted);
  margin-right: 2px;
}
.res-empty {
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
}
.res-chart {
  display: block;
}
.res-row {
  fill: transparent;
  stroke: var(--border);
  stroke-width: 1;
}
.res-bar {
  cursor: pointer;
}
.res-ok {
  fill: var(--ok);
  opacity: .6;
}
.res-warn {
  fill: var(--warn);
  opacity: .7;
}
.res-bad {
  fill: var(--bad);
  opacity: .75;
}
.res-off {
  fill: var(--border);
  opacity: .35;
}
.res-rule {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 2 3;
  opacity: .5;
}
.rl-pop {
  width: 360px;
}
.rl-help,
.rl-head,
.rl-inst {
  color: var(--muted);
  font-size: 12px;
}
.rl-head {
  margin: 8px 0 4px;
}
.rl-sugg {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
  font-size: 12px;
}
.rl-results {
  max-height: 160px;
  overflow-y: auto;
  margin: 6px 0;
}
.rl-result {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 3px 6px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.rl-result:hover {
  background: var(--border);
}
.rl-picked {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 4px 0 8px;
}

/* ---- tooltip ---- */

#tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  max-width: 320px;
  padding: 6px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);
  font-size: 12px;
  pointer-events: none;
}

#tooltip[hidden] {
  display: none;
}

#tooltip .tt-meta {
  color: var(--muted);
}

#tooltip .tt-title {
  font-weight: 500;
  margin-bottom: 2px;
}

#tooltip .tt-dates {
  font-family: var(--font-mono);
  color: var(--muted);
}

/* ---- chat placeholder ---- */

.placeholder-card {
  color: var(--muted);
  text-align: center;
  padding: 24px;
  border-radius: 10px;
}

/* ---- focus and motion ---- */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.grow:focus-visible {
  outline-offset: -2px;
  z-index: 1;
}

.form-control, .form-select {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text);
}

.form-control:focus {
  box-shadow: 0 0 0 2px var(--accent);
  border-color: var(--accent);
}

.dropdown-menu {
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* ---- update banner: sticky above the navbar while the tab runs an older build ---- */

.update-banner {
  position: sticky;
  top: 0;
  z-index: 80;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 6px 16px;
  background: var(--panel);
  border-bottom: 2px solid var(--warn);
  color: var(--text);
  font-weight: 500;
}

/* ---- pane toggle (navbar, stacked layout only) ---- */

.pane-toggle {
  display: none;
  flex: 0 0 auto;
  height: 32px;
  margin-right: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.pane-btn {
  background: var(--panel);
  color: var(--muted);
  border: 0;
  padding: 0 12px;
  font-weight: 500;
}

.pane-btn + .pane-btn {
  border-left: 1px solid var(--border);
}

.pane-btn.active {
  background: var(--accent);
  color: var(--text);
}

/* Below 992 px the panes stack: one visible at a time, picked by body[data-pane]. The plan
   pane keeps at least 320 px; the grid scrolls inside #gantt-scroll, never the window. */
@media (max-width: 991.98px) {
  .pane-toggle:not([hidden]) {
    display: inline-flex;
  }
  .navbar {
    flex-wrap: nowrap;
    overflow: hidden;
  }
  #nav-user {
    max-width: 36vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #main {
    grid-template-columns: 1fr;
    overflow-x: auto;
  }
  #split-v {
    display: none;
  }
  #chat {
    border-right: 0;
  }
  body:not([data-pane="chat"]) #chat {
    display: none;
  }
  body[data-pane="chat"] #right {
    display: none;
  }
  #right {
    min-width: 320px;
  }
  #nav-crumbs {
    display: none;
  }
}

/* ---- audit panel (over the plan, below the toolbar) ---- */

#audit-panel {
  position: absolute;
  top: var(--toolbar-h);
  right: 0;
  bottom: 0;
  width: 340px;
  max-width: 100%;
  z-index: 6;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);
}

#audit-panel[hidden] {
  display: none;
}

.audit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px 12px;
  border-bottom: 1px solid var(--border);
}

.audit-title {
  font-weight: 500;
}

.audit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  flex: 1 1 auto;
  font-size: 12px;
}

.audit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid rgb(var(--border-rgb) / 0.5);
}

.audit-row.undone .audit-what {
  text-decoration: line-through;
  color: var(--muted);
}

.audit-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.audit-who {
  font-weight: 500;
}

.audit-what {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audit-when {
  font-size: 11px;
}

.audit-empty {
  padding: 12px;
}

/* grouped entries (one user gesture, several commands): chevron folds the parts out */
.audit-toggle {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  border-radius: 3px;
}

.audit-toggle:hover {
  color: var(--text);
  background: var(--border);
}

.audit-toggle .caret-svg {
  transform: rotate(-90deg);
}

.audit-row.open .audit-toggle .caret-svg {
  transform: none;
}

.audit-parts {
  margin-top: 4px;
  padding-left: 8px;
  border-left: 2px solid var(--border);
}

.audit-parts[hidden] {
  display: none;
}

.audit-part {
  padding: 2px 0;
  color: var(--muted);
}

#audit-more {
  margin: 8px 12px;
}

/* ---- toasts (ui.js): bottom-right, one line, optional action ---- */

#toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  /* Above Bootstrap's offcanvas (1045) and modals (1055): a toast raised from Settings or a
     dialog must be seen, not hidden under the panel that raised it. */
  z-index: 1090;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-item {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 420px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);
  font-size: 13px;
  pointer-events: auto;
  animation: toast-in 180ms var(--ease);
}

.toast-item.ok { border-left-color: var(--ok); }
.toast-item.warn { border-left-color: var(--warn); }
.toast-item.bad { border-left-color: var(--bad); }

.toast-item.out {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}

.toast-msg {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast-action, .toast-close {
  background: none;
  border: 0;
  color: var(--accent-soft);
  padding: 0 4px;
  font-size: 13px;
}

.toast-close {
  color: var(--muted);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---- context menu (ui.js) ---- */

.ctx-menu {
  position: fixed;
  z-index: 65;
  min-width: 200px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);
  font-size: 13px;
}

.ctx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 5px 10px;
  background: none;
  border: 0;
  border-radius: 4px;
  color: var(--text);
  text-align: left;
}

.ctx-item:hover:not(:disabled), .ctx-item:focus-visible {
  background: var(--border);
  outline: none;
}

.ctx-item:disabled {
  color: var(--faint);
}

.ctx-label {
  flex: 1 1 auto;
  white-space: nowrap;
}

.ctx-hint, .ctx-arrow {
  color: var(--muted);
  font-size: 11px;
  font-family: var(--font-mono);
}

.ctx-sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--border);
}

/* ---- dialogs (ui.js): native dialog, centred, 480 px ---- */

.dlg {
  width: 480px;
  max-width: calc(100vw - 32px);
  padding: 16px 20px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);
}

.dlg::backdrop {
  background: rgb(0 0 0 / 0.5);
}

.dlg-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 8px;
}

.dlg-body {
  color: var(--muted);
  margin-bottom: 12px;
}

.dlg-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

.dlg-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---- inline edit (ui.js): replaces a grid cell's text in place ---- */

.inline-edit {
  width: 100%;
  height: calc(var(--row-h, 28px) - 4px);
  padding: 0 4px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 4px;
  font: inherit;
  font-size: 12px;
  outline: none;
  box-sizing: border-box;
}

.inline-edit.mono-date, .inline-edit.mono-number {
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: right;
}

/* ---- interaction layer (gantt_interact.js): link draw, drag state, row ghost ---- */

.layer-interact {
  pointer-events: none;
}

.link-draw {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
}

.link-draw.ok {
  stroke: var(--accent-soft);
}

.bar-g.link-target .bar {
  fill: rgb(var(--accent-rgb) / 0.85);
  stroke: var(--accent-soft);
  stroke-width: 2;
}

.bar-g.link-target .dot {
  fill: var(--accent-soft);
}

/* Direct manipulation: our own drag never animates; peers' moves still slide. */
#timeline.dragging .bar-g .bar,
#timeline.dragging .bar-g .bar-progress,
#timeline.dragging .bar-g .bar-summary,
#timeline.dragging .bar-g .bar-milestone {
  transition: none;
}

body.gantt-dragging {
  user-select: none;
}

body.gantt-dragging #tooltip {
  display: none;
}

.row-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  max-width: 320px;
  padding: 3px 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);
  color: var(--fg);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.row-ghost.invalid {
  color: var(--muted);
  border-color: var(--bad);
}

.row-ghost[hidden] {
  display: none;
}

/* ui.inlineEdit floats the input over the cell from body, so grid re-renders cannot swallow it. */
.inline-edit {
  position: fixed;
  z-index: 55;
  height: auto;
}

/* ---- grid/timeline splitter (gantt.js #split-grid): scales every column together ---- */

.hdr-grid > .split-grid {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  padding: 0;
  overflow: visible;
  cursor: col-resize;
  touch-action: none;
  z-index: 6;
  background: transparent;
}

.hdr-grid > .split-grid:hover, .hdr-grid > .split-grid:focus-visible, .hdr-grid.col-resizing > .split-grid {
  background: var(--accent);
  outline: none;
}

/* ---- popover card (ui.showPopover) ---- */

.popover-card {
  position: fixed;
  z-index: 70;
  min-width: 200px;
  max-width: 360px;
  padding: 10px 12px;
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);
}

/* ---- task window (#task-dialog) and settings (#settings) ---- */

#task-dialog .modal-dialog {
  --bs-modal-width: 680px;
}

#task-dialog .modal-content, #settings.offcanvas {
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--line);
}

#task-dialog .modal-header, #task-dialog .modal-footer, #settings .offcanvas-header {
  border-color: var(--line);
}

#task-dialog .modal-title, #settings .offcanvas-title {
  font-size: 15px;
  font-weight: 600;
}

.td-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}

.td-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.td-field > span:first-child {
  font-weight: 500;
}

.td-wide {
  grid-column: 1 / -1;
}

.td-check {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  align-self: end;
  padding-bottom: 6px;
  color: var(--fg);
}

.td-check .form-check-input {
  margin: 0;
}

.td-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.td-row .form-control {
  max-width: 96px;
}

.td-details summary {
  cursor: pointer;
}

.td-ai {
  margin: 6px 0 0;
  font-size: 12px;
  resize: vertical;
}

.td-stamps {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

#task-dialog input[type="date"], #task-dialog input[type="number"], #td-key {
  font-family: var(--font-mono);
}

/* Settings holds tables (people, locations), so it covers most of the window rather than a
   phone-width strip. */
#settings.offcanvas {
  --bs-offcanvas-width: min(1100px, 94vw);
}

.settings-body {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 16px;
  padding-top: 8px;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-right: 1px solid var(--line);
  padding-right: 8px;
}

.settings-tab {
  text-align: left;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 13px;
}

.settings-tab:hover {
  color: var(--fg);
  background: var(--line);
}

.settings-tab.active {
  color: var(--fg);
  background: var(--line);
  font-weight: 500;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13px;
}

.settings-section[hidden] {
  display: none;
}

/* Sections are flex columns; buttons keep their own width instead of spanning the panel. */
.settings-section > .btn {
  align-self: flex-start;
}

.settings-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 4px;
}

@media (max-width: 575.98px) {
  .td-body {
    grid-template-columns: 1fr;
  }

  .settings-body {
    grid-template-columns: 1fr;
  }

  .settings-nav {
    flex-direction: row;
    flex-wrap: wrap;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0 0 8px;
  }
}

/* ---- who column and picker ---- */

.c-who {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  white-space: nowrap;
  cursor: pointer;
}
.who-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 6px;
  border-radius: 3px;
  background: var(--border);
  color: var(--text);
  font-size: 11px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.who-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.who-more {
  color: var(--muted);
  font-size: 11px;
}
.who-pop {
  width: 280px;
}
.who-head {
  font-weight: 500;
  margin-bottom: 6px;
}
.who-list {
  max-height: 260px;
  overflow-y: auto;
  margin-bottom: 8px;
}
.who-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
}
.who-name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.who-units {
  width: 72px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 1px 4px;
  text-align: right;
}
.who-pct,
.who-empty {
  color: var(--muted);
}
.who-new {
  display: flex;
  gap: 6px;
}

.tb-group {
  display: inline-flex;
  gap: 2px;
}
.btn-level {
  min-width: 26px;
  font-size: 12px;
  font-weight: 500;
}

/* ---- settings: resources and locations ---- */

.sr-h {
  font-size: 13px;
  font-weight: 600;
  margin: 12px 0 6px;
}
.sr-table {
  width: 100%;
  margin-bottom: 4px;
}
.sr-table td,
.sr-table th {
  font-size: 12px;
  vertical-align: middle;
}
.sr-editor:not(:empty) {
  margin: 8px 0 16px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.sr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}
.sr-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
/* Settings > Instances: the calendar location select stays a readable width. */
.si-loc {
  max-width: 420px;
}
.sr-label,
.sr-sub {
  color: var(--muted);
  font-size: 12px;
}
.sr-sub {
  margin: 10px 0 4px;
}
.sr-absence,
.sr-holiday,
.sr-import {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  margin-bottom: 4px;
}
/* One line per time-away entry: from, to, kind, % available, note (takes the rest), Remove. */
.sr-absence {
  flex-wrap: wrap;
  align-items: center;
}
.sr-absence > input[type="date"] {
  flex: 0 0 140px;
  width: 140px;
}
.sr-absence > select {
  flex: 0 0 150px;
  width: 150px;
}
.sr-absence > input:not([type="date"]) {
  flex: 1 1 140px;
  width: auto;
  min-width: 120px;
}
.sr-absence > button {
  flex: 0 0 auto;
}
.sr-absence .sr-pct {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  font-size: 12px;
  color: var(--muted);
}
.sr-absence .sr-pct[hidden] {
  display: none;
}
.sr-absence .sr-pct input {
  width: 70px;
}
.sr-week {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.sr-day {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  font-size: 12px;
}
.sr-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

/* ---- cost columns ---- */

.c-spent,
.c-left {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.c-left.over {
  color: var(--bad);
}
.cost-more {
  color: var(--muted);
  margin-left: 4px;
  font-size: 11px;
}

/* ---- task window: people ---- */

.td-people {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
/* Task window: the task's links, one line each. */
.td-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 0 8px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.td-links .td-sub {
  color: var(--muted);
}
.td-link {
  display: flex;
  align-items: center;
  gap: 6px;
}
.td-link-kind {
  min-width: 64px;
  color: var(--muted);
}
.td-link-x {
  margin-left: auto;
}
.tp-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}
/* One grid for every person row so the numbers line up: name, units, d/wk, plan, logged,
   cost, remove. */
.tp-row {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) 72px 56px 64px 72px minmax(96px, auto) 32px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.tp-entry,
.tp-log {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.tp-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.tp-units,
.tp-hours {
  width: 80px;
}
.tp-who {
  width: 140px;
}
.tp-num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.tp-entry .tp-num {
  min-width: 40px;
}
.tp-log input[type="date"] {
  width: 140px;
}
.tp-log input[type="text"] {
  flex: 1 1 120px;
  width: auto;
}
.tp-add {
  max-width: 220px;
}
.tp-entries {
  max-height: 160px;
  overflow-y: auto;
}
.tp-note {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tp-remove {
  margin-left: auto;
}

/* ---- sharing ---- */

.dlg.dlg-wide {
  width: 640px;
}
/* The approval window: wide enough for one change per line; a long list scrolls so the
   Apply / Don't apply buttons stay on screen. */
.dlg.dlg-approve {
  width: 860px;
}
.dlg-approve .chat-approve-list {
  max-height: 60vh;
  overflow-y: auto;
}
.sh-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.sh-form .sr-field:first-child {
  flex: 1 1 220px;
}
.sh-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}
.sh-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
}
.sh-row .sh-main {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sh-badge {
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 11px;
  background: var(--border);
  color: var(--muted);
}
.sh-badge.edit {
  background: var(--mount);
  color: var(--bg);
}
.sh-badge.ask {
  background: var(--warn);
  color: var(--bg);
}
.sh-note {
  color: var(--muted);
  font-size: 12px;
}
/* A mount the viewer cannot open (a teammate's share) or whose target is gone. */
.grow.mount-closed .title,
.grow.mount-broken .title {
  color: var(--muted);
  font-style: italic;
}

/* ---- date modes: pinned dates, starts held by links, broken links ---- */

/* Pinned: links never move it. A small stake marks the cell and the bar's start. */
.grow > .c-start.pinned::before,
.grow > .c-finish.pinned::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 10px;
  margin-right: 5px;
  border-radius: 1px;
  background: var(--accent-soft);
  vertical-align: -1px;
}
.grow > .c-start.pinned.broken::before {
  background: var(--bad);
}
/* An auto start the links hold later than the date the user set; both dates of a span task
   (they come from its links). */
.grow > .c-start.held,
.grow > .c-finish.held {
  color: var(--muted);
  font-style: italic;
}
.pin-mark {
  stroke: var(--accent-soft);
  stroke-width: 3;
  stroke-linecap: round;
}
.pin-mark.broken {
  stroke: var(--bad);
}
.link.link-broken {
  stroke: var(--bad);
  stroke-dasharray: 4 3;
  stroke-width: 1.6;
}
.td-checks {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
/* Dates: Auto / Pinned / Span links, one radio group, kept together. */
.td-modes {
  display: inline-flex;
  align-items: center;
  align-self: end;
  gap: 10px;
  padding: 0 0 6px 12px;
  border-left: 1px solid var(--line);
}
.td-modes .td-check {
  padding-bottom: 0;
}

/* ---------- chat pane (style guide: chat) ---------- */

.chat-head {
  display: flex;
  /* The clock stays at the top right when the tabs wrap onto more lines. */
  align-items: flex-start;
  gap: 6px;
  flex: none;
}

/* Tabs wrap onto extra lines rather than scrolling sideways; a few short lines keep every
   chat one click away. */
.chat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  max-height: 96px;
  overflow-y: auto;
}

.chat-history {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.chat-history:hover {
  color: var(--fg);
}

.chat-tab {
  display: flex;
  align-items: center;
  max-width: 180px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  flex: none;
}

.chat-tab-label {
  min-width: 0;
  padding: 3px 4px 3px 10px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-tab-close {
  flex: none;
  padding: 0 6px 1px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  line-height: 1;
  opacity: 0;
}

.chat-tab:hover .chat-tab-close,
.chat-tab.active .chat-tab-close,
.chat-tab-close:focus-visible {
  opacity: 1;
}

.chat-tab-close:hover {
  color: var(--fg);
}

.chat-tab-input {
  width: 150px;
  padding: 2px 6px;
  border: 0;
  border-radius: 5px;
  background: var(--bg);
  color: var(--fg);
  font-size: 12px;
}

button.chat-new {
  padding: 3px 10px;
}

.chat-tab.active {
  color: var(--fg);
  background: var(--line);
}

.chat-new {
  font-weight: 600;
}

.chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}

.chat-empty {
  color: var(--muted);
  margin: auto 0;
  text-align: center;
  padding: 0 12px;
}

.chat-msg {
  display: flex;
}

.chat-msg.user {
  justify-content: flex-end;
}

.chat-bubble {
  max-width: 92%;
  padding: 6px 10px;
  border-radius: 8px;
  overflow-wrap: anywhere;
}

.chat-msg.user .chat-bubble {
  background: var(--line);
}

.chat-msg.assistant .chat-bubble {
  background: var(--card);
  border: 1px solid var(--line);
}

.chat-text {
  white-space: pre-wrap;
}

.chat-status {
  color: var(--muted);
  font-size: 12px;
}

/* Show thinking: a collapsed disclosure above the reply's text. */
.chat-steps {
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
}

.chat-steps > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.chat-steps > summary::-webkit-details-marker {
  display: none;
}

.chat-steps > summary::before {
  content: ">";
  display: inline-block;
  width: 12px;
  transition: transform 120ms;
}

.chat-steps[open] > summary::before {
  transform: rotate(90deg);
}

.chat-step {
  margin: 4px 0 0 12px;
  padding-left: 8px;
  border-left: 2px solid var(--line);
  white-space: pre-wrap;
}

/* Live thinking while a reply streams: a few lines following the tail; .open shows more. */
.chat-live-think {
  max-height: calc(4 * 1.45em);
  overflow-y: auto;
  padding-left: 8px;
  border-left: 2px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.chat-live-think.open {
  max-height: 320px;
}

.chat-live-think + .chat-text:not(:empty) {
  margin-top: 6px;
}

.chat-step-head code {
  font-size: 11px;
  color: var(--faint);
}

.chat-step-io {
  margin: 2px 0 0;
  padding: 4px 6px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 200px;
  overflow-y: auto;
}

.chat-step-io.error {
  color: var(--bad);
}

.chat-fork {
  display: block;
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: 11px;
  opacity: 0;
}

.chat-msg:hover .chat-fork,
.chat-fork:focus-visible {
  opacity: 1;
}

.chat-fork:hover {
  color: var(--accent-soft);
}

@media (prefers-reduced-motion: reduce) {
  .chat-steps > summary::before {
    transition: none;
  }
}

/* Markdown stays body-sized: no enlarged headers. */
.md p,
.md ul,
.md ol,
.md pre {
  margin: 0 0 6px;
}

.md > :last-child {
  margin-bottom: 0;
}

.md ul,
.md ol {
  padding-left: 18px;
}

.md p {
  white-space: pre-wrap;
}

.md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--bg);
  padding: 0 3px;
  border-radius: 3px;
}

.md pre {
  background: var(--bg);
  padding: 6px 8px;
  border-radius: 6px;
  overflow-x: auto;
}

.md pre code {
  padding: 0;
}

.chat-card {
  background: var(--card);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
}

.chat-card[hidden] {
  display: none;
}

.chat-card.error {
  border-left-color: var(--bad);
}

.chat-card.suggest {
  border-left-color: var(--warn);
}

.chat-thinking {
  color: var(--muted);
  font-size: 12px;
  flex: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-thinking[hidden] {
  display: none;
}

.chat-thinking .dots {
  display: inline-block;
  margin-left: 2px;
  animation: chat-shimmer 1.2s ease-in-out infinite;
}

@keyframes chat-shimmer {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-thinking .dots {
    animation: none;
  }
}

.chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: none;
}

.chat-chip {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.chat-chip:hover:not(:disabled),
.chat-tab:hover:not(:disabled) {
  color: var(--fg);
}

.chat-chip:disabled,
.chat-tab:disabled {
  opacity: 0.5;
}

.chat-controls {
  display: flex;
  gap: 6px;
  align-items: center;
  flex: none;
}

.chat-model {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
}

/* Action switch: Read only / Ask / Auto as one segmented control. */
.chat-actions-switch {
  display: flex;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.chat-actions-switch button {
  padding: 3px 8px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.chat-actions-switch button:first-child {
  border-left: 0;
}

.chat-actions-switch button.active {
  background: var(--line);
  color: var(--fg);
}

.chat-actions-switch button:disabled {
  opacity: 0.5;
}

.chat-approve-list {
  margin: 6px 0;
  padding-left: 18px;
}

.chat-approve-list li {
  margin: 2px 0;
}

.chat-composer {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  flex: none;
}

.chat-input {
  resize: vertical;
  min-height: 38px;
  max-height: 200px;
  font-size: 13px;
}

.chat-send.stop {
  background: var(--bad);
  border-color: var(--bad);
}

/* Settings > AI providers */
.ai-provider {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ai-provider-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.ai-key-row {
  display: flex;
  gap: 6px;
}

.ai-lm-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
/* How LM Studio is reached: this server, or this browser (each with its own fields). */
.ai-lm-modes {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}
.ai-lm-mode {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12px;
}
.ai-lm-mode .form-check-input {
  margin: 2px 0 0;
  flex: none;
}
.ai-lm-server,
.ai-lm-browser {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ai-lm-server[hidden],
.ai-lm-browser[hidden] {
  display: none;
}
.ai-relay-state {
  margin-left: 118px;
}

.ai-field {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  align-items: center;
  gap: 2px 8px;
  font-size: 12px;
}

.ai-hint {
  grid-column: 2;
  font-size: 11px;
}

.ai-clear {
  margin-left: 118px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-key-state {
  font-size: 12px;
}

.ai-key-state.ok {
  color: var(--ok);
}

.ai-key-state.bad {
  color: var(--bad);
}

.ai-key-state.muted {
  color: var(--muted);
}


/* "Settings > X" inside messages (ui.linkSettings). */
.settings-link {
  color: var(--accent-soft);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.settings-link:hover {
  color: var(--fg);
}

/* ask_user card: question, option buttons, free answer. */
.chat-ask-q {
  margin-bottom: 6px;
}

.chat-ask-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.chat-ask-actions:empty {
  display: none;
}

.chat-ask-free {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.chat-ask-answer {
  color: var(--fg);
  font-size: 12px;
}

/* Chat attachments: composer chips, and the files on a sent message. */
.chat-attach {
  flex: none;
  align-self: stretch;
  color: var(--muted);
  border: 1px solid var(--line);
}

.chat-attach:hover {
  color: var(--fg);
}

.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: none;
}

.chat-chips[hidden] {
  display: none;
}

.chat-file,
.chat-att-doc {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  color: var(--fg);
  text-decoration: none;
}

.chat-file.error {
  border-color: var(--bad);
}

.chat-file.uploading {
  opacity: 0.7;
}

.chat-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

.chat-chip-thumb {
  width: 20px;
  height: 20px;
  object-fit: cover;
  border-radius: 3px;
}

.chat-chip-x {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 2px;
}

.chat-atts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 4px;
}

.chat-att-img img {
  display: block;
  max-width: 160px;
  max-height: 120px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

#chat.drop-target {
  outline: 2px dashed var(--accent);
  outline-offset: -6px;
}

/* Dividers in the log: a model switch, and a compaction summary (click to read it). */
.chat-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.chat-divider::before,
.chat-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--line);
}

.chat-summary {
  display: block;
  text-align: center;
}

.chat-summary::before,
.chat-summary::after {
  display: none;
}

.chat-summary > summary {
  cursor: pointer;
  list-style: none;
}

.chat-summary > summary::-webkit-details-marker {
  display: none;
}

/* An attachment's extracted text: the part in the conversation, then the read_file rest. */
.att-text {
  max-height: 60vh;
  overflow: auto;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.att-parts {
  max-height: 50vh;
  overflow-y: auto;
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
}

.att-image {
  display: block;
  max-width: 100%;
  max-height: 55vh;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.att-text-cut {
  color: var(--accent-soft);
}

.att-text-rest {
  color: var(--muted);
}

/* Above the newest summary: kept for reading, but the model no longer sees it. */
.chat-past {
  opacity: 0.5;
  transition: opacity 120ms;
}

.chat-past:hover,
.chat-past:focus-within {
  opacity: 0.85;
}

@media (prefers-reduced-motion: reduce) {
  .chat-past {
    transition: none;
  }
}

.chat-summary[open] .md {
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  color: var(--fg);
}

/* Meters: context fill and today's spend, 3 px bars (ok < 70%, warn < 90%, else bad). */
.chat-meters {
  display: flex;
  gap: 12px;
  flex: none;
  font-size: 11px;
  color: var(--muted);
}

.chat-meters[hidden] {
  display: none;
}

.chat-meter {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chat-meter-bar {
  display: inline-block;
  width: 60px;
  height: 3px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}

.chat-meter-bar > span {
  display: block;
  height: 100%;
  background: var(--ok);
}

.chat-meter-bar.warn > span {
  background: var(--warn);
}

.chat-meter-bar.bad > span {
  background: var(--bad);
}

/* ---- issue trackers (milestone 9) ---- */

.tk-conn,
.tk-add {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.tk-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}
.tk-status {
  margin-left: auto;
  font-size: 12px;
}
.tk-status.ok { color: var(--ok); }
.tk-status.warn { color: var(--warn); }
.tk-status.bad { color: var(--bad); }
.tk-error {
  color: var(--bad);
  overflow-wrap: anywhere;
}
.tk-issue {
  flex-wrap: wrap;
}
.tk-issue > span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.tk-state {
  font-size: 11px;
  padding: 0 6px;
  border-radius: 8px;
  border: 1px solid currentColor;
}
.tk-state.open { color: var(--ok); }
.tk-state.closed { color: var(--muted); }
.tk-wb {
  width: auto;
  max-width: 220px;
}
.tk-add-link {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: none;
  max-height: 40%;
  overflow-y: auto;
}
.chat-suggestions[hidden] {
  display: none;
}
.tk-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-left-color: var(--warn);
}
.tk-card-head {
  font-weight: 600;
}
.tk-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}
.tk-item > span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.tk-item-text {
  display: flex;
  flex-direction: column;
}
.tk-ref {
  color: var(--muted);
  font-size: 11px;
}
.tk-all {
  margin-left: auto;
  padding: 0 4px;
}

/* ---- Settings > Admin (milestone 9@) ---- */

.adm-tabs,
.adm-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 8px 0;
}
.adm-filters select {
  width: auto;
}
.adm-scroll {
  overflow-x: auto;
}
.adm-table {
  font-size: 13px;
}
.adm-table td {
  vertical-align: top;
}
.adm-tick {
  text-align: center;
}
.adm-badge {
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 8px;
  border: 1px solid var(--warn);
  color: var(--warn);
  font-size: 11px;
}
.adm-kind {
  color: var(--muted);
  font-size: 11px;
}
.adm-failed td,
.adm-err,
.adm-auth_failed {
  color: var(--bad);
}
.adm-backoff {
  color: var(--warn);
}
.adm-ok {
  color: var(--ok);
}
.tk-steps {
  padding-left: 18px;
}

/* ---- Your issues window ---- */

.iss {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}
.iss-filters,
.iss-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.iss-filters input[type="search"] {
  flex: 1 1 200px;
}
.iss-which,
.iss-where {
  width: auto;
  max-width: 100%;
}
.iss-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 55vh;
  overflow-y: auto;
}
.iss-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.iss-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-wrap: anywhere;
}
.iss-ref {
  color: var(--muted);
  font-size: 11px;
}
.iss-badge {
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 8px;
  border: 1px solid var(--muted);
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.iss-badge.task {
  border-color: var(--ok);
  color: var(--ok);
}
