:root {
  color-scheme: light;
  --bg: #f5f6fb;
  --surface: #ffffff;
  --primary: #3b82f6;
  --primary-soft: #e3f2ff;
  --primary-ink: #1d4ed8;   /* 浅蓝底上的文字用色（对比度 ≥ 4.5:1） */
  --success: #22c55e;
  --success-soft: #dcfce7;
  --warn: #f59e0b;
  --warn-soft: #fef3c7;
  --danger: #ef4444;
  --outline: #e5e7eb;
  --text-main: #111827;
  --text-sub: #6b7280;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", "Noto Sans SC", system-ui, sans-serif;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-soft: 0 8px 20px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(circle at top, #e0f2fe 0, #f5f6fb 45%, #f9fafb 100%);
  color: var(--text-main);
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.container { max-width: 960px; margin: 0 auto; padding: 16px 14px 90px; }
/* 页脚声明（所有页面） */
.site-foot { max-width: 960px; margin: -60px auto 0; padding: 0 14px calc(var(--tabbar-h, 0px) + 24px); color: var(--text-sub); font-size: 12px; line-height: 1.6; text-align: center; }
.site-foot p { margin: 0 0 6px; }
.site-foot a { color: var(--text-sub); text-decoration: underline; text-underline-offset: 2px; }
.site-foot a:hover { color: var(--primary-ink); }
/* 鸣谢语学院：比声明更弱一号字；颜色仍用 --text-sub 以保持 WCAG AA 对比度 */
.thanks { margin: 0 0 10px; font-size: 11px; line-height: 1.7; }
.thanks .thanks-t { display: block; margin-bottom: 2px; letter-spacing: .02em; }
.thanks .thanks-n { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 0; }
.thanks .thanks-n span { white-space: nowrap; }
.thanks .thanks-n span:not(:last-child)::after { content: "·"; padding: 0 6px; }
/* /about 页 */
.about p { font-size: 15px; line-height: 1.8; color: #374151; margin: 0 0 14px; }
.about h2 { font-size: 17px; margin: 22px 0 8px; }

/* ---------- 顶部导航 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(245, 246, 251, 0.88);
  border-bottom: 1px solid rgba(229, 231, 235, 0.8);
}
.topbar-inner {
  max-width: 960px; margin: 0 auto; padding: 10px 14px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 17px; color: var(--text-main); display: flex; align-items: center; gap: 8px; }
.brand-badge {
  width: 26px; height: 26px; border-radius: 8px; color: #fff; font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #3b82f6, #22c55e);
}
.nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.nav a {
  padding: 6px 12px; border-radius: 999px; font-size: 13px; color: var(--text-sub);
}
.nav a.active { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }
.nav a.disabled { opacity: 0.45; pointer-events: none; }
.lang-sel {
  border: 1px solid var(--outline); border-radius: 999px; background: #fff; color: var(--text-sub);
  font-size: 12px; padding: 4px 8px; font-family: inherit; max-width: 150px;
}
.content-note { font-size: 12px; color: #92400e; background: var(--warn-soft); border-radius: 8px; padding: 6px 10px; display: inline-block; }
.content-note[hidden] { display: none; }
.share-btn {
  width: 30px; height: 30px; border-radius: 999px; border: 1px solid var(--outline); background: #fff; color: var(--text-sub);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
}
.share-btn:hover { color: var(--primary); border-color: var(--primary); }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px);
  background: rgba(17, 24, 39, 0.92); color: #fff; font-size: 13px; padding: 8px 14px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.kakao-card { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.kakao-card .kakao-btn {
  background: #FEE500; color: #191919; border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 600; font-size: 14px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; font-family: inherit;
}
/* 聊天软件内置浏览器：更紧凑的顶部导航 */
.in-app .topbar-inner { padding: 8px 12px; gap: 8px; }
.in-app .nav a { padding: 6px 9px; font-size: 12px; }

/* ---------- 通用 ---------- */
h1 { font-size: 22px; margin: 6px 0 4px; }
h2 { font-size: 16px; margin: 0; }
.sub { color: var(--text-sub); font-size: 13px; margin: 0 0 14px; }
.card {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft); padding: 14px 16px; margin-bottom: 14px;
}
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row[hidden] { display: none; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-sub); font-size: 12px; }

.btn {
  border: none; border-radius: 999px; padding: 8px 14px; font-size: 13px;
  background: #e5e7eb; color: #111827; transition: background .15s, transform .05s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: #2563eb; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--outline); }
.btn[disabled] { opacity: .5; cursor: default; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: thin; }
.chip {
  flex-shrink: 0; border: 1px solid var(--outline); background: #fff; color: var(--text-sub);
  border-radius: 999px; padding: 5px 12px; font-size: 12px; white-space: nowrap;
}
.chip.active { background: #2563eb; border-color: #2563eb; color: #fff; }
.chip small { margin-left: 3px; font-size: 11px; }

.seg { display: inline-flex; border: 1px solid var(--outline); border-radius: 999px; overflow: hidden; background: #fff; }
.seg button { border: none; background: transparent; padding: 6px 12px; font-size: 12px; color: var(--text-sub); }
.seg button.active { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }

input[type="search"], input[type="text"] {
  width: 100%; border: 1px solid var(--outline); border-radius: 999px; padding: 9px 14px;
  font-size: 14px; font-family: inherit; background: #fff; outline: none;
}
input[type="search"]:focus { border-color: var(--primary); }
input[type="range"] { accent-color: var(--primary); }

.progress { height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, #3b82f6, #22c55e); border-radius: 999px; transition: width .3s; }

/* ---------- 首页等级卡 ---------- */
.level-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.level-card { display: block; color: inherit; }
.level-card:hover { transform: translateY(-2px); }
.level-card .lv { font-size: 28px; font-weight: 800; color: var(--primary); }
.level-card .lv small { font-size: 13px; color: var(--text-sub); font-weight: 500; margin-left: 6px; }
.level-card p { margin: 6px 0 10px; font-size: 13px; color: var(--text-sub); }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.feature { padding: 12px; border-radius: var(--radius-md); background: #f9fafb; border: 1px solid var(--outline); font-size: 13px; }
.feature b { display: block; margin-bottom: 4px; }
.feature.soon { opacity: .55; }

/* ---------- 词卡 ---------- */
.word-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.word {
  position: relative; background: var(--surface); border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft); padding: 12px 12px 10px 14px; cursor: pointer;
  border: 2px solid transparent; transition: border-color .15s, background .15s;
  content-visibility: auto; contain-intrinsic-size: auto 150px;
}
.word:hover { background: #fbfdff; }
.word.playing { border-color: var(--primary); background: var(--primary-soft); }
.word.mastered { background: #f6fef9; }
.word .num { position: absolute; top: 8px; right: 10px; font-size: 10px; color: var(--text-sub); }
.word .ko { font-size: 20px; font-weight: 700; line-height: 1.25; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.word .pos { font-size: 10px; color: var(--primary-ink); background: var(--primary-soft); border-radius: 6px; padding: 1px 6px; font-weight: 600; }
.word .hanja { font-size: 12px; color: var(--text-sub); font-weight: 400; }
.word .zh { font-size: 14px; color: #374151; margin-top: 4px; }
.word .ex { margin-top: 6px; font-size: 12px; color: var(--text-sub); line-height: 1.45; border-top: 1px dashed var(--outline); padding-top: 6px; }
.word .ex b { font-weight: 500; color: #4b5563; }
.word .hint { font-size: 11px; color: var(--text-sub); margin-top: 4px; }
.word .acts { display: flex; gap: 4px; margin-top: 8px; }
.word .acts button {
  border: 1px solid var(--outline); background: #fff; border-radius: 8px; padding: 4px 9px; font-size: 12px; color: var(--text-sub);
}
.word .acts button.on-fav { background: var(--warn-soft); border-color: #fcd34d; color: #b45309; }
.word .acts button.on-mastered { background: var(--success-soft); border-color: #86efac; color: #15803d; }

/* 遮挡模式 */
.mask-zh .word:not(.revealed) .zh, .mask-zh .word:not(.revealed) .ex,
.mask-ko .word:not(.revealed) .ko, .mask-ko .word:not(.revealed) .ex, .mask-ko .word:not(.revealed) .hint {
  filter: blur(6px); user-select: none;
}

.empty { text-align: center; color: var(--text-sub); padding: 30px 0; font-size: 14px; }

/* ---------- 语法卡 ---------- */
.gram-list { display: flex; flex-direction: column; gap: 10px; }
.gram {
  position: relative; background: var(--surface); border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft); padding: 12px 14px 10px; cursor: pointer;
  border: 2px solid transparent; transition: border-color .15s, background .15s;
  content-visibility: auto; contain-intrinsic-size: auto 120px;
}
.gram:hover { background: #fbfdff; }
.gram.playing { border-color: var(--primary); background: var(--primary-soft); }
.gram.mastered { background: #f6fef9; }
.gram .num { position: absolute; top: 8px; right: 12px; font-size: 10px; color: var(--text-sub); }
.gram .g-head { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding-right: 22px; }
.gram .g-form { font-size: 19px; font-weight: 700; line-height: 1.3; color: var(--text-main); word-break: keep-all; }
.gram .g-meta { display: flex; align-items: center; gap: 6px; justify-self: end; }
.gram .g-cat { font-size: 10px; color: var(--primary-ink); background: var(--primary-soft); border-radius: 6px; padding: 1px 6px; font-weight: 600; white-space: nowrap; }
.gram .g-freq { font-size: 11px; color: var(--warn); letter-spacing: 1px; }
.gram .g-freq i { color: #e5e7eb; font-style: normal; }
.gram .g-meaning { grid-column: 1 / -1; font-size: 14px; color: #374151; }

.gram .g-body { display: none; margin-top: 8px; border-top: 1px dashed var(--outline); padding-top: 8px; font-size: 13px; line-height: 1.55; }
.gram.open .g-body { display: block; }
.gram .lbl {
  display: inline-block; font-size: 10px; font-weight: 700; color: var(--text-sub); background: #f3f4f6;
  border-radius: 5px; padding: 1px 6px; margin-right: 6px; vertical-align: 1px;
}
.gram .g-rule { color: #4b5563; }
.gram .g-ex { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.gram .g-ex li { display: flex; gap: 8px; align-items: flex-start; }
.gram .g-ex li b { display: block; font-weight: 500; color: var(--text-main); font-size: 14px; }
.gram .g-ex li span { display: block; color: var(--text-sub); font-size: 12px; }
.gram .ex-speak {
  flex-shrink: 0; border: 1px solid var(--outline); background: #fff; border-radius: 8px; padding: 2px 6px; font-size: 12px; line-height: 1.4;
}
.gram .g-cmp { margin-top: 8px; font-size: 12px; color: var(--text-sub); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.gram .cmp { border: 1px dashed #93c5fd; background: #eff6ff; color: #1d4ed8; border-radius: 999px; padding: 2px 9px; font-size: 12px; }
.gram .g-trap { margin-top: 8px; background: var(--warn-soft); color: #78350f; border-radius: 8px; padding: 6px 10px; }
.gram .g-trap .lbl { background: #fde68a; color: #78350f; }

.gram .acts { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.gram .acts button {
  border: 1px solid var(--outline); background: #fff; border-radius: 8px; padding: 4px 9px; font-size: 12px; color: var(--text-sub);
}
.gram .acts button.on-fav { background: var(--warn-soft); border-color: #fcd34d; color: #b45309; }
.gram .acts button.on-mastered { background: var(--success-soft); border-color: #86efac; color: #15803d; }

/* 语法遮挡模式：先看形式，点击再显示释义和详情 */
.mask-zh .gram:not(.revealed) .g-meaning,
.mask-zh .gram:not(.revealed) .g-body { filter: blur(6px); user-select: none; }

/* ---------- 题型攻略 / 真题 ---------- */
.tips { margin: 0; padding-left: 18px; font-size: 13px; color: #374151; line-height: 1.6; }
.tips li { margin: 2px 0; }
.qtype-list { display: flex; flex-direction: column; gap: 6px; }
.qtype { border: 1px solid var(--outline); border-radius: var(--radius-md); background: #fff; overflow: hidden; }
.qtype summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; font-size: 14px;
}
.qtype summary::-webkit-details-marker { display: none; }
.qtype summary::after { content: '▼'; margin-left: auto; font-size: 10px; color: #9ca3af; transition: transform .15s; }
.qtype[open] summary::after { transform: rotate(180deg); }
.qtype[open] summary { background: #f9fafb; border-bottom: 1px dashed var(--outline); }
.qtype .qno { font-weight: 700; color: var(--primary-ink); background: var(--primary-soft); border-radius: 6px; padding: 1px 8px; font-size: 12px; white-space: nowrap; }
.qtype .qtitle { font-weight: 600; }
.qtype .qlv { font-size: 10px; border-radius: 6px; padding: 1px 6px; font-weight: 600; color: #fff; background: #6b7280; }
.qtype .qlv.lv1 { background: #15803d; } .qtype .qlv.lv2 { background: #1d4ed8; } .qtype .qlv.lv3 { background: #b45309; } .qtype .qlv.lv4 { background: #b91c1c; }
.qtype .qscore { font-size: 11px; }
.qtype .qbody { padding: 10px 12px 12px; font-size: 13px; line-height: 1.6; color: #374151; }
.qtype .qbody p { margin: 0 0 6px; }
.qtype .qstrat { background: var(--warn-soft); color: #78350f; border-radius: 8px; padding: 6px 10px; }
.qtype .qstrat .lbl { background: #fde68a; color: #78350f; }
.qtype .lbl {
  display: inline-block; font-size: 10px; font-weight: 700; color: var(--text-sub); background: #f3f4f6;
  border-radius: 5px; padding: 1px 6px; margin-right: 6px; vertical-align: 1px;
}
.qtype .qgram { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.qtype .cmp { border: 1px dashed #93c5fd; background: #eff6ff; color: #1d4ed8; border-radius: 999px; padding: 2px 9px; font-size: 12px; }

.round h2 small { font-weight: 500; font-size: 12px; margin-left: 6px; }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.file { display: flex; align-items: center; gap: 10px; border: 1px solid var(--outline); border-radius: var(--radius-md); padding: 8px 10px; background: #fff; }
.file .ficon { font-size: 20px; flex-shrink: 0; }
.file .fmeta { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 13px; }
.file .fmeta span { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .facts { display: flex; gap: 4px; flex-shrink: 0; }
.file .facts .btn { padding: 5px 10px; font-size: 12px; }
body:not(.has-audio) #audioBar { display: none; }

/* ---------- 练习 ---------- */
.mode-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.mode {
  text-align: left; border: 2px solid var(--outline); background: #fff; border-radius: var(--radius-md);
  padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; color: var(--text-main); transition: border-color .15s, background .15s;
}
.mode b { font-size: 14px; }
.mode span { font-size: 12px; color: #4b5563; line-height: 1.4; }
.mode.active { border-color: var(--primary); background: var(--primary-soft); }
.lbl-w { min-width: 56px; }
.sel { border: 1px solid var(--outline); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-family: inherit; background: #fff; }
.seg button small { opacity: .7; }

.wrong-list { display: flex; flex-direction: column; gap: 4px; max-height: 360px; overflow-y: auto; }
.witem { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: #f9fafb; font-size: 13px; }
.witem .wtext { flex: 1; min-width: 0; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.witem .wtext b { font-size: 14px; }
.witem .wtext span { color: var(--text-sub); font-size: 12px; }
.witem .wspeak, .witem .wdel { border: 1px solid var(--outline); background: #fff; border-radius: 6px; padding: 2px 7px; font-size: 12px; color: var(--text-sub); }
.witem .wbadge { font-size: 11px; color: #b45309; background: var(--warn-soft); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.witem .mark { font-weight: 700; width: 16px; text-align: center; }
.witem.ok .mark { color: #15803d; } .witem.bad .mark { color: var(--danger); }
.witem.bad { background: #fef2f2; }

.heat { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; margin-top: 10px; }
.heat .hd { aspect-ratio: 1; border-radius: 6px; background: #f3f4f6; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #4b5563; }
.heat .hd.l1 { background: #bbf7d0; color: #14532d; } .heat .hd.l2 { background: #86efac; color: #14532d; }
.heat .hd.l3 { background: #4ade80; color: #14532d; } .heat .hd.l4 { background: #15803d; color: #fff; }

.qcard { min-height: 320px; display: flex; flex-direction: column; gap: 12px; cursor: default; }
.qcard .qtop { display: flex; gap: 6px; align-items: center; min-height: 20px; }
.qcard .pos { font-size: 10px; color: var(--primary-ink); background: var(--primary-soft); border-radius: 6px; padding: 1px 6px; font-weight: 600; }
.qcard .hanja { font-size: 12px; color: var(--text-sub); }
.qcard .wtag { font-size: 10px; color: #b45309; background: var(--warn-soft); border-radius: 6px; padding: 1px 6px; }
.qcard .qmain { text-align: center; padding: 18px 0 6px; }
.qcard .big { font-size: 36px; font-weight: 700; line-height: 1.3; word-break: keep-all; }
.qcard .big.zh { font-size: 26px; }
.qcard .qsub { text-align: center; font-size: 14px; }
.qcard .hint-box { display: inline-block; background: var(--warn-soft); color: #78350f; border-radius: 8px; padding: 6px 12px; font-size: 13px; }
.qopts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.opt {
  position: relative; text-align: left; border: 2px solid var(--outline); background: #fff; border-radius: var(--radius-md);
  padding: 12px 12px 12px 40px; font-size: 16px; color: var(--text-main); min-height: 52px; transition: border-color .15s, background .15s;
}
.opt:hover:not([disabled]) { border-color: #93c5fd; background: #fbfdff; }
.opt .key { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; border-radius: 6px; background: #f3f4f6; color: #6b7280; font-size: 11px; display: flex; align-items: center; justify-content: center; }
.opt[disabled] { cursor: default; opacity: .8; }
.opt.right { border-color: var(--success); background: var(--success-soft); opacity: 1; }
.opt.right .key { background: var(--success); color: #fff; }
.opt.wrong { border-color: var(--danger); background: #fef2f2; opacity: 1; }
.opt.wrong .key { background: var(--danger); color: #fff; }
.qinput { display: flex; gap: 8px; max-width: 460px; margin: 0 auto; width: 100%; }
.qinput[hidden], .qfeedback[hidden] { display: none; }
.qinput input { flex: 1; border: 2px solid var(--outline); border-radius: 999px; padding: 10px 16px; font-size: 18px; font-family: inherit; outline: none; text-align: center; }
.qinput input:focus { border-color: var(--primary); }
.qfeedback { border-radius: var(--radius-md); padding: 12px 14px; font-size: 14px; line-height: 1.6; }
.qfeedback.ok { background: var(--success-soft); } .qfeedback.bad { background: #fef2f2; }
.qfeedback .fbhead { font-weight: 700; margin-bottom: 4px; }
.qfeedback.ok .fbhead { color: #15803d; } .qfeedback.bad .fbhead { color: var(--danger); }
.qfeedback .ans b { font-size: 18px; } .qfeedback .ans i { color: var(--text-sub); font-style: normal; font-size: 12px; }
.qfeedback .ex { margin-top: 4px; font-size: 13px; }
.qfeedback .ex b { display: block; font-weight: 500; } .qfeedback .ex span { display: block; color: var(--text-sub); font-size: 12px; }
.qfeedback .trap { margin-top: 6px; font-size: 12px; color: #78350f; }
.qsub .ans b { font-size: 22px; } .qsub .ex { margin-top: 6px; font-size: 13px; text-align: left; display: inline-block; }
.qsub .ex b { display: block; font-weight: 500; } .qsub .ex span { display: block; color: var(--text-sub); font-size: 12px; }
.qacts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: auto; }
.qacts .on-fav { background: var(--warn-soft); color: #b45309; }
.qacts .on-mastered { background: var(--success-soft); color: #15803d; }
.score-big { font-size: 56px; font-weight: 800; color: var(--primary); line-height: 1.1; }

/* ---------- 写字练习 ---------- */
.write-page .chips { flex-wrap: wrap; overflow: visible; }
.write-card { display: grid; grid-template-columns: 200px 1fr; gap: 20px; align-items: start; }
@media (max-width: 640px) { .write-card { grid-template-columns: 1fr; } .write-info { flex-direction: row !important; flex-wrap: wrap; align-items: center !important; } .write-info .wchar { font-size: 48px !important; } }
.write-info { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.write-info .wchar { font-size: 84px; font-weight: 700; line-height: 1; color: var(--text-main); }
.write-info .wname { font-size: 18px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.write-info .jpart { background: var(--primary-soft); color: var(--primary-ink); border-radius: 6px; padding: 0 6px; }
.write-info .plus { color: #9ca3af; font-weight: 400; }
.write-info .wrom { font-size: 13px; color: var(--text-sub); font-family: ui-monospace, monospace; }
.write-info .wzh { font-size: 13px; color: var(--text-sub); line-height: 1.5; }
.write-info .wword { font-size: 24px; letter-spacing: 2px; color: var(--text-sub); }
.write-info .wword .on { color: var(--primary); font-weight: 700; text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 4px; }
.write-board { display: flex; flex-direction: column; align-items: center; }
.scroll-hint { display: none; font-size: 12px; color: var(--text-sub); margin-top: 6px; }
@media (max-width: 720px) and (pointer: coarse) { .scroll-hint { display: block; } }
.canvas-wrap { position: relative; width: 100%; max-width: 640px; }
.canvas-wrap canvas {
  display: block; margin: 0 auto; border: 2px solid var(--outline); border-radius: 16px; background: #fff;
  touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
/* 书写中：锁住页面滚动 / 下拉刷新，避免笔画被当成滑屏 */
.write-page { overscroll-behavior: none; }
html.writing, html.writing body { overflow: hidden; touch-action: none; overscroll-behavior: none; }
.write-info .wchar.veil { filter: blur(9px); user-select: none; -webkit-user-select: none; transition: filter .3s; }
.write-info .wex { font-size: 13px; color: var(--text-sub); line-height: 1.5; }
.write-info .wex .ko { color: var(--text-main); font-weight: 600; }
.write-info .wword .done { color: var(--text-main); }
.vocab-row { flex-wrap: wrap; margin-top: 8px; }
.vocab-row .sel { max-width: 180px; }
.cg.word { font-size: 17px; padding: 9px 4px; }
.char-grid.words { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
.cg.veil { color: var(--text-sub); font-size: 14px; font-family: ui-monospace, monospace; }
.canvas-wrap.shake { animation: shake .4s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
.canvas-wrap .toast {
  position: absolute; left: 50%; top: 12px; bottom: auto; transform: translateX(-50%); padding: 6px 14px; border-radius: 999px; opacity: 1;
  background: #1f2937; color: #fff; font-size: 14px; font-weight: 600; pointer-events: none; white-space: nowrap; animation: pop .2s;
}
.canvas-wrap .toast[hidden] { display: none; }
.canvas-wrap .toast.ok { background: #16a34a; } .canvas-wrap .toast.bad { background: var(--danger); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translate(-50%, 0); } }
.stroke-dots { display: flex; gap: 6px; margin-top: 10px; min-height: 10px; }
.stroke-dots i { width: 10px; height: 10px; border-radius: 50%; background: #e5e7eb; }
.stroke-dots i.cur { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.stroke-dots i.done { background: #1f2937; }
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; }
.cg { position: relative; border: 1px solid var(--outline); background: #fff; border-radius: 10px; font-size: 22px; padding: 8px 0; color: var(--text-main); }
.cg.done { background: var(--success-soft); border-color: #86efac; }
.cg.cur { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.cg small { position: absolute; right: 4px; top: 2px; font-size: 9px; color: #15803d; }

/* ---------- 底部播放条 ---------- */
.playbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(255, 255, 255, 0.96); border-top: 1px solid var(--outline);
  box-shadow: 0 -6px 20px rgba(15, 23, 42, 0.06);
}
.playbar-inner { max-width: 960px; margin: 0 auto; padding: 10px 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.playbar .now { flex: 1; min-width: 120px; font-size: 13px; color: var(--text-sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.playbar .now b { color: var(--text-main); font-size: 14px; }

.tts-warn { background: var(--warn-soft); color: #92400e; padding: 8px 12px; border-radius: var(--radius-md); font-size: 12px; margin-bottom: 12px; }

@media (max-width: 520px) {
  .container { padding: 12px 10px 110px; }
  .word-list { grid-template-columns: 1fr; }
  h1 { font-size: 20px; }
}

/* ---------- 账号（Kakao 登录 / 云同步） ---------- */
.acct { display: inline-flex; align-items: center; }
.kakao-login-btn {
  display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px; border: 0; border-radius: 999px;
  background: #FEE500; color: #191919; font-size: 12px; font-weight: 600; font-family: inherit; white-space: nowrap;
}
.kakao-login-btn:active { transform: scale(.97); }
.avatar-btn {
  position: relative; width: 30px; height: 30px; padding: 0; border: 1px solid var(--outline); border-radius: 999px; overflow: visible;
  background: linear-gradient(135deg, #3b82f6, #22c55e); color: #fff; font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; justify-content: center;
}
.avatar-btn img { width: 100%; height: 100%; border-radius: 999px; object-fit: cover; display: block; }
.avatar-btn .sync-dot {
  position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border-radius: 999px; border: 2px solid #fff; background: var(--success);
}
.avatar-btn .sync-dot.dirty { background: var(--warn); }
.card-close {
  position: absolute; top: 6px; right: 8px; width: 28px; height: 28px; border: 0; background: transparent; color: #9ca3af; font-size: 20px; line-height: 1; border-radius: 999px;
}
.card-close:hover { background: #f3f4f6; color: var(--text-main); }
.kakao-card { position: relative; }
.kakao-card[hidden] { display: none; }

/* 底部弹层（账号面板） */
.sheet-mask {
  position: fixed; inset: 0; z-index: 60; background: rgba(17, 24, 39, 0); display: flex; align-items: flex-end; justify-content: center;
  transition: background .22s;
}
.sheet-mask.show { background: rgba(17, 24, 39, .45); }
.sheet {
  width: 100%; max-width: 520px; background: #fff; border-radius: 22px 22px 0 0; padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(15, 23, 42, .18); transform: translateY(100%); transition: transform .26s cubic-bezier(.2,.8,.2,1);
}
.sheet-mask.show .sheet { transform: translateY(0); }
@media (min-width: 640px) {
  .sheet-mask { align-items: center; }
  .sheet { border-radius: 22px; padding-bottom: 18px; transform: translateY(16px) scale(.98); opacity: 0; transition: transform .2s, opacity .2s; }
  .sheet-mask.show .sheet { transform: none; opacity: 1; }
  .sheet-grip { display: none; }
}
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: #e5e7eb; margin: 4px auto 14px; }
.acct-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.acct-avatar { width: 48px; height: 48px; border-radius: 999px; object-fit: cover; }
.acct-initial { display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #3b82f6, #22c55e); color: #fff; font-weight: 700; font-size: 20px; }
.acct-head b { font-size: 16px; }
.acct-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.acct-stats > div { background: #f9fafb; border-radius: 12px; padding: 10px 6px; text-align: center; }
.acct-stats b { display: block; font-size: 20px; color: var(--primary); }
.acct-stats span { font-size: 11px; color: var(--text-sub); }
.acct-sync { margin-bottom: 14px; }
.sheet-acts { display: flex; flex-direction: column; gap: 8px; }
.sheet-acts .btn { padding: 12px; font-size: 14px; border-radius: 12px; }
.sheet-acts .danger { color: var(--danger); }

/* 卡톡内登录门禁 */
.login-gate {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(circle at top, #e0f2fe 0, #f5f6fb 45%, #f9fafb 100%);
}
.gate-box { text-align: center; max-width: 320px; animation: page-in .25s ease-out both; }
.gate-box img { border-radius: 20px; box-shadow: var(--shadow-soft); }
.gate-box h2 { font-size: 20px; margin: 16px 0 8px; }
.gate-box p { font-size: 14px; line-height: 1.6; margin: 0 0 22px; }
.gate-box .kakao-btn {
  width: 100%; justify-content: center; background: #FEE500; color: #191919; border: 0; border-radius: 12px; padding: 14px 16px;
  font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; gap: 8px; font-family: inherit;
}
html.gated body { overflow: hidden; }
/* 界面字典就绪前隐藏正文（非简体用户），由 i18n.js 移除；<head> 内联脚本兜底 1.5s 后自动移除 */
html.i18n-wait body > *:not(script) { visibility: hidden; }

/* ---------- App 外壳：底部 Tab 栏 / 安装 / 触控 ---------- */
:root { --tabbar-h: 0px; }
.tabbar { display: none; }
.install-card img { flex-shrink: 0; }
.install-card .install-desc { margin-top: 2px; }
main.container { animation: page-in .22s ease-out both; }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@view-transition { navigation: auto; }
.topbar { view-transition-name: topbar; }
.tabbar { view-transition-name: tabbar; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .18s; }
@media (prefers-reduced-motion: reduce) {
  main.container { animation: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}
button, .chip, .opt, .mode, .tabbar a, .nav a, .cg { -webkit-touch-callout: none; user-select: none; touch-action: manipulation; }
img { -webkit-user-drag: none; }
html.standalone body { overscroll-behavior-y: none; }
html.standalone .topbar { padding-top: env(safe-area-inset-top); }

@media (max-width: 720px) {
  :root { --tabbar-h: calc(58px + env(safe-area-inset-bottom)); }
  .nav { display: none; }
  .topbar-inner { flex-wrap: nowrap; }
  .brand { margin-right: auto; }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: var(--tabbar-h);
    display: flex; justify-content: space-around; align-items: stretch; padding: 0 4px env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, .94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid rgba(229, 231, 235, .9);
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--text-sub); font-size: 10.5px; font-weight: 500; letter-spacing: .1px; text-decoration: none; border-radius: 12px; padding: 4px 0; min-width: 0;
    transition: color .15s, transform .1s;
  }
  .tabbar a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar a:active { transform: scale(.92); }
  .tabbar svg { width: 24px; height: 24px; }
  .tabbar a.active { color: var(--primary-ink); font-weight: 700; }
  .tabbar a.active svg { stroke-width: 2.4; }
  .container { padding-bottom: calc(var(--tabbar-h) + 16px); }
  .playbar { bottom: var(--tabbar-h); box-shadow: none; }
  body:has(.playbar:not([hidden])) .container { padding-bottom: calc(var(--tabbar-h) + 90px); }
  .toast { bottom: calc(var(--tabbar-h) + 16px); }
  .sheet-mask .toast { bottom: 24px; }
  /* 更大的触控目标、避免 iOS 输入框聚焦放大 */
  .btn { padding: 10px 16px; font-size: 14px; }
  .chip { padding: 8px 14px; font-size: 13px; }
  .seg button { padding: 9px 13px; font-size: 13px; }
  .word .acts button, .gram .acts button { padding: 7px 11px; font-size: 13px; }
  input[type="search"], input[type="text"], .sel, .lang-sel { font-size: 16px; }
  .lang-sel { padding: 4px 6px; max-width: 110px; }
  .in-app .lang-sel { max-width: 90px; }
  .qopts { grid-template-columns: 1fr; }
  .opt { min-height: 56px; }
  .card { border-radius: 16px; padding: 14px; }
}
@media (max-width: 420px) {
  .kakao-login-btn { width: 30px; padding: 0; justify-content: center; }
  .kakao-login-btn span { display: none; }
  .brand-badge { display: none; }
}
