/* 미니멀 — 페이퍼(전자잉크 느낌) / 블랙 테마 */
:root {
  --bg: #e8e6e0;
  --fg: #161616;
  --muted: #64625d;
  --faint: #99968e;
  --line: #cbc8bf;
  --card: #f0eee9;
  --danger: #8a1c1c;
  --sans: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Noto Sans CJK KR", sans-serif;
  --serif: "AppleMyungjo", "Nanum Myeongjo", "Noto Serif KR", "Noto Serif CJK KR", serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
:root[data-theme="black"] {
  --bg: #000000;
  --fg: #ececec;
  --muted: #8f8f8f;
  --faint: #5a5a5a;
  --line: #2a2a2a;
  --card: #111111;
  --danger: #ff8a8a;
  color-scheme: dark;
}

/* ---------- 기본 ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
  touch-action: manipulation;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
button {
  font: inherit; color: inherit; background: none; border: 0; margin: 0; padding: 0;
  cursor: pointer; text-align: inherit; -webkit-appearance: none; appearance: none;
}
button:disabled { cursor: default; }
input, textarea, select {
  font: inherit; font-size: 17px; color: var(--fg); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; width: 100%;
  -webkit-appearance: none; appearance: none;
}
textarea { resize: vertical; line-height: 1.6; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--fg); outline-offset: -1px; }
code {
  font-family: var(--mono); font-size: .88em; background: var(--card);
  border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; white-space: nowrap;
}
code.wrap { white-space: normal; word-break: break-all; }
b { font-weight: 650; }

.view {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) 24px calc(env(safe-area-inset-bottom) + 22px);
}

/* ---------- 홈 ---------- */
.home { display: flex; flex-direction: column; }
.hero { text-align: center; padding-top: 4vh; }
.clock {
  font-size: clamp(76px, 25vw, 120px); font-weight: 200; line-height: 1;
  letter-spacing: -0.04em; font-variant-numeric: tabular-nums;
}
.clock .ampm {
  font-size: .2em; font-weight: 400; letter-spacing: 0; margin-right: .35em;
  vertical-align: 1em; color: var(--muted);
}
.date { margin-top: 12px; font-size: 18px; color: var(--muted); }
.dday { margin-top: 2px; font-size: 18px; font-weight: 600; }
.quote {
  display: block; margin: 18px auto 0; max-width: 20em; padding: 4px 8px;
  text-align: center; font-family: var(--serif); font-size: 16px; line-height: 1.65; color: var(--muted);
}
.apps { margin-top: 24px; flex: 1; display: flex; flex-direction: column; }
.app-row {
  display: flex; align-items: baseline; justify-content: space-between; width: 100%;
  padding: 9px 0; font-size: 28px; line-height: 1.25; letter-spacing: -0.02em;
}
.app-row:active { opacity: .35; }
.app-row .meta { font-size: 16px; color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.empty { color: var(--muted); }

.modebar { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.mode-status { display: flex; align-items: center; gap: 10px; font-size: 18px; min-height: 52px; }
.mode-status .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--fg); flex: none; }
.mode-status .label { flex: 1; }
.text-btn {
  padding: 10px 2px; color: var(--muted); font-size: 15px;
  text-decoration: underline; text-underline-offset: 4px;
}
.mode-status .text-btn { color: var(--fg); font-size: 17px; font-weight: 600; }
.modebar .sub {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 4px; font-size: 14px; color: var(--muted);
}
.modebar .sub b { color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- 버튼·카드 ---------- */
.btn {
  display: block; width: 100%; padding: 15px 16px; border: 1.5px solid var(--fg);
  border-radius: 14px; font-size: 18px; font-weight: 600; text-align: center;
}
.btn.primary { background: var(--fg); color: var(--bg); }
.btn.ghost { border-color: transparent; font-weight: 400; color: var(--muted); }
.btn.sm { padding: 11px 14px; font-size: 16px; border-radius: 12px; }
.btn.danger { color: var(--danger); border-color: currentColor; }
.btn:disabled { opacity: .35; }
.btn:active:not(:disabled) { opacity: .6; }
.row-btns { display: flex; gap: 10px; margin-top: 12px; }
.row-btns .btn { flex: 1; }

.banner {
  font-size: 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 10px;
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px; margin-bottom: 8px; font-size: 15px;
}
.card p { margin: 0; }

/* ---------- 상단 바·제목 ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; margin-bottom: 6px; }
.back { font-size: 17px; padding: 10px 10px 10px 0; }
.title { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; margin: 4px 0 6px; }
.progress-text { font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }

.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; padding: 9px 12px; font-size: 15px; text-align: center; white-space: nowrap; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.seg button:disabled:not([aria-pressed="true"]) { opacity: .4; }
.seg.small button { padding: 7px 10px; font-size: 14px; }

/* ---------- 끄기 관문 ---------- */
.gate { display: flex; flex-direction: column; }
.gate-main {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 8px 0 18px;
}
.kicker { margin: 0; font-size: 17px; color: var(--muted); }
.gate-count {
  font-size: 128px; font-weight: 200; line-height: 1.05;
  font-variant-numeric: tabular-nums; letter-spacing: -0.04em;
}
.breath { font-family: var(--serif); font-size: 20px; min-height: 1.6em; }
.bar { width: 100%; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; margin: 22px 0 24px; }
.bar i { display: block; height: 100%; width: 0; background: var(--fg); }
.q { margin: 0 0 12px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip { border: 1px solid var(--fg); border-radius: 999px; padding: 9px 14px; font-size: 15px; }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.nudge { min-height: 3em; margin: 14px 0 0; max-width: 22em; color: var(--muted); font-size: 15px; }
.gate-actions { display: grid; gap: 6px; }

/* ---------- 공부 타이머 ---------- */
.timer-main { text-align: center; padding: 5vh 0 2vh; }
.timer-display {
  font-size: clamp(64px, 20vw, 96px); font-weight: 200; line-height: 1.1;
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums; margin: 8px 0 22px;
}
.timer-actions { display: grid; gap: 6px; }
.timer-main .seg { margin: 14px auto 0; max-width: 280px; }
.stat-row {
  display: grid; grid-template-columns: 1fr 1fr; margin-top: 18px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.stat-row > div { display: flex; flex-direction: column; padding: 12px 0; }
.stat-row > div + div { border-left: 1px solid var(--line); padding-left: 16px; }
.stat-row span { font-size: 13px; color: var(--muted); }
.stat-row b { font-size: 24px; font-weight: 500; font-variant-numeric: tabular-nums; }
.week { display: grid; gap: 6px; margin: 14px 0 10px; }
.wk { display: grid; grid-template-columns: 2.6em 1fr 3.6em; align-items: center; gap: 10px; font-size: 14px; }
.wk-d { color: var(--muted); }
.wk-bar { height: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.wk-bar i { display: block; height: 100%; background: var(--fg); }
.wk-v { text-align: right; font-variant-numeric: tabular-nums; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; }
.switch-row input[type="checkbox"] {
  width: 51px; height: 31px; flex: none; padding: 0; border: 0; border-radius: 999px;
  background: var(--line); position: relative; transition: background .15s;
}
.switch-row input[type="checkbox"]::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px;
  border-radius: 50%; background: var(--bg); transition: transform .15s;
}
.switch-row input[type="checkbox"]:checked { background: var(--fg); }
.switch-row input[type="checkbox"]:checked::after { transform: translateX(20px); }
.switch-row input[type="checkbox"]:focus { outline-offset: 2px; }

/* ---------- 설정 ---------- */
.section { margin: 28px 0; }
.section h2 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 10px; letter-spacing: .02em; }
.list { border-top: 1px solid var(--line); margin-bottom: 12px; }
.list-item { display: flex; align-items: center; gap: 2px; border-bottom: 1px solid var(--line); }
.li-main { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 11px 0; }
.li-title { font-size: 18px; }
.li-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 40px; height: 44px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 17px;
}
.icon-btn:disabled { opacity: .25; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0; }
.field.col { flex-direction: column; align-items: stretch; gap: 6px; }
.field > span { font-size: 15px; color: var(--muted); }
.field .seg { min-width: 60%; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.note { font-size: 14px; color: var(--muted); margin: 8px 0 0; line-height: 1.55; }
.center { text-align: center; }
.foot { text-align: center; color: var(--faint); font-size: 13px; margin: 36px 0 8px; }

/* ---------- 가이드 ---------- */
.lead { margin: 0 0 4px; }
.steps { margin-top: 18px; border-top: 1px solid var(--line); }
.step { border-bottom: 1px solid var(--line); }
.step summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 14px 0; cursor: pointer; }
.step summary::-webkit-details-marker { display: none; }
.check {
  width: 30px; height: 30px; flex: none; border-radius: 50%; border: 1.5px solid var(--fg);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.step.done .check { background: var(--fg); color: var(--bg); }
.step-title { flex: 1; font-size: 17px; font-weight: 600; }
.step.done .step-title { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.step-time { font-size: 13px; color: var(--muted); white-space: nowrap; }
.step-body { padding: 0 0 16px 42px; font-size: 16px; }
.step-body ol, .step-body ul { margin: 4px 0; padding-left: 1.25em; }
.step-body li { margin: 7px 0; }
.step-body ul li { margin: 4px 0; }
.step-body p { margin: 8px 0; }

/* ---------- 시트(모달)·토스트 ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, .35);
}
.sheet {
  width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; background: var(--bg);
  border-top: 1px solid var(--line); border-radius: 20px 20px 0 0;
  padding: 22px 22px calc(env(safe-area-inset-bottom) + 20px);
}
.sheet h3 { margin: 0 0 12px; font-size: 20px; }
.sheet .btn + .btn { margin-top: 8px; }
.modal-text { margin: 4px 0 8px; font-size: 17px; }
.preset-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.preset {
  padding: 12px 6px; text-align: center; font-size: 15px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
}
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 96px); transform: translateX(-50%);
  z-index: 60; max-width: 86vw; padding: 10px 18px; border-radius: 999px;
  background: var(--fg); color: var(--bg); font-size: 15px; text-align: center;
}
.toast[hidden] { display: none; }
