/* 약챙김 스타일 — 휴대폰 우선. 글자를 크게, 누르는 곳을 넓게(최소 48px). 색 토큰은 :root, 다크 모드는 아래에서 다시 정의. */
:root {
  --bg: #f4f6f5; --surface: #ffffff; --surface-2: #eef2f0; --text: #17201c; --muted: #5d6a64; --line: #dde4e0;
  --brand: #0f7b5f; --brand-ink: #ffffff; --brand-soft: #e1f3ec;
  --ok: #1a8a5a; --ok-soft: #dff3e8; --warn: #a15c00; --warn-soft: #fff1d6; --bad: #c4352b; --bad-soft: #fde6e3;
  --now: #0f62c4; --now-soft: #e3eefc;
  --radius: 18px; --shadow: 0 1px 2px rgba(20, 40, 30, .06), 0 2px 10px rgba(20, 40, 30, .05);
  --tab-h: 64px;
  --sysbar: #0f7b5f;   /* 화면 아래 시스템 버튼(||| □ <) 뒤 띠. build.py SYSBAR와 같은 색 */
  color-scheme: light;
  font-size: 17px;
}
:root[data-font="large"] { font-size: 20px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1412; --surface: #18201c; --surface-2: #212b26; --text: #e8efeb; --muted: #9aaba3; --line: #2c3833;
    --brand: #34c391; --brand-ink: #062118; --brand-soft: #173a2d;
    --ok: #4cd394; --ok-soft: #173a29; --warn: #f2b14b; --warn-soft: #3a2c12; --bad: #ff7b6e; --bad-soft: #3d1b18;
    --now: #6aa8ff; --now-soft: #172a45; --shadow: none; color-scheme: dark; --sysbar: #000;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1412; --surface: #18201c; --surface-2: #212b26; --text: #e8efeb; --muted: #9aaba3; --line: #2c3833;
  --brand: #34c391; --brand-ink: #062118; --brand-soft: #173a2d;
  --ok: #4cd394; --ok-soft: #173a29; --warn: #f2b14b; --warn-soft: #3a2c12; --bad: #ff7b6e; --bad-soft: #3d1b18;
  --now: #6aa8ff; --now-soft: #172a45; --shadow: none; color-scheme: dark; --sysbar: #000;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); line-height: 1.5;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  word-break: keep-all; overflow-wrap: anywhere;
}
a { color: var(--brand); }
button, input, select { font: inherit; color: inherit; }
svg { display: block; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
p { margin: 0; }
[hidden] { display: none !important; }
/* 앱이 화면 맨 아래까지 그려질 때(안드로이드 전체 화면 모드) 시스템 버튼 뒤를 진하게 칠해 버튼이 보이게 한다.
   시스템 막대가 따로 있으면 높이가 0이라 아무것도 그리지 않는다. */
body::after { content: ""; position: fixed; left: 0; right: 0; bottom: 0; height: env(safe-area-inset-bottom); background: var(--sysbar); z-index: 30; pointer-events: none; }

/* ---------- 앱 틀 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.05rem; text-decoration: none; color: var(--text); }
.brand svg { width: 30px; height: 30px; }
.topbar .spacer { flex: 1; }
.app-main { max-width: 560px; margin: 0 auto; padding: 4px 16px calc(var(--tab-h) + 28px + env(safe-area-inset-bottom)); }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; max-width: 140px; height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .78rem; font-weight: 600;
}
.tabbar a svg { width: 26px; height: 26px; }
.tabbar a[aria-current] { color: var(--brand); }
.tabbar a[aria-current] svg { stroke-width: 2.4; }

.date-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 14px; }
.date-line h1 { font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pad { padding: 4px 4px 0; }
.sec { font-size: 1rem; color: var(--muted); margin: 22px 4px 8px; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 18px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer;
  text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.btn svg { width: 20px; height: 20px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.danger:not(.ghost) { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: .9rem; border-radius: 12px; }
.btn.big-btn { min-height: 56px; font-size: 1.08rem; width: 100%; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 12px; cursor: pointer; color: var(--muted); }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:disabled { opacity: .3; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

/* ---------- 오늘 ---------- */
.summary { display: flex; align-items: center; gap: 16px; background: var(--surface); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 12px; }
.summary .big { font-size: 1.2rem; font-weight: 700; }
.summary .big b { color: var(--brand); }
.summary.complete { background: var(--ok-soft); }
.ring { width: 72px; height: 72px; flex: none; }
.ring circle { fill: none; stroke-width: 9; }
.ring-bg { stroke: var(--surface-2); }
.ring-fg { stroke: var(--brand); stroke-linecap: round; transition: stroke-dasharray .4s; }
.ring text { font-size: 17px; font-weight: 800; fill: var(--text); }
.ring-check { fill: none; stroke: var(--ok); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.summary.complete .ring-fg { stroke: var(--ok); }

.slot { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; overflow: hidden; border: 2px solid transparent; }
.slot > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px 6px; }
.slot h3 { font-size: 1.12rem; font-weight: 800; }
.slot .period { color: var(--brand); }
.slot.s-now { border-color: var(--now); }
.slot.s-now .period { color: var(--now); }
.slot.s-late { border-color: var(--warn); }
.slot.s-late .period { color: var(--warn); }
.slot.s-done { opacity: .92; }
.badge { font-size: .82rem; font-weight: 700; border-radius: 99px; padding: 4px 10px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.b-now { background: var(--now); color: #fff; }
.b-late { background: var(--warn-soft); color: var(--warn); }
.b-done { background: var(--ok-soft); color: var(--ok); }
.doses { list-style: none; margin: 0; padding: 0 6px 6px; }
.dose { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--line); }
.dose:first-child { border-top: 0; }
.dose-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 12px 10px; border: 0; background: none; text-align: left; cursor: pointer; border-radius: 12px; }
.dose-text { display: flex; flex-direction: column; min-width: 0; }
.dose-text b { font-size: 1.06rem; }
.dose-text small { color: var(--muted); font-size: .88rem; }
.dose-text .memo { font-style: italic; }
.took { color: var(--ok); font-weight: 700; font-size: .95rem; }
.skipped { color: var(--muted); font-weight: 700; font-size: .95rem; }
.chk {
  flex: none; width: 58px; height: 58px; margin-right: 6px; border-radius: 50%; border: 3px solid var(--line); background: var(--surface);
  display: grid; place-items: center; color: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background .15s, border-color .15s;
}
.chk svg { width: 30px; height: 30px; }
.slot.s-now .chk:not(.on):not(.skip) { border-color: var(--now); color: color-mix(in srgb, var(--now) 25%, transparent); }
.chk.on { background: var(--ok); border-color: var(--ok); color: #fff; animation: pop .25s ease-out; }
.chk.skip { background: var(--surface-2); color: var(--muted); }
.chk:active { transform: scale(.94); }
@keyframes pop { 0% { transform: scale(.8); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
.slot-foot { padding: 0 16px 14px; }
.slot-foot .btn { width: 100%; }

.pill-dot { flex: none; width: 22px; height: 34px; border-radius: 11px; background: linear-gradient(180deg, var(--c) 50%, color-mix(in srgb, var(--c) 55%, #fff) 50%); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); transform: rotate(35deg); }
.pill-dot.lg { width: 26px; height: 40px; border-radius: 13px; }
.pill-dot.xl { width: 34px; height: 54px; border-radius: 17px; }

.notice { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; text-align: left; border: 0; border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; background: var(--now-soft); color: var(--text); font-weight: 600; cursor: pointer; }
.notice svg { width: 20px; height: 20px; flex: none; }
.notice.warn { background: var(--warn-soft); }
.tip { display: flex; gap: 12px; background: var(--brand-soft); border-radius: var(--radius); padding: 16px; margin: 16px 0 12px; }
.tip > svg { width: 28px; height: 28px; flex: none; color: var(--brand); }
.tip p { color: var(--muted); margin: 2px 0 10px; font-size: .92rem; }
.foot-note { color: var(--muted); font-size: .82rem; margin: 18px 4px 0; }

.empty { text-align: center; background: var(--surface); border-radius: var(--radius); padding: 28px 20px; box-shadow: var(--shadow); }
.empty h2 { font-size: 1.3rem; margin-bottom: 8px; }
.empty > p { color: var(--muted); margin-bottom: 18px; }
.empty-art { display: flex; justify-content: center; gap: 18px; margin: 4px 0 18px; }
.feature-list { text-align: left; margin: 22px auto 0; padding: 0 0 0 4px; list-style: none; max-width: 340px; color: var(--muted); font-size: .94rem; }
.feature-list li { padding: 5px 0 5px 26px; position: relative; }
.feature-list li::before { content: ""; position: absolute; left: 4px; top: 12px; width: 10px; height: 6px; border-left: 2.5px solid var(--brand); border-bottom: 2.5px solid var(--brand); transform: rotate(-45deg); }

/* ---------- 기록 ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 12px; }
.card h2 { font-size: 1.08rem; margin-bottom: 8px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 14px 6px; text-align: center; }
.stat b { display: block; font-size: 1.45rem; color: var(--brand); }
.stat span { font-size: .8rem; color: var(--muted); }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal-head h2 { margin: 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-grid .wd { text-align: center; font-size: .78rem; color: var(--muted); padding: 2px 0; }
.day { aspect-ratio: 1; display: grid; place-items: center; border-radius: 12px; border: 0; font-weight: 700; font-size: .95rem; cursor: pointer; background: var(--surface-2); color: var(--text); }
.day.future { background: transparent; color: var(--muted); opacity: .5; font-weight: 500; }
.day.today { outline: 2.5px solid var(--text); outline-offset: -2.5px; }
.c-full { background: var(--ok) !important; color: #fff !important; }
.c-part { background: var(--warn-soft) !important; color: var(--warn) !important; }
.c-miss { background: var(--bad-soft) !important; color: var(--bad) !important; }
.c-skip { background: var(--surface-2); }
.c-none { background: transparent !important; color: var(--muted) !important; }
.c-todo { background: var(--surface-2); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; margin-top: 12px; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; margin-right: -6px; vertical-align: -2px; }
.legend i.c-none { box-shadow: inset 0 0 0 1px var(--line); }
.per-med { list-style: none; margin: 0 0 8px; padding: 0; }
.per-med li { display: grid; grid-template-columns: 26px minmax(0, 1fr) 30% 48px; align-items: center; gap: 10px; padding: 8px 0; }
.per-med .pill-dot { width: 16px; height: 26px; }
.pm-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.per-med b { text-align: right; }

/* ---------- 약 목록 ---------- */
.med-list { list-style: none; margin: 0; padding: 0; }
.med { width: 100%; display: flex; align-items: center; gap: 14px; padding: 16px; margin-bottom: 10px; background: var(--surface); border: 0; border-radius: var(--radius); box-shadow: var(--shadow); text-align: left; cursor: pointer; }
.med > svg { width: 22px; height: 22px; color: var(--muted); flex: none; }
.med-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.med-text b { font-size: 1.08rem; }
.med-text small { color: var(--muted); }
.med-list.dim .med { opacity: .7; }
.warn-text { color: var(--warn); font-weight: 700; }

/* ---------- 설정 ---------- */
.status { font-weight: 700; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.st-on { background: var(--ok-soft); color: var(--ok); }
.st-denied, .st-no { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0 0; border: 0; padding: 0; min-width: 0; }
.field > span, .field legend { font-weight: 700; font-size: .92rem; padding: 0; }
.field legend { margin-bottom: 6px; }
input:not([type=file]):not([type=checkbox]), select {
  width: 100%; min-height: 50px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-size: 1rem;
}
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.help { margin: 10px 0 0; font-size: .9rem; }
.help summary { cursor: pointer; color: var(--brand); font-weight: 700; padding: 6px 0; }
.help p { color: var(--muted); margin: 4px 0 0; }
.links { list-style: none; padding: 0; margin: 0 0 10px; }
.links a { display: block; padding: 10px 0; font-weight: 600; }
.steps { padding-left: 20px; margin: 10px 0 0; }
.steps li { margin: 6px 0; }

/* ---------- 시트 ---------- */
dialog.sheet {
  margin: auto auto 0; width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; overflow-y: auto;
  border: 0; border-radius: 24px 24px 0 0; padding: 22px 18px calc(24px + env(safe-area-inset-bottom)); color: var(--text);
  background: linear-gradient(to top, var(--sysbar) env(safe-area-inset-bottom), var(--bg) env(safe-area-inset-bottom));
  overscroll-behavior: contain;
}
dialog.sheet[open] { animation: up .22s ease-out; }
dialog.sheet::backdrop { background: rgba(0, 0, 0, .45); }
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (min-width: 600px) { dialog.sheet { margin: auto; border-radius: 24px; } }
.sheet h2 { font-size: 1.3rem; padding-right: 44px; margin-bottom: 4px; }
.sheet .close { position: absolute; top: 12px; right: 10px; }
.sheet-head { display: flex; align-items: center; gap: 14px; padding-right: 40px; }
.sheet-head h2 { padding: 0; }
.state-line { margin: 16px 0 0; padding: 12px 14px; background: var(--surface); border-radius: 14px; }
.sheet .slot { box-shadow: none; border: 1px solid var(--line); }
.sheet .slot.s-late { border-color: var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 14px; border-radius: 99px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; }
.chip svg { width: 18px; height: 18px; }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.day-chip { width: 44px; padding: 0; justify-content: center; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--surface); background: var(--c); box-shadow: 0 0 0 1.5px var(--line); cursor: pointer; }
.swatch.on { box-shadow: 0 0 0 3px var(--brand); }
.times { list-style: none; margin: 0 0 10px; padding: 0; }
.times li { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.times input { flex: 1; font-size: 1.15rem; font-weight: 700; }
.times .muted { width: 60px; font-size: .9rem; }
.two { display: grid; grid-template-columns: 1fr 120px; gap: 10px; }
.form-err { color: var(--bad); font-weight: 700; margin-top: 12px; min-height: 1em; }

/* ---------- 안내 메시지 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 14px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  width: calc(100% - 32px); max-width: 520px; display: flex; align-items: center; gap: 12px; justify-content: space-between;
  background: #1d2622; color: #fff; border-radius: 14px; padding: 12px 12px 12px 16px; box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
}
.toast.show { animation: up .2s ease-out; }
.toast button { flex: none; border: 0; background: transparent; color: #7fe3bb; font-weight: 800; min-height: 40px; padding: 0 10px; cursor: pointer; }

/* ---------- 안내 페이지(소개·약관 등) ---------- */
.page { max-width: 720px; margin: 0 auto; padding: 8px 18px 60px; }
.prose h1 { font-size: 1.6rem; margin: 10px 0 14px; }
.prose h2 { font-size: 1.2rem; margin: 28px 0 10px; }
.prose p, .prose li { color: var(--text); }
.prose p { margin: 10px 0; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin: 6px 0; }
.prose table { border-collapse: collapse; width: 100%; font-size: .92rem; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); }
.prose .meta { color: var(--muted); font-size: .9rem; }
.site-footer { border-top: 1px solid var(--line); margin-top: 30px; padding: 20px 18px 40px; color: var(--muted); font-size: .85rem; }
.site-footer .inner { max-width: 720px; margin: 0 auto; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; }
.site-footer a { color: var(--muted); }
.back-app { display: inline-flex; margin-top: 16px; }
noscript p { background: var(--warn-soft); padding: 14px; border-radius: 14px; }
