/* ============================================================
   字帖画布 · 手写识字卡
   ============================================================ */
:root {
  --paper: #f6f2e9;
  --paper-2: #fffdf8;
  --ink: #221f1b;
  --ink-soft: #6f675c;
  --ink-faint: #a89f92;
  --line: #e6ddcd;
  --line-strong: #d6c9b3;
  --red: #bf4a37;
  --red-soft: #d98a77;
  --gold: #b4893c;
  --green: #3d6b57;
  --card: #fffdf9;
  --shadow-soft: 0 12px 34px rgba(74, 58, 32, 0.13), 0 2px 6px rgba(74, 58, 32, 0.06);
  --shadow-card: 0 18px 44px rgba(74, 58, 32, 0.16), 0 2px 8px rgba(74, 58, 32, 0.07);
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  --font-kai: "Kaiti SC", "STKaiti", "KaiTi", "楷体", "BiauKai", "Songti SC", "SimSun", serif;
  --font-serif: "Songti SC", "STSong", "Noto Serif SC", Georgia, serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body { position: fixed; inset: 0; }

button { font-family: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

#app { position: absolute; inset: 0; }

/* ---------------- canvas stage ---------------- */
#stage {
  position: absolute; inset: 0;
  touch-action: none;
  overflow: hidden;
  overflow: clip;
  background:
    radial-gradient(120% 90% at 50% -10%, #fdfaf3 0%, #f6f2e9 45%, #f1ebdf 100%);
}

#stage canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}
#live { pointer-events: none; }

#world {
  position: absolute; top: 0; left: 0;
  width: 0; height: 0;
  transform-origin: 0 0;
  pointer-events: none;
}
#world > * { pointer-events: auto; }

/* ---------------- empty state ---------------- */
#emptyState {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  pointer-events: none;
  transition: opacity .45s ease, transform .45s ease;
  padding: 24px;
}
#emptyState.gone { opacity: 0; transform: scale(.98); pointer-events: none; }
.es-card {
  pointer-events: auto;
  width: min(560px, 92vw);
  text-align: center;
  padding: 34px 30px 26px;
  border-radius: 28px;
  background: rgba(255, 253, 248, .72);
  border: 1px solid rgba(214, 201, 179, .55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  box-shadow: 0 24px 60px rgba(74, 58, 32, .07);
}
.es-glyph {
  width: 74px; height: 74px; margin: 0 auto 14px;
  display: grid; place-items: center;
  font-family: var(--font-kai); font-size: 46px; color: #fff;
  background: linear-gradient(160deg, #cd5f49, #a83c2b);
  border-radius: 20px;
  box-shadow: 0 12px 26px rgba(168, 60, 43, .28);
}
.es-card h2 {
  margin: 0 0 8px; font-size: 22px; font-weight: 600; letter-spacing: .04em;
  font-family: var(--font-serif);
}
.es-card p { margin: 0; color: var(--ink-soft); font-size: 14px; line-height: 1.85; }
.es-samples { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 22px 0 16px; }
.es-samples button {
  width: 62px; height: 62px; border-radius: 16px;
  background: #fffdf8; border: 1px solid var(--line);
  display: grid; place-items: center; gap: 0;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
  box-shadow: 0 2px 6px rgba(74,58,32,.05);
}
.es-samples button span { font-family: var(--font-kai); font-size: 27px; line-height: 1; }
.es-samples button i { font-style: normal; font-size: 10px; color: var(--ink-faint); margin-top: 3px; }
.es-samples button:hover { transform: translateY(-2px); border-color: var(--red-soft); box-shadow: 0 8px 18px rgba(191,74,55,.15); }
.es-tip { font-size: 12px !important; color: var(--ink-faint) !important; letter-spacing: .04em; }

.hint {
  position: absolute; left: 50%; bottom: calc(96px + var(--safe-b));
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: 999px;
  background: rgba(255, 253, 248, .78);
  border: 1px solid var(--line);
  color: var(--ink-soft); font-size: 12px; letter-spacing: .02em;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  pointer-events: none;
  transition: opacity .5s ease;
  white-space: nowrap;
}
.hint b { color: var(--line-strong); font-weight: 400; }
.hint.gone { opacity: 0; }

/* ---------------- top bar ---------------- */
#topbar {
  position: absolute; top: 0; left: 0; right: 0;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
  background: linear-gradient(180deg, rgba(247, 243, 234, .97) 0%, rgba(247, 243, 234, .88) 72%, rgba(247, 243, 234, 0) 100%);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: flex; align-items: flex-start; justify-content: space-between;
  pointer-events: none; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; pointer-events: auto; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  font-family: var(--font-kai); font-size: 25px; color: #fff;
  background: linear-gradient(160deg, #cd5f49, #a83c2b);
  box-shadow: 0 8px 18px rgba(168, 60, 43, .24);
}
.brand-text h1 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: .08em; }
.brand-text p { margin: 2px 0 0; font-size: 10.5px; color: var(--ink-faint); letter-spacing: .12em; }

.top-actions { display: flex; align-items: center; gap: 8px; pointer-events: auto; }
.pill-btn {
  display: flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 15px;
  border-radius: 999px; font-size: 13px;
  background: rgba(255, 253, 248, .86);
  border: 1px solid var(--line);
  color: var(--ink);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 3px 10px rgba(74, 58, 32, .05);
  transition: transform .15s, border-color .15s, background .15s;
}
.pill-btn:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.pill-btn .ico { font-size: 15px; opacity: .8; }
.round-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255, 253, 248, .86);
  border: 1px solid var(--line);
  font-size: 16px; color: var(--ink-soft);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: transform .15s, border-color .15s;
}
.round-btn:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.round-btn:disabled { opacity: .32; cursor: default; transform: none; }
.round-btn.small { width: 32px; height: 32px; font-size: 18px; }

/* ---------------- dock ---------------- */
.dock {
  position: absolute; left: 50%; bottom: calc(16px + var(--safe-b));
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 253, 248, .9);
  border: 1px solid rgba(214, 201, 179, .7);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  backdrop-filter: blur(16px) saturate(1.1);
  box-shadow: var(--shadow-soft);
  z-index: 40;
}
.dock-group { display: flex; align-items: center; gap: 4px; }
.dock-sep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }
.tool {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--ink-soft);
  transition: background .15s, color .15s, transform .15s;
}
.tool svg { width: 21px; height: 21px; }
.tool:hover { background: rgba(191, 74, 55, .07); color: var(--ink); }
.tool.active { background: var(--ink); color: #fff7ee; }
.tool:disabled { opacity: .32; }
.swatch {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--c);
  border: 2px solid transparent;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .06);
  transition: transform .15s, box-shadow .15s;
}
.swatch.active { box-shadow: 0 0 0 2px #fffdf8, 0 0 0 4px var(--c); transform: scale(.94); }

/* ---------------- recognize fab ---------------- */
.recognize-fab {
  position: absolute; right: 18px; bottom: calc(88px + var(--safe-b));
  display: flex; align-items: center; gap: 8px;
  height: 46px; padding: 0 18px 0 8px;
  border-radius: 999px;
  background: linear-gradient(160deg, #cb5c46, #a93b2a);
  color: #fff8f0;
  box-shadow: 0 14px 30px rgba(169, 59, 42, .32);
  font-size: 13px; letter-spacing: .06em;
  z-index: 40;
  animation: fabIn .28s ease;
}
@keyframes fabIn { from { opacity: 0; transform: translateY(8px) scale(.94); } }
.fab-ico {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .16);
  font-family: var(--font-kai); font-size: 17px;
}
.fab-count {
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
  background: rgba(255, 255, 255, .9); color: var(--red);
  font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}

/* ---------------- cards ---------------- */
.card {
  position: absolute;
  width: 328px;
  background: var(--card);
  border-radius: 20px;
  border: 1px solid rgba(214, 201, 179, .55);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transform-origin: 0 0;
  animation: cardIn .32s cubic-bezier(.2, .9, .3, 1.2);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(10px) scale(.94); } }
.card.dragging { box-shadow: 0 26px 60px rgba(74, 58, 32, .26); z-index: 5; }

.card::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px;
  background: linear-gradient(90deg, #c9583f, #d9a05b 55%, #8fa88a);
  opacity: .9;
}

.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 14px 8px;
  cursor: grab;
}
.card-head:active { cursor: grabbing; }
.card-glyph {
  width: 40px; height: 40px; flex: 0 0 auto;
  border-radius: 12px;
  display: grid; place-items: center;
  font-family: var(--font-kai); font-size: 25px; line-height: 1;
  color: var(--red);
  background: #fdf1ec;
  border: 1px solid #f2d9d0;
}
.card-py-wrap { flex: 1; min-width: 0; }
.card-py {
  font-family: var(--font-serif);
  font-size: 21px; letter-spacing: .02em; color: var(--ink);
  line-height: 1.2;
}
.card-py-sub {
  font-size: 10.5px; color: var(--ink-faint); letter-spacing: .04em;
  margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.icon-btn {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--ink-soft); font-size: 14px;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: #f4eee2; color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }
.card-close { opacity: .5; }
.card-close:hover { opacity: 1; color: var(--red); background: #fbeae5; }

.card-body { padding: 0 14px 14px; }

/* tianzige */
.tianzige {
  position: relative;
  width: 100%;
  max-width: 240px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  background:
    linear-gradient(180deg, #fffefb, #fdfbf5);
  overflow: hidden;
}
.tianzige .grid-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.tianzige .grid-svg .outer { fill: none; stroke: #dfa99a; stroke-width: 0.9; }
.tianzige .grid-svg .cross { fill: none; stroke: #e7c0b4; stroke-width: .5; stroke-dasharray: 3 2.4; }
.tianzige .grid-svg .diag { fill: none; stroke: #f0d7ce; stroke-width: .4; stroke-dasharray: 2 3; opacity: .7; }
.tianzige .writer { position: absolute; inset: 4%; display: grid; place-items: center; }
.tianzige .writer svg { display: block; }
.tianzige .trace-hint {
  position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%);
  font-size: 10px; letter-spacing: .1em; color: var(--red);
  background: rgba(255, 253, 248, .9); padding: 2px 8px; border-radius: 999px;
  pointer-events: none; transition: opacity .3s;
}

.card-meta {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px;
}
.meta-chip {
  font-size: 10.5px; letter-spacing: .05em; color: var(--ink-soft);
  background: #f7f2e7; border: 1px solid var(--line);
  padding: 3px 9px; border-radius: 999px;
}
.meta-chip b { font-weight: 600; color: var(--ink); }
.card-meta .spacer { flex: 1; }
.mini-btn {
  height: 28px; padding: 0 11px; border-radius: 999px;
  font-size: 11.5px; letter-spacing: .04em;
  background: #fff; border: 1px solid var(--line);
  color: var(--ink);
  transition: background .15s, border-color .15s, color .15s;
  display: inline-flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.mini-btn:hover { border-color: var(--line-strong); background: #fbf7ee; }
.mini-btn.accent { background: #fdf1ec; border-color: #f0d3c9; color: var(--red); }
.mini-btn.accent:hover { background: #fbe6de; }

/* 音节 / 声母 / 韵母 / 声调 */
.syllable-row { display: flex; gap: 6px; margin-top: 8px; }
.syl {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 3px 5px;
  border-radius: 9px;
  background: #fbf6ec;
  border: 1px solid #f0e6d4;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.syl:hover { background: #f8f1e3; }
.syl b {
  font-family: var(--font-serif);
  font-size: 15px; font-weight: 600; line-height: 1.15;
  color: var(--ink);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.syl span { font-size: 8.5px; letter-spacing: .1em; color: var(--ink-faint); }
.syl-syllable { background: #fdf1ec; border-color: #f2d9d0; }
.syl-syllable b { color: var(--red); }
.syl-radical { background: #f9f2e3; border-color: #e9d9ba; }
.syl-radical b { color: var(--gold); }

/* sections */
.sec-title {
  display: flex; align-items: center; gap: 8px;
  margin: 11px 0 6px;
  font-size: 10.5px; letter-spacing: .18em; color: var(--ink-faint);
}
.sec-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* stroke strip */
.strip {
  display: flex; gap: 6px; overflow-x: auto; padding-bottom: 3px;
  scrollbar-width: none;
}
.strip::-webkit-scrollbar { display: none; }
.strip-cell {
  position: relative; flex: 0 0 auto;
  width: 46px; height: 46px; border-radius: 8px;
  background: #fffefb; border: 1px solid var(--line);
  overflow: hidden;
}
.strip-cell svg { width: 100%; height: 100%; display: block; }
.strip-cell .n {
  position: absolute; left: 3px; top: 2px;
  font-size: 8.5px; line-height: 1; color: #fff;
  background: var(--red); border-radius: 50%;
  width: 13px; height: 13px; display: grid; place-items: center;
  font-weight: 700;
}
.strip-cell .ghost { fill: #e6ddcf; }

/* words */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 11px; border-radius: 11px;
  background: #fbf7ee; border: 1px solid #ece1cd;
  transition: background .15s, border-color .15s, transform .15s;
}
.chip:hover { background: #fdf2e9; border-color: #eccfbf; transform: translateY(-1px); }
.chip b { font-weight: 500; font-family: var(--font-kai); font-size: 17px; line-height: 1.15; letter-spacing: .02em; }
.chip i { font-style: normal; font-size: 9.5px; color: var(--ink-faint); letter-spacing: .02em; }

/* example sentence */
.ex {
  position: relative;
  padding: 8px 11px 8px 13px;
  border-radius: 10px;
  background: linear-gradient(180deg, #fdf7ee, #fbf8f2);
  border: 1px solid #f0e4d2;
  font-size: 13.5px; line-height: 1.7; color: #3a352e;
  font-family: var(--font-serif);
}
.ex + .ex { margin-top: 6px; }
.ex mark { background: transparent; color: var(--red); font-weight: 600; padding: 0 1px; }
.ex .speak-inline {
  position: absolute; right: 4px; bottom: 4px;
  width: 24px; height: 24px; border-radius: 50%;
  color: var(--ink-faint); display: grid; place-items: center;
}
.ex .speak-inline:hover { color: var(--red); background: #fdf1ec; }
.make-sentence {
  margin-top: 5px;
  font-size: 10.5px; color: var(--ink-faint);
  letter-spacing: .04em;
  padding-left: 2px;
}

.card-foot {
  display: flex; align-items: center; gap: 6px; margin-top: 14px;
  padding-top: 10px; border-top: 1px dashed var(--line);
}
.card-foot .hintline { font-size: 10px; color: var(--ink-faint); letter-spacing: .04em; margin-left: auto; }

/* ---------------- sheet ---------------- */
.sheet {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(620px, 100%);
  background: var(--paper-2);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -18px 50px rgba(74, 58, 32, .2);
  border: 1px solid var(--line);
  border-bottom: 0;
  padding: 8px 18px calc(16px + var(--safe-b));
  z-index: 60;
  animation: sheetIn .26s cubic-bezier(.2, .8, .3, 1);
}
@keyframes sheetIn { from { transform: translate(-50%, 30px); opacity: .4; } }
.sheet-handle { width: 38px; height: 4px; border-radius: 999px; background: var(--line-strong); margin: 4px auto 10px; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; }
.sheet-head h3 { margin: 0; font-size: 16px; font-family: var(--font-serif); letter-spacing: .04em; }
.sheet-head p { margin: 3px 0 0; font-size: 11.5px; color: var(--ink-faint); }
.sheet-body {
  display: flex; gap: 10px; overflow-x: auto; padding: 14px 2px 10px;
  justify-content: center;
  scrollbar-width: none;
}
.sheet-body::-webkit-scrollbar { display: none; }
.recog-item {
  flex: 0 0 auto; width: 132px;
  border-radius: 14px; border: 1px solid var(--line);
  background: #fff; padding: 10px;
}
.recog-item .pick {
  font-family: var(--font-kai); font-size: 44px; line-height: 1;
  text-align: center; padding: 4px 0 6px;
  border-bottom: 1px dashed var(--line);
  color: var(--ink);
}
.recog-item .alts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.recog-item .alts button {
  flex: 1 0 30%; padding: 6px 0; border-radius: 8px;
  font-family: var(--font-kai); font-size: 18px;
  background: #faf6ec; border: 1px solid transparent; color: var(--ink-soft);
}
.recog-item .alts button.active { background: #fdf1ec; border-color: #eecfbf; color: var(--red); font-weight: 700; }
.recog-item .alts button:hover { background: #f5eee0; }
.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 6px; }

/* ---------------- buttons / modal ---------------- */
.primary-btn {
  height: 42px; padding: 0 22px; border-radius: 12px;
  background: linear-gradient(160deg, #c9573f, #a6392a);
  color: #fff9f2; font-size: 14px; letter-spacing: .06em;
  box-shadow: 0 8px 18px rgba(166, 57, 42, .24);
  transition: transform .15s, box-shadow .15s;
}
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 24px rgba(166, 57, 42, .3); }
.ghost-btn {
  height: 42px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: #fffdf8; color: var(--ink-soft);
  font-size: 13.5px; letter-spacing: .04em;
}
.ghost-btn:hover { background: #faf5ea; color: var(--ink); }
.ghost-btn.danger:hover { color: var(--red); border-color: #e2b4a6; background: #fdf1ec; }

.modal {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center;
  background: rgba(40, 33, 24, .32);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  padding: 20px;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal-card {
  width: min(420px, 100%);
  background: var(--paper-2); border-radius: 22px;
  padding: 22px;
  box-shadow: 0 30px 70px rgba(40, 33, 24, .3);
  animation: popIn .22s cubic-bezier(.2, .9, .3, 1.15);
}
.modal-card.wide { width: min(560px, 100%); }
@keyframes popIn { from { transform: translateY(12px) scale(.97); opacity: 0; } }
.modal-card h3 { margin: 0 0 6px; font-size: 17px; font-family: var(--font-serif); letter-spacing: .05em; }
.modal-card > p { margin: 0 0 14px; font-size: 12.5px; color: var(--ink-faint); line-height: 1.7; }
#typeInput {
  width: 100%; height: 52px; padding: 0 16px;
  font-size: 20px; font-family: var(--font-kai);
  border-radius: 12px; border: 1px solid var(--line-strong);
  background: #fff; color: var(--ink);
  outline: none;
}
#typeInput:focus { border-color: var(--red-soft); box-shadow: 0 0 0 3px rgba(191, 74, 55, .1); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.help-list { margin: 6px 0 16px; padding: 0 0 0 2px; list-style: none; }
.help-list li { font-size: 13px; line-height: 1.9; color: var(--ink-soft); border-bottom: 1px dashed var(--line); padding: 6px 0; }
.help-list li:last-child { border-bottom: 0; }
.help-list b { color: var(--ink); font-weight: 600; margin-right: 6px; }
.pref-row { display: flex; flex-direction: column; gap: 12px; padding: 4px 0 2px; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .slider {
  width: 40px; height: 23px; border-radius: 999px; background: #e3dac9;
  position: relative; transition: background .2s; flex: 0 0 auto;
}
.switch .slider::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 17px; height: 17px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s;
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::after { transform: translateX(17px); }
.pref-label { font-size: 13px; color: var(--ink-soft); }
.credits { margin: 16px 0 0 !important; font-size: 10.5px !important; color: var(--ink-faint) !important; letter-spacing: .02em; }

.toast {
  position: fixed; left: 50%; bottom: calc(120px + var(--safe-b));
  transform: translateX(-50%);
  background: rgba(34, 31, 27, .9); color: #fdf8f0;
  font-size: 12.5px; letter-spacing: .04em;
  padding: 9px 18px; border-radius: 999px;
  z-index: 90; pointer-events: none;
  animation: toastIn .2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 6px); } }

/* ---------------- responsive ---------------- */
@media (max-width: 720px) {
  .brand-text p { display: none; }
  .pill-btn .lbl { display: none; }
  .pill-btn { padding: 0; width: 40px; justify-content: center; }
  .hint { display: none; }
  .sheet-body { padding-bottom: 6px; }
  .recog-item { width: 118px; }
  .recognize-fab { right: 14px; bottom: calc(80px + var(--safe-b)); }
}

@media (max-width: 540px) {
  .brand-mark { width: 36px; height: 36px; border-radius: 10px; font-size: 22px; }
  .brand-text h1 { font-size: 13.5px; }
  .dock { gap: 3px; padding: 6px 8px; }
  .dock-group { gap: 2px; }
  .dock-sep { height: 18px; margin: 0 1px; }
  .tool { width: 36px; height: 36px; }
  .tool svg { width: 19px; height: 19px; }
  .swatch { width: 20px; height: 20px; }
  .round-btn, .pill-btn { width: 36px; height: 36px; }
  .card-glyph { width: 36px; height: 36px; font-size: 22px; }
  .card-py { font-size: 19px; }
}
@media (max-height: 620px) {
  .dock { bottom: calc(8px + var(--safe-b)); }
  .hint { display: none; }
}

/* ---------------- 生字本 ---------------- */
.ico-svg { width: 15px; height: 15px; opacity: .8; }
.wb-card {
  width: min(1060px, 96vw);
  height: min(868px, 94vh);
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.wb-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px 24px 8px;
}
.wb-head h3 { margin: 0 0 4px; font-size: 18px; font-family: var(--font-serif); letter-spacing: .05em; }
.wb-head p { margin: 0; font-size: 12px; color: var(--ink-faint); }
.wb-body {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 320px 1fr; gap: 18px;
  padding: 6px 24px 0;
}
.wb-form { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; padding-right: 4px; }
.wb-form > * { flex: 0 0 auto; }
.wb-label-row { display: flex; align-items: center; justify-content: space-between; }
.wb-label { font-size: 11px; letter-spacing: .12em; color: var(--ink-faint); }
.link-btn { font-size: 11.5px; color: var(--red); background: none; border: 0; padding: 0; }
.link-btn:hover { text-decoration: underline; }
#wbChars {
  width: 100%; height: 136px; resize: none;
  border-radius: 12px; border: 1px solid var(--line-strong);
  background: #fff; padding: 12px;
  font-size: 15px; line-height: 1.75; font-family: var(--font-kai);
  color: var(--ink); outline: none;
}
#wbChars:focus { border-color: var(--red-soft); box-shadow: 0 0 0 3px rgba(191, 74, 55, .1); }
#wbTitle {
  height: 38px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: #fff; padding: 0 12px; font-size: 14px; color: var(--ink); outline: none; width: 100%;
}
#wbTitle:focus { border-color: var(--red-soft); }
.wb-hint { font-size: 11px; color: var(--ink-faint); }
.seg { display: flex; gap: 4px; background: #f4eee2; padding: 3px; border-radius: 10px; width: fit-content; }
.seg button { width: 40px; height: 30px; border-radius: 8px; font-size: 13px; color: var(--ink-soft); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); font-weight: 600; }
.wb-toggles { display: flex; gap: 18px; flex-wrap: wrap; padding: 6px 0 2px; }
.wb-preview {
  position: relative; min-width: 0; overflow: hidden;
  background: #f3eee3; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 14px;
}
#wbCanvas {
  width: auto; height: auto;
  max-width: 100%; max-height: calc(100% - 46px);
  background: #fff; border-radius: 2px;
  box-shadow: 0 12px 30px rgba(70, 55, 35, .16);
}
.wb-pager { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 12px; color: var(--ink-soft); }
.wb-pager .icon-btn { width: 28px; height: 28px; border-radius: 8px; background: #fff; border: 1px solid var(--line); font-size: 16px; }
.wb-pager .icon-btn:hover { background: #fff; border-color: var(--line-strong); }
.wb-pager .icon-btn:disabled { opacity: .3; }
.wb-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 24px calc(16px + var(--safe-b));
  border-top: 1px solid var(--line);
  margin-top: 12px;
}
.wb-actions button:disabled { opacity: .4; }

@media (max-width: 820px) {
  .wb-card { height: 94vh; }
  .wb-body { display: block; overflow-y: auto; padding-bottom: 6px; }
  .wb-form { overflow: visible; }
  #wbChars { height: 108px; }
  .wb-preview { min-height: 360px; margin-top: 14px; }
  #wbCanvas { max-height: 44vh; }
  .wb-toggles { gap: 12px; }
}

/* ---------------- 列表模式 + 书写台 ---------------- */
.mode-toggle {
  display: flex; gap: 2px; padding: 3px;
  background: rgba(255, 253, 248, .86);
  border: 1px solid var(--line);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.mode-toggle button {
  height: 32px; padding: 0 14px; border-radius: 999px;
  font-size: 12.5px; color: var(--ink-soft);
  transition: background .15s, color .15s;
}
.mode-toggle button.on { background: var(--ink); color: #fff7ee; }

.flow {
  position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: calc(76px + env(safe-area-inset-top, 0px)) 18px calc(34px + env(safe-area-inset-bottom, 0px));
}
.flow-inner { max-width: 1180px; margin: 0 auto; }

.pad-wrap {
  display: flex; gap: 22px; align-items: center;
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(255, 253, 248, .82);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  max-width: 680px;
  margin: 0 auto 26px;
}
.pad {
  position: relative;
  width: 250px; height: 250px; flex: 0 0 auto;
  border-radius: 14px;
  background: #fffefb;
  border: 1px solid #eed9d1;
  overflow: hidden;
}
.pad-grid { position: absolute; inset: 0; width: 100%; height: 100%; }
#padCanvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.pad-hint {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--ink-faint); font-size: 13px; letter-spacing: .1em;
  pointer-events: none; transition: opacity .25s;
}
.pad-side { flex: 1; min-width: 0; }
.pad-head h2 { margin: 0; font-size: 16px; font-family: var(--font-serif); letter-spacing: .06em; }
.pad-sub { display: block; margin-top: 4px; font-size: 12px; color: var(--ink-faint); }
.pad-candidates { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 2px; }
.pad-candidates button {
  min-width: 48px; height: 58px; padding: 4px 9px;
  border-radius: 12px; background: #fff; border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  transition: border-color .15s, background .15s, transform .15s;
}
.pad-candidates button b { font-family: var(--font-kai); font-size: 27px; line-height: 1; font-weight: 500; }
.pad-candidates button i { font-style: normal; font-size: 9.5px; color: var(--ink-faint); }
.pad-candidates button:hover { border-color: var(--red-soft); transform: translateY(-1px); }
.pad-candidates button.top { background: #fdf1ec; border-color: #eecfbf; }
.pad-none { font-size: 12px; color: var(--ink-faint); }
.pad-actions { display: flex; gap: 8px; margin-top: 12px; }
.pad-tip { margin: 12px 0 0; font-size: 11px; color: var(--ink-faint); }

.flow-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(316px, 340px));
  gap: 24px;
  justify-content: center;
}
#flowList .card {
  position: relative !important;
  left: auto !important;
  top: auto !important;
  width: 100%;
  touch-action: pan-y;
}
#flowList .card .tianzige.tracing { touch-action: none; }
#flowList .card .card-head { cursor: default; }

.flow-empty { text-align: center; padding: 22px 10px 40px; }
.flow-empty-title { margin: 0 0 6px; font-family: var(--font-serif); font-size: 16px; }
.flow-empty-sub { margin: 0 0 18px; font-size: 12.5px; color: var(--ink-faint); }
.flow-samples { justify-content: center; margin: 0; }

@media (max-width: 860px) {
  .pad-wrap { flex-direction: column; align-items: stretch; gap: 16px; }
  .pad { width: min(100%, 320px); height: auto; aspect-ratio: 1 / 1; margin: 0 auto; }
  .flow-list { grid-template-columns: 1fr; justify-items: center; }
  .flow-list .card { max-width: 360px; }
}
@media (max-width: 540px) {
  .flow { padding-left: 12px; padding-right: 12px; }
  .mode-toggle button { padding: 0 10px; font-size: 12px; }
  .top-actions { gap: 6px; }
}

/* ---------------- 字库主页 ---------------- */
.write-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 18px 0 14px;
  border-radius: 999px;
  background: linear-gradient(160deg, #c9573f, #a6392a);
  color: #fff8f0; font-size: 13px; letter-spacing: .04em;
  box-shadow: 0 8px 18px rgba(166, 57, 42, .26);
  transition: transform .15s, box-shadow .15s;
}
.write-btn svg { width: 17px; height: 17px; }
.write-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 24px rgba(166, 57, 42, .32); }

#library {
  position: absolute; inset: 0;
  overflow-y: auto;
  padding: calc(84px + env(safe-area-inset-top, 0px)) 20px calc(40px + env(safe-area-inset-bottom, 0px));
}
.lib-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  max-width: 1180px; margin: 0 auto 18px;
}
.lib-title { display: flex; align-items: baseline; gap: 10px; }
.lib-title h2 { margin: 0; font-size: 20px; font-family: var(--font-serif); letter-spacing: .06em; }
#libCount { font-size: 12px; color: var(--ink-faint); letter-spacing: .04em; }
#libSearch {
  height: 34px; width: 190px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line);
  background: rgba(255, 253, 248, .9); color: var(--ink);
  font-size: 12.5px; outline: none;
}
#libSearch:focus { border-color: var(--red-soft); box-shadow: 0 0 0 3px rgba(191, 74, 55, .08); }

.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 14px;
  max-width: 1180px; margin: 0 auto;
}
.tile {
  position: relative;
  aspect-ratio: 1 / 1.06;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid rgba(214, 201, 179, .7);
  box-shadow: 0 3px 10px rgba(74, 58, 32, .06);
  transition: transform .16s, box-shadow .16s, border-color .16s;
}
.tile:hover { transform: translateY(-2px); border-color: var(--red-soft); box-shadow: 0 10px 22px rgba(74, 58, 32, .13); }
.tile-char { font-family: var(--font-kai); font-size: 44px; line-height: 1; color: var(--ink); }
.tile-py { font-family: var(--font-serif); font-size: 11px; color: var(--ink-faint); letter-spacing: .02em; }
.lib-none { grid-column: 1 / -1; text-align: center; color: var(--ink-faint); font-size: 13px; padding: 30px 0; }

.lib-empty { max-width: 560px; margin: 26px auto 0; text-align: center; }
.lib-empty-mark {
  width: 74px; height: 74px; margin: 0 auto 16px;
  display: grid; place-items: center;
  font-family: var(--font-kai); font-size: 46px; color: #fff;
  background: linear-gradient(160deg, #cd5f49, #a83c2b);
  border-radius: 20px;
  box-shadow: 0 12px 26px rgba(168, 60, 43, .26);
}
.lib-empty h3 { margin: 0 0 8px; font-family: var(--font-serif); font-size: 19px; letter-spacing: .04em; }
.lib-empty p { margin: 0; font-size: 13px; line-height: 1.85; color: var(--ink-soft); }
.lib-empty .es-samples { margin: 22px 0 14px; justify-content: center; }
.lib-empty-tip { font-size: 11.5px !important; color: var(--ink-faint) !important; }

/* ---------------- 写字台弹层 ---------------- */
.pad-sheet {
  width: min(440px, 94vw);
  background: var(--paper-2);
  border-radius: 24px;
  padding: 18px 20px 20px;
  box-shadow: 0 30px 70px rgba(40, 33, 24, .3);
  animation: popIn .22s cubic-bezier(.2, .9, .3, 1.15);
}
.pad-sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.pad-sheet-head h3 { margin: 0; font-size: 17px; font-family: var(--font-serif); letter-spacing: .05em; }
.pad-sheet-head p { margin: 4px 0 0; font-size: 12px; color: var(--ink-faint); }
.pad-sheet .pad {
  width: min(100%, 42vh);
  aspect-ratio: 1 / 1;
  height: auto;
  margin: 14px auto 0;
}
.pad-sheet .pad-candidates { min-height: 0; margin-top: 12px; }
.pad-sheet-actions { display: flex; gap: 8px; margin-top: 14px; }

/* ---------------- 字卡详情 ---------------- */
.detail {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column;
  background:
    radial-gradient(120% 90% at 50% -10%, #fdfaf3 0%, #f6f2e9 45%, #f1ebdf 100%);
  animation: fadeIn .18s ease;
}
.detail-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 10px;
}
.detail-bar .ghost-btn.small { height: 34px; padding: 0 14px; font-size: 12.5px; border-radius: 999px; }
.detail-nav { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--ink-soft); }
.detail-nav .icon-btn { width: 30px; height: 30px; border-radius: 50%; background: rgba(255, 253, 248, .9); border: 1px solid var(--line); font-size: 16px; }
.detail-nav .icon-btn:disabled { opacity: .3; }
.detail-body {
  flex: 1; overflow-y: auto;
  display: flex; justify-content: center;
  padding: 6px 16px calc(34px + env(safe-area-inset-bottom, 0px));
}
#detailBody .card,
.in-detail {
  position: relative !important;
  left: auto !important;
  top: auto !important;
  width: min(360px, 100%);
  height: max-content;
  margin: 0 auto;
}
.in-detail .card-close { display: none; }

@media (max-width: 640px) {
  #library { padding-left: 14px; padding-right: 14px; }
  .lib-grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 10px; }
  .tile-char { font-size: 36px; }
  .tile-py { font-size: 10px; }
  .lib-head { flex-wrap: wrap; row-gap: 10px; }
  .lib-title { width: 100%; }
  #libSearch { width: 100%; }
  .write-btn { padding: 0 14px; }
  .write-btn span { display: none; }
  .write-btn { width: 40px; justify-content: center; padding: 0; }
}

/* ---------------- 当前字卡 + 收缩的其他字 ---------------- */
.active-wrap { max-width: 380px; margin: 0 auto 6px; scroll-margin-top: 88px; }
.active-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px 8px;
}
.active-label { font-size: 11px; letter-spacing: .16em; color: var(--ink-faint); }
.active-index { font-size: 11px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.active-card { display: flex; justify-content: center; }
.active-card .card {
  position: relative !important;
  left: auto !important;
  top: auto !important;
  width: 100%;
  touch-action: pan-y;
}
.active-card .card .tianzige.tracing { touch-action: none; }
.active-card .card .card-head { cursor: default; }

.strip-wrap { max-width: 380px; margin: 4px auto 18px; }
.strip-head { display: flex; align-items: baseline; gap: 8px; padding: 0 4px; margin-bottom: 10px; }
.strip-head h3 { margin: 0; font-size: 11px; font-weight: 500; letter-spacing: .16em; color: var(--ink-faint); }
.strip-count { font-size: 11px; color: var(--ink-faint); }
.card-strip {
  display: flex; gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 10px;
  scrollbar-width: thin;
}
.card-strip::-webkit-scrollbar { height: 6px; }
.card-strip::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
.mini-card {
  flex: 0 0 auto;
  width: 78px; height: 88px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 2px 6px rgba(74, 58, 32, .06);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.mini-card:hover { transform: translateY(-2px); border-color: var(--red-soft); box-shadow: 0 8px 16px rgba(74, 58, 32, .12); }
.mini-char { font-family: var(--font-kai); font-size: 30px; line-height: 1; color: var(--ink); }
.mini-py { font-family: var(--font-serif); font-size: 9.5px; color: var(--ink-faint); }

@media (max-width: 640px) {
  .active-wrap { max-width: 100%; }
  .mini-card { width: 68px; height: 78px; }
  .mini-char { font-size: 26px; }
}

/* ---------------- 大格练字 ---------------- */
.sec-title.with-action::after { display: none; }
.sec-title.with-action { display: flex; align-items: center; gap: 8px; }
.sec-action {
  margin-left: auto;
  font-size: 10.5px; letter-spacing: .06em;
  color: var(--red); background: #fdf1ec; border: 1px solid #f0d3c9;
  padding: 2px 9px; border-radius: 999px;
}
.sec-action:hover { background: #fbe6de; }

.practice-overlay {
  position: fixed; inset: 0; z-index: 95;
  background: rgba(40, 33, 24, .42);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 16px;
}
.practice-sheet {
  width: min(540px, 96vw);
  max-height: 94vh;
  overflow-y: auto;
  background: var(--paper-2);
  border-radius: 24px;
  box-shadow: 0 30px 70px rgba(40, 33, 24, .35);
  padding: 16px 18px 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.practice-head { display: flex; align-items: center; gap: 10px; }
.practice-title { display: flex; align-items: baseline; gap: 8px; }
.practice-title b { font-family: var(--font-kai); font-size: 30px; line-height: 1; font-weight: 500; }
.practice-title span { font-size: 12px; color: var(--ink-faint); }
.practice-progress { margin-left: auto; font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.practice-close {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line); background: #fffdf8;
  font-size: 18px; color: var(--ink-soft); flex: 0 0 auto;
}
.practice-close:hover { border-color: var(--line-strong); }
.practice-grid { position: relative; display: flex; justify-content: center; margin: 0 auto; }
.practice-grid svg { display: block; }
.practice-grid-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.practice-strip { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 6px; }
.practice-cell {
  position: relative; flex: 0 0 auto;
  width: 44px; height: 44px; border-radius: 8px;
  border: 1px solid var(--line); background: #fffefb;
  overflow: hidden; opacity: .6;
  transition: opacity .15s, border-color .15s, box-shadow .15s;
}
.practice-cell.is-active { opacity: 1; border-color: var(--red-soft); box-shadow: 0 0 0 2px rgba(191, 74, 55, .14); }
.practice-cell.is-done { opacity: 1; }
.practice-cell svg { width: 100%; height: 100%; display: block; }
.practice-num {
  position: absolute; left: 3px; top: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--red); color: #fff;
  font-size: 8px; line-height: 1;
  display: grid; place-items: center;
}
.practice-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.practice-tip { font-size: 11px; color: var(--ink-faint); }

@media (max-width: 520px) {
  .practice-sheet { padding: 12px 12px 10px; border-radius: 20px; gap: 10px; }
  .practice-cell { width: 36px; height: 36px; }
  .practice-title b { font-size: 26px; }
  .practice-tip { display: none; }
}

a.pill-btn { text-decoration: none; }
a.pill-btn:visited { color: var(--ink); }

a.ghost-btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
a.wb-sheet-link { margin-right: auto; color: var(--red); border-color: #f0d3c9; background: #fdf1ec; }
a.wb-sheet-link:hover { background: #fbe6de; }

/* ---------------- 发音声音选择 ---------------- */
.voice-box {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fdfaf3;
}
.voice-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.voice-title { font-size: 12px; letter-spacing: .12em; color: var(--ink-faint); }
.ghost-btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.voice-select {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-family: inherit;
}
.voice-select:disabled { opacity: .6; }
.voice-hint { margin: 8px 0 0; font-size: 11px; line-height: 1.6; color: var(--ink-faint); }

.cloud-box { margin-top: 10px; background: #fbf7ee; }
.cloud-box input.voice-select { height: 34px; font-size: 12px; }
.cloud-box .cloud-voice { margin-top: 8px; }
.cloud-hint code, .voice-hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10.5px;
  background: #f1eadc;
  padding: 1px 4px;
  border-radius: 4px;
}

/* ---------------- 响应式：按钮文字不换行、顶栏可折行 ---------------- */
#topbar { flex-wrap: wrap; row-gap: 8px; }
.top-actions { flex-wrap: wrap; justify-content: flex-end; row-gap: 8px; }
.pill-btn, .round-btn, .ghost-btn, .primary-btn, .icon-btn, .seg button,
a.pill-btn, a.ghost-btn { white-space: nowrap; }
.wb-actions { flex-wrap: wrap; row-gap: 8px; }
.brand-text { min-width: 0; }
.brand-text p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 560px) {
  .wb-actions { padding: 12px 14px calc(14px + var(--safe-b)); }
  a.wb-sheet-link { width: 100%; margin-right: 0; }
  .wb-actions .ghost-btn, .wb-actions .primary-btn { flex: 1 1 auto; }
  .modal-actions { flex-wrap: wrap; row-gap: 8px; }
}
