:root {
  --ink: #15243a;
  --muted: #617083;
  --paper: #f6f4ee;
  --card: #fffdf9;
  --line: #d8dee5;
  --navy: #163a5f;
  --navy-2: #0f2b48;
  --teal: #2b746e;
  --teal-soft: #dceeea;
  --amber: #b16a1d;
  --amber-soft: #fff1d8;
  --red: #a33c38;
  --red-soft: #fce6e3;
  --shadow: 0 14px 34px rgba(21, 36, 58, 0.08);
  color-scheme: light;
  font-family: "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }
/* hidden 속성은 어떤 display 규칙보다 우선한다. 클래스가 display 를 지정한 요소(.loading-card,
   .item-row 등)에서 [hidden] 이 무시되던 문제를 막는다. */
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  min-height: 78px;
  padding: 14px clamp(18px, 3vw, 42px);
  background: var(--navy-2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 6px 18px rgba(15, 43, 72, 0.2);
}

.brand-block, .topbar-actions, .card-heading, .card-heading > div, .workspace-heading,
.rating-heading, .rail-heading, .dialog-actions { display: flex; align-items: center; }
.brand-block { gap: 13px; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.45); border-radius: 14px; font-weight: 800; font-size: 13px; letter-spacing: .08em; }
.topbar h1 { margin: 2px 0 0; font-size: clamp(19px, 2vw, 25px); line-height: 1.15; }
.eyebrow, .section-kicker { margin: 0; font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.eyebrow { color: #a9ced1; }
.topbar-actions { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.account-label { color: #d6e7ee; font-size: 13px; margin-right: 6px; }

.demo-banner { padding: 9px 18px; background: var(--amber-soft); color: #6c4619; text-align: center; font-weight: 700; border-bottom: 1px solid #e8c68b; }
.button { border: 1px solid transparent; border-radius: 10px; min-height: 40px; padding: 9px 15px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 750; text-decoration: none; cursor: pointer; transition: .16s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button.primary { background: var(--teal); color: white; box-shadow: 0 6px 16px rgba(43,116,110,.18); }
.button.secondary { background: white; color: var(--navy); border-color: var(--line); }
.topbar .button.secondary { background: rgba(255,255,255,.08); color: white; border-color: rgba(255,255,255,.28); }
.button.ghost { background: transparent; color: inherit; border-color: rgba(97,112,131,.35); }
.topbar .button.ghost { border-color: transparent; color: #d8e6ed; }
.button.finalize { background: #9b3a36; color: white; }
.button.compact { min-height: 34px; padding: 6px 11px; }
.button.wide { width: 100%; }
.text-button { border: 0; background: transparent; color: var(--teal); font-weight: 700; cursor: pointer; padding: 10px 0; }

.center-shell { min-height: calc(100vh - 78px); display: grid; place-items: center; padding: 36px 18px; }
.auth-card, .loading-card { width: min(100%, 460px); background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: clamp(25px, 5vw, 42px); box-shadow: var(--shadow); }
.auth-card h2 { margin: 8px 0 12px; font-size: 30px; }
.section-kicker { color: var(--teal); }
.section-kicker.danger { color: var(--red); }
.muted { color: var(--muted); line-height: 1.7; }
.stack-form, .profile-card { display: grid; gap: 15px; }
label { display: grid; gap: 7px; color: #34455a; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #c8d0d9; border-radius: 10px; background: white; color: var(--ink); padding: 11px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(43,116,110,.12); }
textarea { resize: vertical; line-height: 1.55; }
.status-message { min-height: 21px; margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.status-message.error { color: var(--red); }
.status-message.success { color: var(--teal); }
.loading-card { display: flex; align-items: center; gap: 14px; }
.spinner { width: 22px; height: 22px; border: 3px solid #d7e6e5; border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.onboarding-shell { width: min(1100px, calc(100% - 36px)); margin: 34px auto; display: grid; grid-template-columns: 1.25fr .85fr; gap: 24px; }
.intro-panel, .profile-card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: clamp(24px, 4vw, 38px); box-shadow: var(--shadow); }
.intro-panel h2 { margin: 9px 0 14px; font-size: clamp(27px, 3vw, 39px); line-height: 1.2; }
.intro-panel > p:not(.section-kicker) { color: var(--muted); line-height: 1.75; }
.instruction-list { margin: 24px 0 0; padding: 0; list-style: none; counter-reset: steps; display: grid; gap: 13px; }
.instruction-list li { counter-increment: steps; display: grid; grid-template-columns: 32px 1fr; gap: 11px; align-items: start; line-height: 1.55; }
.instruction-list li::before { content: counter(steps); width: 28px; height: 28px; display: grid; place-items: center; color: white; background: var(--navy); border-radius: 50%; font-size: 12px; font-weight: 800; }
.profile-card h3 { margin: 0 0 4px; font-size: 23px; }
.confirmation-list { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 11px; }
.confirmation-list legend { padding: 0 6px; font-weight: 800; }
.confirmation-list label { grid-template-columns: 20px 1fr; align-items: center; font-weight: 600; }
.confirmation-list input { width: 17px; height: 17px; }

.review-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: calc(100vh - 78px); }
.case-rail { background: #edf0f1; border-right: 1px solid #d0d7dc; padding: 23px 16px; position: sticky; top: 78px; height: calc(100vh - 78px); overflow: auto; }
.rail-heading { justify-content: space-between; gap: 12px; }
.rail-heading strong { display: block; margin-top: 5px; font-size: 22px; }
.case-position { font-weight: 800; color: var(--navy); }
.progress-track { height: 7px; background: #d4dbde; border-radius: 10px; overflow: hidden; margin: 16px 0 13px; }
.progress-track span { display: block; height: 100%; width: 0; background: var(--teal); transition: width .2s ease; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 18px; }
.summary-grid div { background: white; border: 1px solid #d7dde0; border-radius: 10px; padding: 9px 4px; text-align: center; }
.summary-grid span { display: block; font-size: 19px; font-weight: 850; }
.summary-grid small { color: var(--muted); }
.case-list { display: grid; gap: 5px; }
.case-link { width: 100%; border: 1px solid transparent; border-radius: 9px; padding: 9px 10px; background: transparent; display: flex; align-items: center; justify-content: space-between; color: #415165; cursor: pointer; }
.case-link:hover { background: rgba(255,255,255,.7); }
.case-link.active { background: white; border-color: #bdc9ce; color: var(--navy); font-weight: 800; box-shadow: 0 3px 10px rgba(21,36,58,.05); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #aeb8c0; }
.status-dot.complete { background: var(--teal); }
.status-dot.needs-rationale { background: var(--amber); }

.workspace { padding: 25px clamp(18px, 3vw, 40px) 40px; max-width: 1580px; width: 100%; margin: 0 auto; }
.workspace-heading, .rating-heading { justify-content: space-between; gap: 18px; margin-bottom: 15px; }
.workspace-heading h2 { margin: 4px 0 0; font-size: 28px; }
.save-state { color: var(--muted); font-size: 13px; background: white; border: 1px solid var(--line); border-radius: 999px; padding: 7px 11px; }
.save-state.saved { color: var(--teal); border-color: #a9d2cd; background: #f4fbfa; }
.evidence-grid { display: grid; grid-template-columns: minmax(360px, 1fr) minmax(360px, 1fr); gap: 16px; }
.evidence-card, .rating-card { background: var(--card); border: 1px solid var(--line); border-radius: 17px; box-shadow: var(--shadow); overflow: hidden; }
.card-heading { min-height: 58px; padding: 11px 15px; justify-content: space-between; border-bottom: 1px solid var(--line); gap: 12px; }
.card-heading > div { gap: 9px; }
.card-heading h3 { margin: 0; font-size: 16px; }
.step-chip { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--teal-soft); color: var(--teal); font-weight: 900; }
.step-chip.dark { background: #e2e8ef; color: var(--navy); }
.zoom-actions { display: flex; gap: 5px; }
.icon-button { min-width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--navy); font-weight: 800; cursor: pointer; }
.image-stage { height: 410px; overflow: auto; display: grid; place-items: center; padding: 18px; background-color: #f0f0ec; background-image: linear-gradient(rgba(23,58,95,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(23,58,95,.045) 1px, transparent 1px); background-size: 22px 22px; }
.image-stage img { display: block; max-width: none; transform-origin: center; transition: transform .12s ease; border-radius: 4px; box-shadow: 0 4px 18px rgba(21,36,58,.16); }
.image-placeholder { width: min(88%, 440px); aspect-ratio: 4 / 3; border: 2px dashed #aeb8b7; border-radius: 14px; background: rgba(255,255,255,.72); display: grid; place-content: center; text-align: center; gap: 8px; color: #5e6f75; padding: 20px; }
.image-placeholder strong { font-size: 20px; color: var(--navy); }
.latex-label { margin: 0; height: 410px; overflow: auto; padding: 21px; white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.65 "Cascadia Mono", Consolas, monospace; color: #263a50; background: #fbfaf6; }

.rating-card { margin-top: 18px; padding: 22px; overflow: visible; }
.rating-heading h3 { margin: 5px 0 0; font-size: 21px; }
.required-note { color: var(--muted); font-size: 12px; }
.readability-row { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(210px, .5fr); gap: 18px; align-items: center; padding: 14px; background: #f2f6f5; border: 1px solid #d8e4e1; border-radius: 12px; }
.readability-row label span, .dimension-copy p { display: block; margin-top: 5px; color: var(--muted); font-weight: 500; font-size: 13px; line-height: 1.45; }
.dimension-fields { display: grid; margin-top: 14px; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.dimension-row { display: grid; grid-template-columns: minmax(230px, 1fr) minmax(360px, 1.35fr); gap: 18px; align-items: center; padding: 15px; background: white; }
.dimension-row + .dimension-row { border-top: 1px solid var(--line); }
.dimension-copy strong { font-size: 15px; }
.score-options { display: grid; grid-template-columns: repeat(5, minmax(50px, 1fr)); gap: 6px; }
.score-options label { display: block; }
.score-options input { position: absolute; opacity: 0; pointer-events: none; }
.score-options span { min-height: 38px; display: grid; place-items: center; border: 1px solid #cbd3da; border-radius: 9px; background: #fafafa; color: #536171; cursor: pointer; font-weight: 800; }
.score-options input:checked + span { color: white; background: var(--navy); border-color: var(--navy); box-shadow: 0 4px 12px rgba(22,58,95,.2); }
.score-options input:focus-visible + span { outline: 3px solid rgba(43,116,110,.28); outline-offset: 2px; }
.detail-grid { margin-top: 15px; display: grid; grid-template-columns: 1.4fr .6fr; gap: 14px; }
.rationale-field { margin-top: 15px; }
.rationale-field > span { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.rationale-field em { color: var(--muted); font-size: 12px; font-style: normal; }
.rationale-field.required em { color: var(--red); font-weight: 800; }
.rationale-field.required textarea { border-color: #d39a95; background: #fffaf9; }
.workspace-footer { display: grid; grid-template-columns: auto minmax(180px, 260px) auto; justify-content: center; gap: 10px; margin-top: 18px; position: sticky; bottom: 12px; z-index: 10; }
.workspace-footer .button { box-shadow: 0 8px 22px rgba(21,36,58,.12); }
.workspace-footer .finalize { grid-column: 1 / -1; }

dialog { border: 0; border-radius: 19px; padding: 0; color: var(--ink); box-shadow: 0 24px 70px rgba(15,43,72,.3); }
dialog::backdrop { background: rgba(15,30,48,.6); backdrop-filter: blur(3px); }
.dialog-card { width: min(520px, calc(100vw - 32px)); padding: 28px; }
.dialog-card h2 { margin: 7px 0 10px; }
.dialog-card p:not(.section-kicker) { color: var(--muted); line-height: 1.65; }
.dialog-actions { justify-content: flex-end; gap: 8px; margin-top: 20px; }

@media (max-width: 1040px) {
  .review-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .evidence-grid { grid-template-columns: 1fr; }
  .image-stage, .latex-label { height: 340px; }
  .dimension-row { grid-template-columns: 1fr; gap: 10px; }
}

@media (max-width: 760px) {
  .topbar { position: static; align-items: flex-start; }
  .brand-mark, .eyebrow, .account-label { display: none; }
  .topbar-actions { gap: 4px; }
  .topbar .button { min-height: 36px; padding: 7px 9px; font-size: 12px; }
  .onboarding-shell { grid-template-columns: 1fr; width: min(100% - 24px, 620px); margin: 18px auto; }
  .review-shell { display: block; }
  .case-rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid #d0d7dc; padding: 14px; }
  .case-list { grid-template-columns: repeat(6, minmax(46px, 1fr)); max-height: 126px; overflow: auto; }
  .case-link { padding: 8px 6px; font-size: 11px; }
  .case-link span:first-child { overflow: hidden; text-overflow: ellipsis; }
  .workspace { padding: 17px 12px 30px; }
  .evidence-grid { grid-template-columns: 1fr; }
  .image-stage, .latex-label { height: 300px; }
  .readability-row, .detail-grid { grid-template-columns: 1fr; }
  .score-options { grid-template-columns: repeat(5, 1fr); }
  .rating-card { padding: 16px; }
  .workspace-footer { grid-template-columns: 1fr 1.35fr 1fr; bottom: 6px; }
  .workspace-footer .button { padding: 8px 7px; font-size: 12px; }
}

.codebook-body { background: #f3f1eb; }
.codebook-topbar { position: static; }
.codebook-shell { width: min(1420px, calc(100% - 36px)); margin: 30px auto 60px; display: grid; gap: 34px; }
.codebook-intro { display: grid; grid-template-columns: 1fr minmax(360px, .8fr); gap: 28px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 30px; box-shadow: var(--shadow); }
.codebook-intro h2 { margin: 7px 0 10px; font-size: 31px; }
.codebook-intro p:not(.section-kicker) { color: var(--muted); line-height: 1.65; }
.version-list { margin: 0; display: grid; grid-template-columns: 90px 1fr; align-content: start; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.version-list dt, .version-list dd { margin: 0; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 12px; overflow-wrap: anywhere; }
.version-list dt { background: #edf1f3; color: var(--navy); font-weight: 800; }
.version-list dd { background: white; font-family: "Cascadia Mono", Consolas, monospace; }
.version-list dt:nth-last-of-type(1), .version-list dd:last-child { border-bottom: 0; }
.section-title { margin: 0 0 13px; font-size: 22px; }
.codebook-table { display: grid; border: 1px solid #cbd4db; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.codebook-row { display: grid; grid-template-columns: 1.35fr repeat(4, 1fr); background: white; }
.codebook-row + .codebook-row { border-top: 1px solid #d6dde2; }
.codebook-row > div { min-width: 0; padding: 15px; line-height: 1.55; font-size: 13px; }
.codebook-row > div + div { border-left: 1px solid #d6dde2; }
.codebook-row > div:nth-child(2) { background: #eaf4ef; }
.codebook-row > div:nth-child(3) { background: #fff7e1; }
.codebook-row > div:nth-child(4) { background: #fcebea; }
.codebook-row > div:nth-child(5) { background: #f1f2f3; }
.codebook-row strong { color: var(--navy); font-size: 15px; }
.codebook-row p { margin: 7px 0 0; color: var(--muted); }
.codebook-header { background: var(--navy); color: white; font-weight: 800; text-align: center; }
.codebook-header > div { background: var(--navy) !important; border-color: rgba(255,255,255,.2) !important; }
.rule-section { background: var(--navy-2); color: white; border-radius: 18px; padding: 27px; }
.rule-grid { margin: 0; padding: 0; list-style: none; counter-reset: codebook-rule; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rule-grid li { counter-increment: codebook-rule; display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; padding: 12px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.1); border-radius: 11px; line-height: 1.5; font-size: 13px; }
.rule-grid li::before { content: counter(codebook-rule); width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; background: #d7ece8; color: var(--navy); font-weight: 900; }
.error-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.error-grid article { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 15px; }
.error-grid strong { color: var(--navy); }
.error-grid p { margin: 6px 0 0; color: var(--muted); line-height: 1.5; font-size: 13px; }

@media (max-width: 900px) {
  .codebook-intro { grid-template-columns: 1fr; }
  .codebook-table { overflow-x: auto; }
  .codebook-row { min-width: 980px; }
  .rule-grid { grid-template-columns: 1fr; }
  .error-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .error-grid { grid-template-columns: 1fr; }
  .codebook-shell { width: min(100% - 20px, 1420px); margin-top: 16px; }
  .codebook-intro { padding: 22px; }
}

.admin-shell { width: min(1180px, calc(100% - 36px)); margin: 30px auto 60px; }
.admin-heading, .admin-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.admin-heading h2 { margin: 5px 0 0; overflow-wrap: anywhere; }
.admin-stats { margin: 20px 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.admin-stats article { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 17px; box-shadow: var(--shadow); }
.admin-stats span { display: block; font-size: 28px; font-weight: 900; color: var(--navy); }
.admin-stats small { color: var(--muted); }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.admin-card { background: var(--card); border: 1px solid var(--line); border-radius: 17px; padding: 22px; box-shadow: var(--shadow); }
.admin-card.full { grid-column: 1 / -1; }
.admin-card h3 { margin: 7px 0 8px; font-size: 21px; }
.admin-card > p:not(.section-kicker) { color: var(--muted); line-height: 1.6; }
.table-scroll { overflow-x: auto; margin-top: 15px; }
table { width: 100%; border-collapse: collapse; background: white; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; font-size: 13px; }
th { color: var(--navy); background: #edf2f3; }
code { font-family: "Cascadia Mono", Consolas, monospace; font-size: .9em; }
@media (max-width: 760px) {
  .admin-grid { grid-template-columns: 1fr; }
  .admin-card.full { grid-column: auto; }
  .admin-stats { grid-template-columns: 1fr 1fr; }
}

/* ===== 플랫폼 확장 (연구 코딩 통합 플랫폼) ===================================== */

/* 진입 화면 — 내 연구 목록 */
.study-list { display: grid; gap: 10px; margin-top: 18px; }
.study-card { display: grid; gap: 4px; width: 100%; text-align: left; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: white; cursor: pointer; transition: .16s ease; }
.study-card:hover { transform: translateY(-1px); border-color: #a9d2cd; box-shadow: 0 8px 20px rgba(21,36,58,.08); }
.study-card strong { font-size: 17px; color: var(--navy); }
.study-card small { color: var(--muted); }
.role-badge { justify-self: start; margin-top: 6px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; background: var(--teal-soft); color: var(--teal); }
.role-badge.admin { background: #e2e8ef; color: var(--navy); }
.role-badge.inactive { background: #eceff1; color: var(--muted); }

/* 문항 렌더링 — 코드북에서 생성되므로 항목 키 리터럴이 없다 */
.item-group { display: grid; margin-top: 14px; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.item-group-title { padding: 10px 15px; background: #eef2f4; color: var(--navy); font-weight: 800; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; border-bottom: 1px solid var(--line); }
.item-row { display: grid; grid-template-columns: minmax(230px, 1fr) minmax(360px, 1.35fr); gap: 18px; align-items: center; padding: 15px; background: white; }
.item-row + .item-row { border-top: 1px solid var(--line); }
.item-row.stacked { grid-template-columns: 1fr; }
.item-copy strong { font-size: 15px; }
.item-copy p { display: block; margin: 5px 0 0; color: var(--muted); font-weight: 500; font-size: 13px; line-height: 1.45; }
.item-row.invalid { background: #fff8f7; box-shadow: inset 3px 0 0 var(--red); }
.item-error { margin: 8px 0 0; color: var(--red); font-size: 12px; font-weight: 700; }
.level-hint { margin: 6px 0 0; display: grid; gap: 3px; }
.level-hint span { color: var(--muted); font-size: 12px; line-height: 1.45; }
.level-hint b { color: var(--navy); }
.choice-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(52px, 1fr)); gap: 6px; }
.choice-options.wide { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.choice-options label { display: block; }
.choice-options input { position: absolute; opacity: 0; pointer-events: none; }
.choice-options span { min-height: 38px; display: grid; place-items: center; text-align: center; padding: 6px 8px; border: 1px solid #cbd3da; border-radius: 9px; background: #fafafa; color: #536171; cursor: pointer; font-weight: 800; font-size: 13px; line-height: 1.3; }
.choice-options input:checked + span { color: white; background: var(--navy); border-color: var(--navy); box-shadow: 0 4px 12px rgba(22,58,95,.2); }
.choice-options input:disabled + span { opacity: .5; cursor: not-allowed; }
.choice-options input:focus-visible + span { outline: 3px solid rgba(43,116,110,.28); outline-offset: 2px; }
.choice-options.multi span { border-radius: 999px; }
.number-input { max-width: 160px; }

/* 증거 패널 */
.evidence-grid.single { grid-template-columns: minmax(0, 1fr); }
.evidence-text { margin: 0; height: 410px; overflow: auto; padding: 21px; white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.65 "Cascadia Mono", Consolas, monospace; color: #263a50; background: #fbfaf6; }
.evidence-note { padding: 18px; color: var(--muted); }

/* 승격 오류 */
.error-list { margin: 14px 0 0; padding: 14px 16px; border: 1px solid #e0b3ae; border-radius: 12px; background: #fdf3f2; display: grid; gap: 6px; }
.error-list strong { color: var(--red); }
.error-list button { justify-self: start; border: 0; background: none; color: var(--navy); font-weight: 700; text-decoration: underline; cursor: pointer; padding: 0; font-size: 13px; }

/* 관리 콘솔 */
.tab-bar { display: flex; gap: 6px; flex-wrap: wrap; margin: 18px 0 4px; border-bottom: 1px solid var(--line); }
.tab-bar button { border: 1px solid transparent; border-bottom: 0; border-radius: 10px 10px 0 0; background: transparent; padding: 10px 16px; font-weight: 750; color: var(--muted); cursor: pointer; }
.tab-bar button.active { background: var(--card); border-color: var(--line); color: var(--navy); }
.study-picker { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.study-picker select { max-width: 420px; }
.phase-pill { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; background: #e2e8ef; color: var(--navy); }
.phase-pill.open { background: var(--teal-soft); color: var(--teal); }
.phase-pill.closed { background: var(--red-soft); color: var(--red); }
td.numeric, th.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.metric-good { color: var(--teal); font-weight: 800; }
.metric-fair { color: var(--amber); font-weight: 800; }
.metric-poor { color: var(--red); font-weight: 800; }
.chain-ok { color: var(--teal); font-weight: 800; }
.chain-broken { color: var(--red); font-weight: 800; }
.audit-meta { color: var(--muted); font-size: 12px; white-space: normal; max-width: 420px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 8px 0 0; }
.danger-zone { border-color: #e0b3ae; background: #fdf6f5; }
.inline-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.inline-form .button { min-height: 42px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-weight: 700; color: #34455a; }
.checkbox-row input { width: 17px; height: 17px; }

/* 코드북 열람 — 코드북 문서 기반 렌더 */
.codebook-item { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); }
.codebook-item + .codebook-item { margin-top: 12px; }
.codebook-item h3 { margin: 6px 0 6px; font-size: 20px; }
.codebook-item > p { margin: 0 0 12px; color: var(--muted); line-height: 1.6; }
.codebook-values { display: grid; gap: 8px; }
.codebook-value { display: grid; grid-template-columns: 120px 1fr; gap: 12px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.codebook-value b { color: var(--navy); }
.codebook-value span { color: var(--muted); line-height: 1.5; font-size: 13px; }
.codebook-value.special { background: #f6f7f8; }
.type-tag { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #e2e8ef; color: var(--navy); font-size: 11px; font-weight: 800; letter-spacing: .04em; }

@media (max-width: 900px) {
  .codebook-value { grid-template-columns: 1fr; gap: 4px; }
  .item-row { grid-template-columns: 1fr; gap: 10px; }
}

@media print {
  .topbar, .tab-bar, .button, .no-print { display: none !important; }
  body { background: white; }
  .codebook-shell { width: 100%; margin: 0; }
  .codebook-item, .rule-section { break-inside: avoid; box-shadow: none; }
  .rule-section { background: white; color: var(--ink); border: 1px solid var(--line); }
  .rule-grid li { background: white; border-color: var(--line); }
}
