/* ===========================================================
   극저온의 세계 — 스타일
   차가운 느낌(파랑/하늘색/흰색), 큰 글씨, 태블릿 친화
   =========================================================== */

:root {
  --side-w: 300px;
  --bg: #f2f8fd;
  --bg-grad-1: #e8f4ff;
  --bg-grad-2: #f7fbff;
  --card: #ffffff;
  --card-2: #f4f9ff;
  --ink: #10243a;
  --ink-soft: #4a6580;
  --line: #d6e6f5;
  --brand: #0a7cc4;
  --brand-deep: #075a8f;
  --brand-soft: #e2f1fc;
  --accent: #00b3c8;
  --warn-bg: #fff1f1;
  --warn-line: #ffc9c9;
  --warn-ink: #b42318;
  --good: #0f9d58;
  --shadow: 0 2px 10px rgba(16, 60, 100, .07);
  --radius: 16px;
  --maxw: 940px;
}

html[data-theme="dark"] {
  --bg: #0d1620;
  --bg-grad-1: #101d2b;
  --bg-grad-2: #0b131c;
  --card: #16232f;
  --card-2: #1b2b3a;
  --ink: #e8f2fa;
  --ink-soft: #9db6cc;
  --line: #27394a;
  --brand: #45b6f0;
  --brand-deep: #8ed3ff;
  --brand-soft: #14303f;
  --accent: #34d3e6;
  --warn-bg: #33191a;
  --warn-line: #6b2a2a;
  --warn-ink: #ff9d95;
  --shadow: 0 2px 12px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1100px 480px at 12% -8%, var(--bg-grad-1), transparent 60%),
    radial-gradient(900px 420px at 92% 4%, var(--bg-grad-2), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.75;
  -webkit-text-size-adjust: 100%;
}

/* ---------- 상단 바 (좁은 화면 전용) ---------- */
#topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  padding: 10px clamp(12px, 3vw, 20px);
  background: color-mix(in srgb, var(--card) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.tb-left { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.tb-left strong { font-size: 18px; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-logo { font-size: 22px; }
.tb-right { display: flex; align-items: center; gap: 6px; }

.tbtn {
  display: inline-grid; place-items: center;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 10px; min-width: 38px; height: 38px; font-size: 16px;
  cursor: pointer; text-decoration: none;
  transition: transform .12s, background .12s;
}
.tbtn:hover { background: var(--brand-soft); }
.tbtn:active { transform: scale(.94); }

/* ---------- 왼쪽 사이드바 ---------- */
#sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
  width: var(--side-w);
  display: flex; flex-direction: column;
  background: var(--card); border-right: 1px solid var(--line);
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin;
}
.side-brand {
  display: flex; align-items: center; gap: 9px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--line);
}
.side-logo { font-size: 24px; }
.side-brand strong { font-size: 19px; letter-spacing: -.03em; line-height: 1.2; }

.side-progress { padding: 16px 20px 14px; border-bottom: 1px solid var(--line); }
.sp-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.sp-top span:first-child { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
#sp-percent { font-size: 20px; font-weight: 800; color: var(--brand); letter-spacing: -.02em; }
.sp-bar { height: 7px; border-radius: 999px; background: var(--brand-soft); overflow: hidden; }
.sp-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--accent)); transition: width .35s ease; }
.sp-sub { margin-top: 8px; font-size: 12.5px; color: var(--ink-soft); }

.side-actions { display: flex; gap: 8px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.sbtn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card-2); color: var(--ink);
  border-radius: 10px; padding: 9px 10px; font: inherit; font-size: 13.5px; font-weight: 700;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s;
}
.sbtn:hover { background: var(--brand-soft); color: var(--brand-deep); }

.side-foot {
  margin-top: auto; padding: 16px 20px 20px;
  border-top: 1px solid var(--line);
  font-size: 12px; color: var(--ink-soft);
}

/* ---------- 단계 목록 (사이드바 안) ---------- */
#stepnav { padding: 12px 12px 18px; }
.snav {
  width: 100%; display: grid;
  grid-template-columns: 26px 1fr auto; align-items: center;
  gap: 4px 10px;
  border: 1px solid transparent; background: none;
  color: var(--ink); border-radius: 10px;
  padding: 9px 10px; font: inherit; font-size: 14.5px; text-align: left;
  cursor: pointer; transition: background .13s, color .13s;
}
.snav + .snav { margin-top: 2px; }
.snav .snum {
  display: grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-deep);
  font-size: 12px; font-weight: 800;
}
.snav .stitle { font-weight: 600; line-height: 1.35; }
.snav .smin { font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.snav:hover { background: var(--brand-soft); }
.snav.active { background: var(--brand); color: #fff; }
.snav.active .snum { background: rgba(255, 255, 255, .25); color: #fff; }
.snav.active .smin { color: rgba(255, 255, 255, .85); }
.snav.done .snum::after { content: "✓"; }
.snav.done .snum { font-size: 13px; background: var(--good); color: #fff; }
.snav.done .snum > * { display: none; }
.snav.rest .snum { background: transparent; border: 1px dashed var(--line); color: var(--ink-soft); }
.snav.rest .stitle { color: var(--ink-soft); font-weight: 500; }
.snav.active.rest .stitle { color: #fff; }

/* ---------- 본문 ---------- */
#app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 26px clamp(16px, 3vw, 40px) 120px;
}

.step-head { margin: 6px 0 22px; }
.step-head .eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand-soft); color: var(--brand-deep);
  border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 700;
}
.step-head h1 {
  margin: 12px 0 4px; font-size: clamp(26px, 5vw, 34px);
  letter-spacing: -.03em; line-height: 1.25;
}
.step-head p.sub { margin: 0; color: var(--ink-soft); font-size: 17px; }

h2.sec {
  margin: 34px 0 12px; font-size: 21px; letter-spacing: -.02em;
  padding-left: 12px; border-left: 5px solid var(--brand); line-height: 1.4;
}

p.body { margin: 0 0 14px; }
b, strong { color: var(--brand-deep); font-weight: 700; }
html[data-theme="dark"] b, html[data-theme="dark"] strong { color: var(--brand-deep); }

/* ---------- 카드 공통 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow); margin: 0 0 16px;
}

/* 강조 숫자 상자 */
.fact {
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  color: #fff; border-radius: var(--radius);
  padding: 22px 24px; margin: 18px 0; text-align: center;
  box-shadow: 0 6px 20px rgba(10, 124, 196, .25);
}
.fact .big { font-size: clamp(34px, 8vw, 52px); font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.fact .label { font-size: 16px; font-weight: 700; opacity: .95; margin-top: 4px; }
.fact .sub { font-size: 14.5px; opacity: .92; margin-top: 10px; line-height: 1.6; }
.fact b, .fact strong { color: #fff; }

/* 목록 */
ul.bullets { margin: 0 0 14px; padding-left: 22px; }
ul.bullets li { margin-bottom: 6px; }

/* 실험 순서 */
ol.steps { list-style: none; counter-reset: s; margin: 0 0 16px; padding: 0; }
ol.steps li {
  counter-increment: s; position: relative;
  padding: 10px 12px 10px 46px; margin-bottom: 8px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 12px;
}
ol.steps li::before {
  content: counter(s);
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}

/* 왜 그럴까? 토글 */
details.why {
  background: var(--card); border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 12px; padding: 0; margin: 0 0 14px; overflow: hidden;
}
details.why summary {
  cursor: pointer; list-style: none; padding: 14px 18px;
  font-weight: 700; color: var(--brand-deep); display: flex; gap: 8px; align-items: center;
}
details.why summary::-webkit-details-marker { display: none; }
details.why summary::before { content: "💡"; }
details.why summary::after { content: "눌러서 확인"; margin-left: auto; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
details.why[open] summary::after { content: "닫기"; }
details.why .ans { padding: 0 18px 16px; color: var(--ink); }

/* 유튜브 영상 */
.video-embed { margin-top: 14px; }
.video-frame {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  background: #000; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--line);
}
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-caption { margin: 10px 0 0; font-size: 14.5px; color: var(--ink-soft); line-height: 1.6; }
.video-fallback { margin: 6px 0 0; font-size: 13px; color: var(--ink-soft); }
.video-fallback a { color: var(--brand); }

/* 비교표 */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 16px; }
.compare .col { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.compare .col h4 { margin: 0; padding: 12px 16px; background: var(--brand-soft); color: var(--brand-deep); font-size: 16px; }
.compare .col ul { margin: 0; padding: 12px 16px 14px 32px; }
.compare .col li { margin-bottom: 5px; }

/* 작은 카드 묶음 */
/* 카드는 한 줄에 최대 3개까지만 (auto-fit 을 쓰면 넓은 화면에서 5개+1개로 갈라집니다) */
.cardgrid { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 0 0 16px; }
@media (min-width: 640px) { .cardgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .cardgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.minicard {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.minicard .ic { font-size: 26px; }
.minicard h4 { margin: 6px 0 6px; font-size: 17px; letter-spacing: -.02em; }
.minicard p { margin: 0; font-size: 15.5px; line-height: 1.65; }

/* 안전 경고 */
.danger {
  background: var(--warn-bg); border: 1px solid var(--warn-line);
  border-left: 6px solid #e5484d; border-radius: 12px;
  padding: 14px 18px; margin: 0 0 18px;
}
.danger h4 { margin: 0 0 8px; color: var(--warn-ink); font-size: 16px; display: flex; align-items: center; gap: 7px; }
.danger ul { margin: 0; padding-left: 20px; }
.danger li { color: var(--warn-ink); margin-bottom: 5px; font-weight: 500; }
.danger b, .danger strong { color: var(--warn-ink); }

/* 사진 자리 (교사가 나중에 채울 자료 사진) */
.photoslot {
  border: 2px dashed var(--line); border-radius: var(--radius);
  background: var(--card-2); padding: 22px; margin: 0 0 16px; text-align: center;
}
.photoslot .tag {
  display: inline-block; background: var(--brand-soft); color: var(--brand-deep);
  border-radius: 999px; padding: 3px 12px; font-size: 12.5px; font-weight: 700; margin-bottom: 8px;
}
.photoslot .desc { color: var(--ink-soft); font-size: 14.5px; margin: 0; line-height: 1.6; }
.photoslot img { max-width: 100%; border-radius: 12px; display: block; margin: 0 auto; }
.photorow { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; align-items: start; }
.photorow .photoslot { margin-bottom: 0; }
.photoslot.filled { border: 1px solid var(--line); border-style: solid; padding: 12px; }
.photoslot.filled img { cursor: zoom-in; }
.photoslot.filled .caption { margin: 10px 0 0; font-size: 13.5px; color: var(--ink-soft); line-height: 1.55; }

/* ---------- 학생 기록 ---------- */
.record-zone { margin-top: 30px; }
.record-zone > h3 {
  font-size: 19px; margin: 0 0 14px;
  display: flex; align-items: center; gap: 8px;
}
.qbox { margin-bottom: 16px; }
.qbox label { display: block; font-weight: 700; margin-bottom: 7px; font-size: 16px; }
.qbox textarea {
  width: 100%; min-height: 84px; resize: vertical;
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font: inherit; font-size: 16px;
  background: var(--card); color: var(--ink);
}
.qbox textarea:focus { outline: 2px solid var(--brand); border-color: var(--brand); }

input[type="text"], input[type="email"], input[type="number"] {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font: inherit; font-size: 16px;
  background: var(--card); color: var(--ink); width: 100%;
}
input:focus { outline: 2px solid var(--brand); border-color: var(--brand); }

/* 사진 업로드 */
.photo-upload { margin-top: 10px; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.pbtn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--brand); background: var(--card); color: var(--brand-deep);
  border-radius: 12px; padding: 11px 18px; font: inherit; font-weight: 700; font-size: 15.5px;
  cursor: pointer; transition: all .15s;
}
.pbtn:hover { background: var(--brand-soft); }
.pbtn:active { transform: scale(.97); }
.pbtn.solid { background: var(--brand); color: #fff; }
.pbtn.solid:hover { background: var(--brand-deep); }
.pbtn[disabled] { opacity: .5; cursor: not-allowed; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.thumb { position: relative; aspect-ratio: 4/3; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--card-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.thumb .del {
  position: absolute; top: 5px; right: 5px;
  width: 26px; height: 26px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.6); color: #fff;
  cursor: pointer; font-size: 13px; line-height: 1;
}
.empty-note { color: var(--ink-soft); font-size: 14.5px; margin: 6px 0 0; }

/* ---------- 센서 실험실 ---------- */
.lab { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin: 0 0 18px; box-shadow: var(--shadow); }
.lab h4 { margin: 0 0 12px; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.lab-status {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 12px; font-size: 15px;
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: #b9c7d4; flex: 0 0 auto; }
.dot.on { background: var(--good); box-shadow: 0 0 0 4px rgba(15,157,88,.18); }
.dot.busy { background: #f0a020; }
.live-temp { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 800; font-size: 22px; color: var(--brand-deep); }
.lab-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
#chart-wrap { position: relative; width: 100%; background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
canvas.chart { width: 100%; height: 320px; display: block; }
.manual-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 15px; }
.manual-table th, .manual-table td { border: 1px solid var(--line); padding: 6px 8px; text-align: center; }
.manual-table th { background: var(--brand-soft); color: var(--brand-deep); }
.manual-table input { padding: 6px 8px; text-align: center; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-soft);
  border-radius: 10px; padding: 8px 16px; font: inherit; font-weight: 700; font-size: 15px; cursor: pointer;
}
.tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.hint { color: var(--ink-soft); font-size: 14px; margin: 8px 0 0; line-height: 1.6; }

/* ---------- 쉬는 시간 ---------- */
.breakwrap { text-align: center; padding: 40px 0 20px; }
.breakwrap .bigtimer {
  font-size: clamp(72px, 22vw, 150px); font-weight: 800;
  font-variant-numeric: tabular-nums; letter-spacing: -.05em;
  color: var(--brand-deep); line-height: 1;
  margin: 20px 0;
}
.breakwrap .bigtimer.done { color: #e5484d; }

/* ---------- 시작 화면 ---------- */
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 16px; }
.field label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 15px; }
.agree {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--brand-soft); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px; margin-top: 6px; cursor: pointer;
}
.agree input { width: 22px; height: 22px; margin-top: 2px; flex: 0 0 auto; accent-color: var(--brand); }
.agree span { font-size: 15.5px; }
.timetable { width: 100%; border-collapse: collapse; font-size: 15px; }
.timetable td { border-bottom: 1px solid var(--line); padding: 9px 6px; }
.timetable td:first-child { width: 46px; font-size: 20px; }
.timetable td:last-child { text-align: right; color: var(--ink-soft); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- 보고서 ---------- */
.report-paper {
  background: #fff; color: #10243a;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 34px clamp(20px, 5vw, 44px); box-shadow: var(--shadow);
}
html[data-theme="dark"] .report-paper { background: #fdfdfd; }
.report-paper .rp-title { text-align: center; margin-bottom: 24px; padding-bottom: 20px; border-bottom: 3px solid #0a7cc4; }
.report-paper .rp-title h1 { margin: 0 0 6px; font-size: 30px; letter-spacing: -.03em; color: #075a8f; }
.report-paper .rp-title p { margin: 0; color: #4a6580; font-size: 15px; }
.rp-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 26px; }
.rp-meta div { background: #f2f8fd; border: 1px solid #d6e6f5; border-radius: 10px; padding: 8px 12px; font-size: 14.5px; }
.rp-meta b { display: block; font-size: 12px; color: #4a6580; font-weight: 600; }
.rp-sec { margin-bottom: 26px; page-break-inside: avoid; }
.rp-sec h2 { font-size: 19px; color: #075a8f; border-left: 5px solid #0a7cc4; padding-left: 11px; margin: 0 0 12px; }
.rp-q { margin-bottom: 12px; }
.rp-q .q { font-weight: 700; font-size: 15px; margin-bottom: 3px; color: #10243a; }
.rp-q .a { font-size: 15px; white-space: pre-wrap; border-bottom: 1px dotted #b9cfe2; padding: 4px 2px 7px; min-height: 24px; color: #10243a; }
.rp-q .a.blank { color: #9db1c4; }
.rp-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.rp-photos img { width: 100%; border-radius: 8px; border: 1px solid #d6e6f5; display: block; }
.rp-datatable { border-collapse: collapse; font-size: 12.5px; margin-top: 8px; }
.rp-datatable th, .rp-datatable td { border: 1px solid #d6e6f5; padding: 3px 8px; text-align: center; }

.email-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.email-row .field { flex: 1 1 260px; }

/* ---------- 하단 바 ---------- */
#bottombar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 45;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px clamp(12px, 3vw, 24px);
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.nav-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 12px; padding: 13px 26px; font: inherit; font-weight: 700; font-size: 16px;
  cursor: pointer; transition: all .15s;
}
.nav-btn:hover { border-color: var(--brand); }
.nav-btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.nav-btn.primary:hover { background: var(--brand-deep); }
.nav-btn[disabled] { opacity: .4; cursor: not-allowed; }
.save-state { font-size: 13px; color: var(--ink-soft); }

/* ---------- 확대 보기 / 토스트 ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(6, 18, 30, .88);
  display: grid; place-items: center; padding: 24px;
}
/* hidden 속성이 display 보다 우선하도록 (없으면 오버레이가 계속 떠 있음) */
.lightbox[hidden], .toast[hidden] { display: none !important; }
.lightbox img { max-width: 96%; max-height: 92%; border-radius: 12px; }
.lightbox-close {
  position: absolute; top: 18px; right: 18px;
  width: 44px; height: 44px; border-radius: 50%;
  border: none; background: rgba(255,255,255,.15); color: #fff; font-size: 20px; cursor: pointer;
}
.toast {
  position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%);
  z-index: 120; background: #10243a; color: #fff;
  padding: 12px 22px; border-radius: 999px; font-size: 15px; font-weight: 600;
  box-shadow: 0 6px 20px rgba(0,0,0,.3); max-width: 90vw; text-align: center;
}

/* ===========================================================
   반응형 — 세 가지 화면을 따로 맞춥니다
     ① 1024px 이상  : 왼쪽 사이드바 + 오른쪽 본문 (데스크탑·16:9 모니터)
     ② 1024px 미만  : 사이드바를 서랍으로 숨기고 상단 바 사용 (태블릿·휴대폰)
     ③ 620px 이하   : 휴대폰 전용 조정
   =========================================================== */

/* ---------- ① 데스크탑: 사이드바 고정 ---------- */
@media (min-width: 1024px) {
  #topbar { display: none; }
  #scrim { display: none !important; }
  /* 사이드바를 뺀 나머지 공간의 한가운데에 본문을 놓습니다.
     (margin-left 만 주면 본문이 왼쪽으로 치우쳐 오른쪽 여백만 커집니다) */
  #app {
    margin-left: calc(var(--side-w) + max(0px, (100vw - var(--side-w) - var(--maxw)) / 2));
    margin-right: 0;
  }
  #bottombar { left: var(--side-w); }
}

/* 16:9 모니터에서 양옆이 비지 않도록 본문을 넓히고 2단으로 흘립니다.
   글을 그냥 넓게 늘이면 한 줄이 너무 길어져 오히려 읽기 어렵기 때문입니다. */
@media (min-width: 1440px) {
  :root { --maxw: 1180px; }
  /* 구역마다 왼쪽=설명, 오른쪽=「왜 그럴까?」·사진 (자리 고정 → 펼쳐도 안 튐) */
  .secgrid {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr);
    gap: 0 38px; align-items: start;
  }
  .secgrid.noside, .secgrid.nomain { grid-template-columns: 1fr; }
  /* 설명 글 없이 상자만 있는 구역은 상자들을 좌우로 나란히 */
  .secgrid.nomain .col-side {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0 38px; align-items: start;
  }
  .blocks > h2.sec { margin-top: 32px; }
  .record-zone .card {
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px 28px; align-items: start;
  }
}

@media (min-width: 1800px) {
  :root { --side-w: 330px; --maxw: 1340px; }
}

/* ---------- ② 태블릿·휴대폰: 사이드바를 서랍으로 ---------- */
@media (max-width: 1023px) {
  #sidebar {
    width: min(310px, 86vw);
    transform: translateX(-102%);
    transition: transform .26s cubic-bezier(.4, 0, .2, 1);
    box-shadow: 6px 0 24px rgba(6, 24, 40, .18);
  }
  body.nav-open #sidebar { transform: none; }
  body.nav-open { overflow: hidden; }
  #scrim {
    position: fixed; inset: 0; z-index: 55;
    background: rgba(6, 20, 34, .45);
    backdrop-filter: blur(2px);
  }
  .side-brand { padding-top: 20px; }
}

/* ---------- ③ 휴대폰 전용 ---------- */
@media (max-width: 620px) {
  body { font-size: 16px; line-height: 1.72; }
  #app { padding: 18px 15px 104px; }

  .step-head { margin-bottom: 16px; }
  .step-head h1 { margin-top: 10px; }
  h2.sec { margin: 26px 0 10px; font-size: 19px; border-left-width: 4px; padding-left: 10px; }

  .card, .lab { padding: 15px 16px; border-radius: 14px; }
  .compare { grid-template-columns: 1fr; }
  .cardgrid { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr 1fr; }

  .fact { padding: 18px 16px; }
  ol.steps li { padding: 9px 10px 9px 42px; }
  details.why summary { padding: 13px 14px; font-size: 15.5px; }
  details.why summary::after { display: none; }
  details.why .ans { padding: 0 14px 14px; }

  /* 손가락으로 누르기 편하게 */
  .pbtn { padding: 13px 16px; font-size: 15px; }
  .photo-actions .pbtn, .lab-buttons .pbtn { flex: 1 1 44%; justify-content: center; }
  .tab { flex: 1; padding: 10px 8px; font-size: 14.5px; }
  .thumbs { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .qbox textarea { min-height: 96px; }

  .nav-btn { padding: 13px 18px; font-size: 15.5px; }
  .save-state { display: none; }
  #bottombar { padding: 10px 14px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }

  .email-row { flex-direction: column; align-items: stretch; }
  .email-row .pbtn { justify-content: center; }
  .report-paper { padding: 22px 16px; }
  .rp-meta { grid-template-columns: 1fr 1fr; }
  .breakwrap { padding: 20px 0 10px; }
}

@media (max-width: 380px) {
  .field-grid { grid-template-columns: 1fr; }
  .photo-actions .pbtn, .lab-buttons .pbtn { flex: 1 1 100%; }
}

/* ---------- 인쇄(PDF 저장) ---------- */
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  #topbar, #sidebar, #stepnav, #scrim, #bottombar, .no-print, #toast, .lightbox { display: none !important; }
  html, body { background: #fff !important; font-size: 11.5pt; }
  #app { max-width: none; padding: 0; margin: 0 !important; }
  .blocks { columns: auto !important; }
  .report-paper { border: none; box-shadow: none; padding: 0; border-radius: 0; }
  .rp-sec { page-break-inside: avoid; }
  .rp-photos img { max-height: 60mm; object-fit: cover; }
  a[href]::after { content: ""; }
}
