:root {
  --bg: #f6f5f2; --card: #fff; --fg: #1f1f1f; --muted: #6b6b6b; --line: #e3e0da;
  --accent: #2f5d8a; --accent-fg: #fff; --danger: #b23b3b; --ok: #2e7d4f; --warn: #a86b00;
  --serif: "Noto Serif KR", "Nanum Myeongjo", serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #17181a; --card: #222326; --fg: #e8e6e3; --muted: #9a9894; --line: #34363a;
          --accent: #6ea0d0; --accent-fg: #111; --danger: #e07070; --ok: #6cc08b; --warn: #e0a940; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.55 system-ui, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif; }
h1 { font-size: 18px; margin: 0; flex: 1; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 18px 0 6px; }
button, select, textarea, input { font: inherit; color: inherit; }
button { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button.danger { color: var(--danger); border-color: var(--danger); }
button.icon { border: 0; background: none; font-size: 20px; padding: 0 6px; display: none; }
select, textarea, input[type=text] { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; width: 100%; }
label { display: block; font-size: 13px; color: var(--muted); }
label.check { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 5; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.bad { color: var(--danger); border-color: var(--danger); }
.layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; padding: 16px; max-width: 1400px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.row { display: flex; gap: 8px; margin: 8px 0; }
.row > * { flex: 1; }
#new button[type=submit] { width: 100%; margin-top: 6px; }
.runs { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow: auto; }
.runs li { padding: 8px; border-radius: 8px; cursor: pointer; border-bottom: 1px solid var(--line); }
.runs li:hover, .runs li.on { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.runs .t { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.badge { padding: 3px 10px; border-radius: 99px; font-size: 13px; white-space: nowrap; background: var(--line); }
.badge.running, .badge.pausing { background: var(--accent); color: var(--accent-fg); }
.badge.completed { background: var(--ok); color: #fff; }
.badge.failed { background: var(--danger); color: #fff; }
.badge.waiting_quota, .badge.paused, .badge.interrupted { background: var(--warn); color: #fff; }
.reason { background: color-mix(in srgb, var(--warn) 14%, transparent); padding: 6px 10px; border-radius: 8px; font-size: 13px; }
.stepper { display: flex; flex-wrap: wrap; gap: 4px; padding: 0; margin: 12px 0 8px; list-style: none; counter-reset: s; }
.stepper li { flex: 1; min-width: 56px; text-align: center; font-size: 12px; padding: 4px 2px; border-bottom: 3px solid var(--line); color: var(--muted); }
.stepper li.done { border-color: var(--ok); color: var(--fg); }
.stepper li.now { border-color: var(--accent); color: var(--fg); font-weight: 600; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
#bar { height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 14px; margin: 10px 0; font-size: 13px; }
.facts div { display: flex; flex-direction: column; }
.facts dt { color: var(--muted); font-size: 12px; }
.facts dd { margin: 0; }
.facts .warn { color: var(--danger); }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
details { position: relative; }
details summary { list-style: none; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
details summary::-webkit-details-marker { display: none; }
.pop { position: absolute; z-index: 4; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; width: 300px; box-shadow: 0 6px 20px rgba(0,0,0,.15); display: grid; gap: 8px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 8px; }
.tabs button { border-radius: 8px 8px 0 0; white-space: nowrap; }
.tabs button.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.view { min-height: 40vh; }
.prose { font-family: var(--serif); font-size: 16.5px; line-height: 1.9; white-space: pre-wrap; max-width: 42em; }
.live { border-left: 3px solid var(--accent); padding-left: 12px; margin-bottom: 18px; }
.live .cursor::after { content: "▍"; animation: blink 1s steps(1) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }
.scene { margin: 0 0 26px; }
.scene h4 { margin: 0 0 6px; font-size: 14px; }
.tag { display: inline-block; white-space: nowrap; font-size: 11px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted); margin-left: 4px; }
.tag.bad { color: var(--danger); border-color: var(--danger); }
.tag.good { color: var(--ok); border-color: var(--ok); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 5px 6px; vertical-align: top; }
.scroll { overflow-x: auto; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.edit { display: grid; gap: 8px; margin-top: 12px; }
.edit .a { display: grid; grid-template-columns: 1fr 2fr auto; gap: 6px; align-items: start; }
.ev { font-family: ui-monospace, monospace; font-size: 12px; white-space: pre-wrap; word-break: break-all; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 8px 16px; border-radius: 10px; z-index: 10; max-width: 90vw; }
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 10px; }
  .stepper li { min-width: 44px; font-size: 11px; }
  button.icon { display: block; }
  #side { display: none; }
  #side.open { display: block; }
  .pop { right: auto; left: 0; width: min(300px, 86vw); }
  .prose { font-size: 16px; }
  .top { gap: 6px; padding: 8px 10px; }
  .top h1 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .top #who { display: none; }
  .top button.small { padding: 4px 8px; }
}

/* 로그인·설정 */
body.locked .top, body.locked .layout { display: none; }
.auth { display: none; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
body.locked .auth { display: flex; }
.auth-card { width: min(380px, 100%); }
.auth-card h1 { margin-bottom: 14px; }
.auth pre { background: var(--bg); padding: 8px; border-radius: 8px; white-space: pre-wrap; }
.err { color: var(--danger); min-height: 1em; margin: 0; }
input[type=password], input[type=number], input[type=url] { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; width: 100%; }
.top #who { margin-left: 4px; }
.opts { margin: 6px 0; }
.opts summary { font-size: 13px; color: var(--muted); padding: 4px 0; border: 0; }
body.modal { overflow: hidden; }
.modal-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; justify-content: center; align-items: flex-start; padding: 24px 12px; overflow: auto; }
.modal-wrap[hidden] { display: none; }
.modal-card { width: min(760px, 100%); }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin: 0; }
legend { font-size: 14px; padding: 0 4px; }
.chain { display: grid; gap: 4px; }
.chain-row { display: grid; grid-template-columns: 52px 1fr auto auto; gap: 4px; align-items: center; }
.row-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.pubbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.final { scroll-margin-top: 70px; border: 1px solid var(--line); border-left: 3px solid var(--ok); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.final h4 { margin: 0 0 6px; font-size: 15px; }
.final p { margin: 4px 0; }
.small-prose { font-size: 15px; line-height: 1.7; }
.sample { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.sample.on { border-color: var(--ok); }
.sample .prose { max-height: 22em; overflow: auto; margin-bottom: 8px; }
.picker { display: grid; gap: 4px; min-width: 0; }
.picker select { width: 100%; }
