:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #3b82f6;
  --brand-strong: #2563eb;
  --wife: #ec4899;
  --ok: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 16px;
  --tab-h: 64px;
  --font: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #111827;
    --surface-2: #1e293b;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --line: #1f2a3c;
  }
}
html[data-font="large"] { --font: 18px; }
html[data-font="xlarge"] { --font: 20px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", system-ui, sans-serif;
  font-size: var(--font);
  line-height: 1.45;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%;
}
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.35em; }
h2 { font-size: 1.1em; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.mono { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

.app { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.boot { min-height: 80vh; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; }
.logo { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 0 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { flex: 1; font-size: 1.15em; }
.topbar .sub { display: block; font-size: .72em; font-weight: 500; color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin: 12px 0;
}
.card.tight { padding: 10px 12px; }
.card h2 { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.wrap { flex-wrap: wrap; }

.btn {
  min-height: 44px; padding: 10px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 34px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  font-size: .85em; white-space: nowrap; cursor: pointer;
}
.chip[aria-pressed="true"] { background: color-mix(in srgb, var(--brand) 16%, var(--surface)); border-color: var(--brand); color: var(--brand-strong); font-weight: 700; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: .78em; font-weight: 700; }
.badge.recommend { background: color-mix(in srgb, var(--ok) 18%, var(--surface)); color: var(--ok); }
.badge.conditional { background: color-mix(in srgb, var(--warn) 20%, var(--surface)); color: #b45309; }
.badge.reject { background: color-mix(in srgb, var(--bad) 16%, var(--surface)); color: var(--bad); }
.badge.neutral { background: var(--surface-2); color: var(--muted); }

.ev { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); align-items: flex-start; }
.ev:last-child { border-bottom: 0; }
.ev .time { width: 52px; font-weight: 700; font-variant-numeric: tabular-nums; flex: none; }
.ev .body { flex: 1; min-width: 0; }
.ev .title { font-weight: 650; overflow-wrap: anywhere; }
.ev .meta { color: var(--muted); font-size: .82em; display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.ev.pending .time { color: var(--warn); }
.ev.cancelled .title { text-decoration: line-through; opacity: .6; }
.ev.cancelled .time, .ev.cancelled .meta { opacity: .6; }
.ev .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-top: 7px; flex: none; }
.ev .dot.wife { background: var(--wife); }
.ack { font-size: .78em; font-weight: 700; }
.ack.ok { color: var(--ok); }
.ack.wait { color: var(--warn); }
.ack.no { color: var(--bad); }

.day { margin: 14px 0 6px; color: var(--muted); font-size: .82em; font-weight: 700; letter-spacing: .04em; }
.day.today { color: var(--brand); }

.stat { display: flex; gap: 12px; }
.stat > div { flex: 1; background: var(--surface-2); border-radius: 12px; padding: 10px; }
.stat b { display: block; font-size: 1.2em; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: .92em; }
.kv:last-child { border-bottom: 0; }
.kv span:last-child { font-weight: 650; text-align: right; }
.kv.bad span:last-child { color: var(--bad); }
.kv.ok span:last-child { color: var(--ok); }
.kv.warn span:last-child { color: #b45309; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field > label { font-size: .82em; font-weight: 700; color: var(--muted); }
.field input, .field select, .field textarea {
  min-height: 46px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); width: 100%;
}
.field textarea { min-height: 80px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabs[hidden] { display: none; }
.tabs a { flex: 1; min-height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .7em; color: var(--muted); font-weight: 600; }
.tabs a .ico { font-size: 1.25em; }
.tabs a[aria-current="page"] { color: var(--brand-strong); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: .85em; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: 90vw;
}
.toast.show { opacity: .96; transform: translateX(-50%) translateY(0); }

.notice { border-left: 3px solid var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--surface)); padding: 10px 12px; border-radius: 8px; font-size: .88em; margin: 8px 0; }
.notice.bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, var(--surface)); }
.notice.good { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, var(--surface)); }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 80px; margin-top: 10px; }
.bars > div { flex: 1; background: color-mix(in srgb, var(--brand) 55%, var(--surface)); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars > div.neg { background: var(--bad); }

.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; min-height: 40px; border: 0; background: transparent; border-radius: 9px; font-weight: 650; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--tab-h) + 18px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: var(--brand); color: #fff; font-size: 1.6em; line-height: 1;
} .fab:active { transform: scale(.96); }

.login { padding: 32px 0; }
.login .card { padding: 22px; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.pinpad button { min-height: 56px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 1.3em; font-weight: 700; }
.pin-dots { display: flex; gap: 12px; justify-content: center; margin: 18px 0; }
.pin-dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.pin-dots i.on { background: var(--brand); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.list li:last-child { border-bottom: 0; }
.linkrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.linkrow:last-child { border-bottom: 0; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: .15s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(20px); }

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