/* ==========================================================================
   WritePadPro — unified writing studio (Phase B)
   Markup: includes/editor-app.php · Controller: assets/js/editor-app.js
   Two layouts on one design system:
     .wpe--quick      homepage "/" (and "/?embed=1")
     .wpe--workspace  "/editor" (left tools sidebar + editor + insights)
   Colours come from style.css ([data-theme] variables). Inline highlight
   colours, the issue popover and the issue list live in wpp-core.css.
   Printing is handled by WPPDoc.printDocument (prints only the document).
   ========================================================================== */

/* ── Design tokens ─────────────────────────────────────────────────────── */
.wpe {
    --wpe-shell: #121a2c;
    --wpe-panel: #182238;
    --wpe-paper: #0d1424;
    --wpe-raise: #1f2a42;
    --wpe-line: rgba(255, 255, 255, 0.07);
    --wpe-line-strong: rgba(255, 255, 255, 0.13);
    --wpe-hover: rgba(255, 255, 255, 0.06);
    --wpe-press: rgba(99, 102, 241, 0.18);
    --wpe-ring: 0 0 0 3px rgba(129, 140, 248, 0.35);
    --wpe-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 24px 60px -24px rgba(0, 0, 0, 0.55);
    --wpe-shadow-pop: 0 18px 48px -12px rgba(0, 0, 0, 0.6);
    --wpe-good: #34d399;
    --wpe-ok: #818cf8;
    --wpe-warn: #fbbf24;
    --wpe-bad: #f87171;
    --wpe-radius: 16px;
    --wpe-radius-sm: 10px;
    --wpe-top: var(--nav-h, 64px);
    --wpe-editor-size: 17px;
    font-family: var(--font);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}
[data-theme="light"] .wpe {
    --wpe-shell: #f4f6fb;
    --wpe-panel: #ffffff;
    --wpe-paper: #ffffff;
    --wpe-raise: #ffffff;
    --wpe-line: rgba(15, 23, 42, 0.08);
    --wpe-line-strong: rgba(15, 23, 42, 0.15);
    --wpe-hover: rgba(15, 23, 42, 0.05);
    --wpe-press: rgba(99, 102, 241, 0.12);
    --wpe-ring: 0 0 0 3px rgba(99, 102, 241, 0.28);
    --wpe-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 24px 60px -28px rgba(15, 23, 42, 0.28);
    --wpe-shadow-pop: 0 18px 48px -12px rgba(15, 23, 42, 0.25);
    --wpe-good: #059669;
    --wpe-ok: #4f46e5;
    --wpe-warn: #b45309;
    --wpe-bad: #dc2626;
}
.wpe *, .wpe *::before, .wpe *::after { box-sizing: border-box; }
.wpe p { margin: 0; color: inherit; line-height: 1.55; }
.wpe strong { color: inherit; }
.wpe ul, .wpe ol { list-style: none; margin: 0; padding: 0; }
.wpe h2, .wpe h3 { letter-spacing: normal; }
.wpe-ico { display: inline-block; flex: none; vertical-align: middle; }

/* ── Shell ─────────────────────────────────────────────────────────────── */
.wpe-wrap { width: 100%; margin: 0 auto; }
.wpe-wrap--quick { max-width: 1280px; padding: 28px 20px 0; }
.wpe-wrap--workspace { max-width: 1720px; padding: 16px 16px 48px; }
.wpe {
    position: relative;
    background: var(--wpe-shell);
    border: 1px solid var(--wpe-line-strong);
    border-radius: 20px;
    box-shadow: var(--wpe-shadow);
}
.wpe[aria-busy="true"] .wpe-editor { opacity: 0.85; }

/* ── Buttons, inputs, selects ──────────────────────────────────────────── */
.wpe-btn, .wpe-iconbtn, .wpe-tb, .wpe-select, .wpe-input, .wpe-tool, .wpe-chip, .wpe-seg, .wpe-view, .wpe-tooltab {
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}
.wpe-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 34px; padding: 0 14px;
    border: 1px solid var(--wpe-line-strong); border-radius: var(--wpe-radius-sm);
    background: var(--wpe-panel); color: var(--text);
    font-size: 13.5px; font-weight: 600; white-space: nowrap; cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
.wpe-btn:hover { border-color: rgba(129, 140, 248, 0.6); color: var(--text); background: var(--wpe-raise); }
.wpe-btn--ghost { background: transparent; border-color: transparent; color: var(--text2); }
.wpe-btn--ghost:hover { background: var(--wpe-hover); border-color: transparent; color: var(--text); }
.wpe-btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.wpe-btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.wpe-btn--sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.wpe-btn--block { width: 100%; }
.wpe-btn:disabled { opacity: .55; cursor: default; }
.wpe-btn .wpe-kbd { margin-left: auto; }

.wpe-iconbtn {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 34px; height: 34px; padding: 0;
    border: 1px solid transparent; border-radius: var(--wpe-radius-sm);
    background: transparent; color: var(--text2); cursor: pointer;
    transition: background-color .15s, color .15s, border-color .15s;
}
.wpe-iconbtn:hover { background: var(--wpe-hover); color: var(--text); }
.wpe-iconbtn[aria-expanded="true"], .wpe-iconbtn[aria-pressed="true"] { background: var(--wpe-press); color: var(--primary); }
[data-theme="dark"] .wpe-iconbtn[aria-expanded="true"], [data-theme="dark"] .wpe-iconbtn[aria-pressed="true"] { color: #a5b4fc; }
.wpe-iconbtn--sm { width: 30px; height: 30px; border-radius: 8px; }
.wpe-iconbtn--danger:hover { color: var(--wpe-bad); background: rgba(239, 68, 68, 0.1); }

.wpe-select, .wpe-input {
    height: 34px; padding: 0 10px;
    border: 1px solid var(--wpe-line-strong); border-radius: var(--wpe-radius-sm);
    background: var(--wpe-paper); color: var(--text);
    font-size: 13.5px; min-width: 0;
    transition: border-color .15s, box-shadow .15s;
}
.wpe-select { padding-right: 28px; cursor: pointer; -webkit-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 9px center; }
.wpe-select option { background: var(--bg2); color: var(--text); }
.wpe-select--sm { height: 30px; font-size: 12.5px; border-radius: 8px; }
.wpe-input::placeholder { color: var(--text3); }
.wpe-select:hover, .wpe-input:hover { border-color: rgba(129, 140, 248, 0.5); }
.wpe-select:focus, .wpe-input:focus { outline: none; border-color: var(--primary); box-shadow: var(--wpe-ring); }
.wpe-input--num { width: 110px; font-variant-numeric: tabular-nums; }

.wpe-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text2); cursor: pointer; user-select: none; }
.wpe-check input { width: 15px; height: 15px; margin: 0; accent-color: var(--primary); }

.wpe-kbd, .wpe kbd {
    display: inline-block; min-width: 20px; padding: 1px 6px;
    font-family: var(--font-mono); font-size: 11px; line-height: 18px; text-align: center;
    color: var(--text2); background: var(--wpe-hover);
    border: 1px solid var(--wpe-line-strong); border-bottom-width: 2px; border-radius: 6px;
}

.wpe-muted { color: var(--text2); }
.wpe-small { font-size: 12.5px; }
.wpe-badge {
    display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px; padding: 0 7px;
    border-radius: 999px; background: var(--wpe-hover); color: var(--text2);
    font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* Visible keyboard focus everywhere in the app */
.wpe :focus { outline: none; }
.wpe :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[data-theme="light"] .wpe :focus-visible { outline-color: #4f46e5; }
.wpe .wpe-editor:focus-visible { outline: none; }

.wpe-hidden-input { position: absolute !important; width: 1px; height: 1px; opacity: 0; pointer-events: none; overflow: hidden; clip: rect(0 0 0 0); }

/* ── Banner (storage blocked / embed) ─────────────────────────────────── */
.wpe-banner {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin: 12px 14px 0; padding: 10px 12px 10px 14px;
    border: 1px solid rgba(245, 158, 11, 0.4); border-radius: 12px;
    background: rgba(245, 158, 11, 0.12); color: var(--text);
    font-size: 13.5px;
}
.wpe-banner > .wpe-ico { color: var(--warning); }
.wpe-banner__text { flex: 1 1 260px; }
.wpe-banner__link { font-weight: 700; color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.wpe-banner__close { display: inline-flex; padding: 6px; border-radius: 8px; color: var(--text2); }
.wpe-banner__close:hover { background: var(--wpe-hover); color: var(--text); }

/* ── Header: tabs + title bar ─────────────────────────────────────────── */
.wpe-head { padding: 10px 14px 10px; border-bottom: 1px solid var(--wpe-line); }
.wpe-tabsbar { display: flex; align-items: center; gap: 6px; min-width: 0; }
.wpe-doctabs {
    display: flex; align-items: center; gap: 4px; flex: 1 1 auto; min-width: 0;
    overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; padding: 2px;
}
.wpe-doctabs::-webkit-scrollbar { height: 4px; }
.wpe-doctab {
    position: relative; display: flex; align-items: center; flex: 0 0 auto; max-width: 220px;
    height: 32px; border-radius: 9px; border: 1px solid transparent;
    color: var(--text2); transition: background-color .15s, color .15s, border-color .15s;
}
.wpe-doctab:hover { background: var(--wpe-hover); color: var(--text); }
.wpe-doctab.is-active { background: var(--wpe-panel); border-color: var(--wpe-line-strong); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.wpe-doctab__btn {
    flex: 1 1 auto; min-width: 0; height: 100%; padding: 0 8px 0 12px;
    background: none; border: 0; color: inherit; font: inherit; font-size: 13px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; cursor: pointer; border-radius: 9px;
}
.wpe-doctab.is-virtual .wpe-doctab__btn { font-style: italic; font-weight: 500; padding-right: 12px; }
.wpe-doctab__x {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 22px; height: 22px; margin-right: 5px; border-radius: 6px;
    color: var(--text3); opacity: 0; transition: opacity .15s, background-color .15s;
}
.wpe-doctab:hover .wpe-doctab__x, .wpe-doctab.is-active .wpe-doctab__x, .wpe-doctab__x:focus-visible { opacity: 1; }
.wpe-doctab__x:hover { background: var(--wpe-hover); color: var(--text); }
.wpe-newdoc { width: 32px; height: 32px; }
.wpe-libbtn { flex: none; }

.wpe-titlebar { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; margin-top: 8px; }
.wpe-titlebar__doc { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 320px; }
.wpe-title {
    flex: 0 1 auto; min-width: 120px; width: 26ch; max-width: 100%;
    height: 36px; padding: 0 8px; margin-left: -8px;
    border: 1px solid transparent; border-radius: 9px;
    background: transparent; color: var(--text);
    font: inherit; font-size: 18px; font-weight: 700; letter-spacing: -0.01em;
    text-overflow: ellipsis;
}
.wpe-title:hover { border-color: var(--wpe-line-strong); }
.wpe-title:focus { outline: none; border-color: var(--primary); box-shadow: var(--wpe-ring); background: var(--wpe-paper); }
.wpe-save {
    display: inline-flex; align-items: center; gap: 6px; flex: none;
    font-size: 12px; font-weight: 600; color: var(--text3); white-space: nowrap;
}
.wpe-save::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .8; }
.wpe-save[data-state="saved"] { color: var(--wpe-good); }
.wpe-save[data-state="saving"], .wpe-save[data-state="pending"], .wpe-save[data-state="loading"] { color: var(--text3); }
.wpe-save[data-state="failed"], .wpe-save[data-state="memory"] { color: var(--wpe-bad); }
.wpe-save[data-state="idle"]::before { background: transparent; border: 1.5px solid currentColor; }
.wpe-wordchip {
    flex: none; padding: 3px 10px; border-radius: 999px;
    background: var(--wpe-hover); color: var(--text2);
    font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.wpe-titlebar__actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.wpe-views { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--wpe-hover); border: 1px solid var(--wpe-line); }
.wpe-view {
    height: 28px; padding: 0 12px; border: 0; border-radius: 7px;
    background: transparent; color: var(--text2); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.wpe-view:hover { color: var(--text); }
.wpe-view.is-active { background: var(--wpe-panel); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); }

.wpe-menuwrap { position: relative; }
.wpe-menu {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
    min-width: 236px; padding: 6px;
    background: var(--wpe-raise); border: 1px solid var(--wpe-line-strong); border-radius: 12px;
    box-shadow: var(--wpe-shadow-pop);
}
.wpe-menu__item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 10px; border: 0; border-radius: 8px;
    background: none; color: var(--text); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer;
}
.wpe-menu__item .wpe-ico { color: var(--text3); }
.wpe-menu__item:hover, .wpe-menu__item:focus-visible { background: var(--wpe-press); outline: none; }
.wpe-menu__item:hover .wpe-ico, .wpe-menu__item:focus-visible .wpe-ico { color: var(--primary); }
.wpe-menu__sep { height: 1px; margin: 5px 6px; background: var(--wpe-line); }

.wpe-theme-ico { display: inline-flex; }
[data-theme="dark"] .wpe-theme-ico--dark, [data-theme="light"] .wpe-theme-ico--light { display: none; }

.wpe-drawer-btn { display: none; }

/* ── Toolbar ───────────────────────────────────────────────────────────── */
.wpe-toolbar {
    position: sticky; top: var(--wpe-top); z-index: 40;
    display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
    padding: 7px 12px;
    background: var(--wpe-shell);
    border-bottom: 1px solid var(--wpe-line);
}
.wpe-tbgroup { display: flex; align-items: center; gap: 2px; }
.wpe-tbmore { display: contents; }
.wpe-tbsep { width: 1px; height: 22px; margin: 0 5px; background: var(--wpe-line-strong); flex: none; }
.wpe-tb-more-only { display: none; }
.wpe-tb {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    min-width: 32px; height: 32px; padding: 0 6px;
    border: 1px solid transparent; border-radius: 8px;
    background: transparent; color: var(--text2); cursor: pointer;
    font-size: 15px; line-height: 1;
    transition: background-color .12s, color .12s;
}
.wpe-tb:hover { background: var(--wpe-hover); color: var(--text); }
.wpe-tb[aria-pressed="true"], .wpe-tb[aria-expanded="true"] { background: var(--wpe-press); color: var(--primary); }
[data-theme="dark"] .wpe-tb[aria-pressed="true"], [data-theme="dark"] .wpe-tb[aria-expanded="true"] { color: #a5b4fc; }
.wpe-tb b, .wpe-tb i, .wpe-tb u, .wpe-tb s { font-size: 15px; color: inherit; }
.wpe-tb--text { font-size: 14px; font-weight: 600; }
.wpe-tb--text sub, .wpe-tb--text sup { font-size: 9px; }
.wpe-tb--more { display: none; }
.wpe-select--tb { height: 32px; font-size: 13px; background-color: transparent; border-color: var(--wpe-line); max-width: 132px; }
.wpe-select--size { width: 64px; }
.wpe-tbcolor {
    position: relative; display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 8px; cursor: pointer; color: var(--text2);
}
.wpe-tbcolor:hover { background: var(--wpe-hover); color: var(--text); }
.wpe-tbcolor__a { font-weight: 800; font-size: 14px; line-height: 1; }
.wpe-tbcolor__hl { font-weight: 700; font-size: 12px; line-height: 1; padding: 0 2px; border-radius: 3px; background: rgba(253, 224, 71, 0.85); color: #1e293b; }
.wpe-tbcolor input {
    position: absolute; left: 6px; right: 6px; bottom: 4px; width: auto; height: 4px;
    padding: 0; border: 0; border-radius: 2px; background: none; cursor: pointer;
    -webkit-appearance: none; appearance: none;
}
.wpe-tbcolor input::-webkit-color-swatch-wrapper { padding: 0; }
.wpe-tbcolor input::-webkit-color-swatch { border: 0; border-radius: 2px; }
.wpe-tbcolor input::-moz-color-swatch { border: 0; border-radius: 2px; }
.wpe-tbcolor input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Special characters */
.wpe-special { padding: 10px 14px 12px; border-bottom: 1px solid var(--wpe-line); background: var(--wpe-panel); }
.wpe-special__tabs, .wpe-segs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--wpe-hover); margin-bottom: 8px; }
.wpe-seg {
    height: 28px; padding: 0 12px; border: 0; border-radius: 7px;
    background: none; color: var(--text2); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.wpe-seg.is-active { background: var(--wpe-panel); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }
.wpe-special__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 4px; }
.wpe-char {
    height: 36px; border: 1px solid var(--wpe-line); border-radius: 8px;
    background: var(--wpe-paper); color: var(--text); font-size: 17px; cursor: pointer;
}
.wpe-char:hover { border-color: var(--primary); background: var(--wpe-press); }

/* ── Find & replace ───────────────────────────────────────────────────── */
.wpe-find { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.wpe-find__row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.wpe-find__row .wpe-input { flex: 1 1 auto; height: 32px; min-width: 0; width: 100%; }  /* inputs must be able to shrink inside the 300px side panel */
.wpe-find__count { flex: none; min-width: 64px; font-size: 12px; color: var(--text2); text-align: right; font-variant-numeric: tabular-nums; }
.wpe-find__opts { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.wpe-findbar {
    position: relative; display: flex; align-items: flex-start; gap: 8px;
    padding: 10px 14px; border-bottom: 1px solid var(--wpe-line); background: var(--wpe-panel);
}
.wpe-findbar .wpe-find { flex: 1 1 auto; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; }
.wpe-findbar .wpe-find__opts { grid-column: 1 / -1; }
.wpe-findbar__close { flex: none; }

/* ── Highlights bar ───────────────────────────────────────────────────── */
.wpe-hlbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 12px; padding: 8px 14px; border-bottom: 1px solid var(--wpe-line); }
.wpe-hlbar__chips { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.wpe-chip {
    display: inline-flex; align-items: center; gap: 6px;
    height: 28px; padding: 0 6px 0 10px;
    border: 1px solid var(--wpe-line-strong); border-radius: 999px;
    background: var(--wpe-panel); color: var(--text); cursor: pointer;
    font-size: 12.5px; font-weight: 600; white-space: nowrap;
    transition: background-color .15s, border-color .15s, opacity .15s;
}
.wpe-chip:hover { border-color: rgba(129, 140, 248, 0.6); }
.wpe-chip[aria-pressed="false"] { background: transparent; color: var(--text3); border-style: dashed; }
.wpe-chip[aria-pressed="false"] .wpp-dot { opacity: .35; }
.wpe-chip__n {
    min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--wpe-hover); color: var(--text2); font-size: 11.5px; font-variant-numeric: tabular-nums;
}
.wpe-chip--grammar[aria-pressed="true"] { border-color: rgba(96, 165, 250, 0.6); }
.wpe-hlbar__status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wpe-hlnote { display: inline-flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text2); }
.wpe-hlnote.is-error { color: var(--wpe-bad); }

/* ── Character limit bar (workspace) ──────────────────────────────────── */
.wpe-limitbar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--wpe-line); font-size: 12.5px; }
.wpe-limitbar__label { color: var(--text2); font-weight: 600; white-space: nowrap; }
.wpe-limitbar__track { flex: 1 1 auto; height: 6px; border-radius: 999px; background: var(--wpe-hover); overflow: hidden; }
.wpe-limitbar__fill { height: 100%; width: 0; border-radius: 999px; background: var(--primary); transition: width .2s; }
.wpe-limitbar.is-near .wpe-limitbar__fill { background: var(--warning); }
.wpe-limitbar.is-over .wpe-limitbar__fill { background: var(--danger); }
.wpe-limitbar__count { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text2); }
.wpe-limitbar.is-over .wpe-limitbar__count { color: var(--wpe-bad); font-weight: 700; }

/* ── Main grid ────────────────────────────────────────────────────────── */
.wpe-main { display: grid; gap: 16px; padding: 16px; align-items: start; }
.wpe--quick .wpe-main { grid-template-columns: minmax(0, 1fr) 316px; }
.wpe--workspace .wpe-main { grid-template-columns: 272px minmax(0, 1fr) 324px; }
.wpe-center { min-width: 0; }

/* Paper + editor */
.wpe-paper {
    position: relative;
    background: var(--wpe-paper); color: var(--text);
    border: 1px solid var(--wpe-line); border-radius: var(--wpe-radius);
    transition: border-color .2s, box-shadow .2s;
}
.wpe-paper:focus-within { border-color: rgba(129, 140, 248, 0.45); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.10); }
.wpe-editor {
    position: relative; min-height: 460px;
    padding: 30px 36px 48px;
    color: inherit; caret-color: var(--primary);
    font-family: inherit; font-size: var(--wpe-editor-size); line-height: 1.75;
    overflow-wrap: break-word; word-wrap: break-word;
    outline: none;
    tab-size: 4;
}
.wpe--workspace .wpe-editor {
    min-height: max(560px, calc(100vh - 300px));
    padding: 44px max(32px, calc((100% - 780px) / 2)) 80px;
}
.wpe-editor.is-empty::before {
    content: attr(data-placeholder);
    position: absolute; pointer-events: none;
    color: var(--text3);
}
/* Document content (the global reset removes bullets, colours strong text, etc.) */
.wpe-editor p { margin: 0 0 0.8em; color: inherit; line-height: inherit; }
.wpe-editor div { color: inherit; }
.wpe-editor h1, .wpe-editor h2, .wpe-editor h3, .wpe-editor h4 { color: inherit; font-weight: 750; line-height: 1.3; letter-spacing: -0.015em; margin: 0.9em 0 0.35em; }
.wpe-editor h1 { font-size: 1.9em; }
.wpe-editor h2 { font-size: 1.5em; }
.wpe-editor h3 { font-size: 1.25em; }
.wpe-editor h4 { font-size: 1.08em; }
.wpe-editor > :first-child { margin-top: 0; }
.wpe-editor strong, .wpe-editor b { color: inherit; font-weight: 700; }
.wpe-editor a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
[data-theme="dark"] .wpe-editor a { color: #a5b4fc; }
.wpe-editor ul { list-style: disc; padding-left: 1.6em; margin: 0.35em 0 0.8em; }
.wpe-editor ol { list-style: decimal; padding-left: 1.6em; margin: 0.35em 0 0.8em; }
.wpe-editor ul ul { list-style: circle; }
.wpe-editor li { margin: 0.15em 0; }
.wpe-editor blockquote { margin: 0.8em 0; padding: 0.15em 0 0.15em 1.1em; border-left: 3px solid var(--primary); color: var(--text2); }
.wpe-editor hr { border: 0; border-top: 1px solid var(--wpe-line-strong); margin: 1.4em 0; }
.wpe-editor code { font-family: var(--font-mono); font-size: 0.9em; padding: 0.1em 0.35em; border-radius: 5px; background: var(--wpe-hover); }
.wpe-editor pre { font-family: var(--font-mono); font-size: 0.88em; padding: 12px 14px; border-radius: 10px; background: var(--wpe-hover); white-space: pre-wrap; margin: 0.8em 0; }
.wpe-editor pre code { padding: 0; background: none; }
.wpe-editor table { border-collapse: collapse; margin: 0.8em 0; max-width: 100%; }
.wpe-editor th, .wpe-editor td { border: 1px solid var(--wpe-line-strong); padding: 6px 10px; vertical-align: top; }
.wpe-editor th { font-weight: 700; background: var(--wpe-hover); }
.wpe-editor sub, .wpe-editor sup { font-size: 0.72em; }
.wpe-editor ::selection { background: rgba(99, 102, 241, 0.32); }

/* Paper styles (workspace) */
.wpe-paper--paper { background: #fdf6e3; color: #3b2e1a; border-color: #e8d8b4; }
.wpe-paper--paper .wpe-editor { font-family: Georgia, 'Times New Roman', serif; }
.wpe-paper--sepia { background: #f3e5c8; color: #4a3520; border-color: #d4b896; }
.wpe-paper--sepia .wpe-editor { font-family: 'Times New Roman', Georgia, serif; }
.wpe-paper--terminal { background: #0b0f0b; color: #4ade80; border-color: #1a3a1a; }
.wpe-paper--terminal .wpe-editor { font-family: var(--font-mono); caret-color: #4ade80; }
.wpe-paper--paper .wpe-editor.is-empty::before, .wpe-paper--sepia .wpe-editor.is-empty::before, .wpe-paper--terminal .wpe-editor.is-empty::before { color: inherit; opacity: .45; }
.wpe-paper--paper .wpe-editor blockquote, .wpe-paper--sepia .wpe-editor blockquote, .wpe-paper--terminal .wpe-editor blockquote { color: inherit; opacity: .85; border-left-color: currentColor; }
.wpe-paper--paper .wpe-editor a, .wpe-paper--sepia .wpe-editor a { color: #7c4a03; }

/* Footer under the editor */
.wpe-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 4px 0; font-size: 12.5px; color: var(--text3); }
.wpe-foot__privacy { display: inline-flex; align-items: center; gap: 6px; }
.wpe-foot__privacy .wpe-ico { color: var(--wpe-good); }
.wpe-foot__link { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--primary); }
[data-theme="dark"] .wpe-foot__link { color: #a5b4fc; }
.wpe-foot__link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ── Sidebars & cards ─────────────────────────────────────────────────── */
.wpe-side { display: grid; gap: 12px; min-width: 0; }
.wpe-side__drawerhead {
    display: none; position: sticky; top: 0; z-index: 2;
    align-items: center; justify-content: space-between;
    margin: 0 -14px 4px; padding: 12px 10px 10px 18px;
    background: var(--wpe-shell); border-bottom: 1px solid var(--wpe-line);
}
.wpe-side__drawertitle { font-size: 15px; font-weight: 750; }
.wpe-card {
    min-width: 0;
    padding: 14px 16px 16px;
    background: var(--wpe-panel);
    border: 1px solid var(--wpe-line);
    border-radius: 14px;
}
.wpe-card__title {
    display: flex; align-items: center; gap: 8px;
    margin: 0 0 12px; font-size: 13px; font-weight: 700; letter-spacing: 0.01em; color: var(--text);
}
.wpe-card__title .wpe-ico { color: var(--primary); }
[data-theme="dark"] .wpe-card__title .wpe-ico { color: #a5b4fc; }
.wpe-subtitle { display: flex; align-items: center; gap: 8px; margin: 14px 0 8px; font-size: 13px; font-weight: 700; color: var(--text); }

/* Statistics */
.wpe-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 0; border-radius: 10px; overflow: hidden; background: var(--wpe-line); }
.wpe-stat { display: flex; flex-direction: column-reverse; gap: 1px; padding: 8px 10px; background: var(--wpe-panel); }
.wpe-stat dt { font-size: 11.5px; color: var(--text2); }
.wpe-stat dd { margin: 0; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wpe-stat--big dd { font-size: 22px; letter-spacing: -0.02em; }
.wpe-stat:last-child:nth-child(odd) { grid-column: 1 / -1; }

/* Readability gauge */
.wpe-gauge { position: relative; width: 168px; margin: 0 auto; }
.wpe-gauge__svg { display: block; width: 100%; height: auto; overflow: visible; }
.wpe-gauge__track { fill: none; stroke: var(--wpe-hover); stroke-width: 10; stroke-linecap: round; }
.wpe-gauge__arc { fill: none; stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .5s ease; }
.wpe-gauge__score { position: absolute; left: 0; right: 0; bottom: 2px; text-align: center; font-size: 30px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.wpe-gauge__label { margin: 4px 0 10px; text-align: center; font-size: 12.5px; color: var(--text2); }
.wpe-kv { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-top: 1px solid var(--wpe-line); font-size: 13px; color: var(--text2); }
.wpe-kv b { color: var(--text); font-variant-numeric: tabular-nums; }
.wpe-details { margin-top: 8px; }
.wpe-details > summary {
    display: flex; align-items: center; gap: 6px; cursor: pointer; list-style: none;
    font-size: 12.5px; font-weight: 600; color: var(--primary); padding: 4px 0;
}
[data-theme="dark"] .wpe-details > summary { color: #a5b4fc; }
.wpe-details > summary::-webkit-details-marker { display: none; }
.wpe-details > summary::after { content: ""; width: 7px; height: 7px; margin-left: 2px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); transition: transform .15s; }
.wpe-details[open] > summary::after { transform: rotate(-135deg) translateY(-1px); }
.wpe-scores { display: grid; gap: 10px; padding-top: 8px; }
.wpe-score__top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.wpe-score__name { font-weight: 600; }
.wpe-score__val { font-variant-numeric: tabular-nums; }
.wpe-score__desc { font-size: 12px; color: var(--text2); margin: 1px 0 5px; }

/* Shared meters */
.wpe-meter { height: 6px; border-radius: 999px; background: var(--wpe-hover); overflow: hidden; }
.wpe-meter > span { display: block; height: 100%; border-radius: 999px; background: var(--primary); transition: width .3s; }
.wpe-meter .is-good { background: var(--wpe-good); }
.wpe-meter .is-ok, .wpe-meter .is-primary { background: var(--primary); }
.wpe-meter .is-warn { background: var(--warning); }
.wpe-meter .is-bad { background: var(--danger); }

/* Rhythm */
.wpe-rhythm { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.wpe-rhythm__score {
    display: flex; align-items: center; justify-content: center; flex: none;
    width: 52px; height: 52px; border-radius: 50%;
    border: 3px solid var(--wpe-line-strong);
    font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.wpe-rhythm__score[data-tone="good"] { border-color: var(--wpe-good); color: var(--wpe-good); }
.wpe-rhythm__score[data-tone="ok"] { border-color: var(--warning); color: var(--wpe-warn); }
.wpe-rhythm__score[data-tone="bad"] { border-color: var(--danger); color: var(--wpe-bad); }
.wpe-rhythm__text { display: grid; gap: 2px; font-size: 12.5px; }
.wpe-rhythm__text b { font-size: 13.5px; }
.wpe-rhythm__chart { display: flex; align-items: flex-end; gap: 2px; height: 52px; padding: 4px 0 0; border-bottom: 1px solid var(--wpe-line); }
.wpe-rhythm__chart span { flex: 1 1 0; min-width: 2px; max-width: 12px; border-radius: 3px 3px 0 0; background: var(--wpe-good); opacity: .85; }
.wpe-rhythm__chart .is-medium { background: var(--warning); }
.wpe-rhythm__chart .is-hard { background: var(--danger); }

/* Context card */
.wpe-ctxgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wpe-ctx { padding: 10px 10px 11px; border-radius: 10px; background: var(--wpe-hover); border: 1px solid var(--wpe-line); min-width: 0; }
.wpe-ctx__label { font-size: 11.5px; color: var(--text2); }
.wpe-ctx__value { font-size: 17px; font-weight: 750; margin: 1px 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wpe-ctx__value small { font-size: 12px; font-weight: 600; color: var(--text2); margin-left: 2px; }
.wpe-ctx__hint { font-size: 11.5px; color: var(--text2); line-height: 1.4; }
.wpe-ctx .wpe-meter { margin-top: 7px; height: 4px; }
.wpe-ctx.is-good .wpe-ctx__value { color: var(--wpe-good); }
.wpe-ctx.is-warn .wpe-ctx__value { color: var(--wpe-warn); }

/* Issues */
.wpe-details--card { margin: 0; }
.wpe-details--card > summary { padding: 0; color: var(--text); }
.wpe-details--card > summary .wpe-card__title { margin: 0; flex: 1 1 auto; }
.wpe-details--card[open] > summary { margin-bottom: 12px; }
.wpe-issues { display: grid; gap: 12px; max-height: 520px; overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; }
.wpe-ig__head { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; color: var(--text2); margin-bottom: 5px; }
.wpe-ig__head b { margin-left: auto; font-variant-numeric: tabular-nums; }
.wpe-ig__list { display: grid; gap: 3px; }
.wpe-ig__item {
    display: grid; gap: 1px; width: 100%; padding: 6px 9px;
    border: 1px solid transparent; border-radius: 8px; background: transparent;
    color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.wpe-ig__item:hover { background: var(--wpe-hover); border-color: var(--wpe-line); }
.wpe-ig__snip { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.wpe-ig__msg { font-size: 12px; color: var(--text2); line-height: 1.4; }

/* Outline */
.wpe-outline__list { display: grid; gap: 1px; }
.wpe-ol {
    display: block; width: 100%; padding: 5px 8px; border: 0; border-radius: 7px;
    background: none; color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wpe-ol:hover { background: var(--wpe-hover); }
.wpe-ol--h1 { font-weight: 700; }
.wpe-ol--h2 { padding-left: 16px; }
.wpe-ol--h3 { padding-left: 26px; color: var(--text2); }
.wpe-ol--h4 { padding-left: 36px; color: var(--text2); font-size: 12.5px; }

/* Goals */
.wpe-goal { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.wpe-ring { width: 64px; height: 64px; flex: none; transform: rotate(-90deg); }
.wpe-ring circle { fill: none; stroke-width: 6; }
.wpe-ring__track { stroke: var(--wpe-hover); }
.wpe-ring__bar { stroke: var(--primary); stroke-linecap: round; transition: stroke-dashoffset .4s ease, stroke .3s; }
.wpe-ring__bar.is-done { stroke: var(--success); }
.wpe-goal__pct { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.wpe-goal__text { font-size: 12.5px; color: var(--text2); }
.wpe-goal__session { margin: 8px 0 10px !important; font-size: 12.5px; color: var(--text2); }
.wpe-field { display: grid; gap: 5px; margin-top: 10px; }
.wpe-field label { font-size: 12px; font-weight: 600; color: var(--text2); }
.wpe-field--inline { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wpe-field__err { min-height: 18px; margin-top: 6px !important; font-size: 12.5px; color: var(--wpe-bad); }

/* Pomodoro */
.wpe-pomo { text-align: center; }
.wpe-pomo__label { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text2); }
.wpe-pomo__time { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.15; margin: 2px 0; }
.wpe.is-pomo-break .wpe-pomo__time { color: var(--wpe-good); }
.wpe-pomo__meta { font-size: 12px; color: var(--text2); }
.wpe-pomo__btns { display: flex; justify-content: center; gap: 6px; margin-top: 10px; }

/* Versions */
.wpe-versions { display: grid; gap: 4px; margin-top: 10px; max-height: 340px; overflow-y: auto; overscroll-behavior: contain; }
.wpe-versions > .wpe-muted { font-size: 12.5px; padding: 4px 2px; }
.wpe-ver { display: flex; align-items: center; gap: 6px; padding: 6px 4px 6px 10px; border-radius: 9px; border: 1px solid transparent; }
.wpe-ver:hover { background: var(--wpe-hover); border-color: var(--wpe-line); }
.wpe-ver__main { display: grid; min-width: 0; flex: 1 1 auto; }
.wpe-ver__label { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wpe-ver.is-auto .wpe-ver__label { font-weight: 500; color: var(--text2); }
.wpe-ver__meta { font-size: 11.5px; color: var(--text3); }
.wpe-ver__actions { display: flex; gap: 1px; flex: none; }

/* Activity */
.wpe-streak { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; font-size: 13px; }
.wpe-streak b { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.wpe-heatmap {
    display: grid; grid-template-rows: repeat(7, auto); grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
    gap: 2px; max-width: 360px;
}
.wpe-heatmap i { display: block; width: 100%; aspect-ratio: 1; border-radius: 2px; background: var(--wpe-hover); }
.wpe-heatlegend i { display: block; width: 9px; height: 9px; border-radius: 2px; background: var(--wpe-hover); }
.wpe-heatmap i.is-pad { background: transparent; }
.wpe-heatmap .l1, .wpe-heatlegend .l1 { background: rgba(99, 102, 241, 0.32); }
.wpe-heatmap .l2, .wpe-heatlegend .l2 { background: rgba(99, 102, 241, 0.55); }
.wpe-heatmap .l3, .wpe-heatlegend .l3 { background: rgba(99, 102, 241, 0.8); }
.wpe-heatmap .l4, .wpe-heatlegend .l4 { background: #22d3ee; }
[data-theme="light"] .wpe-heatmap .l4, [data-theme="light"] .wpe-heatlegend .l4 { background: #0891b2; }
.wpe-heatlegend { display: flex; align-items: center; justify-content: flex-end; gap: 3px; margin: 8px 0 6px; font-size: 11px; color: var(--text3); }
.wpe-heatlegend span { margin: 0 3px; }

/* ── Tools ─────────────────────────────────────────────────────────────── */
.wpe-tools { margin: 0 16px 16px; border: 1px solid var(--wpe-line); border-radius: var(--wpe-radius); background: var(--wpe-panel); }
.wpe-tooltabs { display: flex; gap: 2px; padding: 6px 8px 0; border-bottom: 1px solid var(--wpe-line); overflow-x: auto; scrollbar-width: thin; }
.wpe-tooltab {
    display: inline-flex; align-items: center; gap: 7px; flex: none;
    height: 40px; padding: 0 14px; margin-bottom: -1px;
    border: 0; border-bottom: 2px solid transparent; background: none;
    color: var(--text2); font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.wpe-tooltab:hover { color: var(--text); }
.wpe-tooltab.is-active { color: var(--text); border-bottom-color: var(--primary); }
.wpe-tooltab.is-active .wpe-ico { color: var(--primary); }
[data-theme="dark"] .wpe-tooltab.is-active .wpe-ico { color: #a5b4fc; }
.wpe-toolpanel { padding: 14px; }
.wpe-toolpanel:focus-visible { outline-offset: -2px; }
.wpe-toolgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 8px; }
.wpe-tool {
    display: flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 12px;
    border: 1px solid var(--wpe-line-strong); border-radius: var(--wpe-radius-sm);
    background: var(--wpe-paper); color: var(--text); font-size: 13px; font-weight: 600; text-align: center; cursor: pointer;
    transition: border-color .15s, background-color .15s, color .15s, transform .15s;
}
.wpe-tool:hover { border-color: var(--primary); background: var(--wpe-press); }
.wpe-tool:active { transform: translateY(1px); }
.wpe-toolnote { margin: 0 0 10px !important; font-size: 12.5px; color: var(--text2); }
.wpe-readaloud { margin-top: 16px; padding-top: 4px; border-top: 1px solid var(--wpe-line); }
.wpe-readaloud__row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.wpe-readaloud__row .wpe-select:first-of-type { flex: 1 1 220px; max-width: 360px; }
.wpe-ai { min-height: 120px; }

/* ── Results ──────────────────────────────────────────────────────────── */
.wpe-results { margin: 0 16px 16px; border: 1px solid var(--wpe-line); border-radius: var(--wpe-radius); background: var(--wpe-panel); }
.wpe-results:focus { outline: none; }
.wpe-results__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--wpe-line); }
.wpe-results__title { margin: 0; font-size: 15px; font-weight: 750; }
.wpe-results__body { padding: 14px 16px 16px; max-height: min(72vh, 760px); overflow-y: auto; overscroll-behavior: contain; font-size: 13.5px; }
.wpe-results__body > * + * { margin-top: 10px; }
.wpe.is-review .wpe-results { border-color: rgba(99, 102, 241, 0.6); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.14); }
.wpe-ok { color: var(--wpe-good); font-weight: 600; }
.wpe-warn { color: var(--wpe-warn); font-weight: 600; }
.wpe-bad { color: var(--wpe-bad); font-weight: 600; }
.wpe-brow + .wpe-brow { margin-top: 9px; }
.wpe-brow__top { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; font-size: 13px; }
.wpe-brow__val { color: var(--text2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.wpe-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.wpe-table th { text-align: left; font-size: 11.5px; font-weight: 700; color: var(--text2); padding: 6px 8px; border-bottom: 1px solid var(--wpe-line-strong); }
.wpe-table td { padding: 6px 8px; border-bottom: 1px solid var(--wpe-line); overflow-wrap: anywhere; }
.wpe-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wpe-table tr.is-warn td { color: var(--wpe-warn); }
.wpe-list { display: grid; gap: 2px; counter-reset: wpe; }
.wpe-list li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 8px; border-radius: 7px; counter-increment: wpe; }
.wpe-list li:nth-child(odd) { background: var(--wpe-hover); }
.wpe-list li span::before { content: counter(wpe) ". "; color: var(--text3); font-variant-numeric: tabular-nums; }
.wpe-list li b { font-variant-numeric: tabular-nums; color: var(--text2); }
.wpe-hbars { display: grid; gap: 4px; }
.wpe-hbar { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; align-items: center; gap: 8px; font-size: 12.5px; }
.wpe-hbar__label { text-align: right; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wpe-hbar__track { height: 14px; border-radius: 4px; background: var(--wpe-hover); overflow: hidden; }
.wpe-hbar__track span { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--primary), var(--accent)); }
.wpe-hbar__n { font-variant-numeric: tabular-nums; color: var(--text2); white-space: nowrap; }
.wpe-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.wpe-tile { padding: 12px; border-radius: 12px; background: var(--wpe-hover); border: 1px solid var(--wpe-line); text-align: center; }
.wpe-tile__val { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.wpe-tile__label { font-size: 12px; color: var(--text2); }
.wpe-bigscore { display: flex; align-items: center; gap: 16px; padding: 14px 16px; margin-bottom: 12px; border-radius: 12px; background: var(--wpe-hover); }
.wpe-bigscore__num { font-size: 44px; font-weight: 800; line-height: 1; letter-spacing: -0.04em; color: var(--primary); }
[data-theme="dark"] .wpe-bigscore__num { color: #a5b4fc; }
.wpe-bigscore__text { color: var(--text2); }
.wpe-results__body .wpe-score + .wpe-score { margin-top: 10px; }
.wpe-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.wpe-legend span { padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.wpe-legend .is-easy, .wpe-sent.is-easy .wpe-sent__n { background: rgba(16, 185, 129, 0.16); color: var(--wpe-good); }
.wpe-legend .is-medium, .wpe-sent.is-medium .wpe-sent__n { background: rgba(245, 158, 11, 0.16); color: var(--wpe-warn); }
.wpe-legend .is-hard, .wpe-sent.is-hard .wpe-sent__n { background: rgba(239, 68, 68, 0.16); color: var(--wpe-bad); }
.wpe-sents, .wpe-hits { display: grid; gap: 4px; }
.wpe-sent, .wpe-hit {
    display: block; width: 100%; padding: 7px 10px;
    border: 1px solid var(--wpe-line); border-left-width: 3px; border-radius: 8px;
    background: var(--wpe-paper); color: var(--text); font: inherit; font-size: 13px; line-height: 1.55; text-align: left; cursor: pointer;
}
.wpe-sent:hover, .wpe-hit:hover { border-color: rgba(129, 140, 248, 0.6); }
.wpe-sent.is-easy { border-left-color: var(--success); }
.wpe-sent.is-medium { border-left-color: var(--warning); }
.wpe-sent.is-hard { border-left-color: var(--danger); }
.wpe-sent__n { display: inline-block; margin-right: 8px; padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.wpe-hit { border-left-color: var(--primary); }
.wpe-hit mark { color: inherit; padding: 0 1px; }
.wpe-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.wpe-tag { display: inline-flex; gap: 4px; padding: 2px 9px; border-radius: 999px; background: var(--wpe-hover); border: 1px solid var(--wpe-line); font-size: 12.5px; }
.wpe-tag b { color: var(--text2); }
.wpe-wordcloud { line-height: 1.8; color: var(--text2); overflow-wrap: anywhere; }
.wpe-rcontrols { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.wpe-rcontrols > label:not(.wpe-check) { font-size: 12.5px; font-weight: 600; color: var(--text2); }
.wpe-cardprev { margin: 0; }
.wpe-cardprev img { width: 100%; max-width: 600px; height: auto; border-radius: 12px; border: 1px solid var(--wpe-line-strong); box-shadow: var(--wpe-shadow); }

/* ── Dialogs ──────────────────────────────────────────────────────────── */
.wpe-overlay {
    position: fixed; inset: 0; z-index: 3000;
    display: flex; align-items: center; justify-content: center;
    padding: 24px 16px;
    background: rgba(2, 6, 23, 0.6);
    -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
    animation: wpe-fade .15s ease-out;
}
.wpe-dialog {
    display: flex; flex-direction: column;
    width: min(560px, 100%); max-height: calc(100vh - 48px);
    background: var(--wpe-raise); color: var(--text);
    border: 1px solid var(--wpe-line-strong); border-radius: 18px;
    box-shadow: var(--wpe-shadow-pop);
    animation: wpe-rise .18s ease-out;
}
.wpe-dialog--library { width: min(720px, 100%); }
.wpe-dialog--wide { width: min(880px, 100%); }
.wpe-dialog--small { width: min(440px, 100%); }
.wpe-dialog__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 14px 12px 20px; border-bottom: 1px solid var(--wpe-line); }
.wpe-dialog__title { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 17px; font-weight: 750; min-width: 0; }
.wpe-dialog__title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wpe-dialog__title .wpe-ico { color: var(--primary); flex: none; }
.wpe-dialog__body { padding: 16px 20px; overflow-y: auto; overscroll-behavior: contain; min-height: 0; flex: 1 1 auto; }
.wpe-dialog__foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 12px 20px 16px; border-top: 1px solid var(--wpe-line); }
.wpe-dialog__foot .wpe-small { display: inline-flex; align-items: center; gap: 6px; }
.wpe-dialog__foot--end { justify-content: flex-end; }
.wpe-dialog__footbtns { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.wpe-linkform { display: contents; }
@keyframes wpe-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes wpe-rise { from { opacity: 0; transform: translateY(8px) scale(0.985); } to { opacity: 1; transform: none; } }

/* Library */
.wpe-lib__tools { display: flex; gap: 8px; flex-wrap: wrap; }
.wpe-lib__tools .wpe-input { flex: 1 1 220px; height: 36px; }
.wpe-lib__count { margin: 10px 0 6px !important; font-size: 12.5px; }
.wpe-lib { display: grid; gap: 4px; }
.wpe-lib__item { display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 0; border-radius: 12px; border: 1px solid transparent; }
.wpe-lib__item:hover { background: var(--wpe-hover); border-color: var(--wpe-line); }
.wpe-lib__item.is-current { background: var(--wpe-press); }
.wpe-lib__open { display: grid; gap: 1px; flex: 1 1 auto; min-width: 0; padding: 8px 12px; border: 0; border-radius: 10px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.wpe-lib__title { font-size: 14px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wpe-lib__meta { font-size: 12px; color: var(--text2); }
.wpe-lib__rename { flex: 1 1 auto; margin-left: 8px; }
.wpe-lib__actions { display: flex; gap: 2px; flex: none; }
.wpe-lib__empty { padding: 28px 12px; text-align: center; color: var(--text2); }

/* Shortcuts */
.wpe-keys { display: grid; gap: 0; margin: 0; }
.wpe-keys > div { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 2px; border-bottom: 1px solid var(--wpe-line); }
.wpe-keys > div:last-child { border-bottom: 0; }
.wpe-keys dt { font-size: 12.5px; color: var(--text2); white-space: nowrap; }
.wpe-keys dd { margin: 0; font-size: 13.5px; text-align: right; }

/* Version preview */
.wpe-vp__bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.wpe-vp__bar .wpe-segs { margin-bottom: 0; }
.wpe-vp__sum { font-size: 12.5px; }
.wpe-vp__legend { display: flex; gap: 10px; margin: 10px 0; }
.wpe-vp__content {
    padding: 16px 18px; border-radius: 12px; border: 1px solid var(--wpe-line);
    background: var(--wpe-paper); max-height: 56vh; overflow-y: auto;
    font-size: 15px; line-height: 1.7;
}
.wpe-vp__content--diff { white-space: pre-wrap; overflow-wrap: anywhere; }
.wpe-vp__content--doc h1, .wpe-vp__content--doc h2, .wpe-vp__content--doc h3, .wpe-vp__content--doc h4 { color: inherit; margin: 0.6em 0 0.3em; font-size: 1.2em; }
.wpe-vp__content--doc ul { list-style: disc; padding-left: 1.5em; }
.wpe-vp__content--doc ol { list-style: decimal; padding-left: 1.5em; }
.wpe-vp__content--doc p { margin-bottom: 0.7em; }
.wpp-diff-ins { background: rgba(16, 185, 129, 0.22); color: inherit; text-decoration: none; border-radius: 3px; box-shadow: 0 -2px 0 rgba(16, 185, 129, 0.5) inset; }
.wpp-diff-del { background: rgba(239, 68, 68, 0.2); color: inherit; text-decoration: line-through; text-decoration-color: rgba(248, 113, 113, 0.9); border-radius: 3px; }
.wpe-vp__legend .wpp-diff-ins, .wpe-vp__legend .wpp-diff-del { padding: 1px 8px; font-size: 12px; }

/* ── Snackbar, read-aloud bar, focus exit, backdrop ───────────────────── */
.wpe-snack {
    position: fixed; left: 20px; bottom: 20px; z-index: 2500;
    display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 40px);
    padding: 10px 10px 10px 16px; border-radius: 12px;
    background: #0b1220; color: #f1f5f9; border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 16px 40px -10px rgba(0, 0, 0, 0.55); font-size: 13.5px;
    animation: wpe-rise .18s ease-out;
}
.wpe-snack__btn { padding: 6px 12px; border-radius: 8px; background: rgba(99, 102, 241, 0.25); color: #c7d2fe; font-weight: 700; font-size: 13px; }
.wpe-snack__btn:hover { background: rgba(99, 102, 241, 0.4); color: #fff; }
.wpe-speechbar {
    position: fixed; right: 20px; bottom: 20px; z-index: 2400;
    display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 14px;
    border-radius: 999px; background: var(--wpe-raise); color: var(--text);
    border: 1px solid var(--wpe-line-strong); box-shadow: var(--wpe-shadow-pop); font-size: 13px; font-weight: 600;
}
.wpe-speechbar > .wpe-ico { color: var(--primary); }
.wpe-speechbar__label { margin-right: 4px; }
.wpe-exitfocus {
    position: fixed; top: calc(var(--wpe-top) + 12px); right: 16px; z-index: 900;
    display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
    border-radius: 999px; border: 1px solid var(--wpe-line-strong);
    background: var(--wpe-raise); color: var(--text2); font-size: 12.5px; font-weight: 600; box-shadow: var(--wpe-shadow-pop);
}
.wpe-exitfocus:hover { color: var(--text); }
.wpe-backdrop { position: fixed; inset: 0; z-index: 1150; background: rgba(2, 6, 23, 0.5); }
.wpe-noscript { padding: 16px; text-align: center; color: var(--text2); }

/* ── States: drag, busy, find & speech highlights ─────────────────────── */
.wpe.is-dragover .wpe-paper { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.18); }
.wpe.is-dragover .wpe-paper::after {
    content: "Drop to open the file"; position: absolute; inset: 10px; z-index: 5;
    display: flex; align-items: center; justify-content: center;
    border: 2px dashed var(--primary); border-radius: 12px; background: rgba(99, 102, 241, 0.08);
    color: var(--primary); font-weight: 700; pointer-events: none;
}
.wpe.is-busy, .wpe.is-busy * { cursor: progress; }
::highlight(wpp-find) { background-color: rgba(250, 204, 21, 0.35); }
::highlight(wpp-find-current) { background-color: rgba(249, 115, 22, 0.75); color: #fff; }
::highlight(wpp-speak) { background-color: rgba(34, 211, 238, 0.30); }
[data-theme="light"] ::highlight(wpp-find) { background-color: rgba(250, 204, 21, 0.45); }
[data-theme="light"] ::highlight(wpp-find-current) { background-color: rgba(234, 88, 12, 0.85); color: #fff; }
[data-theme="light"] ::highlight(wpp-speak) { background-color: rgba(8, 145, 178, 0.22); }

/* ── View modes (workspace) ───────────────────────────────────────────── */
.wpe.is-focus { background: transparent; border-color: transparent; box-shadow: none; }
.wpe.is-focus .wpe-head,
.wpe.is-focus .wpe-toolbar,
.wpe.is-focus .wpe-special,
.wpe.is-focus .wpe-hlbar,
.wpe.is-focus .wpe-limitbar,
.wpe.is-focus .wpe-side,
.wpe.is-focus .wpe-tools,
.wpe.is-focus .wpe-results,
.wpe.is-focus .wpe-foot,
.wpe.is-focus .wpe-banner { display: none; }
.wpe.is-focus .wpe-main { grid-template-columns: minmax(0, 1fr); max-width: 820px; margin: 24px auto 0; padding: 0; }
.wpe.is-focus .wpe-paper { border-color: transparent; background: transparent; box-shadow: none; }
.wpe.is-focus .wpe-editor { min-height: 75vh; padding: 24px 16px 30vh; font-size: 19px; line-height: 1.9; }
.wpe.is-typewriter .wpe-editor { height: 72vh; min-height: 320px; overflow-y: auto; padding-top: 32vh; padding-bottom: 32vh; }
.wpe.is-typewriter .wpe-editor.is-empty::before { top: 32vh; }
.wpe:fullscreen { overflow-y: auto; background: var(--bg1); border-radius: 0; border: 0; padding: 8px 12px 24px; --wpe-top: 0px; }
.wpe:-webkit-full-screen { overflow-y: auto; background: var(--bg1); --wpe-top: 0px; }

/* ── Quick mode specifics ─────────────────────────────────────────────── */
.wpe--quick .wpe-side--right .wpe-card { padding: 13px 14px 14px; }

/* ── Embed (timemanagementtools.net iframe) ───────────────────────────── */
body.wpp-embed .wpe-wrap { margin: 0; padding: 0; max-width: none; }
body.wpp-embed .wpe { border-radius: 0; border: 0; box-shadow: none; --wpe-top: 0px; }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1280px) {
    .wpe--workspace .wpe-main { grid-template-columns: 248px minmax(0, 1fr) 300px; }
}
@media (max-width: 1100px) {
    /* Workspace left sidebar → drawer */
    .wpe--workspace .wpe-main { grid-template-columns: minmax(0, 1fr) 300px; }
    .wpe--workspace .wpe-drawer-btn--left { display: inline-flex; }
    .wpe--workspace .wpe-side--left {
        position: fixed; top: 0; bottom: 0; left: 0; z-index: 1200;
        width: min(340px, 88vw); padding: 0 14px 24px; overflow-y: auto; overscroll-behavior: contain;
        align-content: start;
        background: var(--wpe-shell); border-right: 1px solid var(--wpe-line-strong);
        box-shadow: var(--wpe-shadow-pop);
        transform: translateX(-105%); visibility: hidden;
        transition: transform .22s ease, visibility 0s linear .22s;
    }
    .wpe--workspace .wpe-side--left.is-open { transform: none; visibility: visible; transition: transform .22s ease, visibility 0s; }
    .wpe--workspace .wpe-side--left .wpe-side__drawerhead { display: flex; }
}
@media (max-width: 900px) {
    .wpe--quick .wpe-main { grid-template-columns: minmax(0, 1fr) 280px; }
}
@media (max-width: 820px) {
    /* Right sidebar → drawer in both modes */
    .wpe--quick .wpe-main, .wpe--workspace .wpe-main { grid-template-columns: minmax(0, 1fr); }
    .wpe-drawer-btn--right { display: inline-flex; }
    .wpe-side--right {
        position: fixed; top: 0; bottom: 0; right: 0; z-index: 1200;
        width: min(360px, 90vw); padding: 0 14px 24px; overflow-y: auto; overscroll-behavior: contain;
        align-content: start;
        background: var(--wpe-shell); border-left: 1px solid var(--wpe-line-strong);
        box-shadow: var(--wpe-shadow-pop);
        transform: translateX(105%); visibility: hidden;
        transition: transform .22s ease, visibility 0s linear .22s;
    }
    .wpe-side--right.is-open { transform: none; visibility: visible; transition: transform .22s ease, visibility 0s; }
    .wpe-side--right .wpe-side__drawerhead { display: flex; }
    .wpe-wrap--quick { padding: 12px 10px 0; }
    .wpe-wrap--workspace { padding: 8px 8px 32px; }
    .wpe { border-radius: 16px; }
    .wpe-main { padding: 12px; gap: 12px; }
    .wpe-tools { margin: 0 12px 12px; }
    .wpe-results { margin: 0 12px 12px; }
    .wpe-editor, .wpe--workspace .wpe-editor { padding: 22px 20px 40px; min-height: 360px; }
    .wpe-hide-sm { display: none; }
    .wpe-findbar .wpe-find { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
    .wpe-tb--more, .wpe-tb-more-only { display: inline-flex; }
    .wpe-tbmore { display: none; }
    .wpe-toolbar.is-expanded .wpe-tbmore { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; flex-basis: 100%; padding-top: 4px; }
    .wpe-toolbar.is-expanded .wpe-tbmore .wpe-tbsep { display: none; }
    .wpe-select--tb { max-width: 104px; }
    .wpe-titlebar__doc { flex-wrap: wrap; row-gap: 4px; }
    .wpe-title { width: 100%; font-size: 17px; }
    .wpe-titlebar__actions { width: 100%; justify-content: flex-start; }
    .wpe-views { order: 5; }
    .wpe-libbtn span { display: none; }
    .wpe-hlbar { padding: 8px 10px; }
    .wpe-hlbar__chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; width: 100%; }
    .wpe-hlbar__chips::-webkit-scrollbar { display: none; }
    .wpe-chip { flex: none; }
    .wpe-toolgrid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .wpe-dialog__foot { flex-direction: column; align-items: stretch; }
    .wpe-dialog__footbtns { justify-content: flex-end; }
    .wpe-snack { left: 10px; right: 10px; bottom: 10px; }
    .wpe-speechbar { right: 10px; bottom: 74px; }
    .wpe-hbar { grid-template-columns: 84px minmax(0, 1fr) auto; }
    /* 16px stops iOS from zooming into focused fields */
    .wpe-input, .wpe-select, .wpe-title { font-size: 16px; }
}
@media (max-width: 480px) {
    .wpe-wrap--quick { padding: 8px 6px 0; }
    .wpe { border-radius: 14px; }
    .wpe-head { padding: 8px 10px; }
    .wpe-toolbar { padding: 6px 8px; }
    .wpe-main { padding: 8px; }
    .wpe-tools { margin: 0 8px 8px; }
    .wpe-results { margin: 0 8px 8px; }
    .wpe-editor, .wpe--workspace .wpe-editor { padding: 18px 16px 36px; font-size: 16.5px; }
    .wpe-toolpanel { padding: 10px; }
    .wpe-ctxgrid { grid-template-columns: 1fr; }
    .wpe-overlay { padding: 10px; align-items: flex-end; }
    .wpe-dialog { max-height: calc(100vh - 20px); border-radius: 18px 18px 14px 14px; }
}
/* Touch screens: 40px targets */
@media (pointer: coarse) {
    .wpe-tb, .wpe-tbcolor, .wpe-select--tb { min-width: 40px; height: 40px; }
    .wpe-iconbtn { width: 40px; height: 40px; }
    .wpe-iconbtn--sm { width: 36px; height: 36px; }
    .wpe-btn { height: 40px; }
    .wpe-chip { height: 34px; }
    .wpe-doctab { height: 38px; }
    .wpe-doctab__x { opacity: 1; width: 28px; height: 28px; }
    .wpe-tool { min-height: 44px; }
    .wpe-view { height: 34px; }
    .wpe-menu__item { padding: 11px 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .wpe *, .wpe *::before, .wpe *::after, .wpe-overlay, .wpe-dialog, .wpe-snack {
        animation: none !important;
        transition: none !important;
    }
}

@media print {
    .wpe-overlay, .wpe-snack, .wpe-speechbar, .wpe-exitfocus, .wpe-backdrop { display: none !important; }
}
