/* Layout: single scrolling form in thumb-sized segmented rows; section dock + review button pinned to the bottom edge for one-hand use. */
:root {
  --bg: #F5F4F6;
  --surface: #FFFFFF;
  --field: #F8F7F9;
  --ink: #1D191E;
  --muted: #6F6873;
  --line: #E3DFE5;
  --chip: #EEEBF0;
  --chip-strong: #D8D3DB;
  --press: #E2DDE5;
  --accent: #7B1E3E;
  --on-accent: #FFFFFF;
  --knob: #FFFFFF;
  --shadow: rgba(40, 18, 30, 0.14);
  --scrim: rgba(24, 12, 18, 0.4);
  --sw-ring: rgba(0, 0, 0, 0.16);

  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --top-h: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121013; --surface: #1C191D; --field: #161317; --ink: #F2EEF2; --muted: #A69EA8;
    --line: #2F2A31; --chip: #252127; --chip-strong: #3A343C; --press: #302A32;
    --accent: #DE7896; --on-accent: #220C15; --knob: #FFFFFF;
    --shadow: rgba(0, 0, 0, 0.5); --scrim: rgba(0, 0, 0, 0.6); --sw-ring: rgba(255, 255, 255, 0.2);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121013; --surface: #1C191D; --field: #161317; --ink: #F2EEF2; --muted: #A69EA8;
  --line: #2F2A31; --chip: #252127; --chip-strong: #3A343C; --press: #302A32;
  --accent: #DE7896; --on-accent: #220C15; --knob: #FFFFFF;
  --shadow: rgba(0, 0, 0, 0.5); --scrim: rgba(0, 0, 0, 0.6); --sw-ring: rgba(255, 255, 255, 0.2);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 21;
  background: var(--bg);
}
html.locked, html.locked body { overflow: hidden; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap {
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Header */
.top {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.top-row { display: flex; align-items: center; gap: 12px; min-height: var(--top-h); }
.brand { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.mark { font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.title { font-size: 16px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 6px; flex: none; }
.ghost {
  min-height: 36px; padding: 0 12px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 13px; touch-action: manipulation;
}
.lang { display: inline-flex; gap: 6px; align-items: center; }
.lang span { color: var(--muted); }
.lang span.on { color: var(--ink); font-weight: 700; }

/* Form */
main.wrap { padding-bottom: calc(104px + env(safe-area-inset-bottom, 0px)); }
.hint { margin: 14px 2px 0; color: var(--muted); font-size: 13px; }
.sec { padding-top: 22px; scroll-margin-top: calc(var(--top-h) + env(safe-area-inset-top, 0px) + 4px); }
.sec-head { display: flex; align-items: baseline; gap: 8px; margin: 0 2px 10px; }
.sec-head h2 { margin: 0; font-size: 20px; letter-spacing: -0.01em; text-wrap: balance; }
.sec-en { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.14em; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.card.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 12px; }
.card.grid > .field { grid-column: 1 / -1; min-width: 0; }
.card.grid > .field.half { grid-column: auto; }

.field { min-width: 0; }
.lab { display: flex; align-items: baseline; gap: 6px; margin: 0 0 8px; font-size: 14px; }
.lab-ko { font-weight: 650; }
.lab-en { color: var(--muted); font-size: 12px; letter-spacing: 0.02em; }
.lab-state { margin-left: auto; color: var(--muted); font-size: 12px; }
.field.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field.row .lab { margin: 0; flex-wrap: wrap; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 12px; flex-basis: 100%; }

.field input,
.field textarea {
  display: block; width: 100%;
  font: inherit; font-size: 16px; color: var(--ink);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  min-height: 46px;
  -webkit-appearance: none; appearance: none;
}
.field textarea { resize: none; min-height: 96px; line-height: 1.5; overflow: hidden; }
.field input::placeholder, .field textarea::placeholder { color: var(--muted); opacity: 0.75; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.field input[type="date"] { text-align: left; }
.field input[type="date"]::-webkit-date-and-time-value { text-align: left; }

/* Segmented choice rows */
.seg { display: flex; gap: 3px; padding: 3px; background: var(--chip); border-radius: 12px; }
.seg button {
  flex: 1 1 0; min-width: 0; min-height: 46px;
  padding: 6px 2px; border: 0; border-radius: 9px;
  background: transparent; color: var(--ink);
  font: inherit; font-size: 13px; line-height: 1.2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  touch-action: manipulation; word-break: keep-all;
  user-select: none; -webkit-user-select: none;
}
.seg button span { white-space: pre-line; text-align: center; }
.seg[data-n="6"] button { font-size: 12px; letter-spacing: -0.01em; }
.seg button[aria-checked="false"]:active { background: var(--press); }
.seg button[aria-checked="true"] {
  background: var(--accent); color: var(--on-accent); font-weight: 650;
  box-shadow: 0 1px 3px var(--shadow);
}
.seg-row { display: flex; gap: 8px; align-items: stretch; }
.seg-row .seg { flex: 1 1 auto; min-width: 0; }
.side { position: relative; display: flex; flex: 0 0 88px; }
.field .side input { min-height: 52px; padding-right: 28px; text-align: right; font-variant-numeric: tabular-nums; }
.side span { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.sw { width: 14px; height: 14px; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 1px var(--sw-ring); flex: none; }
.seg button[aria-checked="true"] .sw { box-shadow: 0 0 0 2px var(--on-accent); }
.seg.is-empty { padding: 13px 12px; }
.seg-empty { margin: 0; width: 100%; color: var(--muted); font-size: 13px; text-align: center; }
@media (hover: hover) {
  .seg button[aria-checked="false"]:hover { background: var(--press); }
}

/* Switch */
.switch {
  position: relative; flex: none; width: 52px; height: 32px; border: 0; border-radius: 16px;
  background: var(--chip-strong); transition: background 0.18s; touch-action: manipulation;
}
.switch span {
  position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--knob); box-shadow: 0 1px 3px var(--shadow); transition: transform 0.18s;
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"] span { transform: translateX(20px); }

/* Buttons */
.cta {
  flex: none; min-height: 50px; padding: 0 18px; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--on-accent);
  font: inherit; font-size: 15px; font-weight: 700; touch-action: manipulation;
}
.cta.wide { width: 100%; margin-top: 24px; min-height: 54px; }
.cta[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-sec {
  min-height: 50px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 15px; font-weight: 600; touch-action: manipulation;
}

/* Bottom dock */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.dock-row { display: flex; align-items: center; gap: 4px; padding-block: 8px; }
.tab {
  flex: 1 1 0; min-width: 0; min-height: 50px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); font: inherit;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  touch-action: manipulation;
}
.tab-name { font-size: 13px; font-weight: 600; }
.cnt { font-size: 11px; font-variant-numeric: tabular-nums; }
.cnt.done { color: var(--accent); font-weight: 700; }
.tab.on { background: var(--chip); color: var(--ink); }

/* Bottom sheet */
.scrim { position: fixed; inset: 0; z-index: 40; background: var(--scrim); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-height: 88%; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  background: var(--surface); border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 30px var(--shadow);
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
.sheet:not([hidden]) { animation: sheet-up 0.22s ease-out; }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet-in { display: flex; flex-direction: column; gap: 14px; padding-top: 10px; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 4px; }
.sheet h3 { margin: 0; font-size: 18px; }
.note { margin: 0; color: var(--muted); font-size: 13px; }
.missing { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 4px 9px; border-radius: 999px; background: var(--chip); color: var(--muted); }
.ok { color: var(--accent); font-weight: 600; font-size: 13px; margin: 0; }
.sum {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font: 14px/1.6 var(--font); color: var(--ink);
  background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  user-select: text; -webkit-user-select: text;
}
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet-actions .full { grid-column: 1 / -1; }
.pass { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.pass input {
  display: block; width: 100%; min-height: 46px; padding: 11px 12px;
  font: inherit; font-size: 16px; font-weight: 400; color: var(--ink);
  background: var(--field); border: 1px solid var(--line); border-radius: 10px;
  -webkit-appearance: none; appearance: none;
}
.pass input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
a.link { display: flex; align-items: center; justify-content: center; text-decoration: none; }
details summary { color: var(--muted); font-size: 13px; padding: 4px 0; }
.json {
  margin: 8px 0 0; overflow-x: auto; font: 12px/1.5 var(--mono); color: var(--ink);
  background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}

/* Toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  max-width: calc(100% - 32px);
  background: var(--ink); color: var(--bg);
  padding: 10px 14px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 4px 16px var(--shadow);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
