/* Characters explorer (app.php #viewChars). Layout only — the decomposition
   tree and word-web renderers bring their own styles from styles.css (.hv-*). */

/* Mobile-first search: input + Explore always share the top row (button never
   scrolls off), the pinyin toggle tucks to the right and wraps below if tight. */
.ce-search { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 12px; }
.ce-input { flex: 1 1 180px; min-width: 0; max-width: 460px; font-size: 16px; font-family: var(--han);
  padding: 11px 14px; border: 1px solid var(--hairline); border-radius: 10px;
  background: var(--paper-raised); color: var(--ink); }
.ce-input:focus { outline: none; border-color: var(--azure); }
.ce-go { flex: 0 0 auto; white-space: nowrap; }
.ce-py-toggle { flex: 0 0 auto; font-size: 12.5px; padding: 6px 12px; }
@media (min-width: 560px) { .ce-py-toggle { margin-left: auto; } }

/* Staged starter characters — tap instead of typing. */
.ce-picks { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 0 0 18px; }
.ce-picks-lab { font-size: 12.5px; color: var(--ink-whisper); }
.ce-pick { font-family: var(--han); font-size: 19px; line-height: 1; padding: 7px 12px;
  border: 1px solid var(--hairline); border-radius: 10px; background: var(--paper-raised);
  color: var(--ink); cursor: pointer; transition: border-color .12s, background .12s, transform .06s; }
.ce-pick:hover { border-color: var(--azure); background: rgba(var(--accent-rgb), .06); }
.ce-pick:active { transform: translateY(1px); }

.ce-empty { color: var(--ink-whisper); font-style: italic; padding: 24px 0; }
.ce-none { color: var(--ink-whisper); font-style: italic; }

.ce-hero { display: flex; gap: 20px; align-items: center; margin-bottom: 22px; }
.ce-glyph { flex: 0 0 132px; width: 132px; height: 132px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--hairline); border-radius: 14px; }
.ce-glyph svg { width: 100%; height: 100%; }
.ce-glyph .cc-hint path { fill: var(--paper-sunken); }
.ce-glyph .cc-reveal { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.ce-meta { min-width: 0; }
.ce-zh { font-family: var(--han); font-size: 40px; line-height: 1.1; color: var(--ink); }
.ce-py { font-size: 18px; color: var(--azure); font-style: italic; }
.ce-en { font-size: 15px; color: var(--ink-faded); margin-top: 3px; }
.ce-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.ce-badge { font-size: 11.5px; padding: 3px 9px; border-radius: 999px;
  background: var(--paper-sunken); color: var(--ink-faded); }
.ce-badge[class*="lv"] { color: #fff; }
.ce-badge.lv1 { background: #4A7C2F; } .ce-badge.lv2 { background: #1D7A5F; }
.ce-badge.lv3 { background: #8A5A1A; } .ce-badge.lv4 { background: #A8322A; }
.ce-badge.lv5 { background: #5B3A8A; } .ce-badge.lv6 { background: #1E5C99; }
.ce-badge-rank { border: 1px solid var(--hairline); cursor: pointer; font: inherit;
  font-size: 11.5px; transition: border-color .12s, color .12s, background .12s; }
.ce-badge-rank:hover { border-color: var(--azure); color: var(--azure);
  background: rgba(var(--accent-rgb), .06); }
.ce-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ce-actions .btn { font-size: 13px; padding: 9px 14px; min-height: 40px; }

.ce-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .ce-cols { grid-template-columns: 1fr; } .ce-hero { flex-direction: column; text-align: center; align-items: center; } }
.ce-panel { background: var(--paper-raised); border: 1px solid var(--hairline);
  border-radius: 14px; padding: 16px 18px; margin-bottom: 16px; }
.ce-panel h3 { font-size: 13px; letter-spacing: .03em; color: var(--ink-whisper);
  text-transform: uppercase; margin: 0 0 12px; font-weight: 600; }
.ce-tree { padding: 4px 0; }
.ce-ego { display: flex; justify-content: center; }

/* Interactive character math — tap pieces, no radical keyboard. */
.ce-math-lead { font-size: 12.5px; color: var(--ink-whisper); margin: -4px 0 12px; }
.ce-math-board { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.ce-math-parts { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ce-math-plus { font-size: 20px; color: var(--ink-whisper); }
.ce-math-empty { font-size: 13px; color: var(--ink-whisper); font-style: italic; }
.ce-math-eq { font-size: 24px; color: var(--ink-whisper); }
.ce-math-out { font-family: var(--han); font-size: 40px; line-height: 1; color: var(--ink-whisper); }
.ce-math-out.hit { color: var(--gold); }
.ce-math-out.ce-tappable { cursor: pointer; }

/* Component chips: base pieces (removable) vs palette pieces (addable). */
.ce-mchip { font-family: var(--han); font-size: 22px; line-height: 1; min-width: 44px;
  padding: 8px 10px; border-radius: 10px; cursor: pointer; color: var(--ink);
  transition: border-color .12s, background .12s, transform .06s; }
.ce-mchip:active { transform: translateY(1px); }
.ce-mchip-part { border: 1px solid var(--azure); background: rgba(var(--accent-rgb), .08); position: relative; }
.ce-mchip-part::after { content: '×'; position: absolute; top: -6px; right: -4px; font-size: 12px;
  width: 16px; height: 16px; line-height: 16px; text-align: center; border-radius: 50%;
  background: var(--paper-raised); border: 1px solid var(--hairline); color: var(--ink-faded); }
.ce-mchip-add { border: 1px dashed var(--hairline); background: var(--paper); }
.ce-mchip-add:hover { border-color: var(--azure); background: rgba(var(--accent-rgb), .06); }

.ce-math-add { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ce-math-add-lab { font-size: 12.5px; color: var(--ink-whisper); }
.ce-math-palette { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 auto; }
.ce-math-palette .ce-mchip { font-size: 19px; min-width: 40px; padding: 6px 8px; }
.ce-math-reset { font-size: 12.5px; padding: 6px 12px; border: 1px solid var(--hairline);
  border-radius: 999px; background: transparent; color: var(--ink-faded); cursor: pointer; }
.ce-math-reset:hover { border-color: var(--azure); color: var(--azure); }

.ce-sent { padding: 9px 0; border-bottom: 1px solid var(--hairline); }
.ce-sent:last-child { border-bottom: none; }
.ce-sent-zh { font-family: var(--han); font-size: 18px; line-height: 1.9; color: var(--ink); }
.ce-sent-en { font-size: 13.5px; color: var(--ink-faded); }
.ce-more { margin-top: 12px; }

/* HSK-level legend under the word web */
.ce-legend { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 12px; }
.ce-lg { font-size: 11px; color: var(--ink-faded); display: inline-flex; align-items: center; gap: 4px; }
.ce-lg-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ── Frequency browser (top-1000 list behind the "#N most frequent" badge) ──
   Mobile-first: a bottom sheet on phones, a centered dialog on wider screens. */
.ce-freq-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 60; }
.ce-freq { position: fixed; z-index: 61; background: var(--paper);
  display: flex; flex-direction: column; box-shadow: 0 -8px 40px rgba(0,0,0,.28);
  /* phone default: bottom sheet filling most of the viewport */
  left: 0; right: 0; bottom: 0; top: 8vh;
  border-radius: 18px 18px 0 0; }
.ce-freq-head { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 18px 10px; border-bottom: 1px solid var(--hairline); }
.ce-freq-head h3 { font-family: var(--han); font-size: 17px; margin: 0; color: var(--ink); }
.ce-freq-close { flex: none; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--hairline); background: var(--paper-raised);
  color: var(--ink-faded); font-size: 22px; line-height: 1; cursor: pointer; }
.ce-freq-close:hover { border-color: var(--azure); color: var(--azure); }
.ce-freq-lead { font-size: 13px; color: var(--ink-faded); line-height: 1.5;
  margin: 12px 18px 4px; }
.ce-freq-list { flex: 1 1 auto; overflow-y: auto; padding: 6px 10px 4px;
  -webkit-overflow-scrolling: touch; }
.ce-freq-more { align-self: center; margin: 8px auto 16px; }
.ce-fr { display: flex; align-items: center; gap: 12px; padding: 9px 10px;
  border-radius: 12px; }
.ce-fr + .ce-fr { border-top: 1px solid var(--hairline); }
.ce-fr.cur { background: rgba(var(--accent-rgb), .09); border-top-color: transparent; }
.ce-fr-rank { flex: none; width: 44px; text-align: right; font-variant-numeric: tabular-nums;
  font-size: 13px; color: var(--ink-whisper); }
.ce-fr-ch { flex: none; font-family: var(--han); font-size: 28px; line-height: 1;
  min-width: 44px; min-height: 44px; padding: 4px 6px; border: none; background: none;
  color: var(--ink); cursor: pointer; border-radius: 10px; }
.ce-fr-ch:hover { background: var(--paper-sunken); color: var(--azure); }
.ce-fr-meta { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.ce-fr-py { font-size: 14px; color: var(--gold, #B08A3E); }
.ce-fr-en { font-size: 12.5px; color: var(--ink-faded);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ce-fr-save { flex: none; width: 44px; height: 44px; border: none; background: none;
  font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink-whisper); }
.ce-fr-save.on { color: var(--gold, #B08A3E); }
.ce-fr-save:hover { color: var(--azure); }
body.ce-freq-open { overflow: hidden; }
@media (min-width: 720px) {
  .ce-freq { left: 50%; right: auto; top: 50%; bottom: auto;
    transform: translate(-50%, -50%); width: min(560px, 92vw); max-height: 84vh;
    border-radius: 18px; }
}
