/* ===== 공통 스타일 ===== */
:root {
  --bg: #fdf8ef;
  --paper: #ffffff;
  --ink: #23303d;
  --ink-2: #4b5a6a;
  --muted: #7d8a99;
  --line: #e7e0d2;
  --primary: #2fb38f;
  --primary-d: #1f8f71;
  --primary-l: #dff6ee;
  --accent: #ff8a3d;
  --purple: #6c7bff;
  --pink: #ff5c8a;
  --yellow: #ffc94d;
  --danger: #e5484d;
  --danger-l: #fff0f0;
  --ok: #24a148;
  --ok-l: #e8f8ec;
  --code-bg: #1f2633;
  --gold: #f5c518;
  --gold-d: #c8930a;
  --gold-dd: #8a6100;
  --gold-l: #fff6d6;
  --radius: 16px;
  --shadow: 0 6px 20px rgba(60, 50, 30, .08);
  --shadow-2: 0 12px 34px rgba(60, 50, 30, .16);
  --font: "Gowun Dodum", "Noto Sans KR", system-ui, sans-serif;
  --font-title: "Jua", "Gowun Dodum", sans-serif;
  --font-code: "Source Code Pro", "Nanum Gothic Coding", "D2Coding", Consolas, monospace; /* 영어·기호는 Source Code Pro, 한글은 나눔고딕코딩 */
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-title); font-weight: 400; margin: 0 0 .4em; line-height: 1.3; letter-spacing: -.01em; }
a { color: inherit; }
code { font-family: var(--font-code); background: #f1ece2; padding: 1px 6px; border-radius: 6px; font-size: .92em; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* 버튼 */
.btn {
  text-decoration: none;
  font-family: var(--font-title); font-size: 16px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--paper); color: var(--ink); cursor: pointer;
  transition: transform .08s, box-shadow .15s, background .15s;
  box-shadow: 0 3px 0 var(--line);
  white-space: nowrap;
}
.btn:hover { background: #fffdf8; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--primary); border-color: var(--primary-d); color: #fff; box-shadow: 0 3px 0 var(--primary-d); }
.btn.primary:hover { background: #36c09b; }
.btn.danger { background: var(--danger); border-color: #b4292e; color: #fff; box-shadow: 0 3px 0 #b4292e; }
.btn.purple { background: var(--purple); border-color: #4c59d8; color: #fff; box-shadow: 0 3px 0 #4c59d8; }
.btn.yellow { background: var(--yellow); border-color: #d9a520; color: #4a3500; box-shadow: 0 3px 0 #d9a520; }
.btn.small { padding: 5px 11px; font-size: 14px; border-radius: 10px; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,.04); }

/* 키워드 배지: print(출력) */
.kw { display: inline-flex; align-items: baseline; gap: 4px; background: #eef0ff; border: 1px solid #d7dbff; border-radius: 8px; padding: 0 7px 0 2px; white-space: nowrap; }
.kw code { background: transparent; color: #4250d6; font-weight: 700; padding: 0 3px; }
.kw small { color: #5c6680; font-size: .82em; }

/* 설명 상자 */
.box { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; margin: 12px 0; align-items: flex-start; }
.box-icon { font-size: 20px; line-height: 1.3; }
.box-tip { background: #fff7dd; border: 1px solid #ffe7a1; }
.box-warn { background: #fff0ea; border: 1px solid #ffd0bd; }
.box-idea { background: #eaf6ff; border: 1px solid #c7e6ff; }

/* 모달 */
.modal-back {
  position: fixed; inset: 0; background: rgba(30, 36, 48, .45); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fadeIn .15s;
}
.modal {
  background: var(--paper); border-radius: 22px; padding: 26px 28px; max-width: 460px; width: 100%;
  box-shadow: var(--shadow-2); text-align: center; animation: popIn .25s cubic-bezier(.2, 1.4, .5, 1);
  max-height: calc(100vh - 32px); overflow: auto;
}
.modal.wide { max-width: 760px; text-align: left; }
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.modal-pai { margin-bottom: 4px; }
.pin-input { font-size: 24px; text-align: center; letter-spacing: 8px; padding: 10px; width: 200px; border-radius: 12px; border: 2px solid var(--line); font-family: var(--font-code); }
.pin-input:focus { outline: none; border-color: var(--primary); }
.pin-err { color: var(--danger); min-height: 1.4em; margin: 6px 0 0; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { transform: scale(.85); opacity: 0; } }

/* 토스트 */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 1200;
  background: var(--ink); color: #fff; padding: 10px 20px; border-radius: 999px; font-family: var(--font-title);
  box-shadow: var(--shadow-2); animation: popIn .2s; transition: opacity .4s;
}
.toast.out { opacity: 0; }

/* 칭찬 애니메이션 */
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 1100; overflow: hidden; }
.confetti-layer i {
  position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 2px;
  animation-name: confettiFall; animation-timing-function: cubic-bezier(.3, .6, .6, 1); animation-fill-mode: forwards;
}
@keyframes confettiFall {
  to { transform: translate(var(--dx), 105vh) rotate(var(--rot)); }
}
.praise-pop {
  position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 1101;
  display: flex; flex-direction: column; align-items: center; pointer-events: none;
  animation: praiseIn .5s cubic-bezier(.2, 1.6, .4, 1);
  transition: opacity .4s, transform .4s;
}
.praise-pop.out { opacity: 0; transform: translate(-50%, -70%); }
.praise-pop .pai { animation: bounce .6s ease-in-out infinite alternate; filter: drop-shadow(0 8px 14px rgba(0,0,0,.18)); }
.praise-text {
  font-family: var(--font-title); font-size: 44px; color: #fff; margin-top: 4px;
  -webkit-text-stroke: 8px var(--primary-d); paint-order: stroke fill; text-shadow: 0 6px 0 rgba(0,0,0,.12);
}
@keyframes praiseIn { from { transform: translate(-50%, -50%) scale(.3); opacity: 0; } }
@keyframes bounce { to { transform: translateY(-10px) rotate(-4deg); } }

/* 배지 모달 */
.badge-card h2 { font-size: 32px; color: var(--primary-d); margin-top: 6px; }
.badge-name { font-family: var(--font-title); font-size: 20px; margin: 0; }
.badge-shine { display: inline-block; animation: spinIn 1s cubic-bezier(.2, 1.3, .4, 1); position: relative; }
.badge-shine::before {
  content: ""; position: absolute; inset: -30px; z-index: -1;
  background: radial-gradient(circle, rgba(255, 214, 90, .7), transparent 65%);
  animation: glow 1.6s ease-in-out infinite alternate;
}
@keyframes spinIn { from { transform: rotate(-200deg) scale(.2); } }
@keyframes glow { to { transform: scale(1.15); opacity: .6; } }

/* 선생님 모드 표시 */
.teacher-flag {
  display: inline-flex; align-items: center; gap: 4px; background: #fff1c2; color: #7a5600;
  border: 1px solid #f3d26b; border-radius: 999px; padding: 2px 10px; font-size: 13px; font-family: var(--font-title);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ===== 코딩골드스쿨 로고 / 공통 상단 막대 ===== */
.gold-logo { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); }
.gold-text { display: flex; flex-direction: column; line-height: 1.05; }
.gold-text b { font-family: var(--font-title); font-weight: 400; font-size: 22px; letter-spacing: -.01em; }
.gold-text em, .gold-word {
  font-style: normal; background: linear-gradient(180deg, #f9d65c 0%, #e0a800 55%, #b07d00 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 1px 0 rgba(140, 95, 0, .25));
}
.gold-text small { font-family: var(--font); font-size: 10px; letter-spacing: .2em; color: var(--gold-d); font-weight: 700; margin-top: 2px; }
.gold-logo.big { flex-direction: column; gap: 8px; text-align: center; }
.gold-logo.big .gold-text { align-items: center; }
.gold-logo.big .gold-text b { font-size: 34px; }
.gold-logo.big .gold-text small { font-size: 11px; }

.school-bar {
  display: flex; align-items: center; gap: 12px; padding: 10px 28px; background: var(--paper);
  border-bottom: 3px solid var(--gold); box-shadow: 0 2px 10px rgba(0,0,0,.04);
}
.school-bar .spacer { flex: 1; }
.user-chip { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user-name { font-family: var(--font-title); font-size: 16px; white-space: nowrap; }
.user-name small { font-family: var(--font-code); color: var(--muted); font-size: 12px; }

.btn.gold-btn, .btn.yellow { background: linear-gradient(180deg, #ffd84d, #f5b800); border-color: var(--gold-d); color: #4a3300; box-shadow: 0 3px 0 var(--gold-d); }
.btn.gold-btn:hover, .btn.yellow:hover { background: linear-gradient(180deg, #ffe073, #f7c21a); }

.text-input { font-size: 18px; padding: 8px 12px; width: 100%; border-radius: 12px; border: 2px solid var(--line); font-family: var(--font); }
.text-input:focus { outline: none; border-color: var(--gold); }

/* ===== 로그인 화면 ===== */
.gate-page {
  min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background:
    radial-gradient(circle at 12% 18%, rgba(245, 197, 24, .22) 0 90px, transparent 91px),
    radial-gradient(circle at 88% 82%, rgba(245, 197, 24, .18) 0 130px, transparent 131px),
    radial-gradient(circle at 85% 12%, rgba(56, 196, 157, .14) 0 70px, transparent 71px),
    var(--bg);
}
.gate-card {
  width: 100%; max-width: 440px; background: var(--paper); border-radius: 28px; padding: 28px 30px 26px;
  box-shadow: var(--shadow-2); border-top: 6px solid var(--gold); text-align: center;
}
.gate-hello { display: flex; align-items: center; gap: 8px; text-align: left; margin: 14px 0 16px; background: var(--gold-l); border-radius: 16px; padding: 6px 14px 6px 6px; }
.gate-hello p { margin: 0; color: var(--ink-2); font-size: 15px; line-height: 1.45; }
.gate-tabs { display: flex; background: #f4efe3; border-radius: 14px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.gate-tab { flex: 1; border: 0; background: transparent; padding: 9px 6px; border-radius: 10px; font-family: var(--font-title); font-size: 16px; color: var(--muted); cursor: pointer; }
.gate-tab.on { background: var(--paper); color: var(--ink); box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.gate-form { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.gate-form label { display: flex; flex-direction: column; gap: 4px; font-family: var(--font-title); font-size: 15px; }
.gate-form label small { font-family: var(--font); font-size: 12px; color: var(--muted); }
.gate-form input {
  font-family: var(--font); font-size: 18px; padding: 10px 14px; border-radius: 12px; border: 2px solid var(--line); background: #fffdf8;
}
.gate-form input:focus { outline: none; border-color: var(--gold); background: #fff; }
.gate-form .btn { justify-content: center; font-size: 18px; padding: 11px; margin-top: 4px; }
.gate-err { color: var(--danger); min-height: 1.3em; margin: 0; font-size: 14px; }
.gate-err:empty { min-height: 0; }
.gate-note { font-size: 13px; margin: 2px 0 0; text-align: center; }
.gate-msg { text-align: left; }
.gate-card h2 { margin-top: 14px; }
@media (max-width: 480px) {
  .gate-card { padding: 22px 18px; }
  .school-bar { padding: 8px 16px; flex-wrap: wrap; }
  .gold-text b { font-size: 19px; }
}
.id-check { margin: -4px 0 0; font-size: 13px; min-height: 0; }
.id-check.ok { color: var(--ok); }
.id-check.no { color: var(--danger); }

/* ===== 핵심 정리 카드 (회차 화면 · 내 정리 노트) ===== */
.note-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin: 12px 0; }
.note-card { background: var(--paper); border: 1px solid var(--line); border-top: 5px solid var(--lesson-c, var(--gold)); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); break-inside: avoid; }
.note-name { font-family: var(--font-title); font-size: 19px; margin-bottom: 4px; }
.note-name code { font-family: var(--font-code); background: #f3efe6; border-radius: 6px; padding: 0 6px; font-size: 16px; }
.note-code { font-size: 14px !important; margin: 4px 0 6px !important; white-space: pre !important; }
.note-desc { font-size: 15px; color: var(--ink-2); line-height: 1.6; }
.note-warn { margin-top: 6px; font-size: 14px; background: #fff6ec; border-radius: 8px; padding: 4px 8px; color: #8a4b00; }
.note-one { background: var(--gold-l); border: 2px dashed var(--gold); border-radius: 14px; padding: 10px 16px; font-size: 16px; margin-top: 4px; }
