:root {
  color-scheme: dark;
  --bg: #0d0d0c;
  --ink: #f4f0e8;
  --muted: #9d988f;
  --line: #2b2a27;
  --panel: #151513;
  --panel-2: #1b1b18;
  --gold: #d8b774;
  --blue: #8ba7c5;
  --green: #76b38d;
  --amber: #c7954c;
  --red: #d66d61;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background:
    linear-gradient(160deg, rgba(216,183,116,.08), transparent 34rem),
    radial-gradient(circle at top right, rgba(139,167,197,.08), transparent 30rem),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; text-decoration: none; }

button {
  min-height: 40px;
  border: 1px solid var(--line);
  background: #0f0f0e;
  color: var(--ink);
  padding: 0 14px;
  font: inherit;
  font-weight: 700;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: rgba(13,13,12,.82);
  backdrop-filter: blur(18px);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: grid;
  gap: 4px;
}

.brand span {
  font-size: 1.24rem;
  font-weight: 800;
}

.brand small,
.kicker,
.rail-foot,
.muted {
  color: var(--muted);
}

.tabs {
  display: grid;
  gap: 4px;
}

.tabs a {
  display: flex;
  justify-content: space-between;
  border-left: 2px solid transparent;
  padding: 11px 12px;
  color: var(--muted);
}

.tabs a.active {
  border-left-color: var(--gold);
  background: rgba(216,183,116,.08);
  color: var(--ink);
}

.rail-foot {
  margin-top: auto;
  display: grid;
  gap: 6px;
  font-size: .82rem;
}

.main {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 34px 0 56px;
}

.hero,
.detail-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.kicker {
  margin: 0 0 8px;
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.4rem, 7vw, 6rem);
  line-height: .92;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.5rem, 3vw, 2.8rem);
  line-height: 1;
}

h3 {
  margin-bottom: 12px;
  font-size: .9rem;
  color: var(--muted);
  text-transform: uppercase;
}

.hero-status {
  min-width: 160px;
  display: grid;
  justify-items: end;
  gap: 8px;
  color: var(--muted);
}

.hero-status span {
  color: var(--gold);
  font-weight: 800;
}

.cards {
  margin: 30px 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}

.card,
.panel {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
}

.card {
  min-height: 230px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 20px;
  padding: 18px;
}

.card-top,
.metric-row,
.runtime-item,
.file-links a,
.active-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.status {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
}

.status.done { color: var(--green); }
.status.running { color: var(--amber); }
.status.blocked { color: var(--red); }
.status.review { color: var(--blue); }

.card h2 {
  font-size: 1.45rem;
}

.card p {
  color: var(--muted);
  line-height: 1.55;
}

.metric-row {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  color: var(--muted);
  font-size: .84rem;
}

.metric-row b {
  color: var(--ink);
}

.detail {
  display: grid;
  gap: 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr);
  gap: 12px;
}

.panel {
  padding: 18px;
}

.wide {
  min-width: 0;
}

.prompt-text {
  color: var(--ink);
  line-height: 1.55;
}

.runtime-list,
.file-links,
.active-work {
  display: grid;
  gap: 8px;
}

.runtime-item,
.file-links a,
.active-item {
  min-width: 0;
  border-top: 1px solid var(--line);
  padding: 10px 0 0;
  color: var(--muted);
}

.runtime-item b,
.file-links a b,
.active-item b {
  color: var(--ink);
}

.quiet-link {
  border: 1px solid var(--line);
  padding: 10px 13px;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 140%);
  width: min(480px, calc(100vw - 28px));
  border: 1px solid var(--line);
  background: var(--ink);
  color: var(--bg);
  padding: 12px 14px;
  font-weight: 800;
  transition: transform .18s ease;
}

.toast.show {
  transform: translate(-50%, 0);
}

@media (max-width: 900px) {
  .app {
    display: block;
    overflow-x: clip;
  }

  .rail {
    position: static;
    height: auto;
    max-width: 100vw;
    min-width: 0;
    overflow: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: max(14px, env(safe-area-inset-top)) 14px 12px;
  }

  .tabs {
    display: flex;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    contain: paint;
    padding-bottom: 2px;
  }

  .tabs a {
    flex: 0 0 auto;
    border-left: 0;
    border-bottom: 2px solid transparent;
  }

  .tabs a.active {
    border-bottom-color: var(--gold);
  }

  .rail-foot {
    display: flex;
    justify-content: space-between;
  }

  .main {
    width: min(100% - 24px, 760px);
    padding-top: 22px;
  }

  .hero,
  .detail-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-status {
    justify-items: start;
  }

  .cards,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .runtime-item b,
  .file-links a b,
  .active-item b {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .runtime-item span,
  .file-links a span,
  .active-item span {
    flex: 0 0 auto;
  }
}
