/* 색상 토큰 */
:root {
  --brand: #1f5f50; --brand-2: #2e7d6b; --brand-soft: #e6f2ee;
  --bg: #f4f6f5; --card: #fff; --text: #1c2421; --muted: #6b7672;
  --line: #dde3e0; --field: #fbfcfb;
  --warn-bg: #fff4e5; --warn: #9a5b00; --ok-bg: #e7f6ec; --ok: #1e7b3e; --danger: #b3261e;
  --test: #5b4bb7; --test-soft: #eeebfb;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #6fc3ad; --brand-2: #8fd3c1; --brand-soft: #1d332d;
    --bg: #121615; --card: #1a201e; --text: #e6ecea; --muted: #9aa6a2;
    --line: #2c3532; --field: #161b19;
    --warn-bg: #3a2b14; --warn: #f3c27a; --ok-bg: #173523; --ok: #7fd69c; --danger: #f28b82;
    --test: #b3a8f2; --test-soft: #28233f;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: Pretendard, "Malgun Gothic", system-ui, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; -webkit-font-smoothing: antialiased; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

/* 버튼 */
button, .btn { font: inherit; font-size: 14px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); cursor: pointer; transition: background .15s, border-color .15s; }
button:hover, .btn:hover { border-color: var(--brand-2); }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 1px; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { button.primary { color: #0f1a17; } }
button.ghost { background: transparent; }
button.danger { color: var(--danger); }
button.icon { border: 0; background: transparent; color: var(--muted); padding: 4px 8px; }
button.icon:hover { color: var(--danger); }
button.add { border-style: dashed; color: var(--brand); background: transparent; width: 100%; margin-top: 6px; }
.ghost-inv { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); color: #fff; }
.ghost-inv:hover { background: rgba(255,255,255,.22); border-color: #fff; }

/* 상단 바 */
.bar { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 20px; background: #1f5f50; color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 17px; }
.brand small { font-weight: 400; opacity: .8; font-size: 13px; margin-left: 4px; }

/* 레이아웃 */
.wrap { display: grid; grid-template-columns: 260px 1fr; min-height: calc(100vh - 56px); }
#list { border-right: 1px solid var(--line); padding: 14px 10px; background: var(--card); position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; }
.list-head { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 6px 8px; }
.list-head span { background: var(--brand-soft); color: var(--brand); border-radius: 10px; padding: 0 7px; margin-left: 4px; }
.case { display: grid; gap: 2px; width: 100%; text-align: left; margin-bottom: 6px; border-color: transparent; background: transparent; padding: 10px; }
.case:hover { background: var(--bg); border-color: transparent; }
.case.on { background: var(--brand-soft); border-color: var(--brand-2); }
.case b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case small { color: var(--muted); font-size: 12px; }
.pad { padding: 0 6px; }
main { padding: 0 24px 48px; max-width: 980px; width: 100%; justify-self: center; }

.badge { display: inline-block; justify-self: start; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); }
.badge.test { background: var(--test-soft); color: var(--test); }

/* 시작 화면 */
.welcome { max-width: 620px; margin: 64px auto; text-align: center; }
.welcome h2 { font-size: 26px; margin: 0 0 4px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 24px 0; }
.choice { display: grid; gap: 6px; padding: 28px 20px; border-radius: var(--radius); box-shadow: var(--shadow); text-align: left; }
.choice b { font-size: 18px; color: var(--brand); }
.choice span { color: var(--muted); font-size: 13px; }
.choice:hover { border-color: var(--brand-2); transform: translateY(-1px); }
.note { font-size: 13px; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }

/* 편집 화면 */
.toolbar { position: sticky; top: 56px; z-index: 10; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; padding: 14px 0 10px; background: var(--bg); }
.tb-title { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 220px; }
.title-input { flex: 1; font: inherit; font-size: 20px; font-weight: 700; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--text); padding: 4px 2px; }
.title-input:focus { outline: none; border-bottom-color: var(--brand-2); }
.steps { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 12px; }
.steps a { flex: none; font-size: 13px; padding: 5px 12px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); color: var(--muted); text-decoration: none; }
.steps a:hover { color: var(--brand); border-color: var(--brand-2); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px 20px; margin-bottom: 16px; scroll-margin-top: 130px; }
.card h3 { margin: 0 0 12px; font-size: 16px; color: var(--brand); }
.privacy { background: var(--brand-soft); border-color: transparent; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 16px; }
.f { display: block; min-width: 0; }
.f.wide { grid-column: 1 / -1; }
.lbl { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.lbl small { font-weight: 400; color: var(--muted); }
input, textarea, select { width: 100%; font: inherit; font-size: 15px; color: var(--text); background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
input:focus, textarea:focus, select:focus { border-color: var(--brand-2); background: var(--card); }
textarea { min-height: 72px; resize: vertical; field-sizing: content; }
::placeholder { color: var(--muted); opacity: .7; }

/* 반복 행 표 */
table.rows { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
.rows th { font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; padding: 0 4px; }
.rows td { padding: 0 3px; vertical-align: top; }
.rows td textarea { min-height: 40px; min-width: 180px; }
.rows td select { min-width: 76px; }
.scroll { overflow-x: auto; }
.rows td.del { width: 36px; }

.alert { margin-top: 10px; padding: 9px 12px; border-radius: 8px; font-size: 14px; }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }

/* 모바일 */
@media (max-width: 760px) {
  .bar { padding: 8px 12px; position: static; }
  .steps { scrollbar-width: none; }
  .brand small { display: none; }
  .wrap { grid-template-columns: 1fr; }
  #list { position: static; height: auto; display: flex; gap: 8px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; }
  .list-head { display: none; }
  .case { flex: none; width: 170px; margin: 0; border-color: var(--line); }
  main { padding: 0 12px 40px; }
  .toolbar { top: 0; position: static; }
  .card { padding: 14px; }
  .choices { grid-template-columns: 1fr; }
  .welcome { margin: 32px auto; }
  /* 표 행을 카드 형태로 */
  .rows thead { display: none; }
  .rows, .rows tbody, .rows tr, .rows td { display: block; width: 100%; }
  .rows tr { position: relative; border: 1px solid var(--line); border-radius: 10px; padding: 10px 10px 4px; margin-bottom: 8px; background: var(--field); }
  .rows td { padding: 0 0 8px; }
  .rows td::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
  .rows td.del { position: absolute; top: 4px; right: 4px; width: auto; padding: 0; }
  .rows td.del::before { content: none; }
}

/* 출력 양식: 화면에서는 숨기고 인쇄할 때만 표시 */
#report { display: none; }
@media print {
  .no-print { display: none !important; }
  body { background: #fff; color: #000; font-family: "Malgun Gothic", Pretendard, sans-serif; }
  #report { display: block; font-size: 10.5pt; line-height: 1.6; }
  #report h1 { text-align: center; font-size: 16pt; border: 3px double #000; padding: 6px; }
  #report h3 { color: #000; margin-top: 18px; }
  #report h4 { margin: 12px 0 2px; }
  #report h5 { margin: 8px 0 0; }
  #report p { margin: 2px 0 2px 10px; }
  #report table { border-collapse: collapse; width: 100%; margin: 6px 0; page-break-inside: auto; }
  #report th, #report td { border: 1px solid #000; padding: 3px 6px; text-align: left; vertical-align: top; }
  #report th { background: #eef; }
  #report .head th { width: 18%; background: #fff; font-weight: 400; }
  #report tr.cancel td { color: #c00; }
  @page { size: A4; margin: 18mm 16mm; }
}
