/* Word study (vocab/word-study.js). Marks are underline STYLES, never color alone
   (WCAG 1.4.1); tone colors repeat what the pinyin tone marks already say. */
:root {
    --vt1: #c62828; --vt2: #2e7d32; --vt3: #1f5fbf; --vt4: #7b3fa0; --vt5: #5f6b78;   /* Pleco default scheme, darkened for 4.5:1 on paper */
    --v-learning: #b26a00; --v-new: #3b6fd8;
}
body.dark-mode {
    --vt1: #ff8a80; --vt2: #7fd88a; --vt3: #8db8ff; --vt4: #d7a6f2; --vt5: #aab4bf;
    --v-learning: #ffc266; --v-new: #9dbcff;
}
.tone.t1 { color: var(--vt1); } .tone.t2 { color: var(--vt2); } .tone.t3 { color: var(--vt3); }
.tone.t4 { color: var(--vt4); } .tone.t5 { color: var(--vt5); }

.vocab-card, .vocab-panel, .vocab-card *, .vocab-panel * { box-sizing: border-box; }

/* tokens in the reading text */
#reading-pane .vtok { cursor: pointer; border-radius: 3px; }
#reading-pane .vtok:hover { background: color-mix(in srgb, var(--app-accent, #174dc5) 12%, transparent); }
#reading-pane .vtok.vs-learning { text-decoration: underline dotted var(--v-learning); text-decoration-thickness: 2px; text-underline-offset: 4px; }
#reading-pane .vtok.vs-new { text-decoration: underline solid color-mix(in srgb, var(--v-new) 55%, transparent); text-decoration-thickness: 1px; text-underline-offset: 4px; }

/* toolbar button */
#words-btn { position: relative; }
#words-btn .vb-count { position: absolute; top: -4px; right: -6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
    background: var(--app-accent, #174dc5); color: #fff; font: 700 10px/16px Arial, sans-serif; }
body.dark-mode #words-btn .vb-count { color: #10203a; }

/* lookup card: anchored on wide screens, bottom sheet on phones */
.vocab-card { position: fixed; z-index: 1300; width: min(360px, calc(100vw - 16px)); max-height: min(70vh, 520px); overflow: auto;
    background: var(--app-surface, #fffdf8); color: var(--app-ink, #192d45); border: 1px solid var(--app-line, #deded2);
    border-radius: 14px; box-shadow: 0 14px 40px #192d4526; padding: 14px 16px 12px; font-family: Arial, Helvetica, sans-serif; }
.vocab-card.as-sheet { left: 0 !important; right: 0; bottom: 0; top: auto !important; width: 100%; max-height: 72vh;
    border-radius: 18px 18px 0 0; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.vc-top, .vp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.vocab-card h2 { margin: 0; font: 600 28px/1.25 var(--app-serif, Georgia, serif); outline: none; }
.vocab-card h2[lang="zh"], .vocab-card h2[lang="ja"] { font-size: 34px; }
.vc-lemma { font-size: 18px; color: var(--app-muted, #566373); font-weight: 400; }
.vc-x { background: none; border: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--app-muted, #566373); min-width: 44px; min-height: 44px; margin: -8px -10px 0 0; }
.vc-pron { margin: 4px 0 2px; font-size: 19px; display: flex; align-items: center; gap: 8px; }
.vc-say { background: none; border: 1px solid var(--app-line, #deded2); border-radius: 999px; min-height: 36px; min-width: 36px; padding: 0 10px; cursor: pointer; color: inherit; }
.vc-gloss { font-size: 19px; font-weight: 700; margin: 6px 0 4px; }
.vc-meta { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 6px; font-size: 12.5px; }
.vc-badge, .vc-pos, .vc-st { border: 1px solid var(--app-line, #deded2); border-radius: 999px; padding: 2px 8px; color: var(--app-muted, #566373); }
.vc-st { border-color: var(--v-learning); }
.vc-note { font-size: 14px; color: var(--app-muted, #566373); margin: 4px 0; }
.vc-ctx { font: italic 15px/1.5 var(--app-serif, Georgia, serif); margin: 6px 0; }
.vc-more { margin: 6px 0; font-size: 14px; }
.vc-more summary { cursor: pointer; color: var(--app-accent, #174dc5); min-height: 28px; }
.vc-more p { margin: 4px 0 0; }
.vc-actions { display: flex; gap: 8px; margin-top: 12px; }
.vc-btn { flex: 1; min-height: 48px; border-radius: 12px; border: 1px solid var(--app-line, #deded2); background: transparent; color: inherit;
    font: 600 15px Arial, sans-serif; cursor: pointer; padding: 0 10px; text-align: center; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.vc-btn.primary { background: var(--app-accent, #174dc5); border-color: var(--app-accent, #174dc5); color: #fff; }
body.dark-mode .vc-btn.primary { color: #10203a; }
.vc-btn[aria-pressed="true"]:not(.primary) { border-color: var(--app-accent, #174dc5); box-shadow: inset 0 0 0 1px var(--app-accent, #174dc5); }
.vc-btn:disabled { opacity: .6; cursor: default; }
.vc-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; }
.vc-link { background: none; border: none; color: var(--app-accent, #174dc5); cursor: pointer; font-size: 14px; padding: 8px 0; min-height: 40px; text-align: left; }
.vc-status { color: var(--app-muted, #566373); margin: 8px 0; }

/* panel */
.vocab-panel { position: fixed; z-index: 1250; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); overflow: auto;
    background: var(--app-surface, #fffdf8); color: var(--app-ink, #192d45); border-left: 1px solid var(--app-line, #deded2);
    box-shadow: -14px 0 40px #192d451f; padding: 16px 18px 40px; font-family: Arial, Helvetica, sans-serif; }
.vocab-panel h2 { margin: 4px 0 0; font: 600 22px var(--app-serif, Georgia, serif); outline: none; }
.vp-sec { border-top: 1px solid var(--app-line, #deded2); padding: 14px 0 6px; margin-top: 12px; }
.vp-sec h3 { margin: 0 0 8px; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--app-muted, #566373); }
.vp-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 600; }
.vp-row select { min-height: 40px; border-radius: 10px; border: 1px solid var(--app-line, #deded2); background: transparent; color: inherit; padding: 0 8px; font-size: 15px; }
.vp-warn { color: #805000; font-size: 14px; } body.dark-mode .vp-warn { color: #ffc266; }
.vp-big { font-size: 17px; font-weight: 600; margin: 0 0 8px; }
.vp-band.comfortable { color: var(--vt2); } .vp-band.stretch { color: var(--v-learning); } .vp-band.challenging { color: var(--vt1); }
.vp-bar { position: relative; height: 8px; border-radius: 4px; background: var(--app-soft, #eeeee3); }
.vp-bar i { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--vt2); }
.vp-bar b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--app-muted, #566373); opacity: .6; }
.vp-small { font-size: 13.5px; color: var(--app-muted, #566373); line-height: 1.5; margin: 8px 0; }
.vp-list { list-style: none; padding: 0; margin: 6px 0; display: flex; flex-direction: column; gap: 6px; }
.vp-list li { display: flex; align-items: center; gap: 8px; }
.vp-wbtn { flex: 1; display: flex; align-items: baseline; gap: 10px; min-height: 44px; text-align: left; background: none; border: 1px solid var(--app-line, #deded2);
    border-radius: 10px; padding: 6px 10px; cursor: pointer; color: inherit; min-width: 0; }
.vp-w { font: 18px var(--app-serif, Georgia, serif); white-space: nowrap; }
.vp-g { flex: 1; font-size: 13.5px; color: var(--app-muted, #566373); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vp-n { opacity: .7; }
.vp-st { font-size: 12px; border-radius: 999px; padding: 2px 8px; border: 1px solid var(--v-learning); white-space: nowrap; }
.vp-st.known { border-color: var(--vt2); }
.vp-mini { min-height: 40px; min-width: 44px; border-radius: 10px; border: 1px solid var(--app-line, #deded2); background: none; color: inherit; cursor: pointer; font-size: 13px; padding: 0 8px; }
.vp-mini[aria-pressed="true"] { border-color: var(--app-accent, #174dc5); box-shadow: inset 0 0 0 1px var(--app-accent, #174dc5); }
.vp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.vp-chip { min-height: 44px; min-width: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--app-line, #deded2); background: none; color: inherit; cursor: pointer;
    font: 18px var(--app-serif, Georgia, serif); }
.vp-chip.vs-learning { text-decoration: underline dotted var(--v-learning); text-underline-offset: 4px; }
.vp-check { display: flex; align-items: center; gap: 8px; min-height: 40px; font-size: 14.5px; flex-wrap: wrap; }
.vp-check input { width: 20px; height: 20px; }
.vp-tones { font-size: 15px; margin-left: 4px; }
.vp-count { text-transform: none; letter-spacing: 0; font-weight: 400; }
.vp-severo .vc-btn { width: 100%; margin: 4px 0; }
@media (prefers-reduced-motion: no-preference) {
    .vocab-card.as-sheet { animation: vc-up .18s ease-out; }
    @keyframes vc-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
}
