/* ───────────────────────────────────────────────────────────
   Chineseffect Dictionary – calm, Apple-like UI
   ─────────────────────────────────────────────────────────── */
:root {
  --bg: #fbfbfd;
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --line: rgba(0, 0, 0, 0.08);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.1);
  --green: #248a3d; --orange: #c93400; --red: #d70015;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 24px rgba(0,0,0,.06);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.05), 0 18px 50px rgba(0,0,0,.12);
  --r-s: 10px; --r: 16px; --r-l: 22px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font-zh: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.25, .8, .25, 1);
  --top: 56px;
  --tab: 0px;
  --maxw: 880px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  color-scheme: dark;
    --bg: #000; --surface: #1c1c1e; --surface-2: #2c2c2e; --line: rgba(255,255,255,.1);
    --text: #f5f5f7; --text-2: #a1a1a6; --text-3: #8d8d92;
    --accent: #2997ff; --accent-soft: rgba(41,151,255,.16);
    --green: #30d158; --orange: #ff9f0a; --red: #ff453a;
  --shadow: 0 0 0 1px rgba(255,255,255,.06); --shadow-lg: 0 0 0 1px rgba(255,255,255,.08), 0 20px 60px rgba(0,0,0,.6);
}
html { background: var(--bg); }
body, .topbar, .tabbar, .search, .results, .panel, .flash__face, .sheet, .modal, .charcard, .examples, .sent-list, .btn, .chip, #q {
  transition: background-color .3s var(--ease), color .3s var(--ease), border-color .3s var(--ease);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--top) + 12px); }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh; padding-bottom: calc(var(--tab) + env(safe-area-inset-bottom));
}
[lang="zh-Hans"], .zh-sent { font-family: var(--font-zh); }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { letter-spacing: -0.015em; line-height: 1.15; margin: 0; }
h2 { font-size: 1.35rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0.4em 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; width: 100%; }
kbd {
  font: 500 11px/1 var(--font); padding: 3px 5px; border-radius: 5px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--line); vertical-align: middle;
}
.btn kbd, .pill kbd { background: transparent; color: inherit; opacity: .65; border-color: currentColor; margin-left: 6px; }
@media (hover: none) { .btn kbd, .pill kbd, .search__kbd, .rate__ivl kbd { display: none; } }
.muted { color: var(--text-2); }
.small { font-size: 0.86rem; }
.mono { font-family: var(--font-mono); font-size: 12px; }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.gap-s { gap: 8px; } .center { justify-content: center; } .end { justify-content: flex-end; }
.pad { padding: 16px; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 12px; top: 12px; z-index: 99; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent-soft); }

/* ───── top bar ───── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar__inner { max-width: 1100px; margin: 0 auto; height: var(--top); padding: 0 16px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; letter-spacing: -0.01em; margin-right: auto; }
.brand__tile {
  width: 30px; height: 30px; border-radius: 8px; background: #000; color: #fff; display: grid; place-items: center;
  font-size: 18px; font-weight: 500; box-shadow: 0 0 0 1px var(--line);
}
.brand__sub { color: var(--text-2); font-weight: 400; }
.loadbar { height: 2px; background: transparent; position: absolute; left: 0; right: 0; bottom: -1px; }
.loadbar__fill { height: 100%; width: 0; background: var(--accent); transition: width .2s linear; }

/* segmented control */
.seg {
  display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px;
  border: 1px solid var(--line);
}
.seg > a, .seg > button {
  border: 0; background: transparent; color: var(--text); font: 500 14px/1 var(--font); padding: 8px 14px; border-radius: 8px;
  cursor: pointer; white-space: nowrap; transition: background .2s var(--ease), box-shadow .2s var(--ease), color .2s;
}
.seg > .is-on { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 0 0 .5px rgba(0,0,0,.04); }
.seg > :not(.is-on) { color: var(--text-2); }
.seg > :not(.is-on):hover { color: var(--text); }
.seg--sm > a, .seg--sm > button { font-size: 13px; padding: 6px 11px; }
.seg .count { color: var(--text-3); font-weight: 400; margin-left: 2px; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; color: var(--text);
  display: inline-grid; place-items: center; cursor: pointer; font-size: 16px; flex: none;
  transition: background .2s;
}
.icon-btn svg { fill: currentColor; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn--sm { width: 30px; height: 30px; font-size: 14px; color: var(--text-2); }
.icon-btn--add { background: var(--accent-soft); color: var(--accent); font-size: 18px; font-weight: 500; }
.icon-btn--add:hover { background: var(--accent); color: #fff; }

/* tab bar (mobile) */
.tabbar { display: none; }
@media (max-width: 759px) {
  :root { --tab: 58px; }
  .seg--nav { display: none; }
  .brand__sub { display: none; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--tab) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--line);
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text-3); font-size: 11px; font-weight: 500; }
  .tabbar svg { fill: currentColor; }
  .tabbar a.is-on { color: var(--accent); }
}

/* ───── layout ───── */
main { outline: none; }
.view { max-width: var(--maxw); margin: 0 auto; padding: 20px 16px 64px; animation: fade .25s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ───── buttons ───── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: 500 15px/1 var(--font); padding: 11px 18px; border-radius: 980px; cursor: pointer;
  transition: transform .12s var(--ease), background .2s, border-color .2s, box-shadow .2s; white-space: nowrap;
}
.btn:hover { border-color: color-mix(in srgb, var(--text) 22%, transparent); }
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); border-color: transparent; }
.btn--ghost { background: var(--surface-2); border-color: transparent; }
.btn--sm { font-size: 13px; padding: 7px 12px; }
.btn--wide { width: 100%; max-width: 420px; padding: 15px 18px; font-size: 16px; }
.btn--danger-ghost { background: transparent; color: var(--red); border-color: transparent; }
.link-btn { border: 0; background: none; color: var(--accent); font: inherit; font-size: 14px; cursor: pointer; padding: 4px 2px; }
.pill { border: 1px dashed var(--line); background: var(--surface-2); color: var(--text-2); border-radius: 980px; padding: 6px 12px; font: 500 13px/1 var(--font); cursor: pointer; }
.badge {
  display: inline-block; font: 600 11px/1 var(--font); padding: 4px 7px; border-radius: 6px; letter-spacing: .01em;
  background: var(--accent-soft); color: var(--accent); vertical-align: middle; white-space: nowrap;
}
.badge--muted { background: var(--surface-2); color: var(--text-2); }
.badge--blue { background: var(--accent-soft); color: var(--accent); }
.badge--orange { background: color-mix(in srgb, var(--orange) 14%, transparent); color: var(--orange); }
.badge--green { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); }
.saved { color: var(--green); font-weight: 700; width: 36px; text-align: center; flex: none; }

.input, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 12px; padding: 11px 13px; font: 16px/1.4 var(--font); outline: none; resize: vertical;
  transition: border-color .2s, box-shadow .2s;
}
.input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.input--num { width: 90px; }

/* ───── tiles ───── */
.tile {
  --s: 56px;
  width: var(--s); height: var(--s); flex: none; display: inline-grid; place-items: center;
  background: #000; color: #fff; border-radius: calc(var(--s) * .22); overflow: hidden; position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,.12); vertical-align: middle; user-select: none;
  transition: transform .2s var(--ease), box-shadow .2s;
}
[data-theme="dark"] .brand__tile { box-shadow: inset 0 0 0 1px rgba(255,255,255,.16); }
[data-theme="dark"] .tile { box-shadow: none; }
[data-theme="dark"] .tile::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(255,255,255,.16); pointer-events: none; }
.tile__glyph { font-family: var(--font-zh); font-size: calc(var(--s) * .6); font-weight: 500; line-height: 1; transform: translateY(-1%); }
.tile img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile--xs { --s: 26px; } .tile--sm { --s: 36px; } .tile--md { --s: 64px; } .tile--lg { --s: 92px; } .tile--xl { --s: 128px; }
.tile.is-sel { box-shadow: 0 0 0 3px var(--accent); }
a:hover > .tile, .tile[role="button"]:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.tile[role="button"] { cursor: pointer; }

/* ───── search ───── */
.search { position: sticky; top: calc(var(--top) + env(safe-area-inset-top)); z-index: 10; background: var(--bg); padding: 8px 0 4px; margin: -8px 0 8px; }
.search__field { position: relative; }
.search__icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); fill: var(--text-3); pointer-events: none; }
#q {
  width: 100%; height: 54px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface);
  padding: 0 48px 0 46px; font: 400 19px/1 var(--font); color: var(--text); outline: none; box-shadow: var(--shadow);
  transition: box-shadow .2s, border-color .2s; -webkit-appearance: none; appearance: none;
}
#q:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); }
#q::-webkit-search-cancel-button { -webkit-appearance: none; }
.search__kbd { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); }
#q:focus + .search__kbd { opacity: 0; }
.search__status { font-size: 12.5px; color: var(--text-3); margin: 8px 4px 0; min-height: 1.2em; }

/* results */
.results { list-style: none; margin: 4px 0; padding: 0; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.results li + li { border-top: 1px solid var(--line); }
.res { display: flex; gap: 14px; align-items: center; padding: 12px 16px; color: var(--text); transition: background .15s; }
.res:hover, .res:focus-visible { background: var(--surface-2); outline: none; }
.res__tiles { display: flex; gap: 4px; flex: none; }
.res__text { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.res__head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.res__word { font-size: 20px; font-weight: 500; }
.res__def { color: var(--text-2); font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
@media (max-width: 520px) { .res__tiles .tile:nth-child(n+3) { display: none; } .res { gap: 12px; padding: 11px 14px; } }
.pinyin { color: var(--text-2); font-size: 15px; letter-spacing: .01em; }
.pinyin--lg { font-size: 19px; color: var(--text); }

/* panels / breakdown */
.panel { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.panel__head h3 { color: var(--text-2); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.breakdown__zh { font-size: 26px; line-height: 1.5; }
.breakdown__py { margin: 2px 0 4px; }
.breakdown__en { margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: baseline; gap: 7px; padding: 8px 12px; border-radius: 12px; background: var(--surface-2);
  color: var(--text); border: 1px solid transparent; font-size: 15px; cursor: pointer; max-width: 100%; font-family: inherit;
  transition: border-color .15s, background .15s;
}
.chip:hover { border-color: var(--line); background: var(--surface); }
.chip [lang="zh-Hans"] { font-size: 18px; }
.chip .pinyin { font-size: 13px; }
.chip__def { color: var(--text-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.chip--try { padding: 6px 12px; border-radius: 980px; font-size: 14px; background: var(--surface); border-color: var(--line); }

/* home */
.home { display: grid; gap: 28px; padding-top: 8px; }
.try { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 12px; }
.tile-grid a { display: grid; place-items: center; }
.tips ul { padding-left: 18px; margin: 8px 0 0; } .tips li { margin: 4px 0; }

/* ───── word page ───── */
.word__nav { margin-bottom: 6px; }
.back { font-size: 16px; padding-left: 0; }
.word__hero { display: flex; gap: 28px; align-items: flex-start; padding: 12px 0 28px; border-bottom: 1px solid var(--line); }
.word__tiles { display: flex; gap: 10px; flex-wrap: wrap; flex: none; max-width: 50%; }
.word__main { flex: 1; min-width: 0; }
.word__main h1 { font-size: 44px; font-weight: 500; margin-bottom: 6px; }
@media (max-width: 640px) {
  .word__hero { flex-direction: column; gap: 18px; }
  .word__tiles { max-width: none; }
  .word__tiles .tile--xl { --s: 104px; }
}
.reading { padding: 10px 0; }
.reading + .reading { border-top: 1px dashed var(--line); }
.reading__head { display: flex; align-items: center; gap: 10px; }
.defs { margin: 6px 0 0; padding-left: 22px; } .defs li { margin: 3px 0; } .defs li::marker { color: var(--text-3); font-size: .85em; }
.cls { margin-top: 8px; font-size: 15px; }
.sec { padding: 28px 0 8px; }
.sec > h2 { margin-bottom: 16px; }

.w { cursor: pointer; border-radius: 4px; transition: background .15s, box-shadow .15s; box-shadow: inset 0 -1.5px 0 transparent; }
.w:hover, .w.is-active { background: var(--accent-soft); box-shadow: inset 0 -1.5px 0 var(--accent); }
.zh-sent .w + .w { margin-left: 0; }

.chars { display: grid; gap: 14px; }
.charcard { display: flex; gap: 22px; background: var(--surface); border-radius: var(--r-l); padding: 18px; box-shadow: var(--shadow); }
.charcard__stroke { display: flex; flex-direction: column; gap: 10px; flex: none; }
.charcard__info { flex: 1; min-width: 0; }
.charline { display: flex; align-items: baseline; gap: 12px; }
.charline__c { font-size: 34px; font-weight: 500; }
.charcard__def { margin: 4px 0 10px; }
.radical { color: var(--text); font-size: 17px; }
.parts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.part { display: flex; gap: 10px; align-items: center; padding: 8px 12px 8px 8px; border-radius: 14px; background: var(--surface-2); color: var(--text); }
.part__text { display: flex; flex-direction: column; line-height: 1.25; }
.part__text .badge { margin-top: 3px; align-self: flex-start; }
@media (max-width: 640px) { .charcard { flex-direction: column; align-items: stretch; } .charcard__stroke { align-items: center; } }

.stroke__canvas { width: var(--size); height: var(--size); background: #000; border-radius: calc(var(--size) * .14); display: grid; place-items: center; overflow: hidden; }
[data-theme="dark"] .stroke__canvas { box-shadow: inset 0 0 0 1px rgba(255,255,255,.16); }
.stroke__canvas svg { display: block; }
.stroke__msg { color: rgba(255,255,255,.6); font-size: 13px; text-align: center; display: grid; gap: 6px; padding: 12px; }
.stroke__msg span { font-size: 64px; color: #fff; }

.examples { list-style: none; padding: 0; margin: 0; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); }
.ex { display: flex; gap: 14px; align-items: center; padding: 14px 16px; }
.ex + .ex { border-top: 1px solid var(--line); }
.ex__main { flex: 1; min-width: 0; }
.ex__zh { font-size: 20px; line-height: 1.5; }
.ex__py { font-size: 13.5px; }
.ex__en { color: var(--text); font-size: 15px; margin-top: 2px; }

/* ───── cards ───── */
.cards-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.trainer-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.trainer-bar__count { margin-left: auto; color: var(--text-3); font-size: 13px; }
@media (max-width: 520px) { .trainer-bar__count { margin-left: 0; width: 100%; } .cards-head .btn { padding: 9px 14px; font-size: 14px; } }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track { width: 42px; height: 26px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--line); position: relative; transition: background .2s; }
.switch__thumb { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .22s var(--ease); }
.switch input:checked + .switch__track { background: var(--green); border-color: transparent; }
.switch input:checked + .switch__track .switch__thumb { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 4px var(--accent-soft); }

.flash { perspective: 1600px; outline: none; cursor: pointer; margin: 0 auto; max-width: 720px; }
.flash__inner { display: grid; transform-style: preserve-3d; transition: transform .5s var(--ease); }
.flash.is-flipped .flash__inner { transform: rotateY(180deg); }
.flash__face {
  grid-area: 1 / 1; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--surface); border-radius: 24px; box-shadow: var(--shadow-lg); min-height: 300px;
  padding: 36px 32px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 10px;
}
.flash__back { transform: rotateY(180deg); }
.flash:focus-visible .flash__face { box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-lg); }
.flash__label { position: absolute; top: 18px; left: 0; right: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 600; }
.flash__face { position: relative; }
.flash__zh { font-size: clamp(26px, 5.4vw, 38px); line-height: 1.45; font-weight: 500; }
.flash__py { font-size: clamp(15px, 2.6vw, 19px); }
.flash__en { font-size: clamp(20px, 3.8vw, 27px); line-height: 1.35; font-weight: 500; letter-spacing: -0.01em; max-width: 30ch; }
.flash__en--small { font-size: 17px; font-weight: 400; color: var(--text-2); }
.flash__note { font-size: 14px; color: var(--text-3); margin-top: 8px; }
.flash hr { max-width: 200px; margin: 6px auto; }

.answer { display: flex; justify-content: center; margin: 22px auto 0; max-width: 720px; }
.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: 100%; }
.rate__btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 16px; padding: 12px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; font: 600 15px/1.1 var(--font);
  transition: transform .12s var(--ease), background .2s, border-color .2s;
}
.rate__btn:active { transform: scale(.96); }
.rate__ivl { font-size: 12px; font-weight: 500; color: var(--text-3); }
.rate__btn--1 .rate__label { color: var(--red); }
.rate__btn--2 .rate__label { color: var(--orange); }
.rate__btn--3 .rate__label { color: var(--green); }
.rate__btn--4 .rate__label { color: var(--accent); }
.rate__btn:hover { border-color: currentColor; }
.card-tools { display: flex; justify-content: center; margin-top: 14px; }

.empty { text-align: center; padding: 48px 16px; display: grid; gap: 12px; justify-items: center; }
.empty h2 { max-width: 22ch; }
.empty p { max-width: 46ch; }
.empty--sm { padding: 24px; }
.empty__check { width: 64px; height: 64px; border-radius: 50%; background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); display: grid; place-items: center; font-size: 30px; font-weight: 700; }

.list-tools { margin-bottom: 12px; }
.sent-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); }
.sent { display: flex; gap: 12px; padding: 14px 16px; align-items: flex-start; }
.sent + .sent { border-top: 1px solid var(--line); }
.sent__main { flex: 1; min-width: 0; }
.sent__zh { font-size: 20px; line-height: 1.5; }
.sent__py { font-size: 13.5px; }
.sent__en { font-size: 15px; }
.sent__side { display: flex; align-items: center; gap: 2px; flex: none; }
.sent__side .badge { margin-right: 6px; }

/* ───── sheet (quick look) ───── */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.28); z-index: 40; opacity: 0; transition: opacity .25s; }
.sheet-backdrop.is-open { opacity: 1; }
.sheet {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; max-height: 86dvh; overflow: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg);
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .32s var(--ease); outline: none;
}
.sheet.is-open { transform: none; }
@media (min-width: 760px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: 560px; border-radius: 22px; transform: translate(-50%, -46%) scale(.98); opacity: 0; transition: transform .25s var(--ease), opacity .2s; padding: 20px 24px 24px; }
  .sheet.is-open { transform: translate(-50%, -50%); opacity: 1; }
  .sheet__grip { display: none; }
}
.sheet__grip { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.sheet__close { position: absolute; top: 12px; right: 12px; background: var(--surface-2); width: 30px; height: 30px; font-size: 13px; color: var(--text-2); }
.sheet__head { display: flex; align-items: center; gap: 16px; padding: 6px 36px 12px 0; }
.ql__tiles { display: flex; gap: 8px; flex-wrap: wrap; }
.ql__tiles .tile--lg { --s: 72px; }
.ql__title h2 { font-size: 30px; font-weight: 500; }
.ql__reading { padding: 6px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ql__reading .pinyin { font-size: 18px; color: var(--text); }
.ql__def { width: 100%; margin: 0; color: var(--text-2); }
.ql__stroke { display: flex; gap: 16px; align-items: center; margin: 14px 0 4px; padding: 14px; background: var(--surface-2); border-radius: 18px; }
.ql__strokeinfo { display: grid; gap: 8px; min-width: 0; }
.ql__charinfo .charline__c { font-size: 26px; }
.sheet__actions { display: flex; justify-content: flex-end; margin-top: 16px; }
@media (max-width: 759px) { .sheet__actions .btn { width: 100%; } }

/* ───── modal ───── */
.modal {
  border: 0; padding: 0; border-radius: 22px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 40px);
}
.modal--wide { width: min(640px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(0,0,0,.32); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.modal[open] { animation: pop .22s var(--ease); }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(6px); } to { opacity: 1; transform: none; } }
#modalBody { padding: 22px 24px 24px; }
#modalBody h3 { margin: 22px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); }
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.modal__foot { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; gap: 10px; flex-wrap: wrap; }
.btn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.btn-grid .btn { justify-content: flex-start; border-radius: 12px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 4px; }
.stats div { background: var(--surface-2); border-radius: 14px; padding: 12px; display: grid; }
.stats strong { font-size: 20px; letter-spacing: -0.02em; }
.stats span { font-size: 12px; color: var(--text-2); }
#imPasteBox { margin-top: 10px; display: grid; gap: 8px; }
.about { margin-top: 22px; }
.about summary { cursor: pointer; color: var(--text-2); font-size: 14px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 8px 0 0; align-items: center; }
.keys dd { margin: 0; color: var(--text-2); }

.editor { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field__label { font-size: 13px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.field__hint { font-weight: 400; color: var(--text-3); }
.field__label .link-btn { margin-left: auto; font-size: 13px; font-weight: 500; }
.field__help { font-size: 12.5px; color: var(--text-3); }
.field--inline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#edZh { font-size: 22px; font-family: var(--font-zh); }
.editor__preview { font-size: 20px; min-height: 0; padding: 0 2px; }
.editor__preview:empty { display: none; }

/* ───── toast ───── */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--tab) + env(safe-area-inset-bottom)); transform: translate(-50%, 12px); z-index: 60;
  background: rgba(29,29,31,.92); color: #fff; padding: 11px 18px; border-radius: 980px; font-size: 14px; font-weight: 500;
  opacity: 0; transition: opacity .2s, transform .25s var(--ease); pointer-events: none; max-width: calc(100vw - 32px); text-align: center;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
[data-theme="dark"] .toast { background: rgba(242,242,247,.94); color: #000; }
.noscript { padding: 24px; text-align: center; }

/* ───── theme toggle ───── */
.theme-btn .ico { display: none; }
:root[data-theme-pref="auto"] .theme-btn .ico--auto,
:root[data-theme-pref="light"] .theme-btn .ico--light,
:root[data-theme-pref="dark"] .theme-btn .ico--dark { display: block; }
.theme-btn svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[data-theme="dark"] .switch__track { background: #39393d; }
[data-theme="dark"] .seg > .is-on { background: #636366; box-shadow: none; }
[data-theme="dark"] .modal::backdrop, [data-theme="dark"] .sheet-backdrop { background: rgba(0,0,0,.6); }
[data-theme="dark"] .rate__btn, [data-theme="dark"] .chip--try { background: var(--surface); }

/* ───── tappable words: a faint underline per word shows where words begin and end ───── */
.zh-sent .w {
  background-image: linear-gradient(color-mix(in srgb, var(--text) 22%, transparent), color-mix(in srgb, var(--text) 22%, transparent));
  background-repeat: no-repeat; background-size: calc(100% - 4px) 1.5px; background-position: 50% 96%;
  border-radius: 3px; padding: 0 1px;
}
.zh-sent .w:hover, .zh-sent .w.is-active {
  background-color: var(--accent-soft);
  background-image: linear-gradient(var(--accent), var(--accent)); background-size: calc(100% - 4px) 2px;
  box-shadow: none;
}

/* ───── word panel ───── */
@media (min-width: 760px) { .sheet { width: 620px; max-height: 88vh; } }
.wp__back {
  position: absolute; top: 14px; left: 16px; border: 0; background: var(--surface-2); color: var(--accent);
  font: 500 14px/1 var(--font); padding: 7px 11px; border-radius: 980px; cursor: pointer;
}
.wp__back + .ql__tiles { margin-top: 34px; }
.sheet__head { flex-wrap: wrap; }
.wp__reading { padding: 8px 0; }
.wp__reading + .wp__reading { border-top: 1px dashed var(--line); }
.wp__rhead { display: flex; align-items: center; gap: 10px; }
.wp__def { margin: 2px 0 0; }
.wp__sec { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); display: grid; gap: 12px; }
.wp__sec h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); font-weight: 600; }
.wp__sec h3 [lang] { text-transform: none; font-size: 15px; color: var(--text); }
.wp__compose { display: grid; gap: 8px; }
.wp__piece {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; padding: 8px 12px 8px 8px;
  border: 0; border-radius: 14px; background: var(--surface-2); color: var(--text); font: inherit; cursor: pointer;
}
.wp__piece > span:nth-child(2) { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.wp__piece:hover { background: color-mix(in srgb, var(--surface-2) 70%, var(--accent-soft)); }
.wp__chev { color: var(--text-3); font-size: 22px; }
.wp__char { display: flex; gap: 18px; align-items: flex-start; }
.wp__stroke { display: grid; gap: 8px; flex: none; justify-items: center; }
.wp__charinfo { min-width: 0; flex: 1; }
.wp__cdef { margin: 2px 0 8px; }
.wp__facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 6px; font-size: 14px; }
.wp__facts dt { color: var(--text-3); }
.wp__facts dd { margin: 0; }
.wp__link { border: 0; background: var(--accent-soft); color: var(--accent); border-radius: 6px; padding: 1px 6px; font: 500 16px/1.4 var(--font-zh); cursor: pointer; }
.wp__sents { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.wp__sents li { display: grid; font-size: 17px; }
.wp__sents mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
.part { border: 0; font: inherit; cursor: pointer; text-align: left; }
.part:hover { background: color-mix(in srgb, var(--surface-2) 70%, var(--accent-soft)); }
@media (max-width: 520px) { .wp__char { flex-direction: column; align-items: stretch; } .wp__stroke { justify-self: center; } }

/* ───── listen buttons ───── */
.say {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; flex: none;
  border: 0; background: var(--accent-soft); color: var(--accent); cursor: pointer; vertical-align: middle;
  transition: transform .12s var(--ease), background .2s; -webkit-touch-callout: none; user-select: none;
}
.say svg path:not(:first-child) { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.say:hover { background: var(--accent); color: #fff; }
.say:active { transform: scale(.92); }
.say--lg { width: 42px; height: 42px; }
.say--lg svg { width: 22px; height: 22px; }
.say.is-playing .say__w1 { animation: wave 1s infinite; }
.say.is-playing .say__w2 { animation: wave 1s .2s infinite; }
@keyframes wave { 0%,100% { opacity: .25; } 50% { opacity: 1; } }
.no-tts .say { display: none; }
.flash__zhrow { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.word__titlerow { display: flex; align-items: center; gap: 14px; }
.ql__title { display: flex; align-items: center; gap: 12px; }
.charline .say { align-self: center; }
.ex__zh .say, .breakdown__zh .say { margin-left: 4px; }
.rate__q { text-align: center; color: var(--text-2); font-size: 14px; margin: 0 0 10px; width: 100%; }
.answer { flex-direction: column; align-items: center; }
select.input { appearance: auto; width: auto; max-width: 60%; }

/* whole-word illustration: same black rounded tile, wide */
.wtile {
  --s: 56px; height: var(--s); aspect-ratio: 1070 / 507; flex: none; display: inline-block; background: #000;
  border-radius: calc(var(--s) * .22); overflow: hidden; position: relative; vertical-align: middle;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
.wtile img { width: 100%; height: 100%; object-fit: contain; display: block; }
.wtile.tile--xl { --s: 128px; } .wtile.tile--lg { --s: 92px; } .wtile.tile--md { --s: 64px; } .wtile.tile--sm { --s: 36px; }
[data-theme="dark"] .wtile { box-shadow: none; }
[data-theme="dark"] .wtile::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(255,255,255,.16); pointer-events: none; }
@media (max-width: 640px) { .word__tiles .wtile.tile--xl { --s: 104px; } }
