:root {
  --chalk: #EDF0F2;
  --panel: #FFFFFF;
  --line: #D3D9DE;
  --ink: #10202F;
  --ink-2: #4B5B69;
  --work: #FF5A2C;
  --work-tint: #FFD9CC;
  --rest: #3CC2B4;
  --rest-tint: #CDEFEA;
  --prep: #FFC83D;
  --prep-tint: #FFF0C7;
  --long: #7FA8E8;
  --long-tint: #DCE7F9;
  --num: "Big Shoulders Display", "IBM Plex Sans KR", sans-serif;
  --text: "IBM Plex Sans KR", -apple-system, "Apple SD Gothic Neo", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --chalk: #151A20;
    --panel: #1D242C;
    --line: #2E3843;
    --ink: #E9EEF2;
    --ink-2: #9AA8B4;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --chalk: #151A20; --panel: #1D242C; --line: #2E3843; --ink: #E9EEF2; --ink-2: #9AA8B4;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--chalk);
  color: var(--ink);
  font: 400 16px/1.6 var(--text);
  word-break: keep-all;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--work); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.shell {
  display: grid;
  grid-template-columns: 1fr;
  justify-content: center;
  gap: 32px;
  padding: 0 16px;
}
/* 광고 자리: 실제 <ins class="adsbygoogle">가 들어 있을 때만 보인다(주석 상태면 공간 0) */
.ad { display: none; }
.ad-inline:has(ins.adsbygoogle) { display: block; margin: 56px 0 0; padding-bottom: 40px; }
@media (min-width: 1280px) {
  .shell:has(.ad-side ins.adsbygoogle) { grid-template-columns: 160px minmax(0, 720px) 160px; }
  .ad-side:has(ins.adsbygoogle) { display: block; padding-top: 88px; }
  .ad-side .ad-slot { position: sticky; top: 24px; }
  /* 양옆 광고가 보이는 넓은 화면에서는 본문 광고를 숨긴다 */
  .shell:has(.ad-side ins.adsbygoogle) .ad-inline { display: none; }
}
.ad-160 { width: 160px; min-height: 600px; }
.ad-wide { min-height: 100px; }

.setup { width: 100%; max-width: 720px; margin: 0 auto; padding-bottom: 32px; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 20px 0 8px;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; font-weight: 700; font-size: 18px;
}
.brand img { border-radius: 7px; }
.toggles { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.tog {
  border: 0; background: transparent; border-radius: 999px;
  padding: 5px 12px; font-size: 14px; color: var(--ink-2);
}
.tog[aria-pressed="true"] { background: var(--ink); color: var(--chalk); }

.title {
  margin: 28px 0 12px;
  font-weight: 700;
  font-size: clamp(36px, 8vw, 56px);
  line-height: 1.15;
  letter-spacing: -0.03em;
}
.lede { margin: 0 0 28px; color: var(--ink-2); max-width: 34em; }

/* ---------- presets ---------- */
.presets {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin-bottom: 16px;
}
.preset {
  text-align: left; border: 1px solid var(--line); background: var(--panel);
  border-radius: 10px; padding: 10px 12px; font-weight: 700; font-size: 16px; line-height: 1.3;
}
.preset small { display: block; font-weight: 400; font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.preset[aria-checked="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
@media (max-width: 560px) { .presets { grid-template-columns: repeat(2, 1fr); } }

/* ---------- plan ---------- */
.plan {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden;
}
@media (max-width: 640px) { .plan { grid-template-columns: 1fr; } }
.rows { padding: 6px 0; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
}
.row + .row { border-top: 1px solid var(--line); }
.row.is-off .row-name, .row.is-off .val { opacity: .4; }
.row-name { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.dot-work { background: var(--work); }
.dot-rest { background: var(--rest); }
.dot-prep { background: var(--prep); }
.dot-long { background: var(--long); }
.stepper { display: flex; align-items: center; gap: 2px; }
.step {
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--chalk);
  font-size: 20px; line-height: 1; touch-action: manipulation; user-select: none;
}
.step:active { background: var(--line); }
.val {
  min-width: 72px; text-align: center;
  font: 800 30px/1 var(--num); font-variant-numeric: tabular-nums;
}

.summary {
  display: flex; flex-direction: column;
  padding: 20px; gap: 14px;
  border-left: 1px solid var(--line);
}
@media (max-width: 640px) { .summary { border-left: 0; border-top: 1px solid var(--line); } }
.total { display: flex; flex-direction: column; }
.total-label { color: var(--ink-2); font-size: 14px; }
.total-num { font: 900 clamp(72px, 16vw, 112px)/0.9 var(--num); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.strip { display: flex; height: 28px; border-radius: 6px; overflow: hidden; gap: 2px; }
.strip i { display: block; min-width: 2px; }
.strip .s-work { background: var(--work); }
.strip .s-rest { background: var(--rest); }
.strip .s-prep { background: var(--prep); }
.strip .s-long { background: var(--long); }
.start {
  margin-top: auto;
  border: 0; border-radius: 12px; padding: 16px;
  background: var(--work); color: #10202F;
  font-weight: 700; font-size: 18px;
}
.start:hover { filter: brightness(1.05); }
.start:active { transform: translateY(1px); }
.hint { margin: 0; font-size: 12.5px; color: var(--ink-2); text-align: center; }
@media (hover: none) { .hint { display: none; } }

/* ---------- about ---------- */
.about { max-width: 38em; }
.about h2 { font-size: 21px; line-height: 1.35; margin: 36px 0 8px; letter-spacing: -0.02em; }
.about h3 { font-size: 16px; margin: 20px 0 4px; }
.about p, .about li { color: var(--ink-2); }
.about b { color: var(--ink); }
.about a { color: var(--ink); text-underline-offset: 3px; }
.about .more { margin-top: 36px; }
.about ol, .about ul { padding-left: 1.3em; }
.about li + li { margin-top: 6px; }
.foot {
  display: flex; justify-content: space-between; gap: 12px;
  margin-top: 56px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 13px; color: var(--ink-2);
}
.foot { flex-wrap: wrap; }
.foot-links { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.foot-tools { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.foot-tools-label { color: var(--ink); font-weight: 500; }

/* ---------- run screen ---------- */
.run {
  --c: var(--prep); --t: var(--prep-tint);
  position: fixed; inset: 0; z-index: 1000;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr);
  color: #10202F;
  background: var(--t);
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  user-select: none; -webkit-user-select: none;
  transition: background-color .25s;
}
.run[data-phase="work"] { --c: var(--work); --t: var(--work-tint); }
.run[data-phase="rest"] { --c: var(--rest); --t: var(--rest-tint); }
.run[data-phase="long"] { --c: var(--long); --t: var(--long-tint); }
.run[data-phase="done"] { --c: #10202F; --t: #10202F; color: #EDF0F2; }

.tank { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 100%;
  background: var(--c);
  transform-origin: bottom;
  transition: background-color .25s;
}
.run > :not(.tank) { position: relative; }

.run-top {
  display: flex; gap: 16px; align-items: center;
  font-weight: 700; font-size: clamp(16px, 2.6vw, 22px);
}
.ctrl-stop {
  margin-left: auto; align-self: center;
  border: 2px solid #10202F; background: transparent; border-radius: 999px;
  padding: 6px 16px; font-weight: 700; font-size: 15px; line-height: 1.2;
}
.run-left { margin: 0; font-weight: 500; font-variant-numeric: tabular-nums; opacity: .75; }

.face {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; min-height: 0; min-width: 0; cursor: pointer;
}
.face p { margin: 0; }
.phase { font-weight: 700; font-size: clamp(32px, 7vw, 64px); letter-spacing: -0.03em; line-height: 1; margin-bottom: 0.3em !important; }
.clock {
  font: 900 min(52vw, 52vh)/0.82 var(--num);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  margin: 0.04em 0 0.08em !important;
}
.clock.is-long { font-size: min(40vw, 44vh); }
.next { font-size: clamp(16px, 2.6vw, 22px); font-weight: 500; opacity: .75; }
.run.is-paused .clock { animation: blink 1.2s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
.run.is-paused .phase::after { content: " 일시정지"; }

.run-bottom { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.segs { display: flex; gap: 3px; width: min(100%, 720px); height: 10px; }
.segs i { flex: 1; border-radius: 2px; background: rgba(16, 32, 47, .16); }
.segs i.is-past { background: rgba(16, 32, 47, .55); }
.segs i.is-now { background: #10202F; }
.ctrls { display: flex; gap: 10px; align-items: center; }
.ctrl {
  width: 56px; height: 56px; border-radius: 50%;
  border: 2px solid #10202F; background: transparent;
  display: grid; place-items: center;
}
.ctrl svg { width: 24px; height: 24px; fill: #10202F; }
.ctrl-main { width: 72px; height: 72px; background: #10202F; }
.ctrl-main svg { width: 30px; height: 30px; fill: var(--t); }
.ctrl-main .i-play { display: none; }
.run.is-paused .ctrl-main .i-play { display: block; }
.run.is-paused .ctrl-main .i-pause { display: none; }
.run :focus-visible { outline-color: #10202F; }

.done {
  position: absolute !important; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 16px; text-align: center;
  background: #10202F; color: #EDF0F2;
}
.done-title { margin: 0; font-weight: 700; font-size: clamp(40px, 9vw, 80px); letter-spacing: -0.03em; }
.done-sub { margin: 0 0 24px; color: #9AA8B4; font-size: 18px; }
.done-btns { display: flex; gap: 10px; }
.done .start { margin: 0; padding: 14px 28px; }
.ghost { border: 1px solid #4B5B69; background: transparent; color: #EDF0F2; border-radius: 12px; padding: 14px 24px; font-weight: 700; font-size: 18px; }

@media (max-height: 520px) and (orientation: landscape) {
  .phase { font-size: 28px; }
  .phase { margin-bottom: 0.15em !important; }
  .clock { font-size: min(30vw, 46vh); }
  .next { display: none; }
  .ctrl { width: 44px; height: 44px; }
  .ctrl-main { width: 56px; height: 56px; }
  .run-bottom { gap: 6px; }
  .segs { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .run, .fill { transition: none; }
  .run.is-paused .clock { animation: none; opacity: .5; }
}

/* ---------- 404 ---------- */
.nf-code { margin: 40px 0 12px; font: 900 clamp(96px, 24vw, 168px)/0.85 var(--num); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.nf-strip { max-width: 420px; }
.nf .title { margin-top: 24px; font-size: clamp(30px, 6vw, 44px); }
.nf-home { display: inline-block; text-decoration: none; padding: 16px 28px; }
