:root {
  color-scheme: light;
  --bg: #efe6d6;
  --raise: #fbf6ee;
  --ink: #241c14;
  --muted: #514a40;
  --faint: #5f574c;
  --line: #e0d3c0;
  --brass: #7c5310;
  --brass-ink: #fff8ee;
  --good: #1b5a30;
  --bad: #8f2f14;
  --command: #7a4e12;
  --builder: #15586e;
  --gtm: #7d3348;
  --capital: #6d4a0e;
  --shadow: 0 1px 1px rgba(72, 48, 16, 0.04), 0 16px 36px rgba(72, 48, 16, 0.06);
  --sans: "Outfit", "DejaVu Sans", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  --serif: "Fraunces", "Iowan Old Style", Palatino, Georgia, serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12140f;
  --raise: #1c2118;
  --ink: #f4efe6;
  --muted: #c8c0b0;
  --faint: #b1a898;
  --line: #34392e;
  --brass: #e4b15a;
  --brass-ink: #1c1408;
  --good: #c5d7a4;
  --bad: #f0b0a2;
  --command: #e2c08a;
  --builder: #8ec4d6;
  --gtm: #f0b0c0;
  --capital: #e4b15a;
  --shadow: 0 1px 0 rgba(255, 244, 220, 0.04), 0 16px 36px rgba(0, 0, 0, 0.28);
}

html[data-theme="light"] {
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100dvh;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--brass), var(--brass)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.55' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)' opacity='.18'/%3E%3C/svg%3E"),
    radial-gradient(980px 380px at 0% -8%, color-mix(in srgb, var(--brass) 24%, transparent), transparent 62%),
    radial-gradient(720px 420px at 100% 0%, color-mix(in srgb, var(--builder) 12%, transparent), transparent 58%);
  background-repeat: no-repeat, repeat, no-repeat, no-repeat;
  background-size: 100% 3px, 220px 220px, auto, auto;
  background-position: top, 0 0, 0 0, 0 0;
  background-blend-mode: normal, multiply, normal, normal;
  color: var(--ink);
  font: 16.5px/1.5 var(--sans);
  font-synthesis: none;
  text-wrap: pretty;
}

html[data-theme="dark"] body {
  background-blend-mode: normal, overlay, normal, normal;
}

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

button { cursor: pointer; }

::selection {
  background: color-mix(in srgb, var(--brass) 32%, transparent);
}

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 4;
  background: var(--brass);
  color: var(--brass-ink);
  padding: 8px 12px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
}

.skip:focus { top: 12px; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.app {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 26px 0 48px;
}

.banner {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--bad) 55%, var(--line));
  border-radius: 14px;
  color: var(--bad);
  background: color-mix(in srgb, var(--bad) 10%, var(--raise));
}

.desk {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  grid-template-areas:
    "head rail"
    "composer rail"
    "lanes rail"
    "law law";
  gap: 16px 20px;
  align-items: start;
}

.app-head { grid-area: head; }
.composer { grid-area: composer; }
.lanes { grid-area: lanes; }
.rail { grid-area: rail; }
.law { grid-area: law; }

.app-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "brand tools"
    "motto tools";
  gap: 4px 18px;
  align-items: center;
  min-width: 0;
}

.brand { grid-area: brand; min-width: 0; }

.kicker {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 520;
  font-size: 1rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--brass);
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 560;
  font-optical-sizing: auto;
}

h1 {
  margin: 0;
  font-size: clamp(2.35rem, 3.4vw, 3.15rem);
  line-height: 0.92;
  letter-spacing: -0.04em;
  text-wrap: balance;
}

.motto {
  grid-area: motto;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0 0;
  max-width: 36ch;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 520;
  font-size: clamp(1.12rem, 1.6vw, 1.35rem);
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-wrap: balance;
}

.motto::before {
  content: "";
  width: 1.4rem;
  height: 1px;
  flex: none;
  background: var(--brass);
}

.tools {
  grid-area: tools;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  align-self: center;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--raise) 82%, transparent);
}

button, .primary {
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  padding: 8px 12px;
}

.tools button {
  min-height: 36px;
  font-weight: 500;
  font-size: 0.92rem;
}

.primary {
  background: var(--brass);
  color: var(--brass-ink);
  border-color: transparent;
  font-weight: 600;
  border-radius: 12px;
  padding-inline: 18px;
}

.ghost, .status {
  background: transparent;
}

button,
.primary,
select,
textarea,
.lane,
.approval > button {
  transition:
    background-color 180ms var(--ease),
    color 180ms var(--ease),
    border-color 180ms var(--ease),
    transform 160ms var(--ease),
    box-shadow 180ms var(--ease);
}

button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--brass) 12%, var(--raise));
}

.primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--brass) 86%, #fff);
  color: var(--brass-ink);
}

.primary:active:not(:disabled),
button:active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
}

.ghost:hover:not(:disabled),
.status:hover:not(:disabled) {
  background: color-mix(in srgb, var(--brass) 14%, transparent);
}

button:disabled { opacity: 0.55; cursor: not-allowed; }

.composer, .lane, .rail, .law {
  background: var(--raise);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.composer {
  padding: 18px 18px 14px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--brass) 9%, var(--raise)), var(--raise) 56px);
}

.composer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(168px, 210px) auto;
  gap: 12px;
  align-items: end;
}

.field { min-width: 0; display: grid; gap: 6px; }

.field label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}

#work-label {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 560;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-transform: none;
}

textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 72%, var(--raise));
  padding: 11px 12px;
  font-size: 1rem;
}

textarea { resize: vertical; min-height: 64px; line-height: 1.45; }

textarea::placeholder { color: var(--faint); }

textarea:focus-visible, select:focus-visible {
  border-color: color-mix(in srgb, var(--brass) 70%, var(--line));
}

.hint, .does, .note, .why, .meta, .empty, .decision-top span, .decision-top time {
  color: var(--muted);
}

.hint {
  margin: 12px 0 0;
  max-width: 68ch;
  font-size: 0.9rem;
  line-height: 1.55;
}

kbd {
  font-family: inherit;
  font-size: 0.84em;
  font-weight: 600;
  color: var(--ink);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 5px;
  background: var(--bg);
}

.route-error, .decide-error { color: var(--bad); margin: 12px 0 0; font-weight: 600; }

.route-ok {
  margin: 12px 0 0;
  color: var(--good);
  font-weight: 600;
}

.route-card {
  margin-top: 14px;
  padding: 14px 14px 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--lane, var(--brass));
  background: color-mix(in srgb, var(--bg) 55%, var(--raise));
}

.route-card[data-lane="command"] { --lane: var(--command); }
.route-card[data-lane="builder"] { --lane: var(--builder); }
.route-card[data-lane="gtm"] { --lane: var(--gtm); }
.route-card[data-lane="capital"] { --lane: var(--capital); }

.route-kicker {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--lane, var(--brass));
}

.route-card h2 {
  margin: 2px 0 8px;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.route-card ul { margin: 0 0 14px; padding-left: 1.15rem; }

.route-card li + li { margin-top: 4px; }

.lanes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  min-width: 0;
}

.lane {
  position: relative;
  padding: 16px 16px 12px 18px;
  border-radius: 20px;
  min-width: 0;
}

.lane::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 18px;
  bottom: 18px;
  width: 3px;
  border-radius: 99px;
  background: var(--lane, var(--line));
}

.lane[data-lane="command"] { --lane: var(--command); }
.lane[data-lane="builder"] { --lane: var(--builder); }
.lane[data-lane="gtm"] { --lane: var(--gtm); }
.lane[data-lane="capital"] { --lane: var(--capital); }

.lane h2 { margin: 0; display: grid; gap: 2px; }

.label {
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: none;
  color: var(--lane, var(--muted));
}

.agent {
  font-size: 1.45rem;
  letter-spacing: -0.03em;
  line-height: 1.05;
  text-transform: none;
  color: var(--ink);
}

.does {
  margin: 8px 0 12px;
  font-size: 0.9rem;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.4;
  max-width: 36ch;
}

.task, .approval {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

.task:first-of-type, .approval:first-child { border-top: 0; padding-top: 2px; }

.title, .approval h3, .decision-top strong {
  margin: 0;
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 1rem;
  line-height: 1.35;
  text-wrap: balance;
}

.approval h3 {
  font-family: var(--serif);
  font-size: 1.22rem;
  font-weight: 560;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.note, .why {
  margin: 4px 0 0;
  font-size: 0.9rem;
  line-height: 1.45;
}

.task-row, .approval-top, .decision-top, .panel-h, .decide-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.approval-top {
  align-items: flex-start;
  flex-direction: column;
  gap: 6px;
}

.task-row { margin-top: 10px; justify-content: flex-start; }

.ghost {
  color: var(--muted);
  border: 1px solid var(--line);
  background: transparent;
}

.status, .ghost, .approval > button {
  min-height: 32px;
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 500;
}

.status {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 70%, var(--raise));
  border-radius: 999px;
}

.is-in-progress .status {
  color: var(--brass);
  border-color: transparent;
  background: color-mix(in srgb, var(--brass) 18%, var(--raise));
  font-weight: 600;
}

.is-done .title,
.is-done .status { color: var(--muted); }

.is-done .status {
  border-color: transparent;
  background: color-mix(in srgb, var(--good) 14%, var(--raise));
  color: var(--good);
}

.venture, .due, .meta { font-size: 0.8rem; }

.task .meta { margin: 6px 0 0; font-variant-numeric: tabular-nums; }

.overdue { color: var(--bad); font-weight: 600; }

.rail {
  padding: 16px 16px 10px;
  border-radius: 22px;
  position: sticky;
  top: 16px;
  max-height: calc(100dvh - 32px);
  overflow: auto;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--bad) 9%, var(--raise)), var(--raise) 72px);
  scroll-margin-top: 12px;
}

.panel-h { justify-content: space-between; gap: 8px; align-items: baseline; }

.panel-h h2 {
  margin: 0;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
  line-height: 1;
}

.panel-h.second { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }

.count {
  min-width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0 8px;
}

.count.hot {
  color: #fff8f5;
  background: #8f2f14;
  border-color: transparent;
}

.pill {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--lane, var(--muted));
  background: color-mix(in srgb, var(--lane, var(--line)) 14%, var(--raise));
  border-radius: 999px;
  padding: 3px 8px;
}

.pill[data-lane="command"] { --lane: var(--command); }
.pill[data-lane="builder"] { --lane: var(--builder); }
.pill[data-lane="gtm"] { --lane: var(--gtm); }
.pill[data-lane="capital"] { --lane: var(--capital); }

.meta { margin: 6px 0 0; }

.approval > button {
  margin-top: 10px;
  border: 1px solid color-mix(in srgb, var(--brass) 45%, var(--line));
  border-radius: 999px;
  font-weight: 600;
  color: var(--ink);
}

.approval > button:hover:not(:disabled) {
  background: var(--brass);
  color: var(--brass-ink);
  border-color: transparent;
}

.decide { display: grid; gap: 8px; margin-top: 10px; }

.decide label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.decide-error { margin: 0; }

.decide-actions { margin-top: 2px; }

.decisions { list-style: none; margin: 8px 0 0; padding: 0; }

.decisions li { padding: 10px 0; border-top: 1px solid var(--line); }

.decisions li:first-child { border-top: 0; }

.decision-top { justify-content: space-between; align-items: baseline; }

.decision-top time { font-variant-numeric: tabular-nums; font-size: 0.78rem; }

.decisions p { margin: 4px 0 0; line-height: 1.45; }

.empty {
  margin: 8px 0 12px;
  padding: 14px 12px 14px 14px;
  border: 1px dashed color-mix(in srgb, var(--brass) 45%, var(--line));
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg) 62%, transparent);
  font-size: 0.92rem;
  line-height: 1.45;
}

.empty::before {
  content: "";
  display: block;
  width: 1.5rem;
  height: 2px;
  margin-bottom: 8px;
  border-radius: 99px;
  background: var(--brass);
}

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

.skeleton {
  min-height: 168px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background:
    linear-gradient(100deg, transparent 20%, color-mix(in srgb, var(--raise) 70%, var(--line)) 42%, transparent 64%),
    color-mix(in srgb, var(--line) 55%, var(--raise));
  background-size: 220% 100%, auto;
  animation: shimmer 1.15s ease-in-out infinite;
}

.skeleton-rail { min-height: 280px; }

.law {
  border-radius: 20px;
  padding: 4px 18px 16px;
}

.law summary {
  cursor: pointer;
  min-height: 48px;
  display: flex;
  align-items: center;
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 560;
  letter-spacing: -0.02em;
}

.law summary:hover { color: var(--brass); }

.law-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 22px;
  padding-bottom: 4px;
}

.law p { margin: 0; font-size: 0.95rem; line-height: 1.5; max-width: 62ch; }

.app-head,
.composer,
.lane,
.rail,
.law,
.route-card,
.route-ok,
.route-error {
  animation: rise 480ms var(--ease) both;
}

.lane:nth-child(2) { animation-delay: 50ms; }
.lane:nth-child(3) { animation-delay: 100ms; }
.lane:nth-child(4) { animation-delay: 150ms; }
.rail { animation-delay: 70ms; }

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

@keyframes shimmer {
  from { background-position: 120% 0, 0 0; }
  to { background-position: -40% 0, 0 0; }
}

@media (max-width: 1040px) {
  .desk {
    grid-template-columns: 1fr;
    grid-template-areas:
      "head"
      "composer"
      "lanes"
      "rail"
      "law";
  }

  .rail {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 860px) {
  .composer-grid, .law-grid { grid-template-columns: 1fr; }
  .composer-grid .primary { width: 100%; min-height: 46px; }
}

@media (max-width: 720px) {
  .app { width: min(100% - 28px, 1180px); padding: 18px 0 36px; }
  .lanes { grid-template-columns: 1fr; }
  h1 { font-size: 2.45rem; }
  .app-head {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "motto"
      "tools";
    align-items: stretch;
  }
  .tools {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    justify-content: stretch;
  }
  .tools button {
    min-height: 44px;
    padding: 6px 4px;
    font-size: 0.84rem;
    line-height: 1.15;
  }
  button, select, textarea { min-height: 44px; }
  .status, .ghost, .approval > button { min-height: 44px; }
  .composer { padding: 16px; }
  #work-label { font-size: 1.28rem; }
}

@media (scripting: none) {
  .skeleton { animation: none; }
}

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