/* ============================================================
   Cat in the Rain — 1930s Italian rainy-hotel theme
   ============================================================ */

:root {
  --rain-gray:  #7f8b91;
  --rain-deep:  #4e585e;
  --warm-beige: #e7dbc6;
  --cream:      #f7f1e4;
  --dark-green: #2f4636;
  --green-soft: #4a6a53;
  --brown:      #6b4f34;
  --brown-deep: #3c2c1e;
  --ink:        #2a251f;
  --amber:      #d99a3f;
  --ok:         #4a7c59;
  --warn:       #c08a2e;
  --bad:        #a8563f;

  --paper: linear-gradient(180deg, #fbf6ea 0%, #f2e9d7 100%);
  --shadow: 0 10px 30px rgba(28, 22, 16, .18);
  --radius: 16px;
  --font-en: "Georgia", "Times New Roman", serif;
  --font-ko: "Pretendard", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  min-height: 100%;
  font-family: var(--font-ko);
  color: var(--ink);
  background: #3f4a50;
}

body {
  background:
    radial-gradient(1200px 600px at 50% -10%, #6d7a81 0%, #414c53 45%, #2f383e 100%);
  position: relative;
  overflow-x: hidden;
}

/* ── 비 애니메이션 ────────────────────────────────────────── */
#rain-layer {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .55;
}
#rain-layer .drop {
  position: absolute;
  top: -12vh;
  width: 1.4px;
  background: linear-gradient(to bottom, rgba(220,235,240,0), rgba(220,235,240,.85));
  animation: fall linear infinite;
}
@keyframes fall {
  to { transform: translateY(128vh); }
}
@media (prefers-reduced-motion: reduce) {
  #rain-layer { display: none; }
}

/* ── 레이아웃 ────────────────────────────────────────────── */
.wrap {
  position: relative; z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 18px 72px;
}
.card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 26px;
  border: 1px solid rgba(60,44,30,.14);
}
.card + .card { margin-top: 18px; }

/* ── 헤더 ────────────────────────────────────────────────── */
.masthead { text-align: center; padding: 26px 12px 8px; }
.masthead .cat-emoji { font-size: 46px; display: block; line-height: 1; }
.masthead h1 {
  font-family: var(--font-en);
  font-size: clamp(28px, 6vw, 44px);
  letter-spacing: .16em;
  margin: 10px 0 6px;
  color: var(--cream);
  text-transform: uppercase;
  text-shadow: 0 2px 10px rgba(0,0,0,.35);
}
.masthead p {
  margin: 0; color: #d7ddd9; font-style: italic;
  font-family: var(--font-en); font-size: 15px;
}
.masthead .byline { font-size: 12.5px; opacity: .75; margin-top: 6px; letter-spacing: .06em; }

/* ── 폼 ──────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-weight: 700; font-size: 14px;
  margin-bottom: 6px; color: var(--brown-deep);
}
.field .sub { font-weight: 400; color: #6d6055; font-size: 12.5px; }
select, input[type="text"], input[type="password"], textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #cbbda6;
  border-radius: 10px;
  background: #fffdf7;
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--green-soft);
  box-shadow: 0 0 0 3px rgba(74,106,83,.18);
}
textarea { min-height: 108px; resize: vertical; line-height: 1.6; }
.err { color: var(--bad); font-size: 13px; margin-top: 6px; min-height: 18px; }

/* ── 버튼 ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 22px;
  border: none; border-radius: 999px;
  background: var(--dark-green); color: var(--cream);
  font-size: 15px; font-weight: 700; font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(47,70,54,.35);
  transition: transform .12s, background .15s, opacity .15s;
}
.btn:hover:not(:disabled) { background: var(--green-soft); transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.ghost {
  background: transparent; color: var(--brown-deep);
  border: 1.5px solid #c3b49c; box-shadow: none;
}
.btn.ghost:hover:not(:disabled) { background: #efe6d5; }
.btn.wide { width: 100%; }
.btn.small { padding: 8px 16px; font-size: 13.5px; }

/* ── 진행 바 / 발자국 ────────────────────────────────────── */
.progress-shell {
  position: sticky; top: 0; z-index: 5;
  background: rgba(47,56,62,.92);
  backdrop-filter: blur(6px);
  padding: 10px 18px 12px;
  border-radius: 0 0 14px 14px;
  box-shadow: 0 4px 18px rgba(0,0,0,.25);
}
.progress-top {
  display: flex; justify-content: space-between; align-items: center;
  color: #e6ece9; font-size: 12.5px; margin-bottom: 7px; gap: 10px;
}
.progress-bar { height: 8px; background: rgba(255,255,255,.16); border-radius: 999px; overflow: hidden; }
.progress-bar > div {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--amber), #f0c579);
  border-radius: 999px; transition: width .45s ease;
}
.paws { margin-top: 8px; font-size: 15px; letter-spacing: 3px; min-height: 20px; color: #f0c579; }
.paws span { display: inline-block; animation: pawpop .4s ease both; }
@keyframes pawpop { from { transform: scale(.2) translateY(6px); opacity: 0 } to { transform: none; opacity: 1 } }

/* ── 챕터 표지 ───────────────────────────────────────────── */
.chapter-cover { text-align: center; padding: 34px 20px; }
.chapter-cover .big { font-size: 60px; line-height: 1; }
.chapter-cover h2 {
  font-family: var(--font-en); font-size: 27px; margin: 14px 0 4px;
  letter-spacing: .04em; color: var(--brown-deep);
}
.chapter-cover .ko { color: #6d6055; margin: 0 0 4px; font-size: 15px; }
.chapter-cover .focus {
  display: inline-block; margin-top: 10px; padding: 5px 14px;
  background: #e5dcc8; border-radius: 999px; font-size: 12.5px; color: var(--brown);
  letter-spacing: .04em;
}
.cat-walk { font-size: 30px; animation: walk 1.4s ease-in-out infinite alternate; display: inline-block; }
@keyframes walk { from { transform: translateX(-14px) } to { transform: translateX(14px) } }

/* ── 문항 ────────────────────────────────────────────────── */
.qhead {
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; color: #7a6c5c; margin-bottom: 14px; flex-wrap: wrap;
}
.tag {
  padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  background: #e3dbc9; color: var(--brown);
}
.quote {
  font-family: var(--font-en); font-size: 17px; line-height: 1.65;
  background: #fffdf6; border-left: 4px solid var(--green-soft);
  padding: 13px 16px; border-radius: 0 10px 10px 0; margin: 0 0 16px;
  color: #40372c; font-style: italic;
}
.prompt { font-size: 17.5px; font-weight: 700; line-height: 1.6; margin: 0 0 16px; }

.choices { display: grid; gap: 10px; }
.choice {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 13px 16px;
  border: 1.5px solid #d3c6ae; border-radius: 12px;
  background: #fffdf7; cursor: pointer;
  font-size: 15.5px; line-height: 1.5; text-align: left;
  font-family: inherit; color: var(--ink);
  transition: border-color .13s, background .13s, transform .1s;
}
.choice:hover:not(.locked) { border-color: var(--green-soft); background: #f6f1e2; }
.choice .key {
  flex: 0 0 24px; height: 24px; border-radius: 50%;
  background: #e5dcc8; color: var(--brown); font-weight: 700;
  display: grid; place-items: center; font-size: 12.5px; margin-top: 1px;
}
.choice.sel { border-color: var(--green-soft); background: #eef3ea; }
.choice.sel .key { background: var(--green-soft); color: #fff; }
.choice.right { border-color: var(--ok); background: #e9f2ea; }
.choice.right .key { background: var(--ok); color: #fff; }
.choice.wrong { border-color: var(--bad); background: #f7ebe7; }
.choice.wrong .key { background: var(--bad); color: #fff; }
.choice.locked { cursor: default; }

/* ── 힌트 ────────────────────────────────────────────────── */
.hint-box { margin-top: 16px; }
.hint-panel {
  margin-top: 12px; border-radius: 14px; overflow: hidden;
  border: 1.5px solid #d3c6ae; background: #fffdf7;
  animation: fadein .3s ease;
}
@keyframes fadein { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }
.scene-svg { display: block; width: 100%; height: auto; background: #6f7d85; }
.hint-text {
  padding: 13px 16px; font-family: var(--font-en); font-size: 15px;
  line-height: 1.6; color: #443b30;
}
.hint-text b { color: var(--brown); }

/* ── 피드백 ──────────────────────────────────────────────── */
.feedback {
  margin-top: 16px; padding: 14px 16px; border-radius: 12px;
  font-size: 15px; line-height: 1.65; animation: fadein .3s ease;
}
.feedback.good { background: #e9f2ea; border: 1.5px solid var(--ok); }
.feedback.mid  { background: #fbf2df; border: 1.5px solid var(--warn); }
.feedback.bad  { background: #f7ebe7; border: 1.5px solid var(--bad); }
.feedback .lead { font-weight: 700; display: block; margin-bottom: 4px; }

/* ── 감정 타임라인 ───────────────────────────────────────── */
.timeline { display: grid; gap: 10px; margin-bottom: 8px; }
.slot {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 12px;
  border: 1.5px dashed #c9bba2; background: #fffdf7; min-height: 56px;
}
.slot .idx {
  flex: 0 0 26px; height: 26px; border-radius: 50%; background: #e5dcc8;
  color: var(--brown); font-weight: 700; display: grid; place-items: center; font-size: 12.5px;
}
.slot.filled { border-style: solid; border-color: var(--green-soft); background: #eef3ea; }
.slot.ok  { border-color: var(--ok);  background: #e9f2ea; }
.slot.bad { border-color: var(--bad); background: #f7ebe7; }
.slot .txt { font-size: 15px; }
.slot .txt small { color: #6d6055; display: block; font-size: 12.5px; }
.pool { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 12px; }
.emo-chip {
  padding: 9px 14px; border-radius: 999px; border: 1.5px solid #d3c6ae;
  background: #fffdf7; cursor: pointer; font-size: 14.5px; font-family: inherit;
  transition: transform .1s, border-color .13s;
}
.emo-chip:hover:not(:disabled) { border-color: var(--green-soft); transform: translateY(-1px); }
.emo-chip:disabled { opacity: .3; cursor: not-allowed; }

/* ── 결과 화면 ───────────────────────────────────────────── */
.score-big {
  font-family: var(--font-en); font-size: 66px; font-weight: 700;
  color: var(--dark-green); line-height: 1; text-align: center;
}
.score-sub { text-align: center; color: #6d6055; margin-top: 4px; font-size: 14px; }
.cat-bars { display: grid; gap: 11px; margin-top: 22px; }
.cat-bar-row { display: grid; grid-template-columns: 84px 1fr 46px; align-items: center; gap: 12px; font-size: 13.5px; }
.cat-bar { height: 10px; background: #e3dbc9; border-radius: 999px; overflow: hidden; }
.cat-bar > div { height: 100%; background: var(--green-soft); border-radius: 999px; transition: width .8s ease; }
.badge-grid { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 8px; }
.badge {
  width: 128px; padding: 16px 10px; border-radius: 14px; text-align: center;
  background: #fffdf7; border: 1.5px solid #d3c6ae;
}
.badge.earned { border-color: var(--amber); background: #fdf5e6; box-shadow: 0 4px 14px rgba(217,154,63,.22); }
.badge .ic { font-size: 30px; display: block; }
.badge .nm { font-size: 12.5px; font-weight: 700; margin-top: 6px; }
.badge .ko { font-size: 11.5px; color: #7a6c5c; }
.badge:not(.earned) { opacity: .42; filter: grayscale(1); }

.finale { text-align: center; padding: 10px 0 4px; }
.finale .l1 { font-family: var(--font-en); font-size: 26px; color: var(--dark-green); }
.finale .l2 { font-family: var(--font-en); font-size: 19px; color: #6d6055; font-style: italic; margin-top: 6px; }

h3.sec {
  font-size: 15px; letter-spacing: .04em; color: var(--brown);
  border-bottom: 1.5px solid #ddd2ba; padding-bottom: 8px; margin: 26px 0 14px;
}

/* ── 상단 도구 (소리 / 교사용) ───────────────────────────── */
.toolbar {
  position: fixed; top: 12px; right: 12px; z-index: 20;
  display: flex; gap: 8px;
}
.tool-btn {
  border: none; border-radius: 999px; padding: 8px 13px;
  background: rgba(255,255,255,.14); color: #f2f5f3;
  font-size: 12.5px; cursor: pointer; font-family: inherit;
  backdrop-filter: blur(6px); transition: background .15s;
}
.tool-btn:hover { background: rgba(255,255,255,.26); }

/* ── 교사 대시보드 ───────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 12px; }
.stat {
  background: #fffdf7; border: 1.5px solid #ddd2ba; border-radius: 12px;
  padding: 14px; text-align: center;
}
.stat .v { font-family: var(--font-en); font-size: 27px; font-weight: 700; color: var(--dark-green); }
.stat .k { font-size: 12px; color: #7a6c5c; margin-top: 3px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters .field { margin: 0; flex: 1 1 130px; }

.table-wrap { overflow-x: auto; margin-top: 6px; border-radius: 12px; border: 1px solid #ddd2ba; }
table.grid { border-collapse: collapse; width: 100%; font-size: 13.5px; background: #fffdf7; min-width: 780px; }
table.grid th, table.grid td { padding: 9px 11px; border-bottom: 1px solid #eae0cc; text-align: left; white-space: nowrap; }
table.grid th {
  background: #efe6d5; font-size: 12px; color: var(--brown);
  position: sticky; top: 0; cursor: pointer; user-select: none;
}
table.grid th:hover { background: #e6dbc6; }
table.grid tbody tr:hover { background: #f6f1e2; }
table.grid tbody tr { cursor: pointer; }
.score-pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-weight: 700; font-size: 12.5px; }
.s-hi { background: #e0efe3; color: #2f5c3d; }
.s-mid{ background: #fbf0d9; color: #8a6420; }
.s-lo { background: #f6e3dd; color: #8d4331; }

dialog.sheet {
  border: none; border-radius: 16px; padding: 0; max-width: 700px; width: 92vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.4); background: var(--paper);
}
dialog.sheet::backdrop { background: rgba(24,28,31,.6); }
.sheet-body { padding: 24px; max-height: 78vh; overflow-y: auto; }
.kv { display: grid; grid-template-columns: 128px 1fr; gap: 7px 14px; font-size: 14px; }
.kv dt { color: #7a6c5c; }
.kv dd { margin: 0; }
.answer-block {
  background: #fffdf7; border: 1px solid #ddd2ba; border-radius: 10px;
  padding: 12px 14px; margin-top: 9px; font-size: 14px; line-height: 1.65; white-space: pre-wrap;
}
.answer-block .q { font-weight: 700; font-size: 13px; color: var(--brown); display: block; margin-bottom: 5px; }

.muted { color: #7a6c5c; font-size: 13.5px; line-height: 1.65; }
.center { text-align: center; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; align-items: center; }
.grow { flex: 1; }
.hidden { display: none !important; }

.notice {
  background: #fbf2df; border: 1.5px solid #e2c98d; border-radius: 12px;
  padding: 12px 15px; font-size: 13.5px; line-height: 1.6; color: #6a5427;
}

@media (max-width: 560px) {
  .wrap { padding: 16px 12px 60px; }
  .card { padding: 20px 17px; }
  .cat-bar-row { grid-template-columns: 66px 1fr 40px; font-size: 12.5px; }
  .badge { width: calc(50% - 6px); }
  .toolbar { top: 8px; right: 8px; }
}


/* ============================================================
   ── 새 문항 유형 3종 (v2) ───────────────────────────────────
   tf    = 참·거짓      fill = 빈칸 채우기      match = 짝 맞추기
   ============================================================ */

/* ── 참 · 거짓 ──────────────────────────────────────────── */
.tf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tf-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 18px 10px 14px;
  border: 1.5px solid #d3c6ae; border-radius: 14px;
  background: #fffdf7; cursor: pointer; font-family: inherit; color: var(--ink);
  transition: border-color .13s, background .13s, transform .1s;
}
.tf-btn:hover:not(.locked) { border-color: var(--green-soft); background: #f6f1e2; transform: translateY(-1px); }
.tf-btn .ic { font-size: 30px; line-height: 1; }
.tf-btn b { font-family: var(--font-en); font-size: 17px; letter-spacing: .06em; }
.tf-btn small { font-size: 12px; color: #7a6c5c; }
.tf-btn.sel   { border-color: var(--green-soft); background: #eef3ea; }
.tf-btn.right { border-color: var(--ok);  background: #e9f2ea; }
.tf-btn.wrong { border-color: var(--bad); background: #f7ebe7; }
.tf-btn.locked { cursor: default; }

/* ── 빈칸 채우기 ────────────────────────────────────────── */
.cloze {
  font-family: var(--font-en); font-size: 17px; line-height: 2.1;
  background: #fffdf7; border: 1.5px solid #e0d6bf; border-radius: 12px;
  padding: 16px 18px; margin: 0;
}
.blank {
  display: inline-block; min-width: 96px; text-align: center;
  padding: 2px 10px; margin: 0 3px;
  border-bottom: 2.5px solid var(--brown); border-radius: 4px 4px 0 0;
  color: #9a8b78; cursor: pointer; transition: background .13s, color .13s;
}
.blank:hover { background: #f2ead6; }
.blank.filled { color: var(--dark-green); font-weight: 700; background: #eef3ea; }
.blank.ok  { color: var(--ok);  border-color: var(--ok);  background: #e9f2ea; cursor: default; }
.blank.bad { color: var(--bad); border-color: var(--bad); background: #f7ebe7; cursor: default; font-size: 15px; }

.word-chip {
  padding: 9px 15px; border-radius: 999px;
  border: 1.5px solid #d3c6ae; background: #fffdf7;
  font-family: var(--font-en); font-size: 15px; cursor: pointer; color: var(--ink);
  transition: border-color .13s, transform .1s, opacity .13s;
}
.word-chip:hover:not(:disabled) { border-color: var(--green-soft); transform: translateY(-1px); }
.word-chip:disabled { opacity: .3; cursor: not-allowed; }

/* ── 짝 맞추기 ──────────────────────────────────────────── */
.match-grid { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 10px; }
.match-col  { display: grid; gap: 9px; align-content: start; }
.match-l, .match-r {
  position: relative; text-align: left;
  padding: 12px 34px 12px 14px;
  border: 1.5px solid #d3c6ae; border-radius: 12px;
  background: #fffdf7; cursor: pointer; color: var(--ink);
  font-family: inherit; font-size: 14.5px; line-height: 1.45;
  transition: border-color .13s, background .13s, transform .1s;
}
.match-l { font-family: var(--font-en); font-size: 16px; font-weight: 700; }
.match-l:hover:not(.locked), .match-r:hover:not(.locked) { border-color: var(--green-soft); background: #f6f1e2; }
.match-l.picking { border-color: var(--amber); background: #fdf5e6; box-shadow: 0 0 0 3px rgba(217,154,63,.2); }
.match-l.paired, .match-r.paired { border-color: var(--green-soft); background: #eef3ea; }
.pin {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  width: 21px; height: 21px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700; color: #fff; background: transparent;
}
.paired .pin { background: var(--green-soft); }
.match-l.ok,  .match-r.ok  { border-color: var(--ok);  background: #e9f2ea; }
.match-l.ok  .pin, .match-r.ok  .pin { background: var(--ok); }
.match-l.bad, .match-r.bad { border-color: var(--bad); background: #f7ebe7; }
.match-l.bad .pin, .match-r.bad .pin { background: var(--bad); }
.match-l.locked, .match-r.locked { cursor: default; }
.fixnote { display: block; margin-top: 5px; font-size: 12px; color: var(--bad); font-weight: 700; }

@media (max-width: 460px) {
  .match-grid { grid-template-columns: 1fr; }
  .match-col + .match-col { margin-top: 4px; }
}
