/* Content components: tables, notes, charts, the chat thread, the document viewer, the
   workflow canvas and the setup stepper. Split from components.css so neither file grows
   past reading size. */

/* ── table ─────────────────────────────────────────────────────────── */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  background: var(--surface);
  overflow-x: auto;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px var(--s4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-3);
  text-align: left;
  white-space: nowrap;
}

th[data-sortable] {
  cursor: pointer;
}

th[data-sortable]:hover {
  color: var(--fg-2);
}

tbody td {
  padding: 11px var(--s4);
  border-bottom: 1px solid var(--border);
  font-size: var(--t-small);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr {
  transition: background var(--fast);
}

tbody tr[data-clickable]:hover {
  background: var(--surface-2);
  cursor: pointer;
}

tbody tr[data-selected="true"] {
  background: var(--accent-soft);
}

.cell-title {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-width: 0;
}

.cell-title .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 280px;
  font-weight: 500;
}

.bulkbar {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
  padding: var(--s2) var(--s4);
  margin-bottom: var(--s2);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-lg);
  background: var(--accent-soft);
  font-size: var(--t-small);
}

/* ── notes, quotes, lists ──────────────────────────────────────────── */
.note {
  display: flex;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: var(--t-small);
  color: var(--fg-2);
}

.note[data-tone="warn"] {
  border-color: var(--warn-line);
  border-left-color: var(--warn);
  background: var(--warn-soft);
  color: var(--fg);
}

.note[data-tone="bad"] {
  border-color: var(--bad-line);
  border-left-color: var(--bad);
  background: var(--bad-soft);
  color: var(--fg);
}

.note .ico {
  flex: none;
  margin-top: 2px;
  color: var(--accent);
}

.note[data-tone="warn"] .ico {
  color: var(--warn);
}

.note[data-tone="bad"] .ico {
  color: var(--bad);
}

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px var(--s4);
  font-size: var(--t-small);
}

.kv dt {
  color: var(--fg-3);
}

.kv dd {
  color: var(--fg);
}

blockquote.quote {
  padding-left: var(--s3);
  border-left: 2px solid var(--border-strong);
  color: var(--fg-2);
  font-size: var(--t-small);
  line-height: 1.6;
}

.listrow {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.listrow:last-child {
  border-bottom: 0;
}

/* ── meters & bars ─────────────────────────────────────────────────── */
.meter {
  height: 6px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  overflow: hidden;
}

.meter > i {
  display: block;
  height: 100%;
  border-radius: var(--r-full);
  background: var(--accent);
  transition: width var(--base);
}

.meter[data-tone="ok"] > i {
  background: var(--ok);
}

.meter[data-tone="warn"] > i {
  background: var(--warn);
}

.meter[data-tone="bad"] > i {
  background: var(--bad);
}

.usage-meter {
  height: 4px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  overflow: hidden;
}

.usage-meter > i {
  display: block;
  height: 100%;
  background: var(--fg-3);
}

/* ── stat tile ─────────────────────────────────────────────────────── */
.stat {
  padding: var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  margin-top: 2px;
  font-size: var(--t-small);
  color: var(--fg-2);
}

.stat-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: var(--s3);
  font-size: var(--t-micro);
  color: var(--fg-3);
}

.stat-delta[data-dir="up"] {
  color: var(--ok);
}

.stat-delta[data-dir="down"] {
  color: var(--bad);
}

/* ── empty & skeleton ──────────────────────────────────────────────── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s3);
  padding: var(--s7) var(--s4);
  text-align: center;
  color: var(--fg-2);
}

.empty .tile {
  margin-bottom: var(--s1);
}

.empty p {
  max-width: 44ch;
  font-size: var(--t-small);
}

.skeleton {
  border-radius: var(--r-md);
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    var(--surface-3) 50%,
    var(--surface-2) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ── board ─────────────────────────────────────────────────────────── */
.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 272px;
  gap: var(--s3);
  overflow-x: auto;
  padding-bottom: var(--s2);
}

.board-col {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  min-width: 0;
}

.board-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-3);
  padding: 0 2px var(--s1);
}

.board-card {
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--t-small);
  text-align: left;
  width: 100%;
  cursor: grab;
  transition:
    border-color var(--fast),
    background var(--fast);
}

.board-card:hover {
  border-color: var(--border-strong);
}

/* ── chat ──────────────────────────────────────────────────────────── */
.thread {
  display: flex;
  flex-direction: column;
  gap: var(--s6);
  max-width: 780px;
}

.msg {
  display: flex;
  gap: var(--s3);
}

.msg-body {
  flex: 1;
  min-width: 0;
}

.msg-who {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-bottom: 6px;
}

.msg-name {
  font-size: var(--t-small);
  font-weight: 600;
}

.msg-text {
  font-size: 0.9375rem;
  line-height: 1.65;
}

.msg-text p + p {
  margin-top: var(--s3);
}

.msg[data-from="me"] {
  justify-content: flex-end;
}

.msg[data-from="me"] .bubble {
  display: inline-block;
  padding: 10px var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  font-size: 0.9375rem;
}

.cite {
  display: inline-grid;
  place-items: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin: 0 1px;
  border: 1px solid var(--accent-line);
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  vertical-align: 2px;
  position: relative;
  transition:
    background var(--fast),
    color var(--fast);
}

.cite:hover,
.cite[aria-expanded="true"] {
  background: var(--accent);
  color: var(--accent-fg);
}

.cite-pop {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  width: 280px;
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: var(--t-micro);
  font-weight: 400;
  line-height: 1.6;
  text-align: left;
  white-space: normal;
}

.composer {
  flex: none;
  padding: var(--s3) var(--s6) var(--s5);
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.composer-box {
  max-width: 780px;
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  transition: border-color var(--fast);
}

.composer-box:focus-within {
  border-color: var(--border-strong);
}

.composer-box textarea {
  width: 100%;
  border: 0;
  background: none;
  resize: none;
  min-height: 40px;
  font-size: 0.9375rem;
  line-height: 1.6;
}

.composer-box textarea:focus {
  outline: none;
}

.composer-box textarea::placeholder {
  color: var(--fg-3);
}

/* ── document viewer ───────────────────────────────────────────────── */
.viewer {
  padding: var(--s5);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface-2);
}

.paper {
  max-width: 560px;
  margin: 0 auto;
  padding: var(--s6);
  border-radius: var(--r-md);
  background: #fdfcf9;
  color: #26251f;
  font-size: var(--t-small);
  line-height: 1.8;
  box-shadow: 0 1px 2px rgb(26 26 23 / 0.06);
}

:root[data-theme="dark"] .paper {
  background: #1f1f1b;
  color: #ddddd4;
  box-shadow: none;
  border: 1px solid var(--border);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .paper {
    background: #1f1f1b;
    color: #ddddd4;
    box-shadow: none;
    border: 1px solid var(--border);
  }
}

.paper h5 {
  margin: 0 0 var(--s3);
  font-family: var(--font-display);
  font-size: var(--t-h2);
  font-weight: 600;
}

.paper p + p {
  margin-top: var(--s3);
}

.paper mark {
  background: var(--warn-soft);
  color: inherit;
  padding: 1px 2px;
  border-radius: 2px;
  box-shadow: inset 0 -1px 0 var(--warn-line);
}

/* ── timeline ──────────────────────────────────────────────────────── */
.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  padding-left: var(--s4);
  border-left: 1px solid var(--border);
  margin-left: 4px;
}

.timeline > li {
  position: relative;
  font-size: var(--t-small);
}

.timeline > li::before {
  content: "";
  position: absolute;
  left: calc(var(--s4) * -1 - 4px);
  top: 6px;
  width: 7px;
  height: 7px;
  border-radius: var(--r-full);
  background: var(--border-strong);
  outline: 3px solid var(--surface);
}

.timeline > li[data-current="true"]::before {
  background: var(--accent);
}

/* ── workflow canvas ───────────────────────────────────────────────── */
.canvas {
  position: relative;
  min-height: 480px;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background-color: var(--surface);
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 18px 18px;
  overflow: auto;
}

.canvas-inner {
  position: relative;
  width: 780px;
  height: 500px;
}

.node {
  position: absolute;
  width: 184px;
  padding: 10px var(--s3) 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--t-small);
  text-align: left;
  cursor: grab;
  transition:
    border-color var(--fast),
    box-shadow var(--fast);
}

.node::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: var(--r-md) 0 0 var(--r-md);
  background: var(--fg-3);
}

.node[data-kind="start"]::before {
  background: var(--t-mint-fg);
}

.node[data-kind="think"]::before {
  background: var(--t-violet-fg);
}

.node[data-kind="do"]::before {
  background: var(--t-sky-fg);
}

.node[data-kind="people"]::before {
  background: var(--t-sand-fg);
}

.node[data-kind="logic"]::before {
  background: var(--t-stone-fg);
}

.node:hover {
  border-color: var(--border-strong);
}

.node[data-selected="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.node-title {
  font-weight: 600;
}

.node-sub {
  margin-top: 2px;
  font-size: var(--t-micro);
  color: var(--fg-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette-step {
  display: flex;
  align-items: center;
  gap: var(--s2);
  width: 100%;
  padding: 6px var(--s2);
  border-radius: var(--r-sm);
  font-size: var(--t-small);
  color: var(--fg-2);
  text-align: left;
  cursor: grab;
  transition:
    background var(--fast),
    color var(--fast);
}

.palette-step:hover {
  background: var(--surface-2);
  color: var(--fg);
}

/* ── stepper ───────────────────────────────────────────────────────── */
.stepper {
  display: flex;
  gap: var(--s2);
  flex-wrap: wrap;
  margin-bottom: var(--s5);
}

.stepper .step {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 5px 12px 5px 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface);
  font-size: var(--t-micro);
  color: var(--fg-3);
  transition:
    border-color var(--fast),
    color var(--fast);
}

.stepper .step:hover {
  border-color: var(--border-strong);
  color: var(--fg-2);
}

.stepper .step[data-state="current"] {
  border-color: var(--fg);
  color: var(--fg);
  font-weight: 600;
}

.stepper .step[data-state="done"] {
  color: var(--ok);
  border-color: var(--ok-line);
  background: var(--ok-soft);
}

.stepper .step-num {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: var(--r-full);
  background: var(--surface-3);
  font-size: 10px;
  font-weight: 600;
}

.stepper .step[data-state="current"] .step-num {
  background: var(--ink);
  color: var(--ink-fg);
}

.stepper .step[data-state="done"] .step-num {
  background: var(--ok);
  color: #fff;
}

.dropfield {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  padding: var(--s7) var(--s4);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-xl);
  background: var(--surface-2);
  color: var(--fg-2);
  text-align: center;
  width: 100%;
  transition:
    border-color var(--fast),
    background var(--fast);
}

.dropfield:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ── misc ──────────────────────────────────────────────────────────── */
.conflict-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: 6px 10px;
  border: 1px solid var(--warn-line);
  border-radius: var(--r-md);
  background: var(--warn-soft);
  color: var(--fg);
  font-size: var(--t-small);
}

.risk {
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--fg-3);
}

.risk[data-level="write"] {
  color: var(--warn);
  border-color: var(--warn-line);
  background: var(--warn-soft);
}

.risk[data-level="destructive"] {
  color: var(--bad);
  border-color: var(--bad-line);
  background: var(--bad-soft);
}

.risk[data-level="money"] {
  color: var(--t-sand-fg);
  border-color: var(--warn-line);
  background: var(--warn-soft);
}

.redacted {
  display: inline-grid;
  place-items: center;
  min-width: 96px;
  padding: 1px 8px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  color: var(--fg-3);
  font-size: var(--t-micro);
  letter-spacing: 0.04em;
  user-select: none;
}

pre.code {
  margin: 0;
  padding: var(--s3) var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--fg-2);
  font-size: var(--t-micro);
  line-height: 1.7;
  overflow-x: auto;
}

details.advanced summary {
  cursor: pointer;
  font-size: var(--t-small);
  color: var(--fg-2);
  list-style: none;
}

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

details.advanced summary::before {
  content: "▸ ";
  color: var(--fg-3);
}

details.advanced[open] summary::before {
  content: "▾ ";
}

.chart {
  width: 100%;
  height: auto;
  display: block;
}
