/* ===== 기본 색과 글꼴 ===== */
:root {
  --ink: #060a17;
  --ink-2: #0d1533;
  --line: rgba(130, 190, 255, 0.16);
  --text: #eef3ff;
  --dim: #9aa7c7;
  --teal: #3ee0c8;
  --violet: #7b5cff;
  --sans: "Noto Sans KR", system-ui, sans-serif;
  --serif: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --header-h: 76px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--ink);
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }

/* ===== 배경: 회로 기판 느낌의 격자 + 빛 ===== */
.hero, .stage {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  background:
    radial-gradient(60% 50% at 78% 38%, rgba(123, 92, 255, 0.32), transparent 70%),
    radial-gradient(45% 45% at 88% 78%, rgba(62, 224, 200, 0.2), transparent 70%),
    linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 100%);
}
.hero::before, .stage::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: linear-gradient(90deg, transparent 10%, #000 90%);
          mask-image: linear-gradient(90deg, transparent 10%, #000 90%);
  opacity: 0.55;
  pointer-events: none;
}

/* 배경의 큰 한자 (一 二 三 四 五) */
.mark {
  position: absolute;
  right: 4vw; top: 50%;
  transform: translateY(-50%);
  font-family: var(--serif);
  font-weight: 700;
  font-size: min(62vw, 78vh);
  line-height: 1;
  color: rgba(120, 170, 255, 0.09);
  -webkit-text-stroke: 1px rgba(120, 200, 255, 0.28);
  pointer-events: none;
  user-select: none;
}

/* ===== 헤더 ===== */
.site-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  z-index: 10;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: 24px;
  padding: 0 clamp(16px, 3vw, 40px);
  background: linear-gradient(180deg, rgba(6, 10, 23, 0.85), rgba(6, 10, 23, 0));
}
.logo { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.logo-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border: 1.5px solid var(--teal);
  border-radius: 8px;
  font-family: var(--serif); font-weight: 700; font-size: 20px;
  color: var(--teal);
}
.logo-text { font-weight: 700; font-size: 18px; letter-spacing: 0.02em; }

nav { display: flex; justify-self: center; max-width: 100%; gap: clamp(4px, 2vw, 32px); overflow-x: auto; scrollbar-width: none; }
nav::-webkit-scrollbar { display: none; }
nav a {
  padding: 10px 14px;
  font-weight: 500; font-size: 16px;
  white-space: nowrap;
  color: var(--text);
  border-bottom: 2px solid transparent;
  transition: border-color 0.2s, color 0.2s;
}
nav a:hover { color: var(--teal); }
nav a.on { border-bottom-color: var(--teal); color: var(--teal); }

/* ===== 홈 슬라이드 ===== */
.slide {
  position: absolute; inset: 0;
  display: flex; align-items: center;
  padding: var(--header-h) clamp(20px, 6vw, 96px) 0;
  opacity: 0; visibility: hidden;
  transition: opacity 0.7s ease, visibility 0.7s;
}
.slide.active { opacity: 1; visibility: visible; }
.slide-text { position: relative; max-width: 720px; }
.slide-text h1 {
  font-weight: 300;
  font-size: clamp(48px, 9vw, 120px);
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.slide-text p {
  margin-top: 28px;
  font-size: clamp(16px, 2vw, 22px);
  font-weight: 300;
  line-height: 1.7;
  color: var(--dim);
  max-width: 30em;
}
.cta {
  display: inline-block;
  margin-top: 40px;
  padding: 14px 32px;
  border: 1.5px solid var(--text);
  border-radius: 999px;
  font-weight: 500;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.cta:hover { background: var(--teal); border-color: var(--teal); color: var(--ink); }

/* ===== 이전 / 개수 / 다음 컨트롤 ===== */
.ctrl {
  position: absolute; left: clamp(20px, 6vw, 96px); bottom: 40px;
  display: flex; align-items: center; gap: 22px;
  z-index: 2;
}
.round {
  display: grid; place-items: center;
  width: 50px; height: 50px;
  border: 1.5px solid rgba(238, 243, 255, 0.7);
  border-radius: 50%;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.round:hover { background: var(--teal); border-color: var(--teal); color: var(--ink); }
.count { min-width: 64px; text-align: center; font-weight: 500; font-variant-numeric: tabular-nums; }
.pause { width: 28px; height: 28px; display: grid; place-items: center; }
.bars { display: flex; gap: 4px; }
.bars i { display: block; width: 3px; height: 14px; background: var(--text); }
.pause.paused .bars i:first-child { width: 0; background: none; border-left: 12px solid var(--text); border-top: 7px solid transparent; border-bottom: 7px solid transparent; height: 0; }
.pause.paused .bars i:last-child { display: none; }

/* ===== 급수 페이지 ===== */
.stage {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(var(--header-h) + 12px) 20px 120px;
}
.stage-head { position: relative; text-align: center; margin-bottom: 24px; }
.stage-head h1 { font-weight: 300; font-size: clamp(28px, 4vw, 44px); letter-spacing: -0.01em; }
.stage-head p { margin-top: 6px; font-size: 15px; color: var(--dim); }
.state { position: relative; color: var(--dim); text-align: center; line-height: 1.8; }

.card-zone { position: relative; width: min(680px, 100%); }
.card {
  padding: clamp(28px, 5vw, 48px);
  background: rgba(10, 18, 44, 0.72);
  border: 1px solid rgba(130, 190, 255, 0.28);
  border-radius: 20px;
  -webkit-backdrop-filter: blur(10px);
          backdrop-filter: blur(10px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}
.card.from-right { animation: inRight 0.35s ease; }
.card.from-left { animation: inLeft 0.35s ease; }
@keyframes inRight { from { opacity: 0; transform: translateX(48px); } to { opacity: 1; transform: none; } }
@keyframes inLeft { from { opacity: 0; transform: translateX(-48px); } to { opacity: 1; transform: none; } }

.hanzi {
  font-family: var(--serif); font-weight: 700;
  font-size: clamp(72px, 16vw, 128px);
  line-height: 1.1;
  text-align: center;
  letter-spacing: 0.04em;
}
.pinyin-row { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 8px; }
.pinyin { font-size: clamp(22px, 4vw, 30px); font-weight: 300; color: var(--teal); }

.speaker {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border: 1.5px solid rgba(238, 243, 255, 0.55);
  border-radius: 999px;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.speaker:hover, .speaker.playing { border-color: var(--teal); color: var(--teal); }
.pips { display: flex; gap: 5px; }
.pips i { width: 7px; height: 7px; border-radius: 50%; background: rgba(238, 243, 255, 0.25); transition: background 0.15s; }
.pips i.on { background: var(--teal); }

.info { margin-top: 32px; border-top: 1px solid var(--line); }
.info > div { display: grid; grid-template-columns: 76px 1fr; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.info dt { color: var(--dim); font-size: 14px; padding-top: 4px; }
.info dd { line-height: 1.7; font-size: 17px; }
.meaning { font-size: 22px; font-weight: 500; }
.example { font-family: var(--serif); font-size: 20px; }
mark { background: none; color: var(--teal); }

/* 아래쪽 진행 막대 */
.stage .ctrl { left: 50%; transform: translateX(-50%); bottom: 44px; }
.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(238, 243, 255, 0.1); }
.bar-fill { height: 100%; background: var(--teal); transition: width 0.3s ease; }

/* ===== 작은 화면 ===== */
@media (max-width: 720px) {
  :root { --header-h: 116px; }
  .site-header { grid-template-columns: 1fr auto; grid-template-areas: "logo user" "nav nav"; gap: 0 12px; }
  .logo { grid-area: logo; }
  .userbox { grid-area: user; }
  nav { grid-area: nav; justify-self: stretch; }
  nav a { padding: 8px 12px; font-size: 15px; }
  .mark { right: -6vw; }
  .info > div { grid-template-columns: 1fr; gap: 2px; }
  .row2 { grid-template-columns: 1fr; gap: 0; }
  .toolbar-r { width: 100%; }
  .ctrl { bottom: 28px; gap: 14px; }
  .stage .ctrl { bottom: 30px; }
}

/* ===== 헤더 오른쪽 (로그인 영역) ===== */
.userbox { display: flex; align-items: center; gap: 6px; justify-self: end; }
.ulink { padding: 8px 10px; font-size: 15px; color: var(--text); white-space: nowrap; }
.ulink:hover { color: var(--teal); }
.ubtn { padding: 8px 16px; font-size: 15px; font-weight: 500; border: 1.5px solid var(--text); border-radius: 999px; white-space: nowrap; transition: background 0.2s, color 0.2s, border-color 0.2s; }
.ubtn:hover { background: var(--teal); border-color: var(--teal); color: var(--ink); }
.uname { padding: 0 6px; font-size: 15px; color: var(--dim); white-space: nowrap; }

/* ===== 공통 버튼 / 입력칸 ===== */
.btn { padding: 12px 28px; border-radius: 999px; background: var(--teal); color: var(--ink); font-weight: 700; border: 1.5px solid var(--teal); transition: opacity 0.2s; }
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.ghost { background: none; color: var(--text); border-color: rgba(238, 243, 255, 0.55); }
.btn.small { padding: 8px 18px; font-size: 14px; }
.mini { padding: 6px 14px; font-size: 13px; border: 1px solid rgba(238, 243, 255, 0.5); border-radius: 999px; transition: background 0.2s, color 0.2s, border-color 0.2s; }
.mini:hover { border-color: var(--teal); color: var(--teal); }
.mini.danger:hover { border-color: #ff7b8a; color: #ff7b8a; }
.mini.add { margin-top: 12px; }
.linkbtn { color: var(--dim); text-decoration: underline; font-size: 14px; }
.linkbtn:hover { color: var(--teal); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; text-align: left; }
.field label { font-size: 14px; color: var(--dim); }
.field input, .field select {
  width: 100%; padding: 12px 14px;
  font: inherit; color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(130, 190, 255, 0.3);
  border-radius: 10px;
}
.field input:focus, .field select:focus { border-color: var(--teal); outline: none; }
.field select option { background: #0d1533; color: var(--text); }
.form-msg { min-height: 22px; margin-bottom: 8px; font-size: 14px; color: #ff8a97; text-align: left; }
.form-msg.ok { color: var(--teal); }
.notice { margin-bottom: 16px; padding: 12px 14px; font-size: 14px; line-height: 1.6; color: #ffd98a; border: 1px solid rgba(255, 217, 138, 0.4); border-radius: 10px; text-align: left; }

/* ===== 로그인 / 회원가입 카드 ===== */
.stage.auth { padding-bottom: 60px; }
.auth-card {
  position: relative; width: min(420px, 100%);
  padding: clamp(24px, 5vw, 40px);
  background: rgba(10, 18, 44, 0.78);
  border: 1px solid rgba(130, 190, 255, 0.28);
  border-radius: 20px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}
.auth-card h1 { font-weight: 300; font-size: 30px; margin-bottom: 24px; text-align: center; }
.auth-card .btn { width: 100%; padding: 14px; }
.auth-links { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px; font-size: 14px; color: var(--dim); }
.auth-links a { color: var(--teal); }

/* ===== 카드 위 수정/삭제 버튼 ===== */
.card { position: relative; }
.tools { position: absolute; top: 14px; right: 14px; display: flex; gap: 6px; }

/* ===== 팝업 ===== */
.modal-back { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(3, 6, 16, 0.75); overflow-y: auto; }
.modal { width: min(560px, 100%); padding: clamp(20px, 4vw, 32px); background: #0d1533; border: 1px solid rgba(130, 190, 255, 0.3); border-radius: 18px; }
.modal h2 { font-weight: 500; font-size: 22px; margin-bottom: 20px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ===== 알림 ===== */
#toast { position: fixed; left: 50%; bottom: 32px; z-index: 60; transform: translate(-50%, 20px); padding: 12px 22px; background: var(--teal); color: var(--ink); font-weight: 500; border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== 관리자 페이지 ===== */
.panel { min-height: 100vh; padding: calc(var(--header-h) + 24px) clamp(16px, 5vw, 64px) 60px; background: linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 100%); }
.panel-in { max-width: 1100px; margin: 0 auto; }
.panel-in.narrow { max-width: 560px; line-height: 1.8; }
.panel h1 { font-weight: 300; font-size: clamp(26px, 4vw, 36px); margin-bottom: 24px; }
.panel p { color: var(--dim); margin-bottom: 14px; }
.uid { padding: 12px 14px; font-family: Consolas, monospace; color: var(--teal) !important; background: rgba(255, 255, 255, 0.06); border-radius: 10px; word-break: break-all; user-select: all; }
.tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.tabs button { padding: 10px 18px; color: var(--dim); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--teal); border-bottom-color: var(--teal); }
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.toolbar-r { display: flex; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 7px 14px; font-size: 14px; border: 1px solid rgba(238, 243, 255, 0.35); border-radius: 999px; }
.chip.on { background: var(--teal); border-color: var(--teal); color: var(--ink); font-weight: 700; }
.tablewrap { overflow-x: auto; }
.sum { margin-bottom: 8px !important; font-size: 14px; }
.state-l { padding: 32px 0; color: var(--dim); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--dim); font-weight: 400; font-size: 13px; white-space: nowrap; }
td.zh { font-family: var(--serif); font-size: 17px; }
td.ex { max-width: 280px; }
td.act { white-space: nowrap; text-align: right; }
td.act .mini + .mini { margin-left: 6px; }

/* 움직임을 줄이고 싶은 사용자 설정 존중 */
@media (prefers-reduced-motion: reduce) {
  .slide { transition: none; }
  .card.from-right, .card.from-left { animation: none; }
}
