/* 과학쌤과학랩 공용 스킨 — "과학실 노트" 느낌의 밝고 또렷한 도구 UI
 * 폰트: 본문 Noto Sans KR · 큰 제목 Black Han Sans(400만) · 숫자 Roboto Mono (모두 SIL OFL)
 * 페이지 <head>에 구글폰트 link를 함께 넣는다.
 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-primary: #0e7490;
  --c-primary-d: #155e75;
  --c-primary-l: #e0f2f7;
  --c-accent: #f59e0b;
  --c-accent-d: #b45309;
  --c-accent-l: #fff7e6;
  --c-bg: #f4f7f8;
  --c-card: #ffffff;
  --c-line: #dbe3e6;
  --c-text: #1f2d33;
  --c-muted: #5b6b73;
  --c-ok: #15803d;
  --c-ok-l: #dcfce7;
  --c-bad: #b91c1c;
  --c-bad-l: #fee2e2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 40, 50, .04), 0 2px 8px rgba(15, 40, 50, .04);
  --f-body: 'Noto Sans KR', sans-serif;
  --f-title: 'Black Han Sans', sans-serif;
  --f-mono: 'Roboto Mono', monospace;
}

html { -webkit-text-size-adjust: 100%; }
html, body { background: var(--c-bg); color: var(--c-text); }
body {
  font-family: var(--f-body); font-size: 16px; line-height: 1.6;
  word-break: keep-all; overflow-wrap: break-word;
  min-height: 100dvh; overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}
button, select, input, textarea { font: inherit; color: inherit; }
img, svg, canvas { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--c-primary); }
b, strong { font-weight: 700; }
code { font-family: var(--f-mono); font-size: .9em; background: #eef4f6; padding: 0 4px; border-radius: 4px; }

/* ---------- 상단바 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--c-primary); color: #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .12);
}
.topbar .brand { flex: none; display: flex; align-items: center; margin-right: -2px; }
.topbar .brand img {
  display: block; width: 26px; height: 26px; border-radius: 7px;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .35);
}
.topbar .title {
  font-family: var(--f-title); font-weight: 400; font-size: 20px; letter-spacing: .3px;
  color: #fff; text-decoration: none; min-width: 0; margin-right: auto;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .credit { color: var(--c-primary-l); font-size: 13px; text-decoration: none; white-space: nowrap; flex: none; }
.topbar .credit:hover { text-decoration: underline; }

/* ---------- 틀 ---------- */
.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; display: grid; gap: 16px; min-width: 0; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); min-width: 0; }
@media (min-width: 768px) { .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

.page-title { font-family: var(--f-title); font-weight: 400; font-size: clamp(28px, 5vw, 40px); line-height: 1.25; color: var(--c-primary-d); }
.page-sub { color: var(--c-muted); margin-top: 4px; }
h1, h2, h3, h4 { line-height: 1.35; }

/* ---------- 카드 ---------- */
.card {
  background: var(--c-card); border: 1px solid var(--c-line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; min-width: 0;
}
.card-title { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; margin-bottom: 12px; }
.card-title .n {
  flex: none; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--c-primary); color: #fff; font-family: var(--f-mono); font-size: 13px; font-weight: 700;
}

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; min-width: 44px; padding: 8px 16px;
  border: 1px solid #b9ccd4; border-radius: 10px; background: #fff; color: var(--c-text);
  font-weight: 500; font-size: 15px; line-height: 1.3; cursor: pointer; text-decoration: none;
  transition: background .12s, border-color .12s, transform .06s;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn:hover:not(:disabled) { border-color: var(--c-primary); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid rgba(14, 116, 144, .35); outline-offset: 2px; }
.btn.primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--c-primary-d); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--c-primary-d); }
.btn.ghost:hover:not(:disabled) { background: var(--c-primary-l); border-color: transparent; }
.btn.danger { background: #fff1f2; border-color: #fecdd3; color: var(--c-bad); }
.btn.danger:hover:not(:disabled) { border-color: var(--c-bad); }
.btn.accent { background: var(--c-accent-l); border-color: #fcd9a8; color: var(--c-accent-d); }
.btn.accent:hover:not(:disabled) { border-color: var(--c-accent); }
.btn.on { background: var(--c-primary-l); border-color: var(--c-primary); color: var(--c-primary-d); font-weight: 700; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- 뱃지 ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 500; line-height: 1.4; padding: 2px 10px; border-radius: 99px; white-space: nowrap; background: #eef2f4; color: var(--c-muted); }
.badge.ok { background: var(--c-ok-l); color: var(--c-ok); }
.badge.no { background: var(--c-bad-l); color: var(--c-bad); }
.badge.doing { background: #fef3c7; color: #92400e; }
.badge.brand { background: var(--c-primary-l); color: var(--c-primary-d); }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.doing .dot { animation: lab-blink 1s infinite; }
@keyframes lab-blink { 50% { opacity: .25; } }

/* ---------- 실험 찾기 줄(학년 탭 + 검색칸) · 단원 묶음 제목 — 대문·교사 위저드 공용 (core/exp-groups.js) ---------- */
.badge.sn { background: #e0f2fe; color: #075985; }
.find-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-width: 0; }
.find-bar.sticky {
  position: sticky; top: var(--topbar-h, 52px); z-index: 10;
  margin: 0 -16px; padding: 8px 16px; background: var(--c-bg);
  box-shadow: 0 6px 8px -8px rgba(15, 40, 50, .25);
}
.find-tabs { display: inline-flex; flex: none; max-width: 100%; padding: 3px; gap: 2px; border: 1px solid var(--c-line); border-radius: 12px; background: #fff; }
.find-tabs button {
  display: inline-flex; align-items: center; gap: 5px; min-height: 38px; padding: 4px 12px;
  border: 0; border-radius: 9px; background: transparent; color: var(--c-muted);
  font-size: 15px; font-weight: 500; cursor: pointer; white-space: nowrap; word-break: keep-all;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.find-tabs button:hover { color: var(--c-primary-d); }
.find-tabs button[aria-selected="true"] { background: var(--c-primary); color: #fff; font-weight: 700; }
.find-tabs button:focus-visible { outline: 3px solid rgba(14, 116, 144, .35); outline-offset: 1px; }
.find-tabs .n { font-family: var(--f-mono); font-size: 12px; font-weight: 500; opacity: .75; }
.find-q { flex: 1 1 220px; min-width: 0; min-height: 44px; padding: 8px 12px; border: 1px solid #b9ccd4; border-radius: 10px; background: #fff; }
.find-q:focus { outline: 3px solid rgba(14, 116, 144, .25); border-color: var(--c-primary); }
.find-empty { font-size: 15px; color: var(--c-muted); background: #fff; border: 1px dashed var(--c-line); border-radius: var(--radius); padding: 16px; text-align: center; word-break: keep-all; }
.find-empty:empty { display: none; }
.exp-grp { display: grid; gap: 10px; min-width: 0; }
.grp-title {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  font-size: 17px; font-weight: 700; color: var(--c-text); line-height: 1.35; word-break: keep-all;
}
.grp-title::before { content: ""; flex: none; align-self: stretch; width: 5px; min-height: 22px; border-radius: 3px; background: var(--u, var(--c-primary)); }
.grp-title .grp-nm { min-width: 0; }
.grp-title .grp-n { flex: none; margin-left: auto; font-size: 13px; font-weight: 500; color: var(--c-muted); background: #eef2f4; border-radius: 99px; padding: 1px 10px; }
@media (max-width: 767px) {
  .find-bar.sticky { top: var(--topbar-h, 46px); padding: 6px 16px 8px; }
  .find-tabs { flex: 1 1 100%; }
  .find-tabs button { flex: 1 1 0; justify-content: center; padding: 4px 6px; font-size: 14.5px; }
  .find-q { flex-basis: 100%; }
  .grp-title { font-size: 16px; }
}

/* ---------- 단계 표시 ---------- */
.stepper { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; }
.stepper button {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 12px 6px 6px;
  border: 1px solid var(--c-line); border-radius: 99px; background: #fff; cursor: pointer; font-size: 14.5px; color: var(--c-muted);
}
.stepper .sn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: #eef2f4; font-family: var(--f-mono); font-weight: 700; font-size: 14px; color: var(--c-muted); flex: none;
}
.stepper button.done .sn { background: var(--c-primary-l); color: var(--c-primary-d); }
.stepper button.on { border-color: var(--c-primary); color: var(--c-primary-d); font-weight: 700; background: var(--c-primary-l); }
.stepper button.on .sn { background: var(--c-primary); color: #fff; }
@media (max-width: 767px) {
  .stepper { gap: 4px; }
  .stepper button { padding: 6px; }
  .stepper button:not(.on) .sl { display: none; }
  .stepper button.on { padding-right: 12px; }
}

/* ---------- 큰 숫자 ---------- */
.num { font-family: var(--f-mono); font-weight: 500; font-size: 40px; line-height: 1.15; letter-spacing: -.5px; color: var(--c-text); font-variant-numeric: tabular-nums; }
.num .u { font-family: var(--f-body); font-size: 16px; font-weight: 400; color: var(--c-muted); margin-left: 6px; letter-spacing: 0; }

/* ---------- 표 ---------- */
.table { overflow: auto; border: 1px solid var(--c-line); border-radius: 10px; max-width: 100%; -webkit-overflow-scrolling: touch; }
.table table { border-collapse: collapse; width: 100%; font-size: 14px; }
.table th, .table td { padding: 6px 12px; border-bottom: 1px solid #edf2f4; text-align: right; white-space: nowrap; }
.table thead th { background: #f1f7f9; font-weight: 700; position: sticky; top: 0; z-index: 1; }
.table td { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.table td.mk, .table th.mk { text-align: left; font-family: var(--f-body); }
.table td.mk { color: var(--c-accent-d); font-weight: 500; }
.table tfoot th, .table tfoot td { background: #fafcfd; border-bottom: none; border-top: 1px solid var(--c-line); }
.table tfoot th { text-align: left; font-weight: 500; color: var(--c-muted); }
.table td.empty { text-align: center; color: var(--c-muted); font-family: var(--f-body); padding: 18px; white-space: normal; }

/* ---------- 안내 문구 ---------- */
.note { font-size: 14px; color: var(--c-muted); background: #f6fafb; border-left: 4px solid var(--c-primary); border-radius: 6px; padding: 10px 12px; }
.note.warn { border-left-color: var(--c-accent); background: var(--c-accent-l); color: #7c4a06; }
.hint { font-size: 13.5px; color: var(--c-muted); }

/* ---------- 입력 ---------- */
.field { display: grid; gap: 4px; min-width: 0; }
.field > span, .field > label { font-size: 14px; color: var(--c-muted); font-weight: 500; }
.field input, .field select, .field textarea, select.input, input.input, textarea.input {
  width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid #b9ccd4; border-radius: 10px; background: #fff; min-width: 0;
}
.field textarea, textarea.input { min-height: 88px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: 3px solid rgba(14, 116, 144, .25); border-color: var(--c-primary); }
input[type=number] { font-family: var(--f-mono); }

/* ---------- 알림(toast) ---------- */
.lab-toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 100;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 10px 18px; border-radius: 12px;
  background: #1f2d33; color: #fff; font-size: 15px; box-shadow: 0 6px 24px rgba(0, 0, 0, .2);
  transition: opacity .2s, transform .2s;
}
.lab-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 바닥글 링크 · 문제 신고 창 · 저장 공간 경고 ---------- */
.lab-foot { text-align: center; font-size: 13px; color: var(--c-muted); padding: 8px 16px 28px; }
.lab-foot-links { margin-top: 4px; font-size: 13px; color: var(--c-muted); text-align: center; }
.lab-foot-links a, .lab-linkbtn { color: var(--c-muted); }
.lab-linkbtn { background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; }
.lab-linkbtn:hover, .lab-foot-links a:hover { color: var(--c-primary); }
.lab-dialog { margin: auto; border: 0; border-radius: 16px; padding: 0; width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); box-shadow: 0 12px 40px rgba(0, 0, 0, .25); color: var(--c-text); background: var(--c-card); }
.lab-dialog::backdrop { background: rgba(16, 35, 42, .45); }
.lab-dlg-body { display: grid; gap: 10px; padding: 20px; }
.lab-dlg-body h2 { font-family: var(--f-title); font-weight: 400; font-size: 24px; color: var(--c-primary-d); }
.lab-rep-auto { font-size: 14px; background: #f6fafb; border: 1px solid var(--c-line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 4px; }
.lab-rep-auto ul { padding-left: 1.2em; display: grid; gap: 2px; }
.lab-rep-auto code { overflow-wrap: anywhere; }
.lab-rep-mail { align-self: center; font-size: 14px; margin-left: auto; }
.lab-dlg-body .state.no, .lab-storage-warn .state.no { color: var(--c-bad); }
.lab-dlg-body .state:empty { display: none; }
.lab-storage-warn { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 90;
  width: min(560px, calc(100vw - 32px)); display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  background: #fef3c7; color: #78350f; border: 1px solid #f59e0b; border-radius: 12px; padding: 10px 12px; font-size: 14.5px; box-shadow: 0 6px 24px rgba(0, 0, 0, .15); }
.lab-storage-warn.bad { background: var(--c-bad-l); color: #7f1d1d; border-color: #f87171; }
.lab-storage-warn > span { flex: 1 1 220px; min-width: 0; }
.lab-storage-warn .btn { min-height: 36px; padding: 4px 12px; }

@media (max-width: 767px) {
  body { font-size: 15px; }
  .topbar { padding-left: 14px; padding-right: 14px; }
  .topbar .title { font-size: 17px; }
  .topbar .brand img { width: 22px; height: 22px; border-radius: 6px; }
  .wrap { padding: 14px 16px 32px; gap: 12px; }
  .card { padding: 14px; }
  .num { font-size: 34px; }
}
