:root {
  --bg: #EDF0F3;
  --ink: #121A26;
  --muted: #5A6474;
  --rule: #CDD3DB;
  --track: #FFFFFF;
  --frame: #121A26;
  --hatch: rgba(18, 26, 38, .09);
  --on-fill: #121A26;
  --low: #FF7A45;
  --mid: #FFC53D;
  --high: #34D27B;
  --fill: var(--high);
  --display: "Black Han Sans", "IBM Plex Sans KR", sans-serif;
  --body: "IBM Plex Sans KR", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161B23;
    --ink: #E8EDF4;
    --muted: #98A3B3;
    --rule: #2C3543;
    --track: #1E2530;
    --frame: #E8EDF4;
    --hatch: rgba(232, 237, 244, .08);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161B23;
  --ink: #E8EDF4;
  --muted: #98A3B3;
  --rule: #2C3543;
  --track: #1E2530;
  --frame: #E8EDF4;
  --hatch: rgba(232, 237, 244, .08);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.6 var(--body);
  transition: background-color .25s, color .25s;
}
a { color: inherit; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: -1px; }

/* ---------- layout: 광고 레일 | 본문 | 광고 레일 ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 760px);
  justify-content: center;
  gap: 40px;
  padding: 0 16px;
}
.rail { display: none; }
/* 레일은 광고 단위(ins)가 들어 있을 때만 자리를 잡는다. 승인 전에는 본문만 가운데에 */
@media (min-width: 1160px) {
  .layout:has(.rail ins) { grid-template-columns: 160px minmax(0, 760px) 160px; }
  .rail:has(ins) { display: block; padding-top: 28px; }
  .rail .ad-slot { position: sticky; top: 24px; }
  .layout:has(.rail ins) .ad-slot.ad-inline { display: none; }
}
.ad-slot { min-height: 90px; }
.ad-slot:not(:has(ins)) { display: none; }
.ad-rail { width: 160px; min-height: 600px; }
.ad-slot:where(:has(ins:empty)) {
  border: 1px dashed var(--rule);
  border-radius: 6px;
  display: grid;
  place-items: center;
}
.ad-slot:where(:has(ins:empty))::before { content: "광고"; color: var(--muted); font-size: 13px; grid-area: 1 / 1; }
.ad-slot:where(:has(ins:empty)) ins { grid-area: 1 / 1; }
.ad-inline { margin: 40px 0 0; }
.ad-inline ins { width: 100%; }

.main { padding: 20px 0 48px; min-width: 0; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: clamp(28px, 6vw, 56px); }
.brand-h { margin: 0; font: inherit; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-icon { color: var(--frame); flex: none; }
.brand-name { font: 400 24px/1 var(--display); }
.theme {
  display: inline-flex; padding: 3px; gap: 2px;
  border: 1px solid var(--rule); border-radius: 999px;
}
.theme button {
  font: 500 13px/1 var(--body); color: var(--muted);
  background: none; border: 0; border-radius: 999px;
  padding: 8px 12px; cursor: pointer;
}
.theme button[aria-checked="true"] { background: var(--ink); color: var(--bg); }

/* ---------- 게이지 ---------- */
.hero-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-right: 18px; }
.target-label { margin: 0; font: 400 clamp(24px, 4.6vw, 34px)/1.2 var(--display); }
.percent { margin: 0; font: 400 clamp(24px, 4.6vw, 34px)/1.2 var(--display); font-variant-numeric: tabular-nums; }

.gauge {
  position: relative;
  height: clamp(124px, 27vw, 210px);
  margin: 12px 18px 0 0;
  border: 5px solid var(--frame);
  border-radius: 28px;
  background: var(--track);
  container-type: size;
}
/* 배터리 +극 */
.gauge::after {
  content: "";
  position: absolute; top: 32%; bottom: 32%; right: -18px;
  width: 10px; border-radius: 0 6px 6px 0;
  background: var(--frame);
}
.cell {
  position: absolute; inset: 6px;
  border-radius: 18px;
  overflow: hidden;
  display: grid; place-items: center;
}
.cell.full {
  background: var(--fill);
  clip-path: inset(0 calc(100% - var(--p, 0%)) 0 0 round 18px);
  transition: clip-path 1s linear, background-color .6s;
}
.lunch {
  position: absolute; top: 0; bottom: 0;
  left: var(--ls, 0); width: var(--lw, 0);
  background: repeating-linear-gradient(135deg, var(--hatch) 0 7px, transparent 7px 15px);
}
.full .lunch { background: repeating-linear-gradient(135deg, rgba(18, 26, 38, .13) 0 7px, transparent 7px 15px); }
.num {
  position: relative;
  font: 400 58cqh/1 var(--display);
  white-space: nowrap;
  color: var(--ink);
  padding-top: .06em;
}
.full .num { color: var(--on-fill); }
.num .d { display: inline-block; width: .6em; text-align: center; }
.num .c { display: inline-block; width: .3em; text-align: center; }
.num.word { font-size: 46cqh; }

.scale {
  position: relative; height: 44px;
  margin: 0 29px 0 11px;
}
.mark {
  position: absolute; top: 8px;
  font-size: 13px; color: var(--muted);
  white-space: nowrap; font-variant-numeric: tabular-nums;
  transform: translateX(-50%);
}
.mark::before {
  content: ""; position: absolute; left: 50%; top: -8px;
  width: 2px; height: 6px; background: var(--rule);
}
.mark b { color: var(--ink); font-weight: 500; margin-right: 4px; }
.mark.first { transform: none; }
.mark.first::before { left: 0; }
.mark.last { transform: translateX(-100%); }
.mark.last::before { left: auto; right: 0; }
.status { margin: 4px 0 0; color: var(--muted); font-size: 15px; }

.notify-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; min-height: 40px; }
.btn.small { padding: 9px 14px; font-size: 14px; }
.notify-text { font-size: 14px; color: var(--muted); }
.notify-text.on { color: var(--ink); font-weight: 500; }
.notify-text.on::before { content: "🔔 "; }

/* ---------- 현황 ---------- */
.stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 36px 0 28px;
  border-top: 2px solid var(--ink);
}
.stat { padding: 12px 14px 0 0; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat + .stat { padding-left: 14px; border-left: 1px solid var(--rule); }
.stat-k { font-size: 14px; color: var(--muted); }
.stat-v { font: 400 clamp(21px, 4.6vw, 28px)/1.2 var(--display); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.linklike {
  font: 500 15px var(--body); color: var(--ink);
  background: none; border: 0; padding: 0; cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--high); text-decoration-thickness: 3px; text-underline-offset: 4px;
}

/* ---------- 설정 패널 ---------- */
.panel { border-top: 1px solid var(--rule); }
.panel:last-of-type { border-bottom: 1px solid var(--rule); }
.panel summary {
  cursor: pointer; list-style: none;
  padding: 16px 0;
  font: 400 20px/1.2 var(--display);
  display: flex; justify-content: space-between; align-items: center;
}
.panel summary::-webkit-details-marker { display: none; }
.panel summary::after { content: "+"; font: 400 24px/1 var(--body); color: var(--muted); }
.panel[open] summary::after { content: "−"; }
.form { padding: 0 0 24px; display: grid; gap: 22px; }
.times { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 560px) { .times { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
label { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; font-size: 14px; color: var(--muted); }
input[type="time"], input[type="number"], select {
  font: 500 17px var(--body); color: var(--ink);
  background: var(--track); border: 1px solid var(--rule); border-radius: 10px;
  padding: 10px 12px; width: 100%; min-width: 0;
}
fieldset { border: 0; margin: 0; padding: 0; }
legend { font-size: 14px; color: var(--muted); padding: 0; margin-bottom: 8px; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.day input { position: absolute; opacity: 0; pointer-events: none; }
.day span {
  display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 12px;
  border: 1px solid var(--rule); background: var(--track);
  font: 500 15px var(--body); color: var(--ink); cursor: pointer;
}
.day input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.day input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 2px; }
.hint-under { display: block; margin-top: 8px; font-size: 13px; color: var(--muted); }
.salary small, .hint { font-size: 13px; color: var(--muted); }
.with-unit { display: flex; align-items: center; gap: 8px; max-width: 240px; }
.with-unit span { color: var(--ink); font-size: 15px; white-space: nowrap; }
.error { margin: -8px 0 0; color: #C2410C; font-size: 14px; }
:root[data-theme="dark"] .error { color: #FF9A6B; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .error { color: #FF9A6B; } }

.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.saved { margin: 0; font-size: 14px; color: var(--muted); }
.saved.on { color: var(--ink); font-weight: 500; }
.saved.on::before { content: "✓ "; color: var(--high); }

.toggles { display: grid; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 16px; color: var(--ink); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--ink); margin: 0; }
.lead { max-width: 240px; }
.perm { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  font: 500 15px var(--body);
  padding: 11px 18px; border-radius: 12px; cursor: pointer;
  background: var(--ink); color: var(--bg); border: 1px solid var(--ink);
}
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn:disabled { opacity: .5; cursor: default; }
.hint { margin: -10px 0 0; }

/* ---------- 설명 글 ---------- */
.guide { margin-top: 56px; max-width: 680px; }
.guide h2 { font: 400 clamp(24px, 4.6vw, 30px)/1.25 var(--display); margin: 0 0 14px; }
.guide h2:not(:first-child) { margin-top: 48px; padding-top: 28px; border-top: 2px solid var(--ink); }
.guide h3 { font: 700 17px/1.4 var(--body); margin: 28px 0 6px; }
.guide p { margin: 0 0 12px; line-height: 1.75; }
.guide b { font-weight: 700; }
.guide a { text-decoration-color: var(--high); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.guide .more { margin-top: 32px; color: var(--muted); }
.guide .more a { color: var(--ink); }

.foot { margin-top: 48px; font-size: 13px; color: var(--muted); }
.foot p { margin: 4px 0; }
.foot-tools { display: flex; flex-wrap: wrap; gap: 4px 14px; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--rule); }
.foot-tools-label { color: var(--ink); font-weight: 500; }

/* ---------- 토스트 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: var(--ink); color: var(--bg);
  border-left: 10px solid var(--fill);
  padding: 14px 20px; border-radius: 12px;
  font: 400 19px/1.3 var(--display);
  box-shadow: 0 8px 24px rgba(18, 26, 38, .25);
  animation: arrive .35s ease-out;
}
@keyframes arrive { from { transform: translate(-50%, 16px); opacity: 0; } }

@media (max-width: 560px) {
  .gauge { border-width: 4px; border-radius: 22px; margin-right: 14px; }
  .gauge::after { right: -14px; width: 8px; }
  .cell { inset: 5px; border-radius: 15px; }
  .cell.full { clip-path: inset(0 calc(100% - var(--p, 0%)) 0 0 round 15px); }
  .hero-head { margin-right: 14px; }
  .scale { margin: 0 23px 0 9px; }
  .mark.lunch-mark b { display: none; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(3) { grid-column: 1 / -1; border-left: 0; padding-left: 0; border-top: 1px solid var(--rule); margin-top: 12px; }
  .theme button { padding: 7px 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
