:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --card: #ffffff;
  --ink: #1c1f26;
  --sub: #5d6470;
  --mute: #8a909b;
  --line: #e2e5ea;
  --line2: #cfd4dc;
  --accent: #e0502a;
  --accent-dark: #c2401d;
  --accent-soft: #fdefe9;
  --navy: #1b2a6b;
  --ok: #1d8a4b;
  --ok-soft: #e7f6ed;
  --warn: #a8640a;
  --warn-soft: #fff4e2;
  --err: #cc3322;
  --err-soft: #fdecea;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--font); word-break: keep-all; overflow-wrap: anywhere; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-dark); }
h1, h2, h3 { margin: 0; line-height: 1.3; }
.hidden { display: none !important; }
.muted { color: var(--sub); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.spacer { height: 12px; }

/* 버튼 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border-radius: 11px; border: 1px solid var(--line2); background: #fff; cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink);
  -webkit-tap-highlight-color: transparent; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--sub); }
.btn.danger { color: var(--err); border-color: #f1c2bc; }
.btn.small { min-height: 34px; padding: 0 11px; font-size: 14px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }

/* 입력 */
.field { margin: 0 0 18px; }
.field > label, .field .label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 15px; }
.field .req { color: var(--accent); margin-left: 3px; }
.field .help { color: var(--sub); font-size: 13px; margin-top: 5px; }
.field.has-err input, .field.has-err select, .field.has-err textarea { border-color: var(--err); background: #fffafa; }
.field .err { color: var(--err); font-size: 13.5px; margin-top: 5px; font-weight: 600; }
input[type=text], input[type=tel], input[type=email], input[type=date], input[type=number], input[type=password], input[type=search], select, textarea {
  width: 100%; min-height: 48px; padding: 11px 13px; border: 1px solid var(--line2); border-radius: 11px; background: #fff; font-size: 16px; outline: none; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(224, 80, 42, .16); }
input[type=date] { -webkit-appearance: none; appearance: none; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { position: relative; display: inline-flex; align-items: center; min-height: 44px; padding: 9px 14px; border: 1px solid var(--line2);
  border-radius: 11px; background: #fff; cursor: pointer; font-size: 15px; line-height: 1.35; -webkit-tap-highlight-color: transparent; user-select: none; }
.opt.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); font-weight: 700; }
.opt.on::before { content: "✓"; margin-right: 6px; font-weight: 800; }
.opts.stack { flex-direction: column; }
.opts.stack .opt { width: 100%; }
.toggle { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 14px; border: 1px solid var(--line2); border-radius: 11px; background: #fff; cursor: pointer; }
.toggle .sw { width: 44px; height: 26px; border-radius: 13px; background: #cdd2da; position: relative; flex: none; transition: background .15s; }
.toggle .sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle.on .sw { background: var(--accent); }
.toggle.on .sw::after { left: 21px; }
.check { display: flex; gap: 11px; align-items: flex-start; padding: 13px 14px; border: 1px solid var(--line2); border-radius: 11px; background: #fff; cursor: pointer; }
.check .box { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line2); flex: none; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px; margin-top: 1px; }
.check.on { border-color: var(--accent); background: var(--accent-soft); }
.check.on .box { background: var(--accent); border-color: var(--accent); }
.check.on .box::after { content: "✓"; }
.linkbtn { background: none; border: 0; padding: 4px 0; color: var(--accent-dark); font-weight: 600; cursor: pointer; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }

/* 카드 · 배지 */
.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); padding: 18px; }
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 99px; font-size: 12.5px; font-weight: 700; background: #eef0f3; color: var(--sub); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.accent { background: var(--accent-soft); color: var(--accent-dark); }
.badge.navy { background: #e8ebf7; color: var(--navy); }
.notice { padding: 12px 14px; border-radius: 11px; background: var(--warn-soft); color: #6b4300; font-size: 14px; }
.notice.ok { background: var(--ok-soft); color: #0f5a30; }
.notice.err { background: var(--err-soft); color: #8c1d12; }
.notice.info { background: #eef2fb; color: #233a7a; }

/* 패드 */
.pad { position: relative; width: 100%; border: 2px dashed var(--line2); border-radius: 14px; background: #fff; touch-action: none; overflow: hidden; }
.pad canvas { display: block; touch-action: none; }
.pad.inked { border-style: solid; border-color: #b8c0d4; }
.pad-hint { position: absolute; left: 10px; top: 7px; font-size: 12px; color: var(--mute); pointer-events: none; }
.pad-saved { position: absolute; inset: 0; background: #fff; display: grid; place-items: center; padding: 10px; }
.pad-saved img { max-width: 92%; max-height: 80%; }
.pad-saved .tag { position: absolute; left: 10px; top: 8px; }

/* 토스트 */
#toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: rgba(28,31,38,.94); color: #fff; padding: 11px 17px; border-radius: 11px;
  font-size: 14.5px; z-index: 100; max-width: calc(100% - 32px); text-align: center; opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.show { opacity: 1; }
.spin { width: 18px; height: 18px; border: 2.5px solid rgba(0,0,0,.15); border-top-color: var(--accent); border-radius: 50%; animation: sp .7s linear infinite; display: inline-block; }
.btn.primary .spin { border-color: rgba(255,255,255,.35); border-top-color: #fff; }
@keyframes sp { to { transform: rotate(360deg); } }

/* 대화상자 */
.modal-bg { position: fixed; inset: 0; background: rgba(15,18,25,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: 100%; max-width: 620px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .modal-bg { align-items: center; } .modal { border-radius: 18px; } }
.modal h3 { margin-bottom: 14px; font-size: 19px; }
