:root {
  color-scheme: dark;
  --base: #101827;
  --surface: #172133;
  --surface-lighter: #1d2a3e;
  --edge: #2c3a50;
  --text: #f2f0eb;
  --muted: #acb8cb;
  --accent: #f1c77f;
  --accent-deep: #4e3b25;
  --teal: #90ddc4;
  --danger: #f6a8a7;
  --radius: 16px;
  font-family: "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  background: var(--base);
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); letter-spacing: -.045em; }
h2 { font-size: 1.15rem; letter-spacing: -.03em; }
button, select { font: inherit; }
.muted { color: var(--muted); font-size: .875rem; }

.topbar { border-bottom: 1px solid var(--edge); background: #101725; }
.topbar-inner, .shell { max-width: 1180px; margin: 0 auto; padding-inline: 32px; }
.topbar-inner { display: flex; justify-content: space-between; align-items: center; min-height: 66px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; font-weight: 750; letter-spacing: -.025em; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 1px solid #786348; border-radius: 50%; color: var(--accent); font-size: 1.5rem; line-height: 1; }
.connection { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 650; font-size: .875rem; white-space: nowrap; }
.connection::before { content: ""; border-radius: 50%; width: 7px; height: 7px; background: currentColor; }
.connection[data-state="live"] { color: var(--teal); }
.connection[data-state="stale"] { color: var(--accent); }
.connection[data-state="offline"] { color: var(--danger); }

.shell { padding-block: 32px 50px; }
.heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 24px; }
.heading p { margin-top: 4px; }
.picker { display: grid; gap: 5px; color: var(--muted); font-size: .875rem; }
select { width: min(240px, 100%); max-width: 100%; padding: 9px 12px; border: 1px solid var(--edge); border-radius: 9px; background-color: var(--surface); color: var(--text); text-overflow: ellipsis; }
select:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.panel { background: var(--surface); border: 1px solid var(--edge); border-radius: var(--radius); }
.overview { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(220px, 1fr); gap: 25px; padding: 24px; border-top: 2px solid #97794c; background: linear-gradient(115deg, #212a3c, #172133 70%); }
.overview h2 { margin: 9px 0 5px; font-size: clamp(1.22rem, 3vw, 1.58rem); word-break: keep-all; overflow-wrap: anywhere; }
.state { display: inline-block; padding: 3px 9px; background: var(--surface-lighter); border: 1px solid var(--edge); border-radius: 6px; color: var(--muted); font-size: .875rem; font-weight: 700; }
.state[data-state="running"], .stage[data-state="running"] .stage-status { color: var(--accent); }
.state[data-state="done"], .stage[data-state="done"] .stage-status { color: var(--teal); }
.state[data-state="failed"], .stage[data-state="failed"] .stage-status { color: var(--danger); }
.focus { margin-top: 13px; color: var(--text); font-weight: 600; min-height: 1.5em; }
.overview-progress { align-self: center; padding: 14px 0; }
.progress-heading { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.progress-heading span { color: var(--muted); font-weight: 600; }
.progress-heading strong { color: var(--accent); font-size: clamp(1.8rem, 4vw, 2.55rem); line-height: 1.05; font-variant-numeric: tabular-nums; }
progress { display: block; width: 100%; height: 9px; margin-block: 12px 8px; border: 0; border-radius: 20px; appearance: none; background: #344259; color: var(--accent); overflow: hidden; }
progress::-webkit-progress-bar { background: #344259; border-radius: 20px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 20px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 20px; }

.workflow { margin-block: 26px; }
.stages { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; padding: 0; margin: 10px 0 0; list-style: none; }
.stage { display: flex; flex-direction: column; gap: 2px; padding: 11px 12px; border: 1px solid var(--edge); border-radius: 10px; background: var(--surface); }
.stage[data-state="running"] { border-color: #8e7045; background: #292737; }
.stage-name { font-weight: 700; font-size: .95rem; }
.stage-status { color: var(--muted); font-size: .875rem; }
.story-panel { padding: 20px 22px; }
.story-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 10px 9px; border-top: 1px solid var(--edge); }
th { font-size: .875rem; font-weight: 600; color: var(--muted); }
td, th { overflow-wrap: anywhere; }
td:nth-child(n+2), th:nth-child(n+2) { width: 19%; white-space: nowrap; font-variant-numeric: tabular-nums; }
td[data-ready="true"] { color: var(--teal); }
tr[data-current="true"] { background: #222d40; }
.empty { padding: 32px 24px; text-align: center; }
.empty p, .no-stories { margin-top: 8px; color: var(--muted); }

@media (max-width: 760px) {
  .topbar-inner, .shell { padding-inline: 18px; }
  .shell { padding-block-start: 22px; }
  .overview { grid-template-columns: 1fr; gap: 12px; padding: 18px; }
  .overview-progress { padding: 7px 0 0; }
  .stages { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 430px) {
  .heading { display: grid; gap: 12px; }
  .picker { width: 100%; }
  select { width: 100%; }
  .story-panel { padding: 15px 12px; }
  th, td { padding: 9px 5px; }
}
