/* ==========================================================================
   하이퍼닥터 실손 진료 가이드 — 스타일
   진료실에서 한 손으로, 3초 안에 읽히는 것을 목표로 합니다.
   ========================================================================== */

:root {
  color-scheme: light dark;

  --bg: #f4f6f9;
  --bg-tint: #eef2f8;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --surface-3: #e6ebf2;
  --text: #101720;
  --text-mid: #414c5b;
  --text-dim: #6b7788;
  --line: #dfe5ed;
  --line-soft: #eaeef4;

  --accent: #2557d6;
  --accent-hi: #3b6ef0;
  --accent-soft: #e8effe;
  --accent-ring: rgba(37, 87, 214, 0.28);
  --on-accent: #ffffff;

  --ok: #0b7a4b;   --ok-soft: #dff4e9;
  --warn: #93590a; --warn-soft: #fdeed6;
  --info: #0f5aa8; --info-soft: #e2eefc;
  --bad: #b41f31;  --bad-soft: #fce6e9;

  --shadow-1: 0 1px 2px rgba(16, 23, 32, 0.05), 0 1px 3px rgba(16, 23, 32, 0.04);
  --shadow-2: 0 2px 6px rgba(16, 23, 32, 0.07), 0 8px 24px rgba(16, 23, 32, 0.06);
  --shadow-3: 0 10px 34px rgba(16, 23, 32, 0.12);

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --maxw: 880px;

  --ease: cubic-bezier(0.22, 0.72, 0.28, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --fast: 0.14s;
  --mid: 0.26s;
  --slow: 0.42s;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e13;
    --bg-tint: #0e131a;
    --surface: #151b24;
    --surface-2: #1c232e;
    --surface-3: #253040;
    --text: #eaeff6;
    --text-mid: #b6c1d0;
    --text-dim: #8b97a8;
    --line: #262f3c;
    --line-soft: #1e2631;

    --accent: #6f9dff;
    --accent-hi: #8db3ff;
    --accent-soft: #16233c;
    --accent-ring: rgba(111, 157, 255, 0.32);
    --on-accent: #0b1220;

    --ok: #4ecf92;   --ok-soft: #0f2a1f;
    --warn: #e6ae5c; --warn-soft: #2c2314;
    --info: #79b5f7; --info-soft: #12202f;
    --bad: #f5808c;  --bad-soft: #2e161a;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 2px 8px rgba(0, 0, 0, 0.45), 0 12px 28px rgba(0, 0, 0, 0.35);
    --shadow-3: 0 14px 40px rgba(0, 0, 0, 0.55);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6f9;
  --bg-tint: #eef2f8;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --surface-3: #e6ebf2;
  --text: #101720;
  --text-mid: #414c5b;
  --text-dim: #6b7788;
  --line: #dfe5ed;
  --line-soft: #eaeef4;
  --accent: #2557d6;
  --accent-hi: #3b6ef0;
  --accent-soft: #e8effe;
  --accent-ring: rgba(37, 87, 214, 0.28);
  --on-accent: #ffffff;
  --ok: #0b7a4b;   --ok-soft: #dff4e9;
  --warn: #93590a; --warn-soft: #fdeed6;
  --info: #0f5aa8; --info-soft: #e2eefc;
  --bad: #b41f31;  --bad-soft: #fce6e9;
  --shadow-1: 0 1px 2px rgba(16, 23, 32, 0.05), 0 1px 3px rgba(16, 23, 32, 0.04);
  --shadow-2: 0 2px 6px rgba(16, 23, 32, 0.07), 0 8px 24px rgba(16, 23, 32, 0.06);
  --shadow-3: 0 10px 34px rgba(16, 23, 32, 0.12);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0e13;
  --bg-tint: #0e131a;
  --surface: #151b24;
  --surface-2: #1c232e;
  --surface-3: #253040;
  --text: #eaeff6;
  --text-mid: #b6c1d0;
  --text-dim: #8b97a8;
  --line: #262f3c;
  --line-soft: #1e2631;
  --accent: #6f9dff;
  --accent-hi: #8db3ff;
  --accent-soft: #16233c;
  --accent-ring: rgba(111, 157, 255, 0.32);
    --on-accent: #0b1220;
  --ok: #4ecf92;   --ok-soft: #0f2a1f;
  --warn: #e6ae5c; --warn-soft: #2c2314;
  --info: #79b5f7; --info-soft: #12202f;
  --bad: #f5808c;  --bad-soft: #2e161a;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 2px 8px rgba(0, 0, 0, 0.45), 0 12px 28px rgba(0, 0, 0, 0.35);
  --shadow-3: 0 14px 40px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(1100px 480px at 50% -220px, var(--bg-tint), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.62;
  letter-spacing: -0.005em;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ============================================================ 헤더 / 네비 */

.hdr {
  position: sticky;
  top: 0;
  z-index: 30;
  padding-top: env(safe-area-inset-top);
  background: var(--surface); /* color-mix 미지원 브라우저용 */
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-bottom: 1px solid var(--line-soft);
  transition: box-shadow var(--mid) var(--ease), border-color var(--mid) var(--ease);
}

.hdr.scrolled {
  box-shadow: var(--shadow-2);
  border-bottom-color: var(--line);
}

@supports not (backdrop-filter: blur(4px)) {
  .hdr { background: var(--surface); }
}

.hdr-top {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 11px 16px 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  transition: opacity var(--fast) var(--ease);
}
.brand:hover { opacity: 0.75; }

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(140deg, var(--accent-hi), var(--accent));
  box-shadow: 0 2px 9px var(--accent-ring);
  flex: 0 0 auto;
  position: relative;
}
/* 마크 안의 십자 */
.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  background: var(--on-accent);
  border-radius: 1.5px;
}
.brand-mark::before { left: 11.5px; top: 6px; width: 3px; height: 14px; }
.brand-mark::after { left: 6px; top: 11.5px; width: 14px; height: 3px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-sup {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.09em;
}
.brand-main {
  font-size: 15.5px;
  font-weight: 750;
  letter-spacing: -0.035em;
  white-space: nowrap;
}

.hdr-actions { display: flex; gap: 6px; flex: 0 0 auto; }

.icon-btn {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
  border-radius: 9px;
  width: 32px;
  height: 32px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform var(--fast) var(--ease), background var(--fast) var(--ease),
    color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--accent); }
.icon-btn:active { transform: scale(0.9); }

/* ---- 세대 칩 ---- */

.genbar {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px 9px;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.genbar-label {
  font-size: 10.5px;
  color: var(--text-dim);
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.04em;
  flex: 0 0 auto;
}

/* 헤더가 두 줄로 늘어나면 본문이 밀립니다. 항상 한 줄로 둡니다. */
.genchips {
  display: flex;
  gap: 5px;
  flex-wrap: nowrap;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 3px 0;
}
.genchips::-webkit-scrollbar { display: none; }
.genchips .genchip { flex: 0 0 auto; }

.genchip {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 650;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: -0.01em;
  transition: transform var(--fast) var(--ease), background var(--mid) var(--ease),
    color var(--mid) var(--ease), border-color var(--mid) var(--ease),
    box-shadow var(--mid) var(--ease);
}
.genchip:hover { border-color: var(--accent); color: var(--text); }
.genchip:active { transform: scale(0.93); }

.genchip[aria-pressed="true"] {
  background: linear-gradient(140deg, var(--accent-hi), var(--accent));
  border-color: transparent;
  color: var(--on-accent);
  box-shadow: 0 2px 10px var(--accent-ring);
  animation: chipPop var(--mid) var(--ease-out);
}

@keyframes chipPop {
  0%   { transform: scale(0.86); }
  60%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* ---- 탭 ---- */

.tabs {
  position: relative;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 10px;
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tabs a {
  position: relative;
  padding: 9px 13px 11px;
  font-size: 14px;
  font-weight: 650;
  color: var(--text-dim);
  white-space: nowrap;
  letter-spacing: -0.015em;
  border-radius: 8px 8px 0 0;
  transition: color var(--mid) var(--ease), background var(--fast) var(--ease);
}
.tabs a:hover { color: var(--text-mid); background: var(--surface-2); }
.tabs a.on { color: var(--accent); }

/* 활성 탭 아래 미끄러지는 인디케이터 */
.tab-ink {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2.5px;
  width: 0;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(90deg, var(--accent-hi), var(--accent));
  transition: transform var(--mid) var(--ease-out), width var(--mid) var(--ease-out);
  will-change: transform, width;
  pointer-events: none;
}

/* ================================================================= 레이아웃 */

.view {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px 16px 44px;
}

/* 라우트 전환 시에만 붙습니다 (검색 입력 중 재렌더에는 붙지 않음) */
.view.anim > * {
  animation: riseIn var(--slow) var(--ease-out) backwards;
  animation-delay: calc(var(--i, 0) * 34ms);
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 15px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-1);
  transition: box-shadow var(--mid) var(--ease), border-color var(--mid) var(--ease),
    transform var(--mid) var(--ease);
}

h1 {
  font-size: 21px;
  margin: 0 0 5px;
  letter-spacing: -0.035em;
  font-weight: 750;
}
h2 { font-size: 15.5px; margin: 20px 0 9px; letter-spacing: -0.025em; font-weight: 700; }
h3 {
  font-size: 11.5px;
  margin: 0 0 10px;
  color: var(--text-dim);
  font-weight: 750;
  letter-spacing: 0.05em;
}
p { margin: 0 0 10px; }
ul { margin: 0 0 10px; padding-left: 18px; }
li { margin-bottom: 5px; }

.lead { color: var(--text-dim); font-size: 13.5px; margin-bottom: 15px; }

/* ==================================================================== 폼 */

input[type="text"], input[type="search"], input[type="number"],
input[type="date"], select, textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease),
    background var(--fast) var(--ease);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-ring);
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
  cursor: pointer;
}

textarea { line-height: 1.7; resize: vertical; font-size: 14px; }

label.fld { display: block; margin-bottom: 11px; }
label.fld > span {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 5px;
  letter-spacing: 0.01em;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
@media (max-width: 540px) { .grid2 { grid-template-columns: 1fr; } }

/* ---- 버튼 ---- */

.btn {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(140deg, var(--accent-hi), var(--accent));
  color: var(--on-accent);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.015em;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 3px 12px var(--accent-ring);
  transition: transform var(--fast) var(--ease), box-shadow var(--mid) var(--ease),
    filter var(--fast) var(--ease);
}
.btn:hover { transform: translateY(-1.5px); box-shadow: 0 3px 6px rgba(0,0,0,0.14), 0 10px 22px var(--accent-ring); }
.btn:active { transform: translateY(0) scale(0.975); box-shadow: 0 1px 2px rgba(0,0,0,0.12); }

.btn.ghost {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--line);
  box-shadow: var(--shadow-1);
}
.btn.ghost:hover { background: var(--surface-3); border-color: var(--accent); box-shadow: var(--shadow-2); }

.btn.done { animation: btnDone 0.5s var(--ease-out); }
@keyframes btnDone {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.btn-row { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 12px; }

/* 클릭 지점에서 퍼지는 물결 (JS가 --rx/--ry를 넣어줍니다) */
.ripple {
  position: absolute;
  left: var(--rx, 50%);
  top: var(--ry, 50%);
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.32;
  transform: scale(0);
  pointer-events: none;
  z-index: -1;
  animation: ripple 0.62s var(--ease-out) forwards;
}
@keyframes ripple {
  to { transform: scale(18); opacity: 0; }
}

/* ================================================================== 검색 */

.searchwrap { position: relative; margin-bottom: 12px; }

.searchwrap input {
  font-size: 16px;
  padding: 14px 15px 14px 42px;
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  font-weight: 500;
}

.searchwrap::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -8px;
  border: 2px solid var(--text-dim);
  border-radius: 50%;
  pointer-events: none;
  transition: border-color var(--fast) var(--ease);
}
.searchwrap::after {
  content: "";
  position: absolute;
  left: 28px;
  top: 50%;
  width: 6px;
  height: 2px;
  margin-top: 3px;
  background: var(--text-dim);
  transform: rotate(45deg);
  border-radius: 2px;
  pointer-events: none;
  transition: background var(--fast) var(--ease);
}
.searchwrap:focus-within::before { border-color: var(--accent); }
.searchwrap:focus-within::after { background: var(--accent); }

.deptchips {
  display: flex;
  gap: 6px;
  margin: 0 -16px 15px;
  padding: 3px 16px 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 22px), transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 22px), transparent 100%);
}
.deptchips::-webkit-scrollbar { display: none; }

.deptchip {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  flex: 0 0 auto;
  scroll-snap-align: start;
  transition: transform var(--fast) var(--ease), background var(--fast) var(--ease),
    color var(--fast) var(--ease), border-color var(--fast) var(--ease),
    box-shadow var(--fast) var(--ease);
}
.deptchip:hover { color: var(--text); border-color: var(--accent); }
.deptchip:active { transform: scale(0.93); }
.deptchip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
  box-shadow: 0 1px 6px var(--accent-ring);
}

/* ---- 결과 목록 ---- */

.reslist { display: flex; flex-direction: column; gap: 8px; }

.res {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 11px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 12px 14px;
  color: var(--text);
  box-shadow: var(--shadow-1);
  transition: transform var(--fast) var(--ease), box-shadow var(--mid) var(--ease),
    border-color var(--mid) var(--ease);
}
.res::after {
  content: "";
  position: absolute;
  left: 0; top: 12%;
  width: 3px;
  height: 76%;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  opacity: 0;
  transform: scaleY(0.3);
  transition: opacity var(--mid) var(--ease), transform var(--mid) var(--ease-out);
}
.res:hover {
  border-color: var(--line);
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
}
.res:hover::after { opacity: 1; transform: scaleY(1); }
.res:active { transform: translateY(0) scale(0.993); }

.res > span:first-child { min-width: 0; }
.res-name { display: block; font-weight: 650; font-size: 14.5px; letter-spacing: -0.02em; }
.res-sub { display: block; font-size: 11.5px; color: var(--text-dim); margin-top: 2px; line-height: 1.5; }

/* ================================================================ 배지 */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 750;
  padding: 3.5px 10px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
  letter-spacing: -0.01em;
}
.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}
.badge.covered     { background: var(--ok-soft);   color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 34%, transparent); }
.badge.rider       { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 34%, transparent); }
.badge.conditional { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 34%, transparent); }
.badge.excluded    { background: var(--bad-soft);  color: var(--bad);  border-color: color-mix(in srgb, var(--bad) 34%, transparent); }
.badge.none        { background: var(--surface-2); color: var(--text-dim); border-color: var(--line); }
.badge.none::before { opacity: 0.5; }

.tag {
  display: inline-block;
  font-size: 11px;
  padding: 2.5px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-dim);
  margin: 0 5px 5px 0;
  border: 1px solid var(--line-soft);
  font-weight: 550;
}

/* ================================================================== 표 */

.tablewrap {
  position: relative;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -16px;
  padding: 0 16px;
  scrollbar-width: thin;
}
.tablewrap::-webkit-scrollbar { height: 6px; }
.tablewrap::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }

table { border-collapse: collapse; width: 100%; font-size: 13px; min-width: 520px; }

th, td {
  text-align: left;
  padding: 9px 11px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
thead th {
  font-size: 10.5px;
  color: var(--text-dim);
  font-weight: 750;
  white-space: nowrap;
  letter-spacing: 0.04em;
  border-bottom-color: var(--line);
}
tbody th { font-weight: 700; white-space: nowrap; }
tbody tr { transition: background var(--fast) var(--ease); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }

td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

tr.hi td, tr.hi th {
  background: var(--accent-soft);
  border-bottom-color: color-mix(in srgb, var(--accent) 22%, transparent);
}
tr.hi th { box-shadow: inset 3px 0 0 var(--accent); }

/* ============================================================== 노트 / KV */

.note {
  position: relative;
  border-left: 3px solid var(--line);
  padding: 9px 0 9px 13px;
  margin-bottom: 10px;
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.6;
}
.note:last-child { margin-bottom: 0; }
.note.alert { border-left-color: var(--bad); color: var(--text-mid); }
.note.tip { border-left-color: var(--info); }

.kv {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
}
.kv:last-child { border-bottom: 0; padding-bottom: 0; }
.kv > b {
  flex: 0 0 96px;
  font-weight: 700;
  color: var(--text-dim);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  padding-top: 2px;
}

.dim { color: var(--text-dim); font-size: 12px; }

/* ---- 선택 세대 요약 카드 ---- */

.summary {
  border-color: color-mix(in srgb, var(--accent) 38%, transparent);
  background:
    linear-gradient(160deg, var(--accent-soft), transparent 62%),
    var(--surface);
  box-shadow: var(--shadow-2);
}

.summary-top { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.summary-gen { font-size: 12px; font-weight: 750; color: var(--text-dim); letter-spacing: 0.01em; }

/* ============================================================ 서류 체크리스트 */

.doc {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}
.doc:last-child { border-bottom: 0; padding-bottom: 2px; }

.doc-box {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  border: 1.5px solid var(--text-dim);
  border-radius: 5px;
  margin-top: 3px;
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.doc:hover .doc-box { border-color: var(--accent); }

.doc-name { font-weight: 650; font-size: 14px; letter-spacing: -0.02em; }
.doc-meta { display: block; font-size: 12px; color: var(--text-dim); margin-top: 2px; line-height: 1.5; }

.s24 {
  display: inline-block;
  font-size: 10px;
  font-weight: 750;
  padding: 1.5px 7px;
  border-radius: 5px;
  margin-left: 7px;
  vertical-align: 1.5px;
  background: var(--ok-soft);
  color: var(--ok);
  letter-spacing: 0.01em;
}
.s24.no { background: var(--warn-soft); color: var(--warn); }

/* ================================================================ 푸터 */

.ftr {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px 44px;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--text-dim);
}
.ftr-meta { opacity: 0.75; }

.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 12px;
  font-size: 14px;
  animation: riseIn var(--mid) var(--ease-out);
}

/* ================================================================ 광고 슬롯

   높이를 미리 확보해 광고가 뜰 때 본문이 밀리지 않게 합니다.
   환자용 화면과 인쇄물에는 나오지 않습니다.                              */

.adslot {
  min-height: 106px;
  margin: 18px 0 4px;
  display: block;
}

.adslot.placeholder {
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 11.5px;
  letter-spacing: 0.02em;
}

body.patient-mode .adslot { display: none; }

/* ================================================================ 홈 화면 */

.hero { margin-bottom: 20px; }

.art-hero {
  display: block;
  width: 100%;
  height: auto;
  max-width: 420px;
  margin: 0 auto 18px;
}

.hero h1 {
  font-size: 23px;
  line-height: 1.42;
  letter-spacing: -0.04em;
  margin-bottom: 9px;
}
.hero .lead { margin-bottom: 14px; }

/* ---- 일러스트 공통 색 ---- */

.art-bg { fill: var(--surface-2); }
.art-blob { fill: var(--accent-soft); opacity: 0.7; }
.art-card { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; }
.art-ink { fill: var(--line); }
.art-ink-strong { fill: var(--text-dim); }
.art-dash { stroke: var(--line); stroke-width: 1.5; stroke-dasharray: 4 4; }
.art-stroke { stroke: var(--text-dim); stroke-width: 2; fill: none; stroke-linecap: round; }
.art-check { stroke: var(--ok); stroke-width: 2.2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.art-pulse { stroke: var(--accent); stroke-width: 2.4; fill: none; opacity: 0.55; stroke-linecap: round; stroke-linejoin: round; }
.art-track { stroke: var(--line); stroke-width: 2.5; stroke-linecap: round; }
.art-dot { fill: var(--surface); stroke: var(--line); stroke-width: 2.5; }
.art-dot-on { fill: var(--accent); }
.art-lbl { fill: var(--text-dim); font-size: 12px; font-weight: 700; text-anchor: middle; font-family: inherit; }
.art-lbl.on { fill: var(--accent); font-size: 13px; }
.art-pill { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
.art-bar { fill: var(--surface-3); }
.art-bar-on { fill: var(--accent); }
.art-badge-ok { fill: var(--ok-soft); stroke: var(--ok); stroke-width: 1.2; }
.art-badge-bad { fill: var(--bad-soft); stroke: var(--bad); stroke-width: 1.2; }
.art-fill-accent { fill: var(--accent); }
.art-on-accent { fill: var(--on-accent); }
.art-on-accent-soft { fill: var(--on-accent); opacity: 0.5; }
.stop-a { stop-color: var(--accent-hi); }
.stop-b { stop-color: var(--accent); }

/* ---- 현재 상태 카드 ---- */

.statecard p { color: var(--text-mid); font-size: 13.5px; }
.statecard-top { margin-bottom: 9px; }
.statecard.empty-state { border-style: dashed; border-color: var(--line); background: var(--surface-2); }
.statecard h3 { font-size: 14px; color: var(--text); letter-spacing: -0.02em; text-transform: none; }

.ways { margin: 0; padding-left: 20px; font-size: 13.5px; color: var(--text-mid); }
.ways li { margin-bottom: 6px; }

/* ---- 메뉴 격자 ---- */

.menugrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
@media (max-width: 460px) { .menugrid { grid-template-columns: 1fr; } }

.menu {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: block;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 14px 15px 15px;
  color: var(--text);
  box-shadow: var(--shadow-1);
  transition: transform var(--fast) var(--ease), box-shadow var(--mid) var(--ease),
    border-color var(--mid) var(--ease);
}
.menu:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--accent); }
.menu:active { transform: translateY(0) scale(0.99); }

.menu-ic {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 10px;
  transition: background var(--mid) var(--ease);
}
.menu:hover .menu-ic { background: var(--accent); color: var(--on-accent); }
.menu-ic .ic { width: 19px; height: 19px; }

.menu-t { display: block; font-weight: 700; font-size: 14.5px; letter-spacing: -0.025em; margin-bottom: 3px; }
.menu-d { display: block; font-size: 12px; color: var(--text-dim); line-height: 1.55; }

/* ============================================================ 사용법 안내 */

body.modal-open { overflow: hidden; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal[hidden] { display: none; }

.modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 18, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fadeIn var(--mid) var(--ease-out);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  padding: 18px 18px 16px;
  animation: modalIn var(--slow) var(--ease-out);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.modal-x {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 0;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.modal-x:hover { background: var(--surface-3); color: var(--text); }

.art-tour { display: block; width: 100%; height: auto; border-radius: 12px; }
.tour-art { margin-bottom: 16px; }

.tour-step {
  font-size: 11px;
  font-weight: 750;
  color: var(--accent);
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.modal-box h2 { font-size: 18px; margin: 0 0 10px; letter-spacing: -0.03em; }
.tour-body p { font-size: 14px; color: var(--text-mid); line-height: 1.66; }
.tour-body ul { font-size: 14px; color: var(--text-mid); }
.tour-body strong { color: var(--text); }

.tour-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.tour-nav { display: flex; gap: 8px; }
.tour-nav .btn { padding: 9px 15px; }
.tour-nav .btn:disabled { opacity: 0.4; cursor: default; transform: none; box-shadow: none; }

.dots { display: flex; gap: 6px; }
.dot {
  width: 7px;
  height: 7px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-3);
  cursor: pointer;
  transition: width var(--mid) var(--ease), background var(--mid) var(--ease);
}
.dot.on { width: 20px; border-radius: 4px; background: var(--accent); }

/* ========================================================= 환자용 모드 화면

   대기실에서 처음 열어보는 사람이 대상입니다.
   글자와 터치 영역을 키우고 의료진용 UI는 감춥니다.                       */

body.patient-mode .genbar,
body.patient-mode .tabs { display: none; }

body.patient-mode .view { font-size: 16px; }
body.patient-mode h1 { font-size: 24px; margin-bottom: 8px; }
body.patient-mode h2 { font-size: 17px; }
body.patient-mode .lead { font-size: 15px; }

.privacy {
  background: var(--ok-soft);
  border-color: color-mix(in srgb, var(--ok) 30%, transparent);
  color: var(--text-mid);
  font-size: 13.5px;
}
.privacy strong { color: var(--ok); }

.bigchoice { display: flex; flex-direction: column; gap: 9px; margin-bottom: 18px; }

.choice {
  position: relative;
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 15px 46px 15px 17px;
  color: var(--text);
  box-shadow: var(--shadow-1);
  transition: transform var(--fast) var(--ease), box-shadow var(--mid) var(--ease),
    border-color var(--mid) var(--ease);
}
.choice::after {
  content: "";
  position: absolute;
  right: 20px;
  top: 50%;
  width: 9px;
  height: 9px;
  margin-top: -5px;
  border-right: 2.5px solid var(--text-dim);
  border-bottom: 2.5px solid var(--text-dim);
  transform: rotate(-45deg);
  transition: transform var(--mid) var(--ease), border-color var(--fast) var(--ease);
}
.choice:hover { border-color: var(--accent); box-shadow: var(--shadow-2); transform: translateY(-2px); }
.choice:hover::after { border-color: var(--accent); transform: rotate(-45deg) translate(2px, 2px); }
.choice:active { transform: translateY(0) scale(0.99); }
.choice.muted { background: var(--surface-2); box-shadow: none; }

.choice-main { display: block; font-weight: 700; font-size: 16px; letter-spacing: -0.025em; }
.choice-sub { display: block; font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }

/* ---- 의료진에게 보여주는 결과 카드 ---- */

.showcard {
  border-radius: var(--r-lg);
  padding: 26px 20px 22px;
  margin-bottom: 14px;
  text-align: center;
  color: var(--on-accent);
  background: linear-gradient(150deg, var(--accent-hi), var(--accent));
  box-shadow: 0 10px 30px var(--accent-ring);
  animation: showPop var(--slow) var(--ease-out);
}

@keyframes showPop {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: none; }
}

.showcard-eyebrow {
  font-size: 12px;
  font-weight: 700;
  opacity: 0.86;
  letter-spacing: 0.02em;
  margin-bottom: 10px;
}
.showcard-gen {
  font-size: 46px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.05em;
}
.showcard-alias { font-size: 14px; opacity: 0.9; margin-top: 4px; }
.showcard-period { font-size: 12.5px; opacity: 0.8; margin-top: 9px; }

/* ============================================================ 대기실 안내문 */

.poster {
  text-align: center;
  padding: 26px 20px 22px;
}

.poster-clinic {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  margin-bottom: 14px;
}
.poster-title {
  font-size: 27px;
  font-weight: 800;
  line-height: 1.28;
  letter-spacing: -0.04em;
  margin-bottom: 12px;
}
.poster-lead { font-size: 14.5px; color: var(--text-mid); line-height: 1.62; margin-bottom: 20px; }

.poster-qr {
  width: 208px;
  margin: 0 auto 14px;
  padding: 10px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.poster-qr svg { display: block; width: 100%; height: auto; }

.poster-url {
  font-size: 12px;
  color: var(--text-dim);
  word-break: break-all;
  margin-bottom: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.poster-foot {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.6;
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
}

/* ====================================================== 접근성 / 모션 감소 */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .btn:hover, .res:hover { transform: none; }
}

/* ================================================================ 인쇄 */

@media print {
  @page { size: A5; margin: 12mm; }
  .hdr, .tabs, .ftr, .btn-row, .no-print { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .view { padding: 0; max-width: none; }
  .view.anim > * { animation: none; }
  .card {
    border: 0;
    padding: 0;
    margin-bottom: 10px;
    background: #fff;
    box-shadow: none;
  }
  .tablewrap { overflow: visible; margin: 0; padding: 0; }
  table { min-width: 0; }
  .print-only { display: block !important; }
  .doc-box { border-color: #000; }
  .doc { break-inside: avoid; }
  a { color: #000; }

  /* 대기실 안내문은 종이 한 장을 꽉 채웁니다 */
  .poster { text-align: center; padding: 0; }
  .poster-title { font-size: 26pt; margin-bottom: 8mm; }
  .poster-lead { font-size: 12pt; margin-bottom: 10mm; color: #000; }
  .poster-qr { width: 62mm; border: 0; padding: 0; margin: 0 auto 6mm; }
  .poster-url { font-size: 9pt; color: #444; }
  .poster-foot { font-size: 8pt; color: #444; border-top: 1px solid #bbb; }
  .poster-clinic { color: #000; font-size: 11pt; }
}

.print-only { display: none; }
