:root {
  --green-950: #0c3d2c;
  --green-800: #146c43;
  --green-700: #187a4b;
  --green-100: #e7f6ec;
  --green-50: #f4fbf6;
  --yellow-500: #f5c518;
  --yellow-300: #ffe56a;
  --yellow-100: #fff6cc;
  --ink: #143028;
  --muted: #5d7468;
  --line: #d5eadc;
  --white: #ffffff;
  --danger: #c44747;
  --shadow: 0 10px 28px rgba(16, 70, 40, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font-family: "Be Vietnam Pro", "Segoe UI", sans-serif;
  background:
    radial-gradient(900px 420px at 0% -10%, #ffe7a3 0%, transparent 55%),
    radial-gradient(800px 480px at 100% 0%, #bfe8cf 0%, transparent 50%),
    #e7f6ec;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; opacity: 0.48; }
button:focus-visible, .key:focus-visible, .ko-box:focus-visible {
  outline: 3px solid var(--yellow-500);
  outline-offset: 2px;
}

.stage { min-height: 100dvh; display: flex; justify-content: center; }
.phone {
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--green-50);
  position: relative;
  overflow: hidden;
}
.top, .tabs, .keyboard-slot { flex: none; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 14px;
  background: linear-gradient(155deg, #0e5c38 0%, #1b8a4e 68%, #147a45 100%);
  color: white;
}
.brand { display: flex; gap: 10px; align-items: center; min-width: 0; border: 0; background: transparent; color: inherit; text-align: left; padding: 0; }
.brand h1 { margin: 0; font-size: 18px; line-height: 1.15; letter-spacing: -0.02em; }
.tagline { margin: 2px 0 0; font-size: 12px; opacity: 0.86; }
.mark {
  width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--yellow-500); color: var(--green-950);
  font-family: "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-weight: 900; font-size: 24px; flex: none;
}
.count-pill {
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

main {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px 14px 18px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -0.03em; }
h3 { margin: 0; }
.lead, .muted, .tiny, .stat-line { color: var(--muted); }
.lead { margin: 0 0 12px; font-size: 13.5px; line-height: 1.45; }
.tiny { font-size: 12px; }
.stat-line { margin: 10px 0; font-size: 12px; font-weight: 600; }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.zh, .hero-zh { font-family: "Noto Sans SC", "Noto Sans KR", sans-serif; }
.hero-zh { font-size: clamp(32px, 9vw, 44px); font-weight: 700; line-height: 1.3; }
.ko, .hero-ko, .glyph, .big-char, .block-preview, .tab-glyph, .sys-input, .ko-input, .ko-box {
  font-family: "Noto Sans KR", "Malgun Gothic", sans-serif;
  word-break: keep-all;
}
.hero-ko, .hero-vi, .copyable { user-select: text; }

.welcome, .note {
  background: var(--yellow-100);
  border: 1px solid #f0d56a;
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.45;
}
.welcome p { margin: 0 0 10px; }
.notice-card { margin-top: 16px; }
.notice-card strong { display: block; margin-bottom: 6px; }
.notice-card p { margin: 0 0 10px; }

.search, textarea, .text-input, .sys-input {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--white);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
}
.search { margin-bottom: 10px; }
textarea { min-height: 84px; resize: vertical; }
.search:focus, textarea:focus, .text-input:focus, .sys-input:focus {
  border-color: var(--green-700);
  box-shadow: 0 0 0 4px rgba(20, 108, 67, 0.12);
}
.ko-input { font-size: 22px; min-height: 96px; font-weight: 700; }

.chips, .demo-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.chip {
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
}
.chip.on { background: var(--green-800); border-color: var(--green-800); color: white; }

.btn {
  border: 0;
  border-radius: 14px;
  min-height: 48px;
  padding: 0 14px;
  font-weight: 800;
  font-size: 15px;
}
.btn.block { width: 100%; }
.btn.primary {
  background: linear-gradient(#ffe56a, #f5c518);
  color: #14532d;
  box-shadow: 0 4px 0 #d4a60a;
}
.btn.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #d4a60a; }
.btn.green { background: var(--green-800); color: white; }
.btn.ghost { background: var(--white); color: var(--green-800); border: 1.5px solid var(--line); }
.btn.danger { background: var(--danger); color: white; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }
.linkish {
  border: 0;
  background: transparent;
  color: var(--green-800);
  font-weight: 700;
  font-size: 13px;
  padding: 0;
}
.row-end { display: flex; justify-content: flex-end; margin-top: 6px; }

.flip { perspective: 900px; margin-bottom: 10px; }
.flip-inner {
  position: relative;
  min-height: 268px;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(.2, .7, .2, 1);
}
.flip.on .flip-inner { transform: rotateY(180deg); }
.face {
  cursor: pointer;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 16px 14px;
  border-radius: 22px;
  background: white;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: auto;
  transform: rotateY(0deg);
}
.face.front {
  background:
    radial-gradient(140px 90px at 100% 0%, #fff3c4 0%, transparent 70%),
    white;
}
.face.front::before {
  content: "";
  position: absolute;
  left: 18px; right: 18px; top: 0; height: 4px;
  border-radius: 0 0 6px 6px;
  background: var(--yellow-500);
}
.face.back {
  transform: rotateY(180deg);
  background: linear-gradient(180deg, #fffdf6, #fff);
}
.flip:not(.on) .face.back, .flip.on .face.front { pointer-events: none; }
.face-body { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 8px; }
.face-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hero-ko { font-size: clamp(28px, 8vw, 40px); font-weight: 700; line-height: 1.35; }
.pron {
  color: var(--green-800);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.35;
  margin-top: 4px;
}
.item .pron, .review .pron, .opt .pron, .feedback .pron { font-size: 12px; margin-top: 2px; }
.hero-vi { font-size: clamp(22px, 6vw, 30px); font-weight: 800; line-height: 1.35; }

.kind-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--green-800);
  background: var(--green-100);
  border-radius: 999px;
  padding: 3px 7px;
}
.item {
  width: 100%;
  display: flex;
  gap: 8px;
  align-items: center;
  text-align: left;
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 11px 12px;
  margin-bottom: 8px;
}
button.item { color: inherit; }
.item.current { border-color: #e4b40a; box-shadow: inset 0 0 0 1px var(--yellow-500); }
.item .body { flex: 1; min-width: 0; }
.item .kind-tag, .item .ko, .item .vi { display: block; }
.item .ko { font-size: 17px; font-weight: 700; margin-top: 3px; }
.item .vi { color: var(--muted); font-size: 13px; margin-top: 2px; }
.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.list-title { margin: 14px 0 8px; font-size: 13px; color: var(--muted); }
.row-actions { display: flex; flex-direction: column; gap: 6px; }
.mini {
  border: 0;
  background: var(--green-100);
  color: var(--green-800);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 800;
}
.mini.danger { background: #fdecec; color: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 18px 8px 8px; }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }

.field { display: block; margin-bottom: 12px; }
.label { display: block; font-size: 13px; font-weight: 800; margin-bottom: 6px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.label-row .label { margin: 0; }
.ko-box {
  width: 100%;
  min-height: 92px;
  border-radius: 16px;
  background: white;
  border: 1.5px dashed #b7d8c4;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
  font-size: 28px;
  font-weight: 700;
}
.ko-box:focus { border-style: solid; border-color: var(--yellow-500); outline: none; }
.tool-row { display: flex; justify-content: space-between; gap: 8px; margin: 14px 0; }

.hero-action, .prompt-card, .mode-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.hero-action, .prompt-card { padding: 14px; margin-bottom: 12px; }
.mode-card {
  width: 100%;
  text-align: left;
  padding: 14px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
a.mode-card { text-decoration: none; color: inherit; }
.mode-card strong { font-size: 16px; }
.mode-card span { color: var(--muted); font-size: 13px; line-height: 1.4; font-weight: 500; }
.mode-card em { font-style: normal; color: var(--green-800); font-weight: 800; font-size: 13px; margin-top: 4px; }
.google-slot { display: flex; justify-content: center; margin: 16px 0 8px; min-height: 44px; }
.course-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 12px 0 16px; }
.course-card {
  display: flex; gap: 12px; align-items: center;
  width: 100%; text-align: left;
  border: 1.5px solid var(--line); background: var(--white);
  border-radius: 18px; padding: 14px;
  box-shadow: var(--shadow);
}
.course-card .mark { width: 52px; height: 52px; }
.course-card.zh .mark { background: #c4232b; color: #fff6cc; font-family: "Noto Sans SC", sans-serif; }
.course-card.ko .mark { background: var(--yellow-500); color: var(--green-950); }
.course-card.en .mark { background: #1d4e89; color: #fff6cc; }
.hanzi-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hanzi-board {
  position: relative;
  flex: none;
  width: min(100%, 280px);
  aspect-ratio: 1;
  margin: 0 auto;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
}
.hanzi-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    linear-gradient(to right, transparent calc(50% - 0.5px), #e7cfd0 calc(50% - 0.5px), #e7cfd0 calc(50% + 0.5px), transparent calc(50% + 0.5px)),
    linear-gradient(to bottom, transparent calc(50% - 0.5px), #e7cfd0 calc(50% - 0.5px), #e7cfd0 calc(50% + 0.5px), transparent calc(50% + 0.5px)),
    repeating-linear-gradient(-45deg, transparent, transparent 10px, rgba(196, 35, 43, 0.05) 10px, rgba(196, 35, 43, 0.05) 11px);
}
#hanziBox {
  position: absolute;
  inset: 0;
  z-index: 2;
}
#hanziBox svg { display: block; overflow: visible; }
.char-row { display: flex; flex-wrap: nowrap; gap: 6px; margin: 4px 0; overflow: auto; }
.char-cell {
  width: 36px; height: 36px;
  border: 1.5px solid var(--line);
  background: var(--white);
  border-radius: 10px;
  font-family: "Noto Sans SC", sans-serif;
  font-size: 18px; font-weight: 700;
  flex: none;
}
.write-fit {
  display: flex;
  flex-direction: column;
  overflow: hidden !important;
  padding: 8px 12px 8px !important;
  min-height: 0;
  gap: 4px;
}
.write-fit .write-head { flex: none; }
.write-fit .write-tools { flex: none; }
.write-fit .hero-zh { font-size: 22px; margin: 0; line-height: 1.2; }
.write-fit .stat-line, .write-fit .tiny { margin: 0; }
.write-fit .btn { min-height: 40px; }
.write-fit .btn-row { gap: 6px; }
.pinyin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; }
.tone-card { text-align: center; padding: 10px 8px; }
.tone-card .big-char { font-size: 56px; margin: 4px 0; }
.char-cell.on { border-color: #c4232b; background: #fff1f1; color: #8e1524; }

.progress { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.bar { flex: 1; height: 8px; background: #e1f0e6; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--green-800), var(--yellow-500)); border-radius: inherit; }
.progress-label { font-size: 12px; font-weight: 800; color: var(--green-800); white-space: nowrap; }
.q-kicker { margin: 0; font-size: 12px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--green-800); }
.prompt-card { text-align: center; }
.prompt-card .hero-ko, .prompt-card .hero-vi { margin: 10px 0; }
.big-char { font-size: 84px; font-weight: 800; line-height: 1; margin: 6px 0; }
.big-roman { font-size: 42px; font-weight: 800; color: var(--green-800); line-height: 1.1; margin: 8px 0; }
.hint-line { margin: 0; font-weight: 700; }

.opts { display: flex; flex-direction: column; gap: 8px; }
.opt {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: white;
  border: 2px solid var(--line);
  border-radius: 16px;
  min-height: 58px;
  padding: 10px 12px;
  font-weight: 600;
}
.opt:active { border-color: var(--yellow-500); }
.opt:disabled { opacity: 1; }
.opt .badge {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--yellow-100);
  color: #8a6a00;
  font-weight: 800;
}
.opt-text { font-size: 15px; line-height: 1.35; }
.opt.correct { border-color: var(--green-800); background: #e8f8ee; }
.opt.wrong { border-color: #e08a8a; background: #fff2f2; }
.opt.correct .badge { background: var(--green-800); color: white; }
.opt.wrong .badge { background: var(--danger); color: white; }

.feedback { border-radius: 14px; padding: 12px; margin: 10px 0; font-weight: 700; text-align: left; }
.feedback.ok { background: #e5f8ec; color: #0f6b3c; }
.feedback.bad { background: #fff1f1; color: #9d2f2f; }
.yours { margin-top: 4px; font-size: 13px; font-weight: 600; }

.score-wrap { display: flex; justify-content: center; margin: 8px 0 12px; }
.score-ring {
  width: 148px; height: 148px; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(#f5c518 calc(var(--p) * 1%), #e5f2ea 0);
}
.score-inner {
  width: 112px; height: 112px; border-radius: 50%; background: white;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.score-inner strong { font-size: 40px; line-height: 1; }
.score-inner span { color: var(--muted); font-weight: 800; }
.fresh {
  display: inline-block;
  background: var(--yellow-300);
  color: #14532d;
  font-weight: 800;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}
.review {
  background: white;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green-700);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 8px;
}
.review.bad { border-left-color: var(--danger); }
.review .ko { font-size: 18px; font-weight: 700; }
.review .linkish { margin-top: 6px; }

.jamo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 8px; }
.jamo {
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  min-height: 74px;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.jamo:active { background: var(--yellow-100); border-color: var(--yellow-500); }
.jamo .glyph { font-size: 28px; font-weight: 700; line-height: 1; }
.jamo .roman { font-size: 11px; font-weight: 700; color: var(--muted); }
.jamo.tense { box-shadow: inset 0 -3px 0 var(--yellow-500); }
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.slot { background: white; border: 1px solid var(--line); border-radius: 14px; padding: 8px 4px; text-align: center; }
.slot span { display: block; font-size: 11px; color: var(--muted); font-weight: 700; }
.slot b { display: block; margin-top: 4px; font-size: 28px; font-family: "Noto Sans KR", sans-serif; }
.slot.cho { background: #e7f6ec; }
.slot.jung { background: #fff6cc; }
.block-preview { font-size: 72px; font-weight: 800; line-height: 1; min-height: 80px; }

.keyboard-slot { background: #e3f2e8; border-top: 1px solid #cfe3d6; }
.kb { padding: 6px 4px 8px; }
.kb-hint { margin: 2px 6px 6px; text-align: center; font-size: 11px; font-weight: 700; color: #3e6b52; }
.kb-row { display: flex; gap: 4px; margin-bottom: 4px; }
.kb-row.r2 { padding: 0 10px; }
.key {
  flex: 1;
  min-width: 0;
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: white;
  box-shadow: 0 1px 0 #c5d9cc;
  font-family: "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
  touch-action: none;
  user-select: none;
  padding: 0;
}
.key:active { background: var(--yellow-300); }
.key.fn { background: #d7ebdd; font-family: "Be Vietnam Pro", sans-serif; font-size: 14px; font-weight: 800; }
.key.shift.on { background: var(--yellow-500); }
.key.space { font-family: "Be Vietnam Pro", sans-serif; font-size: 13px; font-weight: 700; color: var(--muted); }
.kb-pad { padding: 8px 10px 4px; display: flex; flex-direction: column; gap: 8px; }
.answer-line {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: white;
  border-radius: 14px;
  font-size: 26px;
  font-weight: 700;
  padding: 6px 10px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.sys-input {
  min-height: 52px;
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--line);
}
.composing { border-bottom: 3px solid var(--yellow-500); }
.ph { color: #7f9a8c; font-family: "Be Vietnam Pro", sans-serif; font-size: 14px; font-weight: 600; }

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: white;
  border-top: 1px solid var(--line);
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  z-index: 5;
}
#zhTabs { grid-template-columns: repeat(5, 1fr); }
.tabs button {
  border: 0;
  background: transparent;
  color: #6d8278;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.tabs button.active { color: var(--green-800); }
.ico {
  width: 32px; height: 26px;
  display: grid; place-items: center;
  border-radius: 8px;
}
.tabs button.active .ico { background: var(--yellow-300); }
.tab-glyph { font-size: 18px; font-weight: 800; line-height: 1; }

.toast {
  position: absolute;
  z-index: 50;
  left: 50%;
  top: calc(68px + env(safe-area-inset-top));
  transform: translateX(-50%);
  background: var(--green-950);
  color: white;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  max-width: calc(100% - 28px);
  text-align: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}
.overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(8, 40, 26, 0.46);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  width: 100%;
  max-height: 86%;
  overflow: auto;
  background: white;
  border-radius: 22px 22px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
}
.grab { width: 40px; height: 4px; border-radius: 99px; background: #d5e6db; margin: 4px auto 12px; }
.sheet h3 { margin: 0 0 8px; font-size: 18px; }
.sheet .big { margin: 0; text-align: center; font-size: 72px; font-weight: 800; line-height: 1; font-family: "Noto Sans KR", sans-serif; }
.roman-lg { text-align: center; font-size: 22px; font-weight: 800; color: var(--green-800); margin: 6px 0; }
.sheet-actions { display: flex; gap: 8px; margin-top: 14px; }
.sheet-actions .btn { flex: 1; }
.noscript { padding: 24px; font-family: "Segoe UI", sans-serif; }

html.theme-zh {
  --green-950: #6d1020;
  --green-800: #c4232b;
  --green-700: #d63a42;
  --green-100: #fdecee;
  --green-50: #fff7f7;
  --ink: #3d161a;
  --muted: #8d5c61;
  --line: #f3d2d6;
}
html.theme-zh body {
  background:
    radial-gradient(900px 420px at 0% -10%, #ffe7a3 0%, transparent 55%),
    radial-gradient(800px 480px at 100% 0%, #f7c1c6 0%, transparent 50%),
    #fff1f2;
}
html.theme-zh .top { background: linear-gradient(155deg, #8e1524 0%, #e14b52 68%, #c4232b 100%); }
html.theme-zh .phone { background: var(--green-50); }
html.theme-en {
  --green-950: #102844;
  --green-800: #1d4e89;
  --green-700: #2f6aaf;
  --green-100: #e7f0fa;
  --green-50: #f4f8fc;
  --ink: #17283a;
  --muted: #5d7086;
  --line: #d5e2f0;
}
html.theme-en body {
  background:
    radial-gradient(900px 420px at 0% -10%, #ffe7a3 0%, transparent 55%),
    radial-gradient(800px 480px at 100% 0%, #c9ddf5 0%, transparent 50%),
    #f3f7fc;
}
html.theme-en .top { background: linear-gradient(155deg, #163a66 0%, #3d7ec4 68%, #1d4e89 100%); }
html.theme-en .phone { background: var(--green-50); }
.angry-note { background: #ffe1e4; border-color: #e3a0a6; }
html.mood-angry .mark { background: #c4232b; color: white; }

@media (min-width: 768px) {
  .top {
    padding: 16px 28px 16px;
  }
  .brand h1 { font-size: 22px; }
  .tagline { font-size: 13px; }
  .mark { width: 48px; height: 48px; border-radius: 16px; font-size: 26px; }
  main {
    padding: 24px 32px 28px;
  }
  h2 { font-size: 28px; }
  .lead { font-size: 15px; max-width: 72ch; }
  .flip { max-width: 560px; margin-left: auto; margin-right: auto; }
  .flip-inner { min-height: 320px; }
  .hero-ko { font-size: clamp(32px, 4vw, 48px); }
  .hero-vi { font-size: clamp(26px, 3vw, 36px); }
  .hero-zh { font-size: clamp(36px, 4vw, 52px); }
  .course-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
  .course-card { min-height: 120px; padding: 18px; }
  .course-card:hover, .mode-card:hover, .item:hover, .opt:hover, .jamo:hover {
    border-color: var(--green-700);
    transform: translateY(-1px);
  }
  .opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .prompt-card, .hero-action { max-width: 720px; margin-left: auto; margin-right: auto; }
  .hanzi-board { width: min(100%, 360px); }
  .write-fit { padding: 12px 20px !important; }
  .kb, .kb-pad { max-width: 760px; margin-left: auto; margin-right: auto; }
  .key { height: 46px; font-size: 18px; }
  .overlay { align-items: center; padding: 24px; }
  .sheet {
    width: min(520px, 100%);
    max-height: 80%;
    border-radius: 22px;
    padding: 16px 20px 20px;
  }
  .grab { display: none; }
  #studyList, #cardList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 10px;
  }
  #studyList .list-title, #cardList .list-title, #cardList .empty {
    grid-column: 1 / -1;
  }
  #studyList .item, #cardList .item { margin-bottom: 0; }
  main:has(> .mode-card) {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 12px;
    align-content: start;
  }
  main:has(> .mode-card) > :not(.mode-card) { grid-column: 1 / -1; }
  main:has(> .review) {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
    align-content: start;
  }
  main:has(> .review) > :not(.review) { grid-column: 1 / -1; }
  .phone:has(.tabs:not([hidden])) {
    display: grid;
    grid-template-areas:
      "top top"
      "nav main"
      "nav kb";
    grid-template-columns: 232px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .phone:has(.tabs:not([hidden])) .top { grid-area: top; }
  .phone:has(.tabs:not([hidden])) main { grid-area: main; min-width: 0; }
  .phone:has(.tabs:not([hidden])) .keyboard-slot { grid-area: kb; }
  .phone:has(.tabs:not([hidden])) .tabs:not([hidden]) {
    grid-area: nav;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-content: start;
    border-top: 0;
    border-right: 1px solid var(--line);
    padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
    overflow: auto;
  }
  .phone:has(.tabs:not([hidden])) .tabs button {
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    font-size: 14px;
    padding: 12px 12px;
    border-radius: 14px;
    width: 100%;
  }
  .phone:has(.tabs:not([hidden])) .tabs button.active {
    background: var(--green-100);
  }
  .phone:has(.tabs:not([hidden])) .tabs button.active .ico {
    background: var(--yellow-300);
  }
  .toast { top: calc(80px + env(safe-area-inset-top)); }
}
@media (min-width: 1200px) {
  main { padding: 28px 48px 36px; }
  .top { padding-left: 36px; padding-right: 36px; }
  #studyList, #cardList { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}
@media (max-width: 767px) {
  .phone { width: 100%; max-width: 100%; }
}
@media (max-width: 360px) {
  .key { height: 38px; font-size: 15px; }
  .big-char { font-size: 68px; }
  .tabs button { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .flip-inner { transition: none; }
  .btn.primary:active { transform: none; }
}
