:root {
  color-scheme: light;
  --surface: #eaf0ee;
  --raised: #f5f8f7;
  --ink: #123238;
  --ink-2: #466264;
  --ink-3: #647d7e;
  --line: #c6d4d1;
  --deck: #d7e2df;
  --deck-hatch: #c3d2ce;
  --system: #8b9d9d;
  --c0: #2165b5;
  --c1: #e58a17;
  --c2: #6a45c2;
  --c3: #17a185;
  --c4: #c2365b;
  --c5: #b79b00;
  --warn-bg: #fbeed2;
  --warn-ink: #6f4a00;
  --bad-bg: #f8dfe3;
  --bad-ink: #8c1f3a;
  --ok: #17785f;
  --ridge: rgba(255, 255, 255, .17);
  --focus: #2165b5;
  --font: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface: #10272c;
    --raised: #173339;
    --ink: #e6f0ee;
    --ink-2: #aec3c2;
    --ink-3: #8ba3a3;
    --line: #2c4a50;
    --deck: #1a363c;
    --deck-hatch: #23444a;
    --system: #5f7a7c;
    --c0: #3c86da;
    --c1: #c9780f;
    --c2: #8a63e0;
    --c3: #1ba686;
    --c4: #c93a64;
    --c5: #a08600;
    --warn-bg: #3d3214;
    --warn-ink: #f2d58b;
    --bad-bg: #47202c;
    --bad-ink: #f6b8c7;
    --ok: #5fd0b4;
    --ridge: rgba(255, 255, 255, .11);
    --focus: #7db7f2;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  word-break: keep-all;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.page { width: min(1240px, 100%); margin: 0 auto; padding: 28px 32px 56px; }

.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.verdict h1 { font-size: clamp(25px, 3.2vw, 36px); line-height: 1.2; font-weight: 700; letter-spacing: -.02em; }
.verdict p { margin-top: 6px; color: var(--ink-2); font-size: 16px; overflow-wrap: anywhere; }
.top-side { display: flex; align-items: center; gap: 14px; flex: none; color: var(--ink-2); font-size: 14px; padding-top: 6px; }
.quiet { min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--ink-2); }
.quiet:hover { background: var(--raised); color: var(--ink); }

.alerts { display: grid; gap: 6px; margin-top: 18px; }
.alerts li { padding: 9px 13px; border-radius: 6px; background: var(--warn-bg); color: var(--warn-ink); font-weight: 500; overflow-wrap: anywhere; }
.alerts li.bad { background: var(--bad-bg); color: var(--bad-ink); }

.controls { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; margin-top: 26px; }
.metrics { display: inline-flex; gap: 2px; padding: 3px; border-radius: 8px; background: var(--deck); max-width: 100%; }
.metrics button { min-height: 38px; padding: 0 18px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-2); font-weight: 500; white-space: nowrap; }
.metrics button[aria-checked="true"] { background: var(--ink); color: var(--surface); }

.scale { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; }
.scale[hidden] { display: none; }
.scale button { min-height: 34px; padding: 0 12px; border: 0; border-radius: 5px; background: transparent; color: var(--ink-2); font-size: 14px; white-space: nowrap; }
.scale button[aria-pressed="true"] { background: var(--deck); color: var(--ink); font-weight: 600; }

.holds { display: grid; gap: 22px; margin-top: 22px; }
.hold-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.hold-name { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; min-width: 0; }
.hold-name h3 { font-size: 18px; font-weight: 700; }
.hold-name span { color: var(--ink-3); font-size: 13px; }
.hold-value { flex: none; font-size: 16px; font-weight: 600; }
.hold-value small { color: var(--ink-3); font-size: 13px; font-weight: 400; }

.gauge {
  height: 6px;
  margin-bottom: 4px;
  overflow: hidden;
  border-radius: 2px;
  background-color: var(--deck);
  background-image: repeating-linear-gradient(135deg, transparent 0 3px, var(--deck-hatch) 3px 4px);
}
.gauge i { display: block; height: 100%; min-width: 2px; background: var(--ink); transition: width .35s ease; }
.bar {
  display: flex;
  gap: 2px;
  height: 62px;
  overflow: hidden;
  border-radius: 3px;
  background-color: var(--deck);
}
.bar.total { background-image: repeating-linear-gradient(135deg, transparent 0 7px, var(--deck-hatch) 7px 8px); }
.seg {
  display: block;
  flex: 0 1 auto;
  min-width: 3px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background-color: var(--c, var(--system));
  background-image: repeating-linear-gradient(90deg, var(--ridge) 0 2px, transparent 2px 7px);
  transition: width .35s ease;
}
button.seg:hover { filter: brightness(1.1); }
.seg.selected { box-shadow: inset 0 0 0 2px var(--surface), inset 0 0 0 4px var(--ink); }
.seg.system { --c: var(--system); background-image: none; }
.seg.free { --c: transparent; background: none; }
.c0 { --c: var(--c0); } .c1 { --c: var(--c1); } .c2 { --c: var(--c2); }
.c3 { --c: var(--c3); } .c4 { --c: var(--c4); } .c5 { --c: var(--c5); }
.cx { --c: var(--ink-3); }

.hold.stale .bar, .hold.stale .gauge { opacity: .42; filter: saturate(.3); }
.hold.stale .hold-value { color: var(--bad-ink); }

.legend { display: flex; flex-wrap: wrap; gap: 3px 15px; margin-top: 7px; color: var(--ink-2); font-size: 13px; }
.legend button, .legend span.key { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0; border: 0; background: none; color: inherit; overflow-wrap: anywhere; text-align: left; }
.legend b { color: var(--ink); font-weight: 600; }
.swatch { flex: none; width: 11px; height: 11px; border-radius: 2px; background: var(--c, var(--system)); }
.swatch.free { background: var(--deck); box-shadow: inset 0 0 0 1px var(--line); }
.disk-note { margin-top: 3px; color: var(--ink-3); font-size: 13px; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 430px); gap: 40px; margin-top: 36px; align-items: start; }
.ranking h2 { font-size: 18px; font-weight: 700; margin-bottom: 6px; }

.rows { width: 100%; border-collapse: collapse; }
.row {
  display: grid;
  grid-template-columns: 22px 11px minmax(0, 1fr) 76px 76px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 6px 8px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
}
.row:hover { background: var(--raised); }
.row[aria-pressed="true"] { background: var(--raised); box-shadow: inset 3px 0 0 var(--ink); }
.rank { color: var(--ink-3); font-size: 13px; text-align: right; }
.row-name { min-width: 0; }
.row-name strong { display: block; overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.row-name small { display: block; color: var(--ink-3); font-size: 12.5px; }
.row-value { font-weight: 600; text-align: right; white-space: nowrap; }
.row-value.none { color: var(--ink-3); font-weight: 400; font-size: 13px; }
.spark { display: block; width: 76px; height: 26px; }
.spark path { fill: none; stroke: var(--ink-2); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }

.system-block { margin-top: 16px; }
.system-block summary { min-height: 40px; display: flex; align-items: center; color: var(--ink-2); font-weight: 500; cursor: pointer; }
.system-block summary::before { content: ""; width: 7px; height: 7px; margin: 0 10px 0 4px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
.system-block[open] summary::before { transform: rotate(45deg); }

.detail { position: sticky; top: 16px; padding: 20px; border-radius: 8px; background: var(--raised); }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.detail h2 { font-size: 19px; line-height: 1.3; font-weight: 700; overflow-wrap: anywhere; }
.detail-sub { margin-top: 3px; color: var(--ink-2); font-size: 13.5px; }
.close { display: none; flex: none; width: 40px; height: 40px; border: 0; border-radius: 6px; background: var(--deck); font-size: 20px; line-height: 1; }
.state { display: inline-flex; align-items: center; gap: 5px; font-weight: 500; }
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.state.bad { color: var(--bad-ink); }
.state.bad::before { border-radius: 1px; background: var(--bad-ink); }
.state.off { color: var(--ink-3); }
.state.off::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-3); }

.ranges { display: flex; gap: 2px; margin-top: 16px; overflow-x: auto; }
.ranges button { flex: 1 0 auto; min-height: 34px; padding: 0 9px; border: 0; border-radius: 5px; background: none; color: var(--ink-2); font-size: 13px; }
.ranges button[aria-pressed="true"] { background: var(--deck); color: var(--ink); font-weight: 600; }

.chart-wrap { position: relative; margin-top: 10px; }
.chart { display: block; width: 100%; height: 190px; touch-action: pan-y; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.chart .line { fill: none; stroke: var(--c, var(--ink)); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.peak { stroke-width: 1.25; stroke-dasharray: 3 3; opacity: .7; }
.chart-key { display: flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: 12px; }
.key-line { display: inline-block; width: 16px; height: 0; margin-left: 8px; border-top: 2px solid var(--c, var(--ink)); }
.key-line:first-child { margin-left: 0; }
.key-line.peak { border-top: 1.5px dashed var(--c, var(--ink)); opacity: .75; }
.chart .cross { stroke: var(--ink-3); stroke-width: 1; }
.chart .dot { fill: var(--c, var(--ink)); stroke: var(--raised); stroke-width: 2; }
.tip { position: absolute; top: 2px; z-index: 2; padding: 5px 8px; border-radius: 4px; background: var(--ink); color: var(--surface); font-size: 12px; line-height: 1.4; white-space: nowrap; pointer-events: none; }
.chart-empty { display: grid; place-items: center; height: 190px; color: var(--ink-3); text-align: center; font-size: 14px; }
.table-toggle { margin-top: 4px; color: var(--ink-3); font-size: 12.5px; }
.table-toggle summary { min-height: 28px; display: flex; align-items: center; cursor: pointer; }
.table-scroll { max-height: 180px; overflow: auto; }
.table-toggle table { width: 100%; border-collapse: collapse; }
.table-toggle th, .table-toggle td { padding: 2px 4px; text-align: right; font-weight: 400; }
.table-toggle th:first-child, .table-toggle td:first-child { text-align: left; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; margin: 16px 0 0; }
.facts div { min-width: 0; }
.facts dt { color: var(--ink-3); font-size: 12.5px; }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.boxes { margin-top: 18px; }
.boxes h3 { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.box { padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.box strong { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--ink); font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }

.scrim { display: none; }
.empty { padding: 26px 0; color: var(--ink-2); }

.login-body { display: grid; min-height: 100dvh; place-items: center; padding: 20px; }
.login { width: min(360px, 100%); }
.login-hold { display: flex; gap: 2px; height: 44px; padding: 3px; border-radius: 4px; background: var(--deck); }
.login-hold .seg:nth-child(1) { width: 38%; }
.login-hold .seg:nth-child(2) { width: 17%; }
.login-hold .seg:nth-child(3) { width: 10%; }
.login h1 { margin-top: 18px; font-size: 27px; font-weight: 700; letter-spacing: -.02em; }
.login form { display: grid; gap: 5px; margin-top: 20px; }
.login label { margin-top: 9px; color: var(--ink-2); font-size: 14px; font-weight: 500; }
.login input { width: 100%; height: 46px; padding: 0 12px; border: 1px solid var(--ink-3); border-radius: 6px; background: var(--raised); font-size: 16px; }
.login #code { letter-spacing: .2em; }
.login button { height: 46px; margin-top: 14px; border: 0; border-radius: 6px; background: var(--ink); color: var(--surface); font-weight: 600; }
.login button:disabled { opacity: .6; cursor: wait; }
.form-error { margin-top: 8px; padding: 8px 10px; border-radius: 5px; background: var(--bad-bg); color: var(--bad-ink); font-size: 14px; }

@media (max-width: 920px) {
  .page { padding: max(20px, env(safe-area-inset-top)) 16px 40px; }
  .split { display: block; margin-top: 28px; }
  .top { flex-direction: column; gap: 6px; }
  .top-side { width: 100%; justify-content: space-between; padding-top: 0; }
  .metrics { display: flex; width: 100%; }
  .scale { display: flex; width: 100%; }
  .scale button { flex: 1 1 0; }
  .metrics button { flex: 1 1 0; padding: 0 4px; font-size: 14px; }
  .bar { height: 50px; }
  .row { grid-template-columns: 20px 11px minmax(0, 1fr) 72px; }
  .row .spark { display: none; }
  .detail {
    position: fixed;
    inset: auto 0 0;
    z-index: 20;
    max-height: 88dvh;
    overflow-y: auto;
    border-radius: 12px 12px 0 0;
    padding: 18px 16px max(20px, env(safe-area-inset-bottom));
    transform: translateY(105%);
    visibility: hidden;
    transition: transform .22s ease, visibility .22s;
  }
  .detail.open { transform: none; visibility: visible; }
  .close { display: block; }
  .scrim { position: fixed; inset: 0; z-index: 19; display: block; background: rgba(9, 25, 29, .5); }
  .scrim[hidden] { display: none; }
}

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

@media (forced-colors: active) {
  .seg { border: 1px solid CanvasText; }
}
