/* ================================================================== fonts */

/* Nunito is the closest freely-licensed match to Duolingo's DIN Round, and it
   is self-hosted because Google Fonts is unreliable from the mainland. Latin
   only — Chinese falls through to the rounded system faces below. The
   latin-ext subset carries the IPA glyphs the phonetics need. */
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('fonts/nunito-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
                 U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF,
                 U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('fonts/nunito-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
                 U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ============================================================ design tokens */

:root {
  /* Duolingo palette */
  --green: #58cc02;
  --green-edge: #46a302;
  --green-text: #4e9e00;
  --green-soft: #d7ffb8;
  --green-wash: #eefbe2;

  --blue: #1cb0f6;
  --blue-edge: #1899d6;
  --blue-soft: #ddf4ff;

  --purple: #ce82ff;
  --purple-edge: #a560e8;
  --purple-text: #8b46d6;
  --purple-soft: #f4e8ff;
  --purple-wash: #faf3ff;

  --red: #ff4b4b;
  --red-edge: #ea2b2b;
  --red-soft: #ffdfe0;

  --yellow: #ffc800;
  --yellow-edge: #e5b200;
  --orange: #ff9600;

  /* Neutrals — Duolingo names them after animals. */
  --eel: #4b4b4b;
  --wolf: #777777;
  --hare: #afafaf;
  --swan: #e5e5e5;
  --polar: #f7f7f7;
  --snow: #ffffff;

  /* CET-4 reads green, CET-6 reads purple, everywhere in the product. */
  --lv4: var(--green);
  --lv4-edge: var(--green-edge);
  --lv4-text: var(--green-text);
  --lv4-soft: var(--green-soft);
  --lv4-wash: var(--green-wash);
  --lv6: var(--purple);
  --lv6-edge: var(--purple-edge);
  --lv6-text: var(--purple-text);
  --lv6-soft: var(--purple-soft);
  --lv6-wash: var(--purple-wash);

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;

  --font: 'Nunito', ui-rounded, 'SF Pro Rounded', 'HarmonyOS Sans SC',
          'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei',
          'Noto Sans CJK SC', sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;

  --head-h: 58px;
  --tab-h: 0px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--snow);
  color: var(--eel);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; }
h1, h2, h3, h4 { font-weight: 800; line-height: 1.25; letter-spacing: -.01em; }
svg { display: block; }

::selection { background: var(--green-soft); color: var(--eel); }

:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ============================================================ S0 · loading */

.boot {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--snow);
  transition: opacity .32s ease, visibility .32s;
}
.boot.gone { opacity: 0; visibility: hidden; }

.boot-inner { text-align: center; padding: 0 24px; }

.boot-icon {
  width: 88px;
  height: 88px;
  object-fit: contain;
  animation: bootBounce 1.15s cubic-bezier(.5, .05, .5, .95) infinite;
}

@keyframes bootBounce {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  40% { transform: translateY(-16px) scale(.97, 1.03); }
  70% { transform: translateY(0) scale(1.04, .96); }
}

.boot-name { margin-top: 14px; font-size: 25px; font-weight: 800; }
.boot-tag { margin-top: 2px; color: var(--hare); font-size: 13.5px; }

.boot-bar {
  width: 180px;
  height: 12px;
  margin: 22px auto 0;
  border-radius: 999px;
  background: var(--swan);
  overflow: hidden;
}
.boot-bar i {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: 999px;
  background: var(--green);
  animation: bootSlide 1.1s ease-in-out infinite;
}

@keyframes bootSlide {
  0% { transform: translateX(-105%); }
  100% { transform: translateX(255%); }
}

/* ========================================================= S1 · main scene */

.site-head {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 24px;
  height: var(--head-h);
  padding: 0 22px;
  background: var(--snow);
  border-bottom: 2px solid var(--swan);
}

.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.brand-icon { width: 26px; height: 26px; object-fit: contain; flex: none; }
.brand-name { font-size: 18px; font-weight: 800; color: var(--green-text); }

.site-nav { display: flex; gap: 4px; margin-left: auto; }

.nav-link {
  padding: 7px 15px;
  border: 2px solid transparent;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--wolf);
  text-decoration: none;
  transition: background .15s, color .15s, border-color .15s;
}
.nav-link:hover { background: var(--polar); color: var(--eel); }
.nav-link.active {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue-edge);
}

.tabbar { display: none; }

#view { flex: 1; }

.page { max-width: 1000px; margin: 0 auto; padding: 30px 22px 70px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-head h1 { font-size: 27px; }
.sub { margin-top: 5px; max-width: 58ch; color: var(--wolf); font-size: 13.5px; font-weight: 600; }

.back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 12px;
  color: var(--hare);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: color .15s;
}
.back:hover { color: var(--green-text); }

.site-foot {
  padding: 22px 20px 26px;
  text-align: center;
  border-top: 2px solid var(--swan);
  color: var(--hare);
  font-size: 12.5px;
}
.foot-beian { margin-top: 4px; }
.foot-beian a { color: var(--hare); text-decoration: none; }
.foot-beian a:hover { color: var(--green-text); text-decoration: underline; }
.foot-build { margin-top: 4px; font-size: 11px; opacity: .8; }
.foot-build code { font-family: var(--mono); }

/* ================================================================== pieces */

/* Chunky buttons with a solid bottom edge that compresses on press. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: 2px solid transparent;
  border-radius: var(--r-md);
  background: none;
  font: inherit;
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: .01em;
  white-space: nowrap;
  cursor: pointer;
  transition: filter .12s, background .15s, color .15s, border-color .15s,
              box-shadow .08s, transform .08s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

.btn.primary {
  background: var(--green);
  border-color: var(--green);
  color: var(--snow);
  box-shadow: 0 4px 0 var(--green-edge);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn.primary:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--green-edge); }

.btn.ghost {
  background: var(--snow);
  border-color: var(--swan);
  color: var(--wolf);
  box-shadow: 0 4px 0 var(--swan);
}
.btn.ghost:hover:not(:disabled) { background: var(--polar); color: var(--eel); }
.btn.ghost:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--swan); }

.btn.ghost.danger { color: var(--red); }
.btn.ghost.danger:hover:not(:disabled) { background: var(--red-soft); border-color: #ffc4c4; color: var(--red-edge); }

.upload-btn { cursor: pointer; }

.seg {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 2px solid var(--swan);
  border-radius: 12px;
  background: var(--snow);
}
.seg button {
  padding: 6px 14px;
  border: none;
  border-radius: 8px;
  background: none;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--hare);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.seg button:hover { color: var(--eel); }
.seg button.active { background: var(--blue-soft); color: var(--blue-edge); }

.tag {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--yellow);
  color: #7a5c00;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.tag.local { background: var(--polar); color: var(--hare); }

.empty { padding: 26px 0; color: var(--hare); font-size: 13.5px; }
.empty.small { padding: 14px 0; font-size: 13px; }

.panel {
  padding: 16px 18px;
  border: 2px solid var(--swan);
  border-radius: var(--r-lg);
  background: var(--snow);
}
.panel.wide { margin-top: 16px; }
.panel h3 { font-size: 14px; }
.panel-hint { margin: 4px 0 12px; color: var(--hare); font-size: 12px; line-height: 1.5; }
.panel-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.panel-head-row h3 { margin: 0; }

/* ============================================================ S2 · library */

.dropzone {
  margin-bottom: 22px;
  padding: 22px;
  border: 2px dashed var(--swan);
  border-radius: var(--r-lg);
  text-align: center;
  color: var(--hare);
  font-size: 13.5px;
  font-weight: 700;
  transition: border-color .15s, background .15s, color .15s;
}
.dropzone.over { border-color: var(--green); background: var(--green-wash); color: var(--green-text); }

.novel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(266px, 1fr));
  gap: 16px;
}

.novel-card {
  display: flex;
  flex-direction: column;
  padding: 18px;
  border: 2px solid var(--swan);
  border-radius: var(--r-lg);
  background: var(--snow);
  box-shadow: 0 4px 0 var(--swan);
  transition: transform .16s, box-shadow .16s, border-color .16s;
}
.novel-card:hover {
  transform: translateY(-2px);
  border-color: var(--green);
  box-shadow: 0 6px 0 var(--green-edge);
}

.novel-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.novel-top h2 { font-size: 17px; }

.novel-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 7px;
  min-height: 38px;
  color: var(--wolf);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.55;
}
.novel-meta { margin-top: 8px; color: var(--hare); font-size: 12px; font-weight: 700; }
.novel-meta.small { margin-top: 5px; }

/* Chunky pill progress bar with the Duolingo inner highlight. */
.bar {
  position: relative;
  height: 12px;
  margin-top: 11px;
  border-radius: 999px;
  background: var(--swan);
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--green);
  transition: width .3s;
}

.novel-actions { display: flex; gap: 8px; margin-top: 14px; }
.novel-actions .btn { flex: 1; }

/* =========================================================== S3 · chapters */

.chapter-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(316px, 1fr));
  gap: 8px;
}
.chapter-list button {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 12px 15px;
  border: 2px solid var(--swan);
  border-radius: var(--r-md);
  background: var(--snow);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: border-color .14s, background .14s, transform .08s;
}
.chapter-list button:hover { border-color: var(--green); background: var(--green-wash); }
.chapter-list button:active { transform: translateY(2px); }
.chapter-list button.current { border-color: var(--blue); background: var(--blue-soft); }
.chapter-list .idx {
  color: var(--hare);
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.chapter-list .ttl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.chapter-list .len { color: var(--hare); font-size: 12px; }

/* ============================================================= S4 · reader */

.reader {
  display: grid;
  grid-template-columns: minmax(0, 660px) 248px;
  justify-content: center;
  gap: 36px;
  padding: 28px 22px 80px;
  align-items: start;
}

.reader-main { min-width: 0; }

.chapter-title { margin: 2px 0 10px; font-size: 25px; }
.chapter-rule { width: 46px; height: 5px; border-radius: 999px; background: var(--green); margin-bottom: 22px; }

.prose {
  font-size: 17px;
  font-weight: 600;
  line-height: 2;
  color: var(--eel);
  text-align: justify;
}
.prose p { margin-bottom: .5em; text-indent: 2em; }

/* --------------------------------------------------------- word buttons */

.cet-word {
  display: inline-block;
  margin: 0 .16em;
  padding: .06em .45em;
  border: 2px solid var(--lv4);
  border-bottom-width: 3px;
  border-radius: 9px;
  background: var(--lv4-wash);
  color: var(--lv4-text);
  font: inherit;
  font-size: .84em;
  font-weight: 800;
  line-height: 1.5;
  text-indent: 0;
  vertical-align: baseline;
  cursor: pointer;
  transition: background .14s, color .14s, transform .08s;
}
.cet-word:hover { background: var(--lv4); color: var(--snow); }
.cet-word:active { transform: translateY(1px); border-bottom-width: 2px; }

.cet-word.lv6 {
  border-color: var(--lv6);
  background: var(--lv6-wash);
  color: var(--lv6-text);
}
.cet-word.lv6:hover { background: var(--lv6); color: var(--snow); }

/* Words you already hold onto step back so attention lands on the rest. */
.cet-word.known { border-color: var(--swan); background: var(--snow); color: var(--hare); }
.cet-word.known:hover { border-color: var(--hare); background: var(--polar); color: var(--wolf); }

.cet-word.flash { animation: flash 1.3s ease; }
@keyframes flash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 200, 0, 0); }
  25% { box-shadow: 0 0 0 6px rgba(255, 200, 0, .6); }
}

.chapter-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 36px;
  padding-top: 20px;
  border-top: 2px solid var(--swan);
}
.nav-pos { color: var(--hare); font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ reader side */

.reader-side { position: sticky; top: calc(var(--head-h) + 12px); display: flex; flex-direction: column; gap: 12px; }

.level-pick { display: flex; flex-direction: column; gap: 8px; }

.level-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 2px solid var(--swan);
  border-radius: var(--r-md);
  background: var(--snow);
  box-shadow: 0 3px 0 var(--swan);
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--wolf);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s, box-shadow .1s, transform .08s;
}
.level-opt:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--swan); }
.level-opt .swatch { width: 14px; height: 14px; flex: none; border-radius: 5px; background: var(--lv4); }
.level-opt[data-level="6"] .swatch { background: var(--lv6); }
.level-opt .lbl { flex: 1; }
.level-opt .chk {
  width: 16px;
  height: 16px;
  flex: none;
  border: 2px solid var(--swan);
  border-radius: 50%;
  transition: border-color .15s, background .15s, box-shadow .15s;
}

.level-opt.on { border-color: var(--lv4); background: var(--lv4-wash); color: var(--lv4-text); box-shadow: 0 3px 0 var(--lv4-edge); }
.level-opt.on .chk { border-color: var(--lv4); background: var(--lv4); box-shadow: inset 0 0 0 3px var(--snow); }
.level-opt[data-level="6"].on { border-color: var(--lv6); background: var(--lv6-wash); color: var(--lv6-text); box-shadow: 0 3px 0 var(--lv6-edge); }
.level-opt[data-level="6"].on .chk { border-color: var(--lv6); background: var(--lv6); box-shadow: inset 0 0 0 3px var(--snow); }

.side-count { display: flex; align-items: baseline; gap: 5px; margin-bottom: 10px; }
.side-count b { font-size: 23px; font-weight: 800; }
.side-count span { color: var(--hare); font-size: 12px; }

.word-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.word-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 2px solid var(--lv4);
  border-radius: 9px;
  background: var(--lv4-wash);
  color: var(--lv4-text);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: background .14s, color .14s;
}
.word-chip.lv6 { border-color: var(--lv6); background: var(--lv6-wash); color: var(--lv6-text); }
.word-chip:hover { background: var(--lv4); color: var(--snow); }
.word-chip.lv6:hover { background: var(--lv6); color: var(--snow); }
.word-chip em { font-style: normal; font-size: 10px; font-weight: 700; opacity: .7; font-variant-numeric: tabular-nums; }

/* Floating reader settings trigger — mobile only. */
.reader-fab { display: none; }

/* ============================================================= S5 · bubble */

.bubble {
  --c: var(--lv4);
  --c-text: var(--lv4-text);
  --c-wash: var(--lv4-wash);
  position: absolute;
  z-index: 60;
  width: 258px;
  border: 2px solid var(--c);
  border-radius: var(--r-md);
  background: var(--snow);
  box-shadow: 0 6px 0 rgba(0, 0, 0, .06), 0 12px 28px rgba(0, 0, 0, .14);
  font-size: 13px;
  animation: pop .13s ease-out;
}
.bubble.lv6 { --c: var(--lv6); --c-text: var(--lv6-text); --c-wash: var(--lv6-wash); }

@keyframes pop { from { opacity: 0; transform: scale(.95) translateY(4px); } }

/* Pointer aimed back at the word's top-right corner. */
.bubble::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 14px;
  width: 12px;
  height: 12px;
  background: var(--snow);
  border-right: 2px solid var(--c);
  border-bottom: 2px solid var(--c);
  transform: rotate(45deg);
}
.bubble.flip-x::after { left: auto; right: 14px; }
.bubble.flip-y::after { top: -8px; bottom: auto; background: var(--c-wash); transform: rotate(225deg); }

.bubble-head {
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex-wrap: wrap;
  padding: 10px 12px 9px;
  border-bottom: 2px solid var(--c);
  border-radius: 10px 10px 0 0;
  background: var(--c-wash);
}
.bubble-head strong { font-size: 17px; font-weight: 800; color: var(--c-text); }
.ph { color: var(--hare); font-size: 12px; font-weight: 700; }

.lv {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--green);
  color: var(--snow);
  font-size: 10px;
  font-weight: 800;
}
.lv6 { background: var(--purple-edge); }

.bubble-body { padding: 10px 12px 11px; }
.bubble-zh { line-height: 1.55; }
.bubble-zh em { margin-right: 5px; color: var(--hare); font-style: italic; font-size: 12px; }
.bubble-origin {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 2px dashed var(--swan);
  color: var(--wolf);
  font-size: 12px;
}
.bubble-origin b { color: var(--eel); font-weight: 800; }
.bubble-mem { margin-top: 4px; color: var(--hare); font-size: 11.5px; }

.bubble-more {
  display: block;
  width: 100%;
  padding: 9px;
  border: none;
  border-top: 2px solid var(--swan);
  border-radius: 0 0 10px 10px;
  background: none;
  font: inherit;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--c-text);
  cursor: pointer;
  transition: background .14s;
}
.bubble-more:hover { background: var(--c-wash); }

/* ====================================================== S6 · modal / sheet */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(35, 35, 35, .5);
  animation: fade .15s ease;
}

@keyframes fade { from { opacity: 0; } }

.modal {
  --c: var(--lv4);
  --c-edge: var(--lv4-edge);
  --c-text: var(--lv4-text);
  --c-wash: var(--lv4-wash);
  position: relative;
  width: 100%;
  max-width: 430px;
  max-height: 86vh;
  overflow-y: auto;
  border: 2px solid var(--swan);
  border-radius: var(--r-lg);
  background: var(--snow);
  box-shadow: 0 10px 0 rgba(0, 0, 0, .06), 0 24px 60px rgba(0, 0, 0, .28);
  animation: rise .2s ease-out;
}
.modal.lv6 { --c: var(--lv6); --c-edge: var(--lv6-edge); --c-text: var(--lv6-text); --c-wash: var(--lv6-wash); }

@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes sheetUp { from { transform: translateY(100%); } }

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, .7);
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  color: var(--wolf);
  cursor: pointer;
  transition: background .14s, color .14s;
}
.modal-close:hover { background: var(--swan); color: var(--eel); }

.modal-head {
  display: flex;
  align-items: baseline;
  gap: 9px;
  flex-wrap: wrap;
  padding: 20px 54px 17px 22px;
  border-bottom: 2px solid var(--c);
  background: var(--c-wash);
}
.modal-head h2 { font-size: 27px; font-weight: 800; color: var(--c-text); }

.modal-body { padding: 2px 22px 20px; }

.modal-block { margin-top: 17px; }
.modal-block h4 {
  margin-bottom: 5px;
  color: var(--hare);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.modal-block > p { font-size: 14px; font-weight: 600; line-height: 1.6; }

.en-def { color: var(--wolf); }
.en-ex {
  padding: 8px 12px;
  border-radius: var(--r-sm);
  background: var(--polar);
  font-style: italic;
  color: var(--eel);
}
.zh-ex { margin-top: 4px; padding-left: 12px; color: var(--hare); font-size: 13px; }

.mem-bar { height: 12px; border-radius: 999px; background: var(--swan); overflow: hidden; }
.mem-bar i { display: block; height: 100%; border-radius: 999px; background: var(--c); transition: width .3s; }
.mem-line { margin-top: 6px; color: var(--hare); font-size: 12.5px; font-weight: 700; }

.modal-grade { display: flex; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 2px solid var(--swan); }
.modal-grade .btn { flex: 1; padding: 10px 8px; }

/* review card */
.card-modal { max-width: 392px; text-align: center; }
.card-modal .modal-body { padding: 24px 22px 22px; }
.card-progress { color: var(--hare); font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.card-word { margin-top: 8px; font-size: 32px; font-weight: 800; }
.card-ph { margin-bottom: 18px; color: var(--hare); font-size: 13.5px; font-weight: 700; }
.reveal { margin: 0 auto; }
.card-back { margin-top: 6px; text-align: left; }
.card-zh { font-size: 14.5px; }
.card-en { margin-top: 8px; color: var(--wolf); font-size: 13.5px; line-height: 1.55; }
.card-ex { margin-top: 10px; font-style: italic; font-size: 13px; }
.card-exz { color: var(--hare); font-size: 12.5px; }
.done-title { padding-top: 4px; font-size: 21px; }
.done-sub { margin: 8px 0 18px; color: var(--wolf); font-size: 13.5px; }

/* ========================================================== S7 · dashboard */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(136px, 1fr)); gap: 12px; }

.stat-card {
  padding: 14px 16px;
  border: 2px solid var(--swan);
  border-radius: var(--r-md);
  background: var(--snow);
}
.stat-label { color: var(--hare); font-size: 12px; font-weight: 700; }
.stat-value { margin-top: 1px; font-size: 27px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-value em { margin-left: 3px; color: var(--hare); font-size: 12.5px; font-style: normal; font-weight: 700; }

.two-col { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; align-items: start; }

.curve { width: 100%; height: auto; }
.curve .grid { stroke: var(--swan); stroke-width: 1.5; }
.curve .axis { fill: var(--hare); font-size: 10px; font-family: var(--font); font-weight: 700; }
.curve-line { fill: none; stroke: var(--green); stroke-width: 3; stroke-linecap: round; }
.curve-area { fill: rgba(88, 204, 2, .12); stroke: none; }

.bars { display: flex; align-items: flex-end; gap: 7px; height: 138px; padding-top: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.bar-stack { flex: 1; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 3px; }
.bar-stack i { display: block; width: 100%; border-radius: 5px; }
.seg-new { background: var(--green); }
.seg-rev { background: var(--blue); }
.bar-col span { color: var(--hare); font-size: 10.5px; font-weight: 700; }

.legend { display: flex; align-items: center; gap: 6px; margin-top: 10px; color: var(--hare); font-size: 12px; font-weight: 700; }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 4px; }
.legend .dot.new { background: var(--green); }
.legend .dot.rev { background: var(--blue); margin-left: 10px; }

.due-list { list-style: none; }
.due-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 2px solid var(--polar);
}
.due-list li:last-child { border-bottom: none; }
.due-word strong { font-size: 14.5px; font-weight: 800; }
.due-word .zh { margin-left: 9px; color: var(--hare); font-size: 12.5px; }
.due-meta { display: flex; align-items: center; gap: 10px; }
.mem-pill {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-text);
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.mem-pill.weak { background: var(--red-soft); color: var(--red-edge); }
.due-meta .when { color: var(--hare); font-size: 12px; font-weight: 700; }

.danger-zone { border-color: #ffd6d6; }

/* ============================================================== S8 · toast */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + var(--tab-h));
  transform: translate(-50%, 14px);
  z-index: 100;
  padding: 11px 22px;
  border-radius: 999px;
  background: var(--eel);
  color: var(--snow);
  font-size: 13px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--red-edge); }

/* ====================================================== covers & avatars */

/* Emoji covers stand in for artwork: no image requests, no layout shift. */
.cover {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  font-size: 24px;
  line-height: 1;
}
.cover.lg { width: 84px; height: 84px; border-radius: var(--r-lg); font-size: 44px; }

.tint-green { background: var(--green-soft); }
.tint-blue { background: var(--blue-soft); }
.tint-purple { background: var(--purple-soft); }
.tint-yellow { background: #fff0bf; }
.tint-red { background: var(--red-soft); }

.avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  cursor: default;
}
.avatar.sm { width: 30px; height: 30px; font-size: 16px; }
.avatar.lg { width: 64px; height: 64px; font-size: 34px; }
.avatar.xl { width: 76px; height: 76px; font-size: 40px; cursor: pointer; }

/* The VIP ring is a gradient disc peeking out from behind the avatar. */
.avatar::before {
  content: '';
  position: absolute;
  inset: -3px;
  z-index: -1;
  border-radius: inherit;
  background: var(--ring, var(--swan));
}
.avatar.xl::before { inset: -4px; }

.ring-v0 { --ring: var(--swan); }
.ring-v1 { --ring: linear-gradient(135deg, #d89b6a, #a9673a); }
.ring-v2 { --ring: linear-gradient(135deg, #dfe6ec, #9aa7b4); }
.ring-v3 { --ring: linear-gradient(135deg, #ffd954, #e5a100); }
.ring-v4 { --ring: linear-gradient(135deg, #8fe9ff, #1cb0f6); }
.ring-v5 { --ring: linear-gradient(135deg, #ce82ff, #1cb0f6, #ce82ff); }
.ring-v6 {
  --ring: conic-gradient(#ff4b4b, #ffc800, #58cc02, #1cb0f6, #ce82ff, #ff4b4b);
}
.ring-v6::before { animation: ringSpin 4s linear infinite; }

@keyframes ringSpin {
  to { transform: rotate(1turn); }
}

/* --------------------------------------------------------- header identity */

.head-user {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 10px;
  padding: 4px 12px 4px 4px;
  border: 2px solid var(--swan);
  border-radius: 999px;
  text-decoration: none;
  transition: border-color .15s, background .15s;
}
.head-user:hover { border-color: var(--green); background: var(--green-wash); }
.head-user.member { border-color: var(--yellow); background: #fffaea; }
.head-user.guest { padding: 6px 16px; }
.head-name {
  max-width: 7em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 800;
}
.head-login { font-size: 13px; font-weight: 800; color: var(--green-text); }

/* ------------------------------------------------------- search & category */

.search-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
  padding: 0 14px;
  border: 2px solid var(--swan);
  border-radius: 999px;
  background: var(--snow);
  transition: border-color .15s, box-shadow .15s;
}
.search-bar:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-wash); }
.search-bar svg { width: 18px; height: 18px; fill: var(--hare); flex: none; }
.search-bar input {
  flex: 1;
  min-width: 0;
  padding: 11px 0;
  border: none;
  background: none;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--eel);
}
.search-bar input:focus { outline: none; }
.search-bar input::-webkit-search-cancel-button { display: none; }
.search-clear {
  flex: none;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: var(--swan);
  color: var(--wolf);
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}
.search-clear:hover { background: var(--hare); color: var(--snow); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 18px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 13px;
  border: 2px solid var(--swan);
  border-radius: 999px;
  background: var(--snow);
  font: inherit;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--wolf);
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.chip:hover { border-color: var(--hare); color: var(--eel); }
.chip em {
  font-style: normal;
  font-size: 11px;
  color: var(--hare);
  font-variant-numeric: tabular-nums;
}
.chip.on { border-color: var(--green); background: var(--green-wash); color: var(--green-text); }
.chip.on em { color: var(--green-text); }

.novel-head { flex: 1; min-width: 0; }
.novel-head h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.novel-head .novel-meta { margin-top: 2px; }

.tag-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.mini-tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--polar);
  color: var(--wolf);
  font-size: 11px;
  font-weight: 800;
}

.novel-hero { display: flex; align-items: center; gap: 18px; margin-bottom: 22px; }
.novel-hero h1 { font-size: 26px; }
.novel-hero .sub { margin-top: 6px; }

/* ========================================================= S12 · rankings */

.rank-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.rank-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 11px 15px;
  border: 2px solid var(--swan);
  border-radius: var(--r-lg);
  background: var(--snow);
  cursor: pointer;
  transition: border-color .15s, transform .1s, box-shadow .15s;
}
.rank-row:hover { border-color: var(--green); box-shadow: 0 4px 0 var(--green-edge); transform: translateY(-2px); }
.rank-no {
  flex: none;
  width: 26px;
  color: var(--hare);
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
/* The top three get the medal treatment; everyone else stays quiet. */
.rank-row.top .rank-no { color: var(--snow); border-radius: 8px; }
.rank-row.top-1 .rank-no { background: var(--yellow); }
.rank-row.top-2 .rank-no { background: var(--hare); }
.rank-row.top-3 .rank-no { background: #d89b6a; }

.rank-main { flex: 1; min-width: 0; }
.rank-main h3 { font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-sub { margin-top: 3px; color: var(--hare); font-size: 12px; font-weight: 700; }

.rank-metric { flex: none; font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rank-metric.heat { color: var(--orange); }
.rank-metric.up { color: var(--green-text); }
.rank-metric.fresh { color: var(--hare); font-size: 12px; }

/* ============================================================= S9 · auth */

.page.narrow { max-width: 460px; }

.auth-head { text-align: center; margin-bottom: 18px; }
.auth-icon { width: 60px; height: 60px; object-fit: contain; }
.auth-head h1 { margin-top: 10px; font-size: 24px; }
.auth-head .sub { margin: 6px auto 0; }

.seg.wide { display: flex; width: 100%; margin-bottom: 14px; }
.seg.wide button { flex: 1; padding: 8px; font-size: 13.5px; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 800; color: var(--wolf); }
.field > span i { margin-left: 5px; font-style: normal; font-weight: 700; color: var(--hare); }
.field-row { display: flex; gap: 8px; }
.field-row input { flex: 1; min-width: 0; }
.field-row .btn { flex: none; }

.input,
.field input {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid var(--swan);
  border-radius: var(--r-md);
  background: var(--snow);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--eel);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus,
.field input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-wash);
}

.btn.block { width: 100%; padding: 13px; font-size: 15px; }

.form-error {
  padding: 9px 13px;
  border-radius: var(--r-sm);
  background: var(--red-soft);
  color: var(--red-edge);
  font-size: 12.5px;
  font-weight: 800;
}
.form-foot { text-align: center; color: var(--hare); font-size: 12px; font-weight: 700; }

.link {
  border: none;
  background: none;
  font: inherit;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--blue-edge);
  cursor: pointer;
  text-decoration: underline;
}

.auth-note {
  margin-top: 16px;
  padding: 11px 14px;
  border: 2px dashed var(--swan);
  border-radius: var(--r-md);
  color: var(--hare);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.6;
}

/* ================================================== S10 · account & VIP */

.guest-card { text-align: center; padding: 34px 22px; }
.guest-card h2 { margin-top: 14px; font-size: 20px; }
.guest-card .panel-hint { margin: 8px auto 18px; max-width: 26em; }

.profile-card {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  padding: 20px;
  border: 2px solid var(--swan);
  border-radius: var(--r-lg);
  background: var(--snow);
  box-shadow: 0 4px 0 var(--swan);
}
.profile-card.member {
  border-color: var(--yellow);
  background: linear-gradient(180deg, #fffbf0, var(--snow));
  box-shadow: 0 4px 0 var(--yellow-edge);
}
.profile-main { flex: 1; min-width: 0; }
.profile-card h1 { display: flex; align-items: center; gap: 8px; font-size: 21px; }
.profile-sub { margin-top: 4px; color: var(--hare); font-size: 12px; font-weight: 700; }
.profile-bio { margin-top: 6px; color: var(--wolf); font-size: 13px; font-weight: 600; }

.member-badge {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--yellow);
  color: #7a5c00;
  font-size: 11px;
  font-weight: 800;
}

.vip-line { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.vip-badge {
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--swan);
  color: var(--wolf);
  font-size: 11.5px;
  font-weight: 800;
  white-space: nowrap;
}
.vip-badge.big { padding: 6px 16px; font-size: 14px; }
.vip-badge.v1 { background: linear-gradient(135deg, #d89b6a, #a9673a); color: var(--snow); }
.vip-badge.v2 { background: linear-gradient(135deg, #dfe6ec, #9aa7b4); color: #4b5560; }
.vip-badge.v3 { background: linear-gradient(135deg, #ffd954, #e5a100); color: #6b4e00; }
.vip-badge.v4 { background: linear-gradient(135deg, #8fe9ff, #1cb0f6); color: var(--snow); }
.vip-badge.v5 { background: linear-gradient(135deg, #ce82ff, #1cb0f6); color: var(--snow); }
.vip-badge.v6 {
  background: conic-gradient(#ff4b4b, #ffc800, #58cc02, #1cb0f6, #ce82ff, #ff4b4b);
  color: var(--snow);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}

.vip-bar {
  flex: 1;
  min-width: 90px;
  height: 10px;
  border-radius: 999px;
  background: var(--swan);
  overflow: hidden;
}
.vip-bar i { display: block; height: 100%; border-radius: 999px; background: var(--yellow); transition: width .3s; }
.vip-next { color: var(--hare); font-size: 11.5px; font-weight: 700; }

/* ---------------------------------------------------------------- check-in */

.cycle { display: flex; gap: 6px; margin-bottom: 14px; }
.cycle-day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 2px;
  border: 2px solid var(--swan);
  border-radius: var(--r-sm);
  background: var(--polar);
  color: var(--hare);
}
.cycle-day b { font-size: 13px; font-weight: 800; }
.cycle-day em { font-style: normal; font-size: 10px; font-weight: 700; }
.cycle-day.big { border-color: var(--yellow); background: #fff6d9; color: #8a6a00; }
.cycle-day.done { border-color: var(--green); background: var(--green-wash); color: var(--green-text); }

.week-strip { display: flex; gap: 6px; }
.day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 2px;
  border: 2px solid var(--swan);
  border-radius: var(--r-md);
  background: var(--snow);
  font: inherit;
  color: var(--hare);
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.day:hover:not(:disabled) { border-color: var(--blue); background: var(--blue-soft); color: var(--blue-edge); }
.day:disabled { cursor: default; }
.day em { font-style: normal; font-size: 12px; font-weight: 800; }
.day i { font-style: normal; font-size: 11px; font-weight: 800; }
.day.signed { border-color: var(--green); background: var(--green); color: var(--snow); }
.day.today { border-color: var(--blue); color: var(--blue-edge); }
.day.today.signed { background: var(--green); border-color: var(--green-edge); color: var(--snow); }

.sign-actions { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.sign-actions .panel-hint { margin: 0; }

/* -------------------------------------------------------------- membership */

.vip-promo.on { border-color: var(--yellow); }
.perk-row { display: flex; flex-wrap: wrap; gap: 8px; }
.perk {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--polar);
  font-size: 12px;
  font-weight: 800;
  color: var(--wolf);
}

.vip-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 20px 22px;
  border: 2px solid var(--swan);
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, #fffaea, var(--snow));
}
.vip-hero.on { border-color: var(--yellow); box-shadow: 0 4px 0 var(--yellow-edge); }
.vip-hero h1 { font-size: 25px; }

.plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.plan-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 16px;
  border: 2px solid var(--swan);
  border-radius: var(--r-lg);
  background: var(--snow);
  box-shadow: 0 4px 0 var(--swan);
  text-align: center;
}
.plan-card.hot { border-color: var(--yellow); box-shadow: 0 4px 0 var(--yellow-edge); }
.plan-card h3 { font-size: 16px; }
.plan-card .btn { margin-top: 6px; }

.plan-tag {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--red);
  color: var(--snow);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.plan-price { display: flex; align-items: baseline; justify-content: center; gap: 2px; color: var(--orange); }
.plan-price em { font-style: normal; font-size: 14px; font-weight: 800; }
.plan-price b { font-size: 32px; font-weight: 800; font-variant-numeric: tabular-nums; }
.plan-price s { margin-left: 5px; color: var(--hare); font-size: 12px; font-weight: 700; }
.plan-meta { color: var(--hare); font-size: 12px; font-weight: 700; }

.perk-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.perk-list li { display: flex; align-items: flex-start; gap: 12px; }
.perk-icon {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: var(--polar);
  font-size: 18px;
}
.perk-list b { display: block; font-size: 13.5px; }
.perk-list em { display: block; margin-top: 2px; color: var(--hare); font-style: normal; font-size: 12px; font-weight: 700; }

.level-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.level-row { display: flex; align-items: center; gap: 12px; opacity: .5; }
.level-row.reached { opacity: 1; }
.level-row div { flex: 1; }
.level-row b { display: block; font-size: 13.5px; }
.level-row em { display: block; color: var(--hare); font-style: normal; font-size: 11.5px; font-weight: 700; }
.level-state { color: var(--hare); font-size: 12px; font-weight: 800; }
.level-row.reached .level-state { color: var(--green-text); }

/* --------------------------------------------------------- profile editor */

.avatar-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.avatar-opt {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--swan);
  border-radius: var(--r-sm);
  background: var(--snow);
  font-size: 20px;
  cursor: pointer;
  transition: border-color .12s, background .12s, transform .08s;
}
.avatar-opt:hover { border-color: var(--hare); transform: translateY(-1px); }
.avatar-opt.on { border-color: var(--green); background: var(--green-wash); }

.tint-row { display: flex; gap: 8px; }
.tint-opt {
  width: 34px;
  height: 34px;
  border: 3px solid transparent;
  border-radius: 50%;
  cursor: pointer;
}
.tint-opt.on { border-color: var(--eel); }

.form-actions { display: flex; gap: 8px; margin-top: 18px; }
.form-actions .btn { flex: 1; }

/* ---------------------------------------------------------- swipe affordance */

.swipe-hint { display: none; }

/* =============================================================== responsive */

@media (max-width: 1020px) {
  .reader { grid-template-columns: minmax(0, 660px); }
  .reader-side { position: static; flex-direction: row; flex-wrap: wrap; }
  .reader-side .panel { flex: 1; min-width: 208px; }
  .level-pick { flex-direction: row; }
  .level-opt { flex: 1; }
}

@media (max-width: 860px) {
  .two-col { grid-template-columns: 1fr; }
  .chapter-list { grid-template-columns: 1fr; }
}

/* ==================================================================== phone
   Laid out for a 360×667 CSS viewport, i.e. the 720×1334 design canvas at
   dpr 2. Everything below scales from a root em pinned to that width, so the
   proportions hold from a 320px phone up to a 430px one. */

@media (max-width: 767px) {
  :root {
    --head-h: 3.25rem;
    --tab-h: calc(3.5rem + env(safe-area-inset-bottom, 0px));
  }

  /* 16px at exactly 360px wide. */
  html { font-size: clamp(14px, 4.4444vw, 19px); }

  body { font-size: .9375rem; background: var(--snow); }

  .site-head { gap: .75rem; padding: 0 1rem; border-bottom-width: 2px; }
  .brand-icon { width: 1.5rem; height: 1.5rem; }
  .brand-name { font-size: 1.0625rem; }
  .site-nav { display: none; }

  /* Bottom tab bar replaces the header nav. */
  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: flex;
    height: var(--tab-h);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--snow);
    border-top: 2px solid var(--swan);
  }
  .tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .125rem;
    border: none;
    border-radius: 0;
    padding: 0;
    color: var(--hare);
    text-decoration: none;
    transition: color .15s;
  }
  .tab svg { width: 1.5rem; height: 1.5rem; fill: currentColor; }
  .tab span { font-size: .6875rem; font-weight: 800; }
  .tab:hover { background: none; color: var(--hare); }
  .tab.active { background: none; border-color: transparent; color: var(--green); }

  .page { padding: 1.125rem 1rem 1.5rem; }
  .page-head { margin-bottom: 1rem; }
  .page-head h1 { font-size: 1.5rem; }
  .sub { font-size: .8125rem; }

  /* Full-bleed upload button reads as a primary action on a phone. */
  .page-head > .upload-btn { width: 100%; padding: .75rem; font-size: .9375rem; }

  .dropzone { display: none; }

  .novel-grid { grid-template-columns: 1fr; gap: .75rem; }
  .novel-card { padding: .875rem 1rem; border-radius: 1rem; }
  .novel-top h2 { font-size: 1.0625rem; }
  .novel-desc { min-height: 0; -webkit-line-clamp: 2; font-size: .8125rem; }
  .novel-actions .btn { padding: .625rem; font-size: .875rem; }

  .chapter-list button { padding: .8125rem .875rem; }
  .chapter-list .ttl { font-size: .9375rem; }

  /* Reading page goes edge to edge; settings move into a bottom sheet. */
  .reader { display: block; padding: 1rem 1.125rem 2rem; }
  .chapter-title { font-size: 1.375rem; }
  .chapter-rule { height: .3125rem; margin-bottom: 1.125rem; }
  .prose { font-size: 1.0625rem; line-height: 1.95; }
  .cet-word { margin: 0 .2em; padding: .1em .4em; font-size: .86em; }
  .chapter-nav { margin-top: 1.75rem; padding-top: 1rem; }
  .chapter-nav .btn { padding: .625rem 1rem; }

  .reader-side { display: none; }

  .reader-fab {
    position: fixed;
    right: 1rem;
    bottom: calc(var(--tab-h) + 1rem);
    z-index: 45;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.25rem;
    height: 3.25rem;
    border: 2px solid var(--green-edge);
    border-radius: 50%;
    background: var(--green);
    color: var(--snow);
    box-shadow: 0 4px 0 var(--green-edge), 0 8px 20px rgba(0, 0, 0, .18);
    cursor: pointer;
  }
  .reader-fab:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--green-edge); }
  .reader-fab svg { width: 1.5rem; height: 1.5rem; fill: currentColor; }

  /* Every overlay becomes a bottom sheet. */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    max-width: none;
    max-height: 88vh;
    border: none;
    border-top: 3px solid var(--c, var(--swan));
    border-radius: 1.25rem 1.25rem 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    animation: sheetUp .24s cubic-bezier(.2, .8, .3, 1);
  }
  .modal::before {
    content: '';
    position: absolute;
    top: .5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 2.25rem;
    height: .25rem;
    border-radius: 999px;
    background: var(--swan);
  }
  .modal-head { padding: 1.5rem 3.5rem 1rem 1.25rem; }
  .modal-head h2 { font-size: 1.625rem; }
  .modal-body { padding: .125rem 1.25rem 1.25rem; }
  .modal-close { top: .75rem; right: .75rem; }
  .modal-grade .btn { padding: .75rem .25rem; font-size: .8125rem; }

  .card-modal { text-align: center; }
  .card-word { font-size: 1.875rem; }

  /* Reader settings sheet */
  .sheet-body { padding: 1.25rem 1.25rem 1.5rem; }
  .sheet-body .panel { border: none; padding: 0; margin-bottom: 1.25rem; }
  .sheet-body .panel:last-child { margin-bottom: 0; }
  .level-pick { flex-direction: column; }
  .level-opt { padding: .75rem .875rem; font-size: .9375rem; }
  .seg { width: 100%; }
  .seg button { flex: 1; padding: .5rem; }
  .word-chips { max-height: 8rem; overflow-y: auto; }

  /* Bubble only ever appears on hover-capable pointers, but keep it sane. */
  .bubble { width: min(16rem, calc(100vw - 1.5rem)); }

  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: .625rem; }
  .stat-card { padding: .75rem .875rem; }
  .stat-value { font-size: 1.5rem; }
  .panel { padding: .875rem 1rem; border-radius: 1rem; }

  /* One reservation at the bottom of the page keeps the fixed tab bar from
     covering the footer; padding on both #view and the footer double-counted. */
  body { padding-bottom: var(--tab-h); }
  .site-foot { padding: 1.25rem 1rem; }
  #toast { bottom: calc(var(--tab-h) + 1rem); }
}

/* Phone sizing for everything added after the first release. */
@media (max-width: 767px) {
  .head-user { margin-left: auto; padding: .1875rem .625rem .1875rem .1875rem; }
  .head-name { display: none; }
  .head-user.guest { padding: .375rem .875rem; }

  .search-bar { margin-bottom: .625rem; padding: 0 .875rem; }
  .search-bar input { padding: .625rem 0; font-size: .875rem; }
  .chips { gap: .375rem; margin-bottom: .875rem; overflow-x: auto; flex-wrap: nowrap; padding-bottom: .25rem; }
  .chip { flex: none; padding: .375rem .75rem; font-size: .75rem; }

  .cover { width: 2.5rem; height: 2.5rem; font-size: 1.375rem; }
  .cover.lg { width: 4rem; height: 4rem; font-size: 2rem; }
  .novel-hero { gap: .875rem; margin-bottom: 1.25rem; }
  .novel-hero h1 { font-size: 1.375rem; }

  .rank-row { padding: .625rem .75rem; gap: .625rem; border-radius: 1rem; }
  .rank-no { width: 1.375rem; font-size: .875rem; }
  .rank-main h3 { font-size: .9375rem; }
  .rank-sub { font-size: .6875rem; }
  .rank-metric { font-size: .8125rem; }

  .profile-card { flex-wrap: wrap; padding: 1rem; gap: .875rem; }
  .profile-card h1 { font-size: 1.25rem; }
  .profile-card > .btn { width: 100%; }
  .vip-line { width: 100%; }

  .cycle { gap: .25rem; }
  .cycle-day { padding: .5rem .125rem; }
  .cycle-day b { font-size: .75rem; }
  .cycle-day em { font-size: .5625rem; }
  .week-strip { gap: .25rem; }
  .day { padding: .625rem .125rem; }

  .plan-grid { grid-template-columns: 1fr; gap: 1.25rem; }
  .vip-hero { padding: 1rem; }
  .vip-hero h1 { font-size: 1.375rem; }

  .avatar-grid { grid-template-columns: repeat(6, 1fr); }

  /* The gesture is the primary way to turn a page on a phone, so say so. */
  .swipe-hint {
    display: block;
    margin-top: .75rem;
    color: var(--hare);
    font-size: .75rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: .08em;
  }
  .reader-main { will-change: transform; }
}

/* Touch devices never get the hover bubble; a tap opens the full entry. */
@media (hover: none) {
  .cet-word:hover { background: var(--lv4-wash); color: var(--lv4-text); }
  .cet-word.lv6:hover { background: var(--lv6-wash); color: var(--lv6-text); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
