/*
 * TeXConverter's colours: the one place they're set.
 *
 * Every page of the website, the Word task pane and the desktop app takes its
 * colours from here: the builds put this file at the top of each stylesheet
 * (scripts/build.mjs for the pane and the website, scripts/build-cli.mjs for
 * the desktop app). Change a value here, then run `npm run theme`: it remakes
 * the logo and the screenshots, rebuilds and tests (step by step in docs/THEME.md).
 * No other stylesheet defines these names (tests/unit/desktop-ui.test.ts).
 *
 *   --brand …        buttons, links, what's chosen (teal)
 *   --accent         the second colour: badges, highlights (saffron)
 *   --ink-0 … 3      the dark bands: the home page's top, the footer, the stats and sign-up bands
 *   --glow-1 … 3     the soft lights over the dark bands
 *   --hero-…         text on the dark bands
 *   --grad-1 … 3     the coloured words in the headline
 *   --icon-from/to   icons' and numbered steps' tiles
 */
:root {
  --brand: #0e7c6b;
  --brand-hover: #0a6457;
  --brand-pressed: #084c42;
  --brand-tint: #e7f5f1;
  --brand-hi: #14a08a;
  --accent: #e8a317;
  --accent-tint: #fdf4e1;

  --fg: #1f2826;
  --fg-secondary: #3d4946;
  --fg-muted: #5d6b67;
  --bg: #ffffff;
  --bg-subtle: #f8faf9;
  --bg-hover: #eef3f1;
  --border: #cfd8d5;
  --border-subtle: #e3eae7;

  --danger-bg: #fdf3f4;
  --danger-border: #f3d6d8;
  --danger-fg: #a4262c;
  --warn-bg: #fff8e6;
  --warn-border: #f7e2b0;
  --warn-fg: #8a6100;
  --ok-bg: #eff6ef;
  --ok-border: #cfe4cf;
  --ok-fg: #0e700e;

  --ink-0: #03201b;
  --ink-1: #062c26;
  --ink-2: #0a3d35;
  --ink-3: #0f5a4c;
  --glow-1: #14b8a6;
  --glow-2: #e8a317;
  --glow-3: #10b981;
  --hero-fg: #e3f1ed;
  --hero-muted: #b3cdc6;
  --hero-dim: #8db0a7;
  --hero-accent: #5eead4;
  --grad-1: #5eead4;
  --grad-2: #2dd4bf;
  --grad-3: #fbbf24;
  --icon-from: #14b8a6;
  --icon-to: #0e7c6b;
  --live: #34d399;

  --radius: 4px;
  --radius-lg: 6px;
  color-scheme: light dark;
  /* Ticks, radio buttons, sliders and progress bars in the brand's colour, not the browser's blue. */
  accent-color: var(--brand);
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #22a28c;
    --brand-hover: #2bb39b;
    --brand-pressed: #1a8a76;
    --brand-tint: #0b2a25;
    --brand-hi: #3cc5ad;
    --accent: #f0b84a;
    --accent-tint: #33270d;

    --fg: #ffffff;
    --fg-secondary: #d4dbd9;
    --fg-muted: #a9b5b2;
    --bg: #1b1f1e;
    --bg-subtle: #222826;
    --bg-hover: #323a38;
    --border: #46504d;
    --border-subtle: #39423f;

    --danger-bg: #3a2325;
    --danger-border: #5c3438;
    --danger-fg: #f1707b;
    --warn-bg: #3a2f16;
    --warn-border: #5c4a22;
    --warn-fg: #f0c674;
    --ok-bg: #1f3320;
    --ok-border: #34502f;
    --ok-fg: #6cc46c;
  }
}

/*
 * The website: home, download, docs, plans, account and admin.
 *
 * Its colours, the dark bands' too, are frontend/theme.css's: the one place the
 * colours are set for the website, the Word task pane and the desktop app
 * (scripts/build.mjs puts them on top of this file). Change a colour there,
 * not here: use the theme's names (var(--brand), var(--ink-1)).
 */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("assets/fonts/inter.woff2") format("woff2");
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; scroll-padding-top: 64px; }
html, body { overflow-x: clip; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-subtle);
  color: var(--fg);
  font: 15px/1.6 "Inter", "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body.home { background: var(--bg); }

a { color: var(--brand); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
code { font-family: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace; font-size: .92em; }

.skip-link { position: absolute; left: 12px; top: -48px; z-index: 100; padding: 8px 14px; border-radius: 8px; background: var(--brand); color: #fff; text-decoration: none; }
.skip-link:focus { top: 12px; }

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .82);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(15, 23, 42, .08);
}
.site-header-inner { max-width: 1200px; margin: 0 auto; padding: 0 20px; height: 64px; display: flex; align-items: center; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; color: var(--fg); text-decoration: none; flex-shrink: 0; }
.brand img { border-radius: 7px; }
.site-nav { display: flex; gap: 3px; flex: none; min-width: 0; margin-left: auto; }
.site-nav a, .header-link, .site-nav-menu summary { color: var(--fg-secondary); text-decoration: none; padding: 7px 10px; border-radius: 8px; font-weight: 550; font-size: 14px; white-space: nowrap; }
.site-nav a:hover, .header-link:hover, .site-nav-menu summary:hover { color: var(--fg); background: rgba(15, 23, 42, .05); }
.site-nav a[aria-current="page"], .header-link[aria-current="page"], .site-nav-menu summary[aria-current="page"] { color: var(--brand); background: var(--brand-tint); }
.site-nav-menu { position: relative; flex: none; }
.site-nav-menu summary { display: block; cursor: pointer; list-style: none; }
.site-nav-menu summary::-webkit-details-marker { display: none; }
.site-nav-popover { position: absolute; top: calc(100% + 8px); left: 0; z-index: 60; display: none; min-width: 240px; padding: 7px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); box-shadow: 0 12px 32px rgba(16, 24, 40, .16); }
.site-nav-menu[open] .site-nav-popover { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 10px; left: 50%; width: min(620px, calc(100vw - 32px)); transform: translateX(-50%); }
.site-nav-popover a { white-space: normal; }
.site-nav-group { display: grid; align-content: start; gap: 2px; }
.site-nav-heading { margin: 4px 10px 4px; color: var(--fg-muted); font-size: 11.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.site-nav-popover a.site-nav-all { grid-column: 1 / -1; margin-top: 4px; padding: 10px; border-top: 1px solid var(--border-subtle); border-radius: 0 0 8px 8px; color: var(--brand); font-weight: 600; }
@media (max-width: 760px) {
  .site-nav-popover { position: fixed; top: var(--site-header-height, 64px); left: 16px; right: 16px; min-width: 0; max-height: calc(100vh - var(--site-header-height, 64px) - 16px); overflow-y: auto; }
  .site-nav-menu[open] .site-nav-popover { grid-template-columns: minmax(0, 1fr); left: 16px; width: auto; transform: none; }
}
.site-nav-popover a { display: block; padding: 9px 10px; border-radius: 8px; }
.site-nav-popover a strong { display: block; color: var(--fg); font-weight: 600; }
.site-nav-popover a small { display: block; margin-top: 1px; color: var(--fg-muted); font-size: 12.5px; font-weight: 400; }
.site-nav-popover a:hover { background: var(--bg-hover); color: var(--fg); }
.home .site-nav-popover a { color: var(--fg); }
.home .site-nav-popover a.site-nav-all { color: var(--brand); }
.home .site-nav-popover a:hover { color: var(--fg); background: var(--bg-hover); }

.feature-guide { max-width: 960px; margin: 0 auto; padding: 52px 20px 80px; }
.feature-guide-head { margin-bottom: 28px; }
.feature-guide-head h1 { max-width: 20ch; margin: 0 0 12px; font-size: clamp(32px, 5vw, 48px); line-height: 1.08; letter-spacing: -.035em; }
.feature-guide-head > p:not(.eyebrow) { max-width: 64ch; margin: 0 0 20px; color: var(--fg-secondary); font-size: 17px; line-height: 1.6; }
.feature-guide-card { scroll-margin-top: 24px; margin: 16px 0; padding: 24px; border: 1px solid var(--border-subtle); border-radius: 14px; background: var(--bg); }
.feature-guide-card h2 { margin: 0 0 9px; font-size: 23px; letter-spacing: -.02em; }
.feature-guide-card p { max-width: 72ch; margin: 0 0 14px; color: var(--fg-secondary); line-height: 1.65; }
.feature-guide-card ol { padding-left: 22px; color: var(--fg-secondary); line-height: 1.7; }
.feature-guide-card li { padding-left: 3px; margin: 4px 0; }
.feature-try-link { display: inline-block; margin-top: 3px; color: var(--brand); font-weight: 650; text-decoration: none; }
.feature-try-link:hover { text-decoration: underline; }
.feature-guide-more { margin-top: 28px; color: var(--fg-secondary); }

.feature-detail { max-width: 1120px; margin: 0 auto; padding: 28px 24px 76px; }
.feature-breadcrumb { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; color: var(--fg-muted); font-size: 13px; }
.feature-breadcrumb a { color: var(--fg-secondary); text-decoration: none; }
.feature-breadcrumb a:hover { color: var(--brand); text-decoration: underline; }
.feature-detail-hero { overflow: hidden; position: relative; padding: clamp(34px, 7vw, 70px); border: 1px solid color-mix(in srgb, var(--hero-dim) 18%, transparent); border-radius: 22px; color: var(--hero-fg); background: radial-gradient(45% 90% at 90% 0%, color-mix(in srgb, var(--glow-1) 28%, transparent), transparent 72%), radial-gradient(40% 90% at 0% 100%, color-mix(in srgb, var(--glow-2) 20%, transparent), transparent 72%), linear-gradient(135deg, var(--ink-1), var(--ink-2)); }
.feature-detail-hero .eyebrow { margin: 0 0 14px; color: var(--hero-accent); }
.feature-detail-hero h1 { max-width: 16ch; margin: 0 0 18px; color: #fff; font-size: clamp(36px, 6vw, 58px); line-height: 1.04; letter-spacing: -.045em; }
.feature-detail-lead { max-width: 66ch; margin: 0; color: var(--hero-muted); font-size: clamp(16px, 2vw, 19px); line-height: 1.65; }
.feature-detail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.feature-detail-actions .btn-glass { border-color: rgba(226, 232, 240, .32); }
.feature-steps { padding: clamp(40px, 6vw, 64px) 0 28px; }
.feature-section-head { margin-bottom: 22px; }
.feature-section-head .eyebrow { margin-bottom: 8px; }
.feature-section-head h2 { margin: 0; font-size: clamp(25px, 4vw, 34px); letter-spacing: -.03em; }
.feature-step-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.feature-step-grid article { min-height: 205px; padding: 22px; border: 1px solid var(--border-subtle); border-radius: 14px; background: var(--bg); }
.feature-step-number { display: inline-block; margin-bottom: 22px; color: var(--brand); font-size: 12px; font-weight: 750; letter-spacing: .12em; }
.feature-step-grid h3 { margin: 0 0 8px; font-size: 18px; letter-spacing: -.015em; }
.feature-step-grid p { margin: 0; color: var(--fg-secondary); font-size: 14.5px; line-height: 1.65; }
.feature-detail-note { margin-top: 22px; padding: 22px 24px; border-left: 3px solid var(--brand); border-radius: 0 12px 12px 0; background: var(--bg-subtle); }
.feature-detail-note h2 { margin: 0 0 7px; font-size: 17px; }
.feature-detail-note p { max-width: 75ch; margin: 0; color: var(--fg-secondary); line-height: 1.65; }
.feature-detail-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin: 28px 0 0; }
.feature-detail-footer a { color: var(--brand); font-size: 14px; font-weight: 650; text-decoration: none; }
.feature-detail-footer a:hover { text-decoration: underline; }
@media (max-width: 760px) { .feature-detail { padding: 20px 16px 56px; } .feature-step-grid { grid-template-columns: 1fr; } .feature-step-grid article { min-height: 0; } .feature-step-number { margin-bottom: 12px; } }
/* Product pages: what it reads, the plans strip and the questions. */
.feature-checks { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 22px 0 0; padding: 0; list-style: none; color: var(--hero-muted); font-size: 14px; }
.feature-checks li::before { content: "\2713"; margin-right: 8px; color: var(--hero-accent); font-weight: 700; }
.feature-points { padding: clamp(40px, 6vw, 64px) 0 0; }
.feature-point-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.feature-point-grid article { padding: 20px 22px; border: 1px solid var(--border-subtle); border-radius: 14px; background: var(--bg-subtle); }
.feature-point-grid h3 { margin: 0 0 6px; font-size: 16px; letter-spacing: -.01em; }
.feature-point-grid p { margin: 0; color: var(--fg-secondary); font-size: 14.5px; line-height: 1.6; }
.feature-plans { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px; margin-top: 28px; padding: 24px 26px; border: 1px solid var(--border-subtle); border-radius: 16px; background: var(--bg); }
.feature-plans h2 { margin: 0 0 6px; font-size: 20px; letter-spacing: -.02em; }
.feature-plans p { max-width: 62ch; margin: 0; color: var(--fg-secondary); line-height: 1.6; }
.feature-plans .feature-detail-actions { margin-top: 0; }
.feature-faq { padding: clamp(36px, 5vw, 56px) 0 0; }
@media (max-width: 860px) { .feature-point-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .feature-point-grid { grid-template-columns: 1fr; } .feature-plans { padding: 20px; } }
.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

@media (prefers-color-scheme: dark) {
  .site-header { background: rgba(24, 24, 27, .8); border-bottom-color: rgba(255, 255, 255, .08); }
  .site-nav a:hover, .header-link:hover, .site-nav-menu summary:hover { background: rgba(255, 255, 255, .07); }
}

/* On the home page the header sits on the dark hero. */
.home .site-header { background: color-mix(in srgb, var(--ink-0) 72%, transparent); border-bottom-color: rgba(255, 255, 255, .08); }
.home .brand, .home .site-nav a, .home .header-link, .home .site-nav-menu summary { color: var(--hero-fg); }
.home .site-nav a:hover, .home .header-link:hover, .home .site-nav-menu summary:hover { color: #ffffff; background: rgba(255, 255, 255, .08); }

/* The menu button: phones and small tablets only (siteHeader in scripts/website.mjs). */
.site-mobile-nav { display: none; }
.site-mobile-nav summary { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 10px; color: var(--fg); cursor: pointer; list-style: none; }
.site-mobile-nav summary::-webkit-details-marker { display: none; }
.site-mobile-nav summary svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.site-mobile-nav .site-mobile-close, .site-mobile-nav[open] .site-mobile-open { display: none; }
.site-mobile-nav[open] .site-mobile-close { display: block; }
.site-mobile-nav[open] summary { background: var(--bg-hover); }
.site-mobile-panel { position: absolute; top: 100%; left: 0; right: 0; max-height: calc(100vh - 64px); max-height: calc(100dvh - 64px); overflow-y: auto; padding: 8px 16px 22px; border-bottom: 1px solid var(--border); background: var(--bg); box-shadow: 0 18px 40px rgba(15, 23, 42, .18); }
.site-mobile-products { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border-subtle); }
.site-mobile-heading { grid-column: 1 / -1; margin: 14px 0 4px; color: var(--fg-muted); font-size: 11.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.site-mobile-panel a { display: block; padding: 10px 8px; border-radius: 8px; color: var(--fg); font-size: 15px; font-weight: 550; text-decoration: none; }
.site-mobile-panel a:hover, .site-mobile-panel a[aria-current="page"] { background: var(--brand-tint); color: var(--brand); }
.site-mobile-all { grid-column: 1 / -1; color: var(--brand) !important; }
.site-mobile-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px; padding-top: 10px; }
.home .site-mobile-nav summary { border-color: rgba(255, 255, 255, .22); color: var(--hero-fg); }
.home .site-mobile-nav[open] summary { background: rgba(255, 255, 255, .1); }

@media (max-width: 820px) {
  .site-header-inner { gap: 10px; padding: 0 16px; }
  .site-nav, .header-actions .header-link { display: none; }
  .header-actions { margin-left: auto; }
  .site-mobile-nav { display: block; }
}
@media (max-width: 380px) {
  .site-header .brand { gap: 8px; font-size: 16px; }
  .site-header .brand img { width: 26px; height: 26px; }
  .header-actions .btn-sm { padding-left: 10px; padding-right: 10px; }
}
@media (max-width: 340px) {
  .site-mobile-products, .site-mobile-links { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- product pages (scripts/product-pages.mjs) ---------- */

.product-steps { margin: 0; padding: 0; list-style: none; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.product-steps li { padding: 22px; border: 1px solid var(--border-subtle); border-radius: 14px; background: var(--bg); }
.product-steps .feature-step-number { margin-bottom: 14px; padding: 3px 10px; border-radius: 999px; background: var(--brand-tint); letter-spacing: .06em; text-transform: uppercase; }
.product-steps-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 20px 0 0; color: var(--fg-muted); font-size: 14px; }
.product-tips { margin-top: 12px; padding: 24px 26px; border: 1px solid var(--border-subtle); border-left: 3px solid var(--brand); border-radius: 0 14px 14px 0; background: var(--bg-subtle); }
.product-tips h2 { margin: 0 0 12px; font-size: 19px; letter-spacing: -.015em; }
.product-tips ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 28px; margin: 0; padding: 0; list-style: none; }
.product-tips li { position: relative; padding-left: 26px; color: var(--fg-secondary); line-height: 1.6; }
.product-tips li::before { content: "¹3"; position: absolute; left: 0; top: 0; color: var(--brand); font-weight: 700; }
.product-related { padding-top: clamp(28px, 4vw, 44px); }
.product-related h2 { margin: 0 0 16px; font-size: clamp(21px, 3vw, 26px); letter-spacing: -.02em; }
.product-related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.product-related-grid a { display: flex; flex-direction: column; gap: 5px; padding: 18px 20px; border: 1px solid var(--border-subtle); border-radius: 14px; background: var(--bg); color: var(--fg); text-decoration: none; transition: border-color .15s, box-shadow .15s, transform .15s; }
.product-related-grid a:hover { border-color: var(--brand); box-shadow: 0 10px 24px rgba(15, 23, 42, .08); transform: translateY(-1px); }
.product-related-grid strong { font-size: 16px; font-weight: 650; }
.product-related-grid span { color: var(--fg-secondary); font-size: 14px; line-height: 1.55; }
.product-related-grid em { margin-top: auto; padding-top: 8px; color: var(--brand); font-size: 14px; font-style: normal; font-weight: 650; }
.products-overview .feature-guide-head { margin-bottom: 8px; }
.products-group { padding-top: 28px; }
.products-group h2 { margin: 0 0 14px; color: var(--fg-muted); font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
@media (max-width: 760px) {
  .product-tips { padding: 20px; }
  .product-tips ul { grid-template-columns: minmax(0, 1fr); }
  .product-steps-cta .btn { width: 100%; justify-content: center; }
  .product-page .feature-detail-actions .btn { flex: 1 1 100%; justify-content: center; }
}

/* ---------- footer ---------- */

.site-footer { background: var(--ink-0); color: var(--hero-dim); padding: 56px 20px 28px; font-size: 14px; }
.site-footer-inner { max-width: 1200px; margin: 0 auto; }
.footer-top { display: grid; grid-template-columns: 1.4fr repeat(6, minmax(0, 1fr)); gap: 28px; padding-bottom: 36px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
@media (max-width: 1080px) { .footer-top { grid-template-columns: repeat(3, minmax(0, 1fr)); } .footer-brand { grid-column: 1 / -1; } }
.footer-brand .brand { color: #ffffff; margin-bottom: 12px; }
.footer-brand p { max-width: 30ch; margin: 0; line-height: 1.6; }
.footer-col h2 { margin: 4px 0 14px; font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--hero-fg); }
.footer-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.site-footer a { color: var(--hero-dim); text-decoration: none; }
.site-footer a:hover { color: #ffffff; }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding-top: 22px; font-size: 12.5px; color: color-mix(in srgb, var(--hero-dim) 75%, var(--ink-0)); }
@media (max-width: 820px) {
  .footer-top { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer-brand { grid-column: 1 / -1; }
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-weight: 600;
  font-size: 14.5px;
  padding: 8px 18px;
  min-height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, box-shadow .15s, transform .15s;
}
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn-primary { background: linear-gradient(180deg, var(--brand-hi), var(--brand)); border-color: var(--brand-hover); color: #fff; box-shadow: 0 1px 2px color-mix(in srgb, var(--brand) 30%, transparent), inset 0 1px 0 rgba(255, 255, 255, .15); }
.btn-primary:hover { background: linear-gradient(180deg, var(--brand), var(--brand-hover)); border-color: var(--brand-pressed); }
.btn-danger { background: var(--danger-fg); border-color: var(--danger-fg); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-danger { background: #c4314b; border-color: #c4314b; } }
.btn-wide { width: 100%; }
.btn-sm { min-height: 34px; padding: 6px 14px; font-size: 14px; border-radius: 9px; }
.btn-lg { min-height: 50px; padding: 12px 26px; font-size: 16px; border-radius: 12px; }
.btn-glass { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .22); color: #ffffff; }
.btn-glass:hover { background: rgba(255, 255, 255, .15); }
.btn-on-brand { background: #ffffff; border-color: #ffffff; color: var(--ink-2); }
.btn-on-brand:hover { background: var(--brand-tint); }
.btn-ghost-on-brand { background: transparent; border-color: rgba(255, 255, 255, .5); color: #ffffff; }
.btn-ghost-on-brand:hover { background: rgba(255, 255, 255, .12); }

/* ---------- inner pages ---------- */

.page { width: 100%; max-width: 680px; margin: 0 auto; padding: 40px 20px 56px; flex: 1; }
.page-wide { max-width: 1120px; }
h1 { margin: 0 0 16px; font-size: 32px; line-height: 1.2; font-weight: 700; letter-spacing: -.025em; }
h2 { margin: 0 0 8px; font-size: 18px; font-weight: 650; letter-spacing: -.01em; }
h3 { margin: 20px 0 8px; font-size: 14px; font-weight: 600; color: var(--fg-secondary); }
p { margin: 0 0 10px; }
.lead { color: var(--fg-secondary); margin-bottom: 24px; font-size: 16.5px; }
.muted { color: var(--fg-muted); }
.small { font-size: 13px; }
.center { text-align: center; }

.page-hero { text-align: center; max-width: 720px; margin: 0 auto 36px; }
.page-hero h1 { font-size: clamp(30px, 4.5vw, 42px); }
.page-hero .lead { margin: 0 auto; max-width: 60ch; }

/* ---------- pieces ---------- */

.card {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .04);
}
.card-attention { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }

.notice {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
.notice-info { background: var(--brand-tint); border-color: var(--brand); }
.notice-ok { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-fg); }
.notice-warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-fg); }
.notice-danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-fg); }

.row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.field { display: flex; flex-direction: column; gap: 5px; width: 100%; }
.field-inline { flex: 1 1 220px; width: auto; }
.field span { font-size: 13px; font-weight: 500; color: var(--fg-secondary); }
.field input, .field select, .field textarea {
  font: inherit;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.field select { width: auto; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }

.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--fg-muted); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border-subtle); }

/* ---------- sign-in popup (web/src/signin.ts) ---------- */

.modal-open { overflow: hidden; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(2px);
  animation: modal-fade .15s ease-out;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  position: relative;
  width: 100%;
  max-width: 400px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 32px 28px 22px;
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, .28);
  text-align: center;
  animation: modal-rise .18s ease-out;
}
.modal h2 { font-size: 21px; margin: 10px 0 6px; }
.modal .stack { align-items: stretch; text-align: left; }
.modal .notice { text-align: left; margin: 12px 0 0; }
.modal-logo { display: block; margin: 0 auto; border-radius: 10px; }
.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--fg-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { background: var(--bg-hover); color: var(--fg); }
.modal-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px; }
.modal-foot { margin: 18px 0 0; }
.modal-foot a { color: inherit; }
.btn-google { margin-top: 18px; gap: 10px; }
.btn-link { border-color: transparent; background: transparent; color: var(--brand); font-weight: 500; }
.btn-link:hover { background: var(--brand-tint); }
.signed-out { text-align: center; padding: 36px 24px; }
.signed-out p { max-width: 46ch; margin: 0 auto 18px; }
/* The sign-in gate: one look for every page or panel that needs an account (account, PDF, photos). */
.signed-out.gate { position: relative; display: flex; flex-direction: column; align-items: center; max-width: 620px; margin: 8px auto; padding: 40px 32px 0; overflow: hidden; border: 1px solid var(--border-subtle); border-radius: 18px; background: radial-gradient(120% 70% at 50% 0%, var(--brand-tint), transparent 62%), var(--bg); box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 16px 40px rgba(15, 23, 42, .07); }
.signed-out.gate[hidden] { display: none; }
.gate-icon { display: grid; place-items: center; width: 60px; height: 60px; margin-bottom: 16px; border: 1px solid var(--border-subtle); border-radius: 18px; background: var(--bg); color: var(--brand); box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 16%, transparent); }
.signed-out .gate-eyebrow { margin: 0 0 6px; color: var(--brand); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.gate .gate-title { margin: 0 0 10px; font-size: 24px; line-height: 1.25; letter-spacing: -.01em; }
.signed-out .gate-lead { max-width: 50ch; margin: 0 auto 20px; color: var(--fg-secondary); font-size: 15px; line-height: 1.55; }
.gate-points { display: grid; gap: 9px; margin: 0 auto 24px; padding: 0; list-style: none; text-align: left; }
.gate-points li { position: relative; padding-left: 28px; color: var(--fg); font-size: 14.5px; line-height: 1.45; }
.gate-points li::before { content: ""; position: absolute; left: 0; top: 1px; width: 18px; height: 18px; box-sizing: border-box; border: 1px solid var(--ok-border); border-radius: 50%; background: var(--ok-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 8.2l2.3 2.3 4.7-5' fill='none' stroke='%2322a33a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 13px no-repeat; }
.gate-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 28px; }
.gate-actions .btn { min-height: 46px; padding: 10px 22px; border-radius: 12px; font-size: 15px; }
.signed-out .gate-foot { align-self: stretch; max-width: none; margin: 0 -32px; padding: 14px 24px; border-top: 1px solid var(--border-subtle); background: var(--bg-subtle); color: var(--fg-muted); font-size: 13px; line-height: 1.6; }
.gate-foot a { color: var(--brand); font-weight: 500; text-decoration: none; white-space: nowrap; }
.gate-foot a:hover { text-decoration: underline; }
@media (max-width: 560px) {
  .signed-out.gate { padding: 30px 18px 0; border-radius: 14px; }
  .gate .gate-title { font-size: 20px; }
  .gate-actions { align-self: stretch; flex-direction: column; }
  .signed-out .gate-foot { margin: 0 -18px; padding: 12px 16px; }
}
@keyframes modal-fade { from { opacity: 0; } }
@keyframes modal-rise { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { .modal-backdrop, .modal { animation: none; } }

.link-code {
  font: 600 26px/1.2 "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  letter-spacing: .08em;
  margin: 4px 0 12px;
}

.confirm { margin-top: 12px; padding: 12px; border-radius: 10px; background: var(--warn-bg); border: 1px solid var(--warn-border); }

.device-list { list-style: none; margin: 0 0 16px; padding: 0; }
.device-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border-subtle);
  overflow-wrap: anywhere;
}
.device-list li > div { min-width: 0; overflow-wrap: break-word; }
.device-list li > .btn, .device-list li > button { flex: none; white-space: nowrap; }
@media (max-width: 560px) {
  .device-list li { flex-wrap: wrap; }
  .device-list li > div { flex: 1 1 100%; }
  .account-main .device-list li > .btn, .account-main .device-list li > button { margin-left: 48px; }
}
.device-update { display: inline-block; margin-top: 4px; font-size: 0.9em; font-weight: 600; }

/* ---------- admin ---------- */

.row-between { justify-content: space-between; align-items: center; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin: 0; }
.stats > div { padding: 12px 14px; border: 1px solid var(--border-subtle); border-radius: 10px; background: var(--bg-subtle); }
.stats > div.stat-alert { background: var(--warn-bg); border-color: var(--warn-border); }
.stats dt { font-size: 13px; color: var(--fg-muted); }
.stats dd { margin: 4px 0 0; font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }

.table-wrap { position: relative; overflow-x: auto; margin-bottom: 8px; } /* relative: screen-reader-only labels in a cell stay inside the scroller, not widening the page */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--fg-muted); font-size: 13px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.table td { padding: 8px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; overflow-wrap: anywhere; }
.plain-list, .audit-list { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.plain-list li, .audit-list li { padding: 6px 0; border-top: 1px solid var(--border-subtle); overflow-wrap: anywhere; }
.audit-list li.audit-entry { display: grid; grid-template-columns: 11.5em minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; }
.audit-list time { color: var(--fg-muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.audit-list .why { display: block; color: var(--fg-muted); }
@media (max-width: 560px) { .audit-list li.audit-entry { grid-template-columns: minmax(0, 1fr); } }
.link-btn { font: inherit; padding: 0; border: 0; background: none; color: var(--brand); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; margin-bottom: 12px; }
.toolbar .field-inline { flex: 1 1 200px; }
.toolbar .field-fit { flex: 0 1 auto; }
.toolbar .field { min-width: 0; max-width: 100%; }
.toolbar .field select { max-width: 100%; }

.tabs-row { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; overflow-y: hidden; }
.converter-tabs { margin-bottom: 14px; }
.converter-tabs .tab-btn { flex: none; }
.ai-mode-tabs { display: flex; gap: 6px; margin: 0 0 14px; overflow-x: auto; }
.ai-mode-tabs .tab-btn { flex: none; border: 1px solid var(--border); border-radius: 9px 9px 0 0; }
.ai-mode-tabs .tab-btn[aria-selected="true"] { border-color: var(--brand); background: var(--brand-tint); }
.card > .field { margin-bottom: 12px; }
.tab-btn { font: inherit; padding: 8px 14px; border: 0; background: none; color: var(--fg-secondary); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab-btn[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--brand); font-weight: 600; }
/* Not ".matrix": the home page draws a matrix in an equation under that name. */
.feature-matrix th, .feature-matrix td { text-align: center; }
.feature-matrix th:first-child, .feature-matrix td:first-child { text-align: left; min-width: 240px; position: sticky; left: 0; z-index: 1; background: var(--bg); }
.feature-matrix td:first-child small { display: block; color: var(--fg-muted); font-size: 12.5px; }
.feature-matrix thead th { vertical-align: bottom; }
.feature-matrix .plan-off { color: var(--fg-muted); font-weight: 400; }
.feature-matrix input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--brand); }
.feature-matrix input[type="checkbox"]:disabled { cursor: default; }
.feature-matrix tr.feature-off td { opacity: .55; }
.feature-matrix tr.group th { text-align: left; background: var(--bg-subtle); color: var(--fg-secondary); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; padding-top: 12px; }
.feature-edit { display: grid; gap: 6px; margin-top: 6px; }
.feature-matrix select.where { display: block; margin: 4px auto 0; font: inherit; font-size: 12px; padding: 2px 4px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--fg); max-width: 150px; }
.feature-matrix select.where:disabled { border-color: transparent; background: transparent; appearance: none; text-align: center; }
.settings-group + .settings-group { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.settings-group h3 { margin: 0 0 10px; }
.ai-keys { display: grid; gap: 12px; }
.ai-key { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; }
.ai-key strong { flex: 1 1 100%; }
.ai-key p { flex: 1 1 100%; margin: 0; }
.ai-key input { flex: 1 1 260px; min-width: 0; }
.setting { align-self: start; }
.setting input[type="checkbox"] { width: 18px; height: 18px; }
.setting small { font-size: 12.5px; }
.pill { display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); color: var(--fg-muted); white-space: nowrap; }
.pill-warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-fg); }
.pill-ok { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-fg); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 14px; align-items: end; margin-bottom: 10px; }
.cell-input { font: inherit; font-size: 14px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--fg); width: 100%; min-width: 64px; }
.cell-input:disabled { border-color: transparent; background: transparent; }

/* ---------- account ---------- */

.profile { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0 0 14px; }
.profile dt { color: var(--fg-muted); font-size: 13.5px; }
.profile dd { margin: 0; overflow-wrap: anywhere; }
.field input.code-input { font: 600 22px/1.2 "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace; letter-spacing: .3em; max-width: 12em; }
/* The sign-in popup's look: later than the base rules above, so these win. */
.modal-backdrop { background: color-mix(in srgb, var(--ink-0) 52%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal-auth { max-width: 420px; padding: 36px 32px 24px; border-radius: 20px; border-color: rgba(15, 23, 42, .06); box-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 32px 80px -12px rgba(15, 23, 42, .38); }
.modal-auth::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; border-radius: 20px 20px 0 0; background: linear-gradient(90deg, var(--brand), var(--icon-from) 55%, var(--icon-to)); }
.modal-auth-head { margin-bottom: 22px; }
.modal-auth .modal-logo { width: 48px; height: 48px; border-radius: 12px; box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 22%, transparent); }
.modal-auth h2 { margin: 16px 0 6px; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.modal-sub { max-width: 34ch; margin: 0 auto; color: var(--fg-muted); font-size: 14px; line-height: 1.55; }
.signin-free { display: inline-block; margin: 12px auto 0; padding: 4px 12px; border: 1px solid var(--ok-border); border-radius: 999px; background: var(--ok-bg); color: var(--ok-fg); font-size: 12.5px; font-weight: 600; }
.signin-free[hidden] { display: none; }
.modal-close { display: inline-grid; place-items: center; top: 14px; right: 14px; width: 32px; height: 32px; border-radius: 999px; }
.modal-auth .notice { margin: 0 0 14px; font-size: 14px; }
.modal-auth .btn-google { margin-top: 0; min-height: 46px; border-radius: 12px; font-size: 15px; box-shadow: 0 1px 2px rgba(15, 23, 42, .05); }
.modal-auth .btn-google:hover { border-color: #b7bfcc; background: var(--bg-subtle); }
.modal-auth .divider { margin: 20px 0; font-size: 12.5px; }
.modal-auth .stack { gap: 14px; }
.modal-auth .field span { font-size: 13px; font-weight: 600; color: var(--fg-secondary); }
.modal-auth .field input { min-height: 46px; padding: 10px 14px; border-radius: 12px; font-size: 15px; }
.modal-auth .btn-primary { min-height: 46px; border-radius: 12px; font-size: 15px; }
.modal-auth .field input.code-input { max-width: none; text-align: center; font-size: 26px; letter-spacing: .5em; padding-left: calc(14px + .5em); }
.modal-auth .field input.code-input::placeholder { color: var(--border); }
.code-sent { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--brand-tint); color: var(--fg-secondary); font-size: 14px; line-height: 1.5; }
.code-sent p { margin: 0; }
.code-sent strong { color: var(--fg); overflow-wrap: anywhere; }
.code-sent-icon { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--bg); color: var(--brand); }
.modal-auth .modal-links .btn-link { padding: 6px 8px; min-height: 0; font-size: 13.5px; }
.modal-auth #code-hint { margin: 0; text-align: center; }
.modal-trust { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 22px 0 0; color: var(--fg-muted); font-size: 12.5px; }
.modal-auth .modal-foot { margin: 14px -32px -24px; padding: 14px 32px; border-top: 1px solid var(--border-subtle); background: var(--bg-subtle); border-radius: 0 0 20px 20px; font-size: 12.5px; }
.modal-auth .modal-foot a { color: var(--fg-secondary); font-weight: 500; }
@media (max-width: 480px) {
  .modal-auth { padding: 30px 20px 20px; }
  .modal-auth .modal-foot { margin: 14px -20px -20px; padding: 12px 20px; }
}

/* The account page: a header with who is signed in, a section menu, and cards. */
.account-page { padding-top: 32px; }
.account-title { margin-bottom: 20px; }
.account-title h1 { margin: 0 0 4px; font-size: 28px; }
.account-title p { margin: 0; }
.account-hero { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; margin-bottom: 22px; padding: 22px 24px; border-radius: 18px; color: var(--hero-fg); background: radial-gradient(60% 140% at 100% 0%, color-mix(in srgb, var(--glow-1) 35%, transparent), transparent 60%), radial-gradient(50% 120% at 0% 100%, color-mix(in srgb, var(--glow-2) 25%, transparent), transparent 65%), linear-gradient(135deg, var(--ink-1), var(--ink-2)); box-shadow: 0 10px 30px -10px color-mix(in srgb, var(--ink-1) 50%, transparent); }
.acct-avatar { flex: none; display: grid; place-items: center; width: 60px; height: 60px; border-radius: 999px; background: linear-gradient(135deg, var(--icon-from), var(--icon-to)); color: #fff; font-size: 21px; font-weight: 700; letter-spacing: .02em; box-shadow: 0 0 0 3px rgba(255, 255, 255, .16); }
.account-hero-text { flex: 1 1 220px; min-width: 0; }
.account-hero-name { margin: 0 0 6px; color: #fff; font-size: 21px; font-weight: 700; letter-spacing: -.015em; overflow-wrap: anywhere; }
.account-hero-meta { margin: 0; }
.acct-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .2); color: var(--hero-fg); font-size: 12.5px; font-weight: 600; }
.acct-badge:empty { display: none; }
.acct-badge::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: var(--live); }
.account-hero-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.account-hero-actions .btn { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .24); color: #fff; }
.account-hero-actions .btn:hover { background: rgba(255, 255, 255, .16); }
.account-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 24px; align-items: start; }
.account-nav { position: sticky; top: 84px; display: grid; gap: 2px; padding: 8px; border: 1px solid var(--border-subtle); border-radius: 14px; background: var(--bg); }
.account-nav-list { display: grid; gap: 2px; }
.account-nav a { padding: 8px 12px; border-radius: 9px; color: var(--fg-secondary); font-size: 14px; font-weight: 550; text-decoration: none; }
.account-nav a:hover { background: var(--bg-hover); color: var(--fg); }
.account-nav a[href="#delete"] { margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--border-subtle); border-radius: 0 0 9px 9px; color: var(--danger-fg); }
.account-main { min-width: 0; }
.account-main .card { scroll-margin-top: 84px; padding: 22px 24px; border-radius: 16px; }
.modal-auth:has(#code-form:not([hidden])) #google, .modal-auth:has(#code-form:not([hidden])) .divider { display: none; }
.account-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); column-gap: 16px; scroll-margin-top: 84px; }
.account-pair > .card { margin-bottom: 16px; }
.account-pair > #teams { order: 1; grid-column: 1 / -1; }
.acct-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.acct-head h2 { margin: 0; font-size: 17px; }
.acct-icon { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--brand-tint); color: var(--brand); }
.card-danger { border-color: var(--danger-border); }
.card-danger .acct-icon { background: var(--danger-bg); color: var(--danger-fg); }
.account-main .profile { gap: 0; margin-bottom: 16px; border: 1px solid var(--border-subtle); border-radius: 12px; overflow: hidden; }
.account-main .profile dt, .account-main .profile dd { padding: 11px 14px; border-top: 1px solid var(--border-subtle); }
.account-main .profile dt:first-of-type, .account-main .profile dd:first-of-type { border-top: 0; }
.account-main .profile dt { background: var(--bg-subtle); font-weight: 500; }
.plan-line { margin-bottom: 6px; }
.plan-line strong, .stat-figure strong { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.stat-figure { margin-bottom: 6px; }
.account-main .device-list li { padding: 12px 14px; margin-top: 8px; border: 1px solid var(--border-subtle); border-radius: 12px; background: var(--bg-subtle); }
.account-main .device-list li:first-child { margin-top: 0; }
.account-main .device-list li > div { position: relative; padding-left: 48px; min-height: 36px; }
.account-main .device-list li > div::before { content: ""; position: absolute; left: 0; top: 50%; width: 36px; height: 36px; margin-top: -18px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border-subtle); }
/* The icon is a mask filled with the theme colour, so it follows theme.css. */
.account-main .device-list li > div::after { content: ""; position: absolute; left: 9px; top: 50%; width: 18px; height: 18px; margin-top: -9px; background: var(--brand); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='4' width='18' height='12' rx='2' fill='none' stroke='%23000' stroke-width='1.8'/%3E%3Cpath d='M8 20h8M12 16v4' stroke='%23000' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") center / 18px no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='4' width='18' height='12' rx='2' fill='none' stroke='%23000' stroke-width='1.8'/%3E%3Cpath d='M8 20h8M12 16v4' stroke='%23000' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") center / 18px no-repeat; }
.account-main #sessions li > div::after { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9' fill='none' stroke='%23000' stroke-width='1.8'/%3E%3Cpath d='M3 12h18M12 3c2.5 2.5 3.8 5.5 3.8 9s-1.3 6.5-3.8 9c-2.5-2.5-3.8-5.5-3.8-9S9.5 5.5 12 3z' fill='none' stroke='%23000' stroke-width='1.8'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9' fill='none' stroke='%23000' stroke-width='1.8'/%3E%3Cpath d='M3 12h18M12 3c2.5 2.5 3.8 5.5 3.8 9s-1.3 6.5-3.8 9c-2.5-2.5-3.8-5.5-3.8-9S9.5 5.5 12 3z' fill='none' stroke='%23000' stroke-width='1.8'/%3E%3C/svg%3E"); }
.account-main .device-list .muted { font-size: 13px; }
.account-main .table-wrap { border: 1px solid var(--border-subtle); border-radius: 12px; }
.account-main .table th { padding: 10px 14px; background: var(--bg-subtle); border-bottom-color: var(--border-subtle); }
.account-main .table td { padding: 11px 14px; }
.account-main .table tr:last-child td { border-bottom: 0; }
.account-main .confirm { padding: 14px 16px; border-radius: 12px; }
@media (max-width: 860px) {
  .account-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .account-nav { position: static; display: flex; overflow-x: auto; margin-bottom: 16px; padding: 6px; }
  .account-nav a { flex: none; white-space: nowrap; }
  .account-nav a[href="#delete"] { margin: 0; padding-top: 8px; border-top: 0; border-radius: 9px; }
  .account-pair { grid-template-columns: minmax(0, 1fr); gap: 0; }
}
@media (max-width: 560px) {
  .account-hero { padding: 18px; }
  .account-hero-actions { width: 100%; }
  .account-hero-actions .btn { flex: 1; }
  .account-hero { gap: 14px; }
  .account-hero .acct-avatar { width: 52px; height: 52px; font-size: 18px; }
  .account-hero-text { flex-basis: 0; }
  .account-hero-name { font-size: 17px; line-height: 1.3; }
  .account-hero-actions .btn { justify-content: center; min-height: 42px; white-space: nowrap; }
  .account-main .card { padding: 18px; }
  .account-main .profile { grid-template-columns: minmax(0, 1fr); }
  .account-main .profile dt { padding-bottom: 2px; background: none; border-top: 1px solid var(--border-subtle); }
  .account-main .profile dd { padding-top: 0; border-top: 0; }
}
@media (prefers-color-scheme: dark) {
  .modal-auth { border-color: var(--border-subtle); }
  .modal-auth .btn-google:hover { border-color: var(--border); }
}

/* ---------- pricing page ---------- */

.segmented { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--border-subtle); border-radius: 12px; background: var(--bg); margin-bottom: 20px; }
.segment { font: inherit; font-weight: 500; border: 0; padding: 6px 16px; border-radius: 9px; background: transparent; color: var(--fg-secondary); cursor: pointer; }
.segment[aria-checked="true"] { background: var(--brand); color: #fff; }

.topups { margin-top: 20px; }
.topups h2 { margin-bottom: 4px; }
.topups > p { margin-bottom: 18px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 18px; margin-bottom: 24px; }
.plan { display: flex; flex-direction: column; margin: 0; padding: 24px; transition: border-color .15s, box-shadow .15s, transform .15s; }
.plan:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(15, 23, 42, .04), 0 16px 32px rgba(15, 23, 42, .08); }
.plan h2 { font-size: 19px; }
.plan-current { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.plan-price { font-size: 30px; font-weight: 750; letter-spacing: -.02em; margin: 6px 0 12px; }
.plan-saving { font-size: 12.5px; font-weight: 600; letter-spacing: 0; vertical-align: middle; }
.plan-features { margin: 0 0 20px; padding-left: 0; list-style: none; flex: 1; }
.plan-features li { position: relative; padding-left: 24px; margin-bottom: 7px; color: var(--fg-secondary); font-size: 14.5px; }
.plan-features li::before { content: ""; position: absolute; left: 0; top: .3em; width: 15px; height: 15px; border-radius: 50%; background: var(--brand-tint); box-shadow: inset 0 0 0 1px var(--brand); }
.plan-features li::after { content: ""; position: absolute; left: 5px; top: calc(.3em + 4px); width: 4px; height: 7px; border: solid var(--brand); border-width: 0 1.6px 1.6px 0; transform: rotate(45deg); }
.plan-yours { margin: 0; font-weight: 600; color: var(--brand); }
.badge { font-size: 11.5px; padding: 1px 7px; border-radius: 999px; background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--warn-border); white-space: nowrap; }

/* The Plans page's own: the most popular plan, a price with its period, the Enterprise band, credits by number, questions. */
.pricing-plans { grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); align-items: stretch; margin-top: 8px; }
.pricing .plan { position: relative; }
.plan-popular { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint), 0 16px 32px rgba(15, 23, 42, .08); }
.plan-badge { position: absolute; top: -12px; left: 24px; padding: 3px 12px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 12px; font-weight: 650; letter-spacing: .02em; }
.plan-about { margin: 4px 0 0; color: var(--fg-muted); font-size: 14px; }
@media (min-width: 900px) { .plan-about { min-height: 4.4em; } }
.pricing .plan-price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 6px; margin: 14px 0 2px; }
.plan-price strong { font-size: 34px; font-weight: 750; letter-spacing: -.02em; }
.plan-per { font-size: 15px; font-weight: 500; color: var(--fg-muted); letter-spacing: 0; }
.plan-billed { margin: 0 0 16px; min-height: 1.5em; }
.pricing .plan-features { flex: 1; }
.plan-features-small li { font-size: 13.5px; margin-bottom: 5px; }
.plan-includes { margin-top: 14px; border-top: 1px solid var(--border-subtle); padding-top: 10px; }
.plan-includes summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--brand); }
.plan-includes .plan-features { margin: 10px 0 0; }

.pricing-enterprise { display: flex; align-items: center; justify-content: space-between; gap: 18px 28px; flex-wrap: wrap; margin: 4px 0 40px; padding: 24px 28px; background: linear-gradient(120deg, var(--brand-tint), transparent 70%); }
.pricing-enterprise > div { flex: 1 1 320px; }
.pricing-enterprise .eyebrow { margin-bottom: 4px; }
.pricing-reading { margin: 4px 0 40px; padding: 24px 28px; }
.pricing-reading h2 { margin-top: 0; }
.pricing-reading td, .pricing-reading th[scope="row"] { white-space: nowrap; }
@media (max-width: 600px) { .pricing-reading { padding: 18px 16px; } .pricing-reading td, .pricing-reading th[scope="row"] { white-space: normal; } }
.pricing-enterprise h2 { font-size: 20px; margin: 0 0 4px; }
.pricing-enterprise p:last-child { margin: 0; }

.credits-any { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); max-width: 820px; margin: 0 auto 22px; padding: 0; overflow: hidden; }
.credits-choose { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; padding: 26px 28px; }
.credits-summary { display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 26px 28px; background: linear-gradient(160deg, var(--brand-tint), transparent 85%); border-left: 1px solid var(--border-subtle); }
.credits-picker { display: inline-flex; align-items: center; gap: 8px; }
.credits-label { font-weight: 650; font-size: 15px; }
.credits-step { width: 44px; height: 44px; padding: 0; font-size: 22px; line-height: 1; justify-content: center; border-radius: 12px; }
.credits-count { width: 100px; height: 44px; text-align: center; font: inherit; font-size: 20px; font-weight: 700; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--fg); }
.credits-count:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.credits-tiers { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px; width: 100%; }
.credits-tier { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 9px 8px; font: inherit; cursor: pointer; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--fg); transition: border-color .15s, background .15s; }
.credits-tier strong { font-size: 15px; }
.credits-tier span { font-size: 12.5px; font-weight: 600; color: var(--ok-fg); }
.credits-tier:hover { border-color: var(--brand); }
.credits-tier:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-tint); border-color: var(--brand); }
.credits-tier[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-tint); box-shadow: inset 0 0 0 1px var(--brand); }
.credits-next { margin: 0; min-height: 1.5em; font-size: 13.5px; font-weight: 600; color: var(--brand); }
.credits-total { margin: 0; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.credits-total strong { font-size: 36px; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; }
.credits-was { font-size: 18px; color: var(--fg-muted); }
.credits-was:empty { display: none; }
.credits-save { align-self: flex-start; margin: 0; font-size: 12.5px; font-weight: 650; padding: 2px 9px; border-radius: 999px; background: var(--ok-bg); color: var(--ok-fg); border: 1px solid var(--ok-border); }
.credits-rate { margin: 0 0 8px; font-size: 14px; }
.credits-action .btn { width: 100%; justify-content: center; }
.credits-fine { margin: 2px 0 0; font-size: 12.5px; text-align: center; }

.pricing-faq { max-width: 760px; margin: 48px auto 28px; }
.pricing-faq h2 { margin-bottom: 14px; }
.pricing-faq details { border: 1px solid var(--border-subtle); border-radius: 12px; padding: 0 18px; margin-bottom: 10px; background: var(--bg); }
.pricing-faq summary { cursor: pointer; font-weight: 600; padding: 14px 0; }
.pricing-faq details p { margin: 0 0 14px; color: var(--fg-secondary); }
@media (max-width: 560px) {
  .credits-any { grid-template-columns: 1fr; }
  .credits-choose { align-items: center; padding: 22px 16px; }
  .credits-summary { border-left: 0; border-top: 1px solid var(--border-subtle); padding: 22px 16px; align-items: center; text-align: center; }
  .credits-total { justify-content: center; }
  .credits-save { align-self: center; }
  .credits-action { width: 100%; }
  .pricing-enterprise .btn { width: 100%; }
}

/* ---------- home: hero ---------- */

.hero {
  position: relative;
  color: var(--hero-fg);
  background:
    radial-gradient(60% 55% at 85% 20%, color-mix(in srgb, var(--glow-1) 35%, transparent), transparent 70%),
    radial-gradient(50% 60% at 10% 10%, color-mix(in srgb, var(--glow-2) 28%, transparent), transparent 70%),
    radial-gradient(40% 40% at 60% 100%, color-mix(in srgb, var(--glow-3) 25%, transparent), transparent 70%),
    linear-gradient(180deg, var(--ink-0) 0%, var(--ink-1) 60%, var(--ink-2) 100%);
  overflow: hidden;
  margin-top: -64px;
  padding-top: 64px;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(70% 60% at 50% 30%, #000 30%, transparent 80%);
  mask-image: radial-gradient(70% 60% at 50% 30%, #000 30%, transparent 80%);
  pointer-events: none;
}
.hero-inner { position: relative; max-width: 1200px; margin: 0 auto; padding: 72px 20px 56px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 56px; align-items: center; }
.hero-badge { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 22px; padding: 6px 14px 6px 10px; border-radius: 999px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .14); font-size: 13px; font-weight: 500; color: var(--hero-muted); }
.hero-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 4px color-mix(in srgb, var(--live) 18%, transparent); }
.hero h1 { color: #ffffff; font-size: clamp(38px, 5.6vw, 64px); line-height: 1.04; letter-spacing: -.035em; font-weight: 800; margin: 0 0 22px; }
.grad { background: linear-gradient(92deg, var(--hero-accent) 0%, var(--grad-2) 40%, var(--grad-3) 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-lead { font-size: 18px; line-height: 1.65; color: var(--hero-muted); margin: 0 0 30px; max-width: 34em; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 22px; }
.hero-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 14px; color: var(--hero-dim); }
.hero-checks li { display: inline-flex; align-items: center; gap: 7px; }
.hero-checks li::before { content: "✓"; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: color-mix(in srgb, var(--live) 16%, transparent); color: var(--live); font-size: 11px; font-weight: 700; }

/* The product mock-up: a Word window drawn in HTML, only to show the idea. */
.mock {
  margin: 0;
  border-radius: 14px;
  background: #f3f3f3;
  color: #242424;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .12), 0 30px 80px -10px rgba(0, 0, 0, .6), 0 10px 30px rgba(15, 23, 42, .4);
  transform: perspective(1800px) rotateY(-6deg) rotateX(2deg);
  transform-origin: left center;
  font-family: "Segoe UI", "Inter", sans-serif;
}
.mock-titlebar { display: flex; align-items: center; gap: 12px; height: 34px; padding: 0 12px; background: #185abd; color: #ffffff; font-size: 12px; }
.mock-dots { display: inline-flex; gap: 6px; }
.mock-dots i { width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, .45); }
.mock-title { flex: 1; text-align: center; margin-right: 46px; opacity: .92; }
.mock-ribbon { display: flex; gap: 2px; padding: 6px 10px; background: #ffffff; border-bottom: 1px solid #e1e1e1; font-size: 11.5px; color: #444; overflow: hidden; white-space: nowrap; }
.mock-ribbon span { padding: 3px 9px; border-radius: 4px; }
.mock-ribbon .on { color: #185abd; box-shadow: inset 0 -2px #185abd; border-radius: 0; }
.mock-ribbon .mock-addin { margin-left: auto; background: var(--brand-tint); color: var(--brand); font-weight: 600; }
.mock-body { display: grid; grid-template-columns: minmax(0, 1fr) 250px; height: 540px; }
.mock-doc { padding: 22px 22px 0; background: #e9e9e9; overflow: hidden; }
.mock-page { background: #ffffff; min-height: 100%; padding: 26px 26px 20px; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); font: 13px/1.5 Calibri, "Segoe UI", sans-serif; }
.mock-q { margin: 0 0 6px; font-weight: 600; color: #222; }
.mock-line { display: block; height: 7px; border-radius: 4px; background: #e5e7eb; margin: 0 0 9px; }
.mock-line.w90 { width: 90%; }
.mock-line.w80 { width: 80%; }
.mock-line.w70 { width: 70%; }
.mock-line.w60 { width: 60%; }
.mock-line + .mock-q { margin-top: 18px; }
.eq-new { outline: 1.5px dashed color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 4px; border-radius: 2px; background: color-mix(in srgb, var(--brand) 6%, transparent); }
.mock-pane { background: #fafafa; border-left: 1px solid #e1e1e1; padding: 12px; display: flex; flex-direction: column; gap: 6px; font-size: 11.5px; }
.mock-pane-head { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.mock-label { font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #707070; margin-top: 4px; }
.mock-input { font: 10.5px/1.45 "Cascadia Mono", Consolas, monospace; background: #ffffff; border: 1px solid var(--brand); border-radius: 6px; padding: 7px 8px; box-shadow: 0 0 0 2px var(--brand-tint); overflow-wrap: anywhere; color: #1f2937; }
.caret { display: inline-block; width: 1px; height: 12px; background: var(--brand); vertical-align: -2px; margin-left: 1px; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.mock-preview { background: #ffffff; border: 1px solid #e1e1e1; border-radius: 6px; padding: 8px; display: grid; place-items: center; min-height: 54px; }
.mock-btn { background: var(--brand); color: #ffffff; border-radius: 6px; text-align: center; padding: 6px; font-weight: 600; font-size: 11.5px; }
.mock-btn-inline { display: inline-block; padding: 5px 12px; }
.mock-chips { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.mock-chips span { display: grid; place-items: center; height: 24px; background: #ffffff; border: 1px solid #e1e1e1; border-radius: 5px; font: 13px "Cambria Math", Cambria, serif; }
/* The real pane, docked where Word docks it. */
.mock-pane-shot { padding: 0; display: block; overflow: hidden; background: #f3f5f8; }
.mock-pane-shot img { display: block; width: 100%; height: auto; }

.works-with { position: relative; max-width: 1200px; margin: 0 auto; padding: 22px 20px 40px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 14px 34px; font-size: 14px; color: var(--hero-dim); }
.works-label { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: color-mix(in srgb, var(--hero-dim) 75%, var(--ink-0)); }
.works-item { display: inline-flex; align-items: center; gap: 8px; color: var(--hero-muted); font-weight: 500; }

@media (max-width: 980px) {
  .hero-inner { grid-template-columns: minmax(0, 1fr); padding-top: 48px; gap: 44px; }
  .mock { transform: none; }
}
@media (max-width: 560px) {
  .mock-body { grid-template-columns: minmax(0, 1fr); height: 520px; }
  .mock-doc { display: none; }
  .mock-pane { border-left: 0; }
  .mock-ribbon span:not(.on):not(.mock-addin) { display: none; }
  .mock-title { margin-right: 0; }
}

/* A hand-set equation, only to show the idea: the real one is Word's. */
.eq { margin: 4px 0; font: 24px/1 "Cambria Math", Cambria, "STIX Two Math", "Times New Roman", serif; display: flex; align-items: center; flex-wrap: wrap; color: var(--fg); }
.mock .eq { color: #111; }
.eq-sm { font-size: 18px; margin: 4px 0 12px; }
.eq-xs { font-size: 15px; margin: 0; }
.eq i { font-style: italic; }
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin: 0 2px; }
.frac .num { padding: 0 4px 3px; display: inline-flex; align-items: flex-end; }
.frac .den { padding: 3px 4px 0; border-top: 1.5px solid currentColor; align-self: stretch; text-align: center; }
.sqrt { display: inline-flex; align-items: stretch; }
.sqrt::before { content: "√"; font-size: 1.1em; margin-right: 1px; }
.sqrt .radicand { border-top: 1.5px solid currentColor; padding: 2px 2px 0; }
.eq sup { font-size: .6em; position: relative; top: -.85em; vertical-align: baseline; line-height: 0; }
.eq sup sup { font-size: .8em; top: -.6em; }
.lims sup, .lims sub { position: static; }
.frac .den sup { top: -.45em; }
.bigop { display: inline-flex; align-items: center; font-size: 1.5em; margin-right: 3px; }
.lims { display: inline-flex; flex-direction: column; justify-content: space-between; font-size: .42em; height: 2.2em; margin-left: 1px; }
.lims sup, .lims sub { font-size: 1em; vertical-align: baseline; line-height: 1; }
.bigop-sum { flex-direction: column; font-size: 1em; }
.bigop-sum { position: relative; display: inline-grid; justify-items: center; font-size: 1.6em; line-height: 1; padding: 14px 0; }
.lims-under { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; align-items: center; font-size: .36em; height: auto; margin: 0; }
.paren { font-size: 2.2em; font-weight: 200; line-height: 1; }
.eq .matrix { display: inline-grid; grid-template-columns: auto auto; gap: 4px 16px; padding: 0 4px; }

/* ---------- home: sections ---------- */

.section { padding: 96px 20px; background: var(--bg); }
.section-alt { background: var(--bg-subtle); border-top: 1px solid var(--border-subtle); border-bottom: 1px solid var(--border-subtle); }
.section-inner { max-width: 1200px; margin: 0 auto; }
.section-narrow { max-width: 780px; }
.section-head { text-align: center; max-width: 760px; margin: 0 auto 56px; }
.eyebrow { margin: 0 0 12px; font-size: 13px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--brand); }
.section-title { font-size: clamp(28px, 3.8vw, 42px); line-height: 1.15; letter-spacing: -.028em; font-weight: 750; margin: 0 0 14px; }
.section-lead { color: var(--fg-muted); font-size: 17.5px; line-height: 1.65; margin: 0 auto; max-width: 46em; }
.text-link { font-weight: 600; text-decoration: none; }
.text-link:hover { text-decoration: underline; }

.showcase { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 64px; align-items: center; margin-bottom: 96px; }
.showcase:last-child { margin-bottom: 0; }
.showcase-flip .showcase-copy { order: 2; }
.showcase-tag { display: inline-block; padding: 4px 12px; border-radius: 999px; background: var(--brand-tint); color: var(--brand); font-size: 13px; font-weight: 600; margin-bottom: 16px; }
.showcase h3 { margin: 0 0 14px; font-size: clamp(24px, 2.8vw, 32px); line-height: 1.2; letter-spacing: -.022em; font-weight: 720; color: var(--fg); }
.showcase-copy > p { color: var(--fg-muted); font-size: 16.5px; line-height: 1.7; margin-bottom: 20px; }
.showcase-visual {
  position: relative;
  padding: 36px;
  border-radius: 24px;
  background:
    radial-gradient(70% 70% at 100% 0%, color-mix(in srgb, var(--glow-1) 14%, transparent), transparent 70%),
    radial-gradient(70% 70% at 0% 100%, color-mix(in srgb, var(--glow-2) 14%, transparent), transparent 70%),
    var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  display: grid;
  gap: 14px;
  justify-items: stretch;
}

.ticks { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ticks li { position: relative; padding-left: 30px; color: var(--fg-secondary); font-size: 15px; }
.ticks li::before { content: ""; position: absolute; left: 0; top: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--brand-tint); }
.ticks li::after { content: ""; position: absolute; left: 7px; top: 6px; width: 5px; height: 9px; border: solid var(--brand); border-width: 0 2px 2px 0; transform: rotate(45deg); }

.code-card, .eq-card, .doc-card, .plot-card, .palette-card {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 12px 32px rgba(15, 23, 42, .08);
}
.code-card { overflow: hidden; }
.code-card-head { display: flex; justify-content: space-between; align-items: center; padding: 9px 14px; border-bottom: 1px solid var(--border-subtle); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-muted); }
.copy-pill { text-transform: none; letter-spacing: 0; padding: 1px 8px; border-radius: 999px; background: var(--ok-bg); color: var(--ok-fg); border: 1px solid var(--ok-border); }
.code-card pre, .plot-card pre { margin: 0; padding: 14px 16px; font: 14px/1.55 "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--fg); }
.eq-card { padding: 22px 20px 14px; display: grid; justify-items: center; }
.eq-card .eq { font-size: 26px; }
.eq-card-note { margin: 10px 0 0; font-size: 12.5px; font-weight: 600; color: var(--ok-fg); }
.arrow-down { justify-self: center; width: 36px; height: 36px; border-radius: 50%; background: var(--bg); border: 1px solid var(--border-subtle); position: relative; box-shadow: 0 4px 12px rgba(15, 23, 42, .08); }
.arrow-down::after { content: ""; position: absolute; left: 50%; top: 45%; width: 9px; height: 9px; border: solid var(--brand); border-width: 0 2px 2px 0; transform: translate(-50%, -50%) rotate(45deg); }

.doc-card { overflow: hidden; }
.doc-card-head { padding: 12px 16px; font-weight: 650; border-bottom: 1px solid var(--border-subtle); }
.doc-list { list-style: none; margin: 0; padding: 6px 0; }
.doc-list li { display: flex; align-items: center; gap: 10px; padding: 9px 16px; font-size: 13.5px; overflow-wrap: anywhere; }
.doc-list li + li { border-top: 1px solid var(--border-subtle); }
.doc-list .ok { display: inline-grid; place-items: center; flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%; background: var(--ok-bg); color: var(--ok-fg); font-size: 11px; font-weight: 700; }
.doc-card-foot { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border-subtle); background: var(--bg-subtle); font-size: 13px; color: var(--fg-muted); }

.plot-card { overflow: hidden; }
.plot-card svg { display: block; width: 100%; height: auto; padding: 14px 10px 0; }
.plot-card pre { border-top: 1px solid var(--border-subtle); font-size: 13px; }
.plot-grid { stroke: var(--border-subtle); }
.plot-axis { stroke: var(--fg-muted); }
.plot-curve { stroke: var(--brand); }
.plot-label { fill: var(--fg-secondary); font: italic 13px "Cambria Math", Cambria, serif; }
.plot-tick { fill: var(--fg-muted); font: 12px "Inter", sans-serif; }

/* The subject palettes: real screenshots of the pane behind radio-button tabs. */
.shots { justify-items: center; }
.shots > input { position: absolute; opacity: 0; pointer-events: none; }
.shot-tabs { display: inline-flex; gap: 2px; padding: 4px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border-subtle); box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.shot-tabs label { padding: 7px 16px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--fg-muted); cursor: pointer; user-select: none; }
.shot-tabs label:hover { color: var(--fg); }
#shot-maths:checked ~ .shot-tabs [for="shot-maths"],
#shot-physics:checked ~ .shot-tabs [for="shot-physics"],
#shot-chemistry:checked ~ .shot-tabs [for="shot-chemistry"] { background: var(--brand-tint); color: var(--brand); }
#shot-maths:focus-visible ~ .shot-tabs [for="shot-maths"],
#shot-physics:focus-visible ~ .shot-tabs [for="shot-physics"],
#shot-chemistry:focus-visible ~ .shot-tabs [for="shot-chemistry"] { outline: 2px solid var(--brand); outline-offset: 1px; }
.shot-frame { margin: 0; width: min(300px, 100%); border-radius: 16px; overflow: hidden; background: #f3f5f8; box-shadow: 0 0 0 1px rgba(15, 23, 42, .08), 0 24px 48px -12px rgba(15, 23, 42, .28); }
.shot { display: none; width: 100%; height: auto; aspect-ratio: 360 / 860; object-fit: cover; object-position: top; }
#shot-maths:checked ~ .shot-frame .shot-maths,
#shot-physics:checked ~ .shot-frame .shot-physics,
#shot-chemistry:checked ~ .shot-frame .shot-chemistry { display: block; }
.shot-caption { margin: 0; font-size: 12.5px; color: var(--fg-muted); }
.showcase-cta { margin: 24px 0 0; }

@media (max-width: 900px) {
  .section { padding: 72px 16px; }
  .showcase { grid-template-columns: minmax(0, 1fr); gap: 32px; margin-bottom: 72px; }
  .showcase-flip .showcase-copy { order: 0; }
  .showcase-visual { padding: 20px; }
}

.stats-band { background: linear-gradient(120deg, var(--ink-1), var(--ink-2) 55%, var(--ink-3)); color: #ffffff; padding: 64px 20px; }
.stats-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 32px; text-align: center; }
.stat strong { display: block; font-size: clamp(34px, 4.5vw, 48px); font-weight: 800; letter-spacing: -.03em; line-height: 1.1; background: linear-gradient(180deg, #ffffff, var(--hero-accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat span { display: block; margin-top: 8px; color: var(--hero-muted); font-size: 14.5px; }
@media (max-width: 720px) { .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.audience-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.audience { padding: 30px; border-radius: 18px; border: 1px solid var(--border-subtle); background: var(--bg); transition: transform .15s, box-shadow .15s, border-color .15s; }
.audience:hover { transform: translateY(-3px); box-shadow: 0 16px 40px rgba(15, 23, 42, .08); border-color: var(--border); }
.audience h3 { margin: 18px 0 8px; font-size: 19px; color: var(--fg); }
.audience p { margin: 0; color: var(--fg-muted); }
.audience-icon { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: linear-gradient(135deg, var(--icon-from), var(--icon-to)); color: #ffffff; box-shadow: 0 8px 20px color-mix(in srgb, var(--glow-1) 30%, transparent); }
@media (max-width: 860px) { .audience-grid { grid-template-columns: minmax(0, 1fr); } }

.diagram { margin: 16px 0 24px; }
.diagram img { display: block; max-width: 100%; height: auto; border-radius: 16px; border: 1px solid var(--border-subtle); background: var(--bg); box-shadow: 0 12px 40px rgba(15, 23, 42, .06); }
.diagram figcaption { margin-top: 8px; font-size: 13px; color: var(--fg-muted); }
.diagram-wide { max-width: 900px; margin-left: auto; margin-right: auto; }
.diagram-wide img { width: 100%; }

.steps { counter-reset: step; list-style: none; padding: 0; margin: 0 0 32px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.steps li { counter-increment: step; position: relative; padding: 28px; background: var(--bg); border: 1px solid var(--border-subtle); border-radius: 18px; display: grid; gap: 6px; }
.steps li::before { content: counter(step); width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 10px; background: linear-gradient(135deg, var(--icon-from), var(--icon-to)); color: #fff; font-weight: 750; font-size: 17px; }
.steps strong { color: var(--fg); font-size: 18px; }
.steps span { color: var(--fg-muted); }
@media (max-width: 860px) { .steps { grid-template-columns: minmax(0, 1fr); } }

.platforms { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 12px; }
.platform { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; border: 1px solid var(--border-subtle); border-radius: 14px; background: var(--bg-subtle); color: var(--fg); text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.platform span { color: var(--fg-muted); font-size: 14px; }
.platform:hover, .card-link:hover { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }

/* As many columns as there are plans (the catalogue's, from web/src/index.ts), down to one on a phone. */
.price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); gap: 16px; align-items: stretch; margin-bottom: 20px; }
.price-grid[hidden] { display: none; }
.price-card { position: relative; display: flex; flex-direction: column; padding: 30px 22px 24px; border-radius: 20px; background: var(--bg); border: 1px solid var(--border-subtle); }
.price-card h3 { margin: 0 0 6px; font-size: 18px; color: var(--fg); }
.price { margin: 0 0 22px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.price strong { font-size: 36px; font-weight: 800; letter-spacing: -.035em; }
.price span { color: var(--fg-muted); }
.price-card .ticks { flex: 1; align-content: start; margin-bottom: 26px; }
.price-card-featured { border: 2px solid transparent; background: linear-gradient(var(--bg), var(--bg)) padding-box, linear-gradient(135deg, var(--icon-from), var(--icon-to)) border-box; box-shadow: 0 20px 50px color-mix(in srgb, var(--glow-1) 18%, transparent); }

.faq { display: grid; gap: 12px; margin-bottom: 28px; }
.faq details { border: 1px solid var(--border-subtle); border-radius: 14px; background: var(--bg); padding: 0 22px; transition: border-color .15s, box-shadow .15s; }
.faq details[open] { border-color: var(--border); box-shadow: 0 8px 24px rgba(15, 23, 42, .06); }
.faq summary { cursor: pointer; list-style: none; padding: 18px 28px 18px 0; font-weight: 600; font-size: 16px; position: relative; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: ""; position: absolute; right: 4px; top: 50%; width: 8px; height: 8px; border: solid var(--fg-muted); border-width: 0 2px 2px 0; transform: translateY(-70%) rotate(45deg); transition: transform .2s; }
.faq details[open] summary::after { transform: translateY(-30%) rotate(-135deg); }
.faq details p { margin: 0 0 18px; color: var(--fg-muted); line-height: 1.7; }

.cta-band {
  position: relative;
  padding: 96px 20px;
  color: #ffffff;
  text-align: center;
  background:
    radial-gradient(50% 80% at 20% 0%, color-mix(in srgb, var(--glow-2) 35%, transparent), transparent 70%),
    radial-gradient(50% 80% at 80% 100%, rgba(139, 92, 246, .35), transparent 70%),
    linear-gradient(135deg, var(--ink-1), var(--ink-2));
}
.cta-band h2 { font-size: clamp(28px, 4vw, 44px); line-height: 1.15; letter-spacing: -.03em; font-weight: 800; margin: 0 0 12px; }
.cta-band p { margin: 0 0 30px; color: var(--hero-muted); font-size: 18px; }
.cta-inner .hero-actions { justify-content: center; margin: 0; }

/* ---------- download ---------- */

.download-group { margin: 40px 0 16px; font-size: 21px; letter-spacing: -.015em; }
.download-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 18px; }
.download { display: flex; flex-direction: column; margin: 0; padding: 26px; transition: box-shadow .15s, transform .15s; }
.download:hover { transform: translateY(-2px); box-shadow: 0 16px 36px rgba(15, 23, 42, .08); }
.download h3 { margin: 0 0 4px; font-size: 18px; color: var(--fg); }
.download-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; margin-bottom: 14px; background: linear-gradient(135deg, var(--icon-from), var(--icon-to)); color: #ffffff; }
.download-steps { margin: 8px 0 20px; padding-left: 20px; flex: 1; font-size: 14.5px; color: var(--fg-secondary); }
.download-steps li { margin-bottom: 4px; }
.download-store { margin: 4px 0 4px; }
.download-store p { margin: 6px 0 0; }
.download .btn-wide { margin-top: auto; }
.download-done { margin: 10px 0 0; padding: 8px 12px; border: 1px solid var(--ok-border); border-radius: 8px; background: var(--ok-bg); color: var(--ok-fg); }
.cmd { margin: 4px 0 16px; padding: 10px 12px; font: 13px/1.4 "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace; background: var(--bg-subtle); border: 1px solid var(--border-subtle); border-radius: 10px; overflow-x: auto; flex: 1; white-space: pre-wrap; overflow-wrap: anywhere; }
.download-note { margin-top: 28px; text-align: center; }

/* ---------- docs ---------- */

.docs-layout { width: 100%; max-width: 1240px; margin: 0 auto; padding: 32px 20px 56px; display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 48px; flex: 1; }
.docs-nav { position: sticky; top: 88px; align-self: start; font-size: 14px; max-height: calc(100vh - 110px); overflow-y: auto; }
.docs-nav ul { list-style: none; margin: 0 0 14px; padding: 0; }
.docs-nav li a { display: block; padding: 6px 12px; border-radius: 8px; color: var(--fg-secondary); text-decoration: none; }
.docs-nav li a:hover { background: var(--bg-hover); color: var(--fg); }
.docs-nav a[aria-current="page"] { background: var(--brand-tint); color: var(--brand); font-weight: 600; }
.docs-home { display: block; padding: 6px 12px; margin-bottom: 8px; font-weight: 650; color: var(--fg); text-decoration: none; }
.docs-nav-group { margin: 14px 0 6px; padding: 0 12px; font-size: 12px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-muted); }
.docs-main { min-width: 0; }
.docs-index-group { margin: 32px 0 14px; font-size: 19px; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 14px; }
.card-link { display: flex; flex-direction: column; gap: 4px; margin: 0; color: var(--fg); text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.card-link .muted { font-size: 14px; }

.prose { max-width: 780px; font-size: 16px; line-height: 1.75; overflow-wrap: break-word; }
.prose h1 { font-size: clamp(30px, 4vw, 40px); margin: 0 0 20px; }
.prose h2 { font-size: 24px; margin: 44px 0 12px; padding-top: 12px; border-top: 1px solid var(--border-subtle); letter-spacing: -.02em; }
.prose h3 { font-size: 18px; margin: 30px 0 8px; color: var(--fg); }
.prose h2, .prose h3, .prose h4 { position: relative; scroll-margin-top: 90px; }
.prose .anchor { position: absolute; left: -1em; width: 1em; color: var(--fg-muted); text-decoration: none; opacity: 0; }
.prose h2:hover .anchor, .prose h3:hover .anchor { opacity: 1; }
.prose p, .prose ul, .prose ol { margin: 0 0 16px; }
.prose li { margin-bottom: 6px; }
.prose code { font-size: .88em; padding: 2px 6px; background: var(--bg-hover); border-radius: 6px; }
.prose pre { margin: 0 0 18px; padding: 14px 16px; background: var(--ink-0); color: var(--hero-fg); border-radius: 12px; overflow-x: auto; font-size: 13.5px; line-height: 1.6; }
.prose pre code { padding: 0; background: none; color: inherit; }
.prose blockquote { margin: 0 0 16px; padding: 10px 16px; border-left: 3px solid var(--brand); color: var(--fg-secondary); background: var(--brand-tint); border-radius: 0 10px 10px 0; }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.55; }
.prose th, .prose td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border-subtle); vertical-align: top; }
.prose th { font-weight: 600; border-bottom-color: var(--border); background: var(--bg-subtle); }
.prose .table-wrap { margin: 0 0 18px; border: 1px solid var(--border-subtle); border-radius: 12px; }
.prose img { max-width: 100%; }

.docs-pager { max-width: 780px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 48px; }
.docs-pager a { display: flex; flex-direction: column; padding: 14px 16px; border: 1px solid var(--border-subtle); border-radius: 12px; background: var(--bg); text-decoration: none; font-weight: 600; transition: border-color .15s; }
.docs-pager a span { font-size: 12.5px; font-weight: 400; color: var(--fg-muted); }
.docs-pager-next { text-align: right; }
.docs-pager a:hover { border-color: var(--brand); }

@media (max-width: 860px) {
  .docs-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .docs-nav { position: static; max-height: none; border: 1px solid var(--border-subtle); border-radius: 12px; padding: 10px; background: var(--bg); }
  .docs-nav ul { display: flex; flex-wrap: wrap; gap: 2px; }
  .prose .anchor { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- try it live (try.html) ---------- */

.try-hero {
  padding: 56px 20px 34px;
  color: var(--hero-fg);
  background:
    radial-gradient(50% 80% at 85% 0%, color-mix(in srgb, var(--glow-1) 32%, transparent), transparent 70%),
    radial-gradient(45% 80% at 5% 0%, color-mix(in srgb, var(--glow-2) 25%, transparent), transparent 70%),
    linear-gradient(180deg, var(--ink-0), var(--ink-2));
}
.try-hero .eyebrow { color: var(--hero-accent); }
.try-hero h1 { margin: 0 0 14px; color: #ffffff; font-size: clamp(30px, 4.4vw, 48px); line-height: 1.1; letter-spacing: -.03em; font-weight: 800; }
.try-lead { margin: 0; max-width: 46em; color: var(--hero-muted); font-size: 17px; line-height: 1.65; }

.try-body { padding: 28px 20px 80px; background: var(--bg-subtle); }
.try-modes { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 4px; margin-bottom: 20px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border-subtle); box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.try-mode { font: inherit; font-size: 14.5px; font-weight: 600; padding: 8px 18px; border: 0; border-radius: 9px; background: transparent; color: var(--fg-muted); cursor: pointer; }
.try-mode:hover { color: var(--fg); }
.try-mode[aria-selected="true"] { background: var(--brand); color: #ffffff; }

.try-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.try-ocr-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .try-ocr-grid { grid-template-columns: minmax(0, 1fr); } }
.try-ocr-copy { margin: 0; color: var(--fg-secondary); font-size: 14px; line-height: 1.55; }
.try-ocr-result textarea { width: 100%; min-height: 180px; }
.try-ocr-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.try-ocr-or { display: flex; align-items: center; gap: 10px; color: var(--fg-muted); font-size: 12px; }
.try-ocr-or::before, .try-ocr-or::after { content: ""; height: 1px; flex: 1; background: var(--border-subtle); }
.try-ocr-pdf-preview { display: grid; gap: 10px; max-height: 540px; overflow: auto; }
.try-ocr-pdf-page { margin: 0; padding: 6px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.try-ocr-pdf-page img { display: block; max-width: 100%; max-height: 320px; margin: auto; object-fit: contain; }
.try-ocr-pdf-page figcaption { padding-top: 5px; color: var(--fg-muted); font-size: 12px; text-align: center; }
.try-ocr-review { margin: 0; padding: 9px 11px; border-radius: var(--radius); background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-fg); font-size: 13px; }
.try-ocr-review[hidden], .try-mode[hidden] { display: none; }
@media (max-width: 900px) { .try-grid { grid-template-columns: minmax(0, 1fr); } }
.try-card { display: flex; flex-direction: column; gap: 10px; padding: 18px; background: var(--bg); border: 1px solid var(--border-subtle); border-radius: 16px; box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 12px 32px rgba(15, 23, 42, .06); min-width: 0; }
.try-result { position: sticky; top: 84px; }
@media (max-width: 900px) { .try-result { position: static; } }
.try-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.try-card-title { font-size: 12px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-muted); }
.try-card-note { font-size: 12.5px; color: var(--fg-muted); }
.try-editor-head { margin-top: 8px; }

.try-subjects { display: flex; gap: 2px; padding: 3px; border-radius: 11px; background: #e9edf3; }
.try-subject { flex: 1 1 0; min-width: 0; font: inherit; font-size: 14px; font-weight: 600; padding: 7px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--fg-muted); cursor: pointer; }
.try-subject:hover { color: var(--fg); }
.try-subject[aria-selected="true"] { background: var(--bg); color: var(--brand); box-shadow: 0 1px 2px rgba(16, 24, 40, .1), 0 1px 1px rgba(16, 24, 40, .06); }
.try-groups { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 10px; border-bottom: 1px solid var(--border-subtle); }
.try-group { font: inherit; font-size: 13px; font-weight: 500; padding: 4px 11px; border: 1px solid var(--border-subtle); border-radius: 999px; background: var(--bg); color: var(--fg-secondary); cursor: pointer; }
.try-group:hover { border-color: var(--border); color: var(--fg); }
.try-group[aria-selected="true"] { background: var(--brand-tint); border-color: var(--brand); color: var(--brand); font-weight: 650; }

.try-keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; max-height: 250px; overflow-y: auto; padding: 2px 1px; }
.try-key { display: flex; align-items: center; justify-content: center; height: 46px; padding: 2px; font: 20px/1 "Cambria Math", "STIX Two Math", "Latin Modern Math", Cambria, Georgia, serif; color: var(--fg); background: linear-gradient(180deg, #ffffff, #f7f9fc); border: 1px solid #dfe4ec; border-radius: 10px; box-shadow: 0 1px 0 rgba(16, 24, 40, .05); cursor: pointer; overflow: hidden; white-space: nowrap; transition: transform .08s ease, box-shadow .12s ease, border-color .12s ease, color .12s ease; }
.try-key:hover { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 1px var(--brand), 0 4px 10px color-mix(in srgb, var(--brand) 14%, transparent); transform: translateY(-1px); }
.try-key.is-word { font-size: 14px; }
/* The palette's template miniatures, as the pane draws them (frontend/taskpane.css). */
.try-key .slot { display: inline-block; width: 8px; height: 8px; border: 1px dashed currentColor; border-radius: 1.5px; opacity: .6; vertical-align: middle; }
.try-key .t-frac { display: inline-flex; flex-direction: column; align-items: center; line-height: 1; font-size: 13px; }
.try-key .t-frac .t-den { border-top: 1px solid currentColor; padding-top: 2px; margin-top: 1px; }
.try-key .t-rad { display: inline-flex; align-items: flex-start; line-height: 1; font-size: 19px; }
.try-key .t-rad .t-radicand { border-top: 1px solid currentColor; padding: 2px 2px 0; margin-top: 1px; font-size: 13px; }
.try-key .t-rad .t-deg { font-size: 8px; margin-right: -3px; }
.try-key .t-over { border-top: 1px solid currentColor; padding-top: 1px; }
.try-key .t-acc { display: inline-block; line-height: .5; font-size: 13px; }
.try-key .t-base { font-size: 14px; }
.try-key .t-ss { display: inline-flex; flex-direction: column; font-size: 9px; line-height: 1; }
.try-key .t-bigop, .try-key .t-xarrow { display: inline-flex; flex-direction: column; align-items: center; line-height: 1; font-size: 17px; }
.try-key .t-bigop sup, .try-key .t-bigop sub, .try-key .t-xarrow sup, .try-key .t-xarrow sub { font-size: 8px; line-height: 1; }
.try-key sup, .try-key sub { font-size: 9px; }
.try-key .t-mat { display: inline-flex; align-items: center; font-size: 19px; line-height: 1; }
.try-key .t-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 0 1px; }
.try-key .t-grid i, .try-key .t-stack i { display: block; width: 6px; height: 6px; border: 1px dashed currentColor; opacity: .6; }
.try-key .t-stack { display: grid; gap: 3px; }
.try-key .t-stack i { width: 13px; }
/* Aligned equations: rows with an = in them, so the button differs from Stacked. */
.try-key .t-stack-eq i { position: relative; } .try-key .t-stack-eq i::after { content: "="; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -55%); font-size: 7px; font-style: normal; line-height: 1; opacity: 1; }
.try-key .t-grid-text i { width: auto; height: auto; border: 0; opacity: 1; font-size: 9px; line-height: 1; font-style: normal; text-align: center; }
.try-key .t-evalbar { font-size: 19px; line-height: 1; margin-left: 1px; }
/* Boxed, underlined, coloured and augmented-matrix button faces. */
.try-key .t-boxed { display: inline-block; padding: 1px 2px; border: 1px solid currentColor; line-height: 1; }
.try-key .t-under { display: inline-block; border-bottom: 1px solid currentColor; padding-bottom: 1px; line-height: 1; }
.try-key .t-color-red { color: var(--danger-fg); font-weight: 600; }
.try-key .t-color-blue { color: var(--brand); font-weight: 600; }
.try-key .t-rule { display: inline-block; width: 1px; align-self: stretch; margin: 0 2px; background: currentColor; opacity: .7; }
.try-key .t-col { display: grid; gap: 2px; }
.try-key .t-col i { display: block; width: 5px; height: 5px; border: 1px dashed currentColor; opacity: .6; }
.try-key .t-cancel { position: relative; display: inline-block; padding: 1px 3px; }
.try-key .t-cancel::before, .try-key .t-cancel-x::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top right, transparent 45%, currentColor 45%, currentColor 55%, transparent 55%); }
.try-key .t-cancel-x::after { background: linear-gradient(to bottom right, transparent 45%, currentColor 45%, currentColor 55%, transparent 55%); }
.try-key .t-brace { display: inline-block; font-size: 15px; line-height: 1; }

.try-latex { width: 100%; min-height: 84px; padding: 11px 13px; font: 14.5px/1.55 "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace; color: var(--fg); background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 10px; resize: vertical; }
.try-latex:focus { outline: none; background: var(--bg); border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.try-code { font-size: 13px; min-height: 260px; }
.try-select { font: inherit; font-size: 14.5px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--fg); }
.try-hint { margin: 6px 0 0; }
.try-editor-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.try-check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--fg-secondary); cursor: pointer; }
.try-check input { accent-color: var(--brand); }
.try-quiet { background: transparent; border-color: transparent; color: var(--fg-muted); }
.try-quiet:hover { background: var(--bg-hover); }
.try-examples-title { margin: 8px 0 0; font-size: 13px; font-weight: 600; color: var(--fg-muted); }
.try-examples { display: flex; flex-wrap: wrap; gap: 6px; }
.try-example { font: inherit; font-size: 13px; padding: 5px 11px; border: 1px dashed var(--border); border-radius: 8px; background: var(--bg); color: var(--fg-secondary); cursor: pointer; }
.try-example:hover { border-style: solid; border-color: var(--brand); color: var(--brand); }

.try-live { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ok-fg); }
.try-live i { width: 8px; height: 8px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 3px color-mix(in srgb, var(--live) 22%, transparent); }
.try-paper { display: grid; place-items: safe center; min-height: 190px; padding: 28px 22px; background: #ffffff; color: #111111; border: 1px solid var(--border-subtle); border-radius: 12px; box-shadow: inset 0 1px 2px rgba(16, 24, 40, .04); overflow-x: auto; }
.try-preview { font-size: 26px; max-width: 100%; }
.try-preview math { font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", math; }
.try-preview:empty::before { content: "Type LaTeX, click a symbol, or pick an example."; font: italic 14px "Inter", sans-serif; color: #6b7280; }
.try-figure img { display: block; max-width: 100%; height: auto; }
.try-error { margin: 0; white-space: pre-wrap; font-size: 14px; }
.try-actions { display: grid; gap: 8px; }
.try-actions-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.try-actions .btn:disabled { opacity: .5; cursor: default; }
.try-tables-actions { max-width: 440px; margin: 14px 0 8px; }
.try-status { margin: 0; padding: 10px 12px; border-radius: 10px; font-size: 14px; border: 1px solid; }
.try-status-ok { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-fg); }
.try-status-danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-fg); }
.try-facts { margin-top: 6px; }
.try-facts li { font-size: 14px; }
.try-upsell { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: space-between; margin-top: 4px; padding: 14px 16px; border-radius: 12px; background: var(--brand-tint); }
.try-upsell p { margin: 0; flex: 1 1 260px; font-size: 14px; color: var(--fg-secondary); }
.try-doc-summary { margin: 0; font-size: 14.5px; font-weight: 600; }
.try-doc-intro { margin: 0; color: var(--fg-secondary); font-size: 13.5px; line-height: 1.5; }
.try-doc-field { display: grid; gap: 6px; margin: 14px 0 8px; font-size: 13px; font-weight: 650; color: var(--fg-secondary); }
.try-doc-field .try-select { width: 100%; max-width: 440px; }
.try-doc-file-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 14px 0 10px; }
.try-doc-file-row label.btn { cursor: pointer; }
.try-doc-file-name { color: var(--fg-muted); font-size: 13px; overflow-wrap: anywhere; }
.try-doc-download-bar { position: sticky; bottom: 12px; z-index: 5; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 18px; margin-top: 16px; padding: 18px 20px; border: 1px solid var(--border-subtle); border-radius: 12px; background: var(--bg-subtle); box-shadow: 0 6px 24px rgba(15, 23, 42, .10); }
.try-doc-download-bar p { margin: 4px 0 0; color: var(--fg-secondary); font-size: 13px; }
.try-doc-download-bar [role="status"] { grid-column: 1 / -1; min-height: 1.3em; color: var(--fg-muted); font-size: 13px; }
@media (max-width: 560px) { .try-doc-download-bar { grid-template-columns: 1fr; } .try-doc-download-bar .btn { width: 100%; } }
.try-work { padding: 8px 0 40px; }
.try-work h2 { margin: 0 0 4px; }
.try-work .try-status { margin: 10px 0; }

/* ---------- Your work (frontend/src/your-work.ts) ---------- */
.your-work-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.your-work-search { flex: 1 1 220px; min-width: 0; }
.your-work-search, .your-work-filter, .your-work-rename { font: inherit; padding: 7px 10px; border: 1px solid var(--border-subtle); border-radius: 8px; background: var(--bg, #fff); color: inherit; }
.your-work-list { list-style: none; margin: 0; padding: 0; }
.your-work-item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 10px 0; border-top: 1px solid var(--border-subtle); overflow-wrap: anywhere; }
.your-work-item.is-pinned .your-work-title::before { content: "★ "; }
.your-work-text { display: flex; flex-direction: column; gap: 2px; flex: 1 1 240px; min-width: 0; }
.your-work-title { font-weight: 600; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; }
.your-work-meta { color: var(--fg-secondary); font-size: 13px; }
.your-work-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.your-work-renaming { display: flex; gap: 6px; flex-wrap: wrap; }
.your-work-empty { margin: 8px 0; }
.your-work-more { margin-top: 8px; }
.try-doc-page { margin: 0; padding: 18px 20px; border: 1px solid var(--border-subtle); border-radius: 12px; max-height: 520px; overflow-y: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; line-height: 1.75; }
.try-doc-page:empty { display: none; }
.try-doc-page math { font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", math; font-size: 1.12em; }
.try-doc-page math[display="block"] { margin: 6px 0; }
.try-doc-page > p { margin: 0 0 12px; }
.try-doc-page > h1, .try-doc-page > h2, .try-doc-page > h3, .try-doc-page > h4 { margin: 12px 0 8px; line-height: 1.3; }
.try-doc-page table { max-width: 100%; border-collapse: collapse; }
.try-doc-page td { padding: 5px 8px; border: 1px solid var(--border-subtle); vertical-align: top; }
.try-doc-image-placeholder { color: var(--fg-muted); font-style: italic; }
.try-doc-fill { display: inline-block; width: 3em; }
.try-doc-blank { display: inline-block; max-width: 100%; border-bottom: 1px solid currentColor; vertical-align: baseline; height: 1em; }
.try-doc-bad { padding: 1px 4px; border-radius: 4px; background: var(--danger-bg); color: var(--danger-fg); font-size: 0.85em; text-decoration: underline wavy; text-underline-offset: 3px; }
.try-doc-problems { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 13px; color: var(--danger-fg); }
.try-doc-problems:empty { display: none; }
.try-doc-problems code { margin-right: 6px; overflow-wrap: anywhere; }

/* ---- graph builder (frontend/src/graph-editor.ts; the Word pane styles the same classes) ---- */
.try-grid-graph { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
@media (max-width: 900px) { .try-grid-graph { grid-template-columns: minmax(0, 1fr); } }
.gb-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.gb-subjects { display: flex; gap: 2px; padding: 3px; border-radius: 11px; background: #e9edf3; }
.gb-subject { flex: 1 1 0; min-width: 0; font: inherit; font-size: 14px; font-weight: 600; padding: 7px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--fg-muted); cursor: pointer; }
.gb-subject:hover { color: var(--fg); }
.gb-subject[aria-selected="true"] { background: var(--bg); color: var(--brand); box-shadow: 0 1px 2px rgba(16, 24, 40, .1); }
.gb-start { display: flex; align-items: center; gap: 10px; }
.gb-label { flex: none; font-size: 12px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-muted); }
.gb-preset, .gb-select { flex: 1 1 auto; min-width: 0; font: inherit; font-size: 14px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); color: var(--fg); }
.gb-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.gb-line { display: grid; gap: 5px; padding: 6px; border: 1px solid var(--border-subtle); border-radius: 10px; background: var(--bg); }
.gb-line.has-error { border-color: var(--danger-border); background: var(--danger-bg); }
.gb-line-head { display: flex; align-items: center; gap: 6px; }
.gb-input { width: 100%; min-width: 0; font: 14px/1.4 "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace; padding: 7px 9px; color: var(--fg); background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 8px; }
.gb-input:focus { outline: none; background: var(--bg); border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.gb-line-input { flex: 1 1 auto; border-color: transparent; background: transparent; }
.gb-add { border-style: dashed; }
.gb-swatch { flex: none; width: 18px; height: 18px; padding: 0; border: 2px solid var(--bg); border-radius: 50%; box-shadow: 0 0 0 1px var(--border); cursor: pointer; }
.gb-swatch.is-hidden { opacity: .3; }
.gb-icon { flex: none; width: 28px; height: 28px; padding: 0; font-family: inherit; font-size: 15px; line-height: 1; border: 0; border-radius: 7px; background: transparent; color: var(--fg-muted); cursor: pointer; }
.gb-icon:hover { background: var(--bg-hover); color: var(--fg); }
.gb-remove:hover { color: var(--danger-fg); }
.gb-palette { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 2px 26px; }
.gb-palette[hidden] { display: none; }
.gb-chip { width: 22px; height: 22px; padding: 0; border: 2px solid var(--bg); border-radius: 50%; box-shadow: 0 0 0 1px var(--border); cursor: pointer; }
.gb-chip:hover { box-shadow: 0 0 0 2px var(--brand); }
.gb-slider { display: flex; align-items: center; gap: 6px; padding-left: 26px; }
.gb-slider[hidden] { display: none; }
.gb-slider input[type=range] { flex: 1 1 auto; min-width: 60px; accent-color: var(--brand); }
.gb-num { width: 74px; flex: none; font-size: 13px; padding: 4px 6px; }
.gb-range-end { width: 58px; }
.gb-message { padding-left: 26px; font-size: 13px; color: var(--fg-muted); overflow-wrap: anywhere; }
.gb-message[hidden] { display: none; }
.gb-message.is-error { color: var(--danger-fg); }
.gb-message.is-result { color: var(--ok-fg); font-weight: 600; }
.gb-help, .gb-settings { border: 1px solid var(--border-subtle); border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.gb-help summary, .gb-settings summary { cursor: pointer; font-weight: 600; color: var(--fg-secondary); }
.gb-help dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 10px 0 6px; }
.gb-help dt { font: 13px "Cascadia Mono", Consolas, monospace; color: var(--brand); }
.gb-help dd { margin: 0; font-size: 13px; color: var(--fg-secondary); }
@media (max-width: 520px) { .gb-help dl { grid-template-columns: 1fr; } .gb-help dd { margin-bottom: 6px; } }
.gb-note { margin: 4px 0 2px; font-size: 13px; color: var(--fg-muted); }
.gb-settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-top: 10px; }
@media (max-width: 520px) { .gb-settings-grid { grid-template-columns: 1fr; } }
.gb-field { display: grid; gap: 4px; font-size: 12.5px; color: var(--fg-muted); }
.gb-field .gb-input, .gb-field .gb-select { font-size: 13.5px; }
.gb-check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--fg-secondary); cursor: pointer; }
.gb-check input { accent-color: var(--brand); }
.gb-view-row { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.gb-view-row .gb-num { width: 100%; }
.gb-stage { display: grid; gap: 8px; }
.gb-canvas { position: relative; overflow: hidden; background: #ffffff; border: 1px solid var(--border-subtle); border-radius: 12px; touch-action: none; }
.gb-canvas:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 35%, transparent); outline-offset: 2px; }
.gb-figure { display: block; width: 100%; height: auto; cursor: grab; user-select: none; -webkit-user-select: none; }
.gb-canvas.is-dragging .gb-figure { cursor: grabbing; }
.gb-tools { position: absolute; top: 8px; right: 8px; display: grid; gap: 4px; }
.gb-tool { width: 32px; height: 32px; padding: 0; font-family: inherit; font-size: 17px; font-weight: 600; line-height: 1; color: #333333; background: rgba(255, 255, 255, .92); border: 1px solid #d6d9de; border-radius: 8px; box-shadow: 0 1px 2px rgba(16, 24, 40, .08); cursor: pointer; }
.gb-tool:hover { border-color: var(--brand); color: var(--brand); }
.gb-readout { position: absolute; left: 8px; bottom: 6px; font: 12px "Cascadia Mono", Consolas, monospace; color: #555555; background: rgba(255, 255, 255, .85); padding: 1px 6px; border-radius: 5px; pointer-events: none; }
.gb-readout:empty { display: none; }
.gb-error { margin: 0; font-size: 14px; color: var(--danger-fg); }
.gb-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.gb-actions .btn { flex: 1 1 auto; }

@media (prefers-color-scheme: dark) {
  .try-subjects, .gb-subjects { background: #2a2c30; }
  .try-key { background: linear-gradient(180deg, #303236, #2a2c30); border-color: #3d4045; }
}

/* ---------- admin: diagram library ---------- */

.library-preview { margin: 10px 0; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; overflow: auto; text-align: center; }
.library-preview:empty { display: none; }
.library-preview img { max-width: 100%; height: auto; }
#library-source { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }

/* ---------- ai.html ---------- */

.ai-thumb { display: block; max-width: 100%; max-height: 220px; margin: 8px 0 12px; border: 1px solid var(--border); border-radius: 8px; }
/* The crop box over a photo (ai.html, frontend/src/photo-crop.ts): what's outside it is dimmed. */
.crop { margin: 8px 0 12px; }
.crop-stage { position: relative; display: inline-block; max-width: 100%; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair; line-height: 0; }
.crop-stage img { display: block; max-width: 100%; max-height: 420px; pointer-events: none; }
.crop-box { position: absolute; box-sizing: border-box; border: 2px solid #fff; outline: 1px solid rgba(0, 0, 0, .6); box-shadow: 0 0 0 9999px rgba(0, 0, 0, .45); cursor: move; }
.crop-box:focus-visible { outline: 3px solid var(--brand); }
.crop-handle { position: absolute; width: 22px; height: 22px; margin: -11px; border-radius: 50%; background: #fff; border: 2px solid var(--brand); box-sizing: border-box; }
.crop-nw { left: 0; top: 0; cursor: nwse-resize; }
.crop-ne { right: 0; top: 0; cursor: nesw-resize; }
.crop-sw { left: 0; bottom: 0; cursor: nesw-resize; }
.crop-se { right: 0; bottom: 0; cursor: nwse-resize; }
.crop-help { margin: 6px 0 0; line-height: 1.5; }
.crop-help .btn-link { display: inline; padding: 0; min-height: 0; vertical-align: baseline; }
.ai-preview { margin: 4px 0 14px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: #fff; color: #111; overflow: auto; text-align: center; }
.ai-preview:empty { display: none; }
.ai-preview img { max-width: 100%; height: auto; }
.ai-preview math { font-size: 1.4em; }
/* Your creations (ai.html): a tile per saved result, drawn again from its LaTeX. */
.creations { list-style: none; margin: 8px 0 12px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.creation { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; }
.creation-pinned { border-color: var(--brand); background: var(--brand-tint); }
.creation-thumb { height: 120px; display: flex; align-items: center; justify-content: center; overflow: hidden; border-radius: 8px; background: #fff; color: #111; }
.creation-thumb img { max-width: 100%; max-height: 120px; }
.creation-thumb code { font-size: 12px; white-space: pre-wrap; word-break: break-word; padding: 6px; text-align: left; }
.creation-photo { max-width: 100%; max-height: 72px; align-self: flex-start; border-radius: 6px; border: 1px solid var(--border); }
.creation-meta { font-size: 13px; color: var(--fg-muted); }
.creation-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.creation-actions .btn { padding: 4px 10px; font-size: 13px; }
#result-source { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }

/* ---------- the admin dashboard (web/admin.html): an app of its own ---------- */

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

body.admin { background: var(--bg-subtle); min-height: 100vh; }
.admin-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 56px;
  padding: 0 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-subtle);
}
.admin-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; font-weight: 700; letter-spacing: -.01em; }
.admin-brand img { border-radius: 7px; }
.admin-brand-tag { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--brand-tint); color: var(--brand); }
.env-badge { font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 3px 9px; border-radius: 6px; background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--warn-border); }
.admin-top-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.admin-top-link { color: var(--fg-secondary); text-decoration: none; font-size: 14px; }
.admin-top-link:hover { color: var(--fg); text-decoration: underline; }
.admin-who { display: flex; align-items: center; gap: 10px; padding-left: 14px; border-left: 1px solid var(--border-subtle); }
.admin-who-text { display: flex; flex-direction: column; line-height: 1.25; }
.admin-who-text strong { font-size: 13.5px; font-weight: 600; }
.admin-who-text span { font-size: 12px; color: var(--fg-muted); }
.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-hi), var(--ink-2));
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
}
.avatar-sm { width: 28px; height: 28px; font-size: 12.5px; }

.admin-layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); flex: 1; }
.admin-nav {
  position: sticky;
  top: 56px;
  align-self: start;
  height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 12px;
  border-right: 1px solid var(--border-subtle);
  background: var(--bg);
}
.admin-nav[hidden] { display: none; }
.admin-nav-list { display: flex; flex-direction: column; gap: 2px; }
.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--fg-secondary);
  font: inherit;
  font-size: 14.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.admin-nav-item svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.admin-nav-item:hover { background: var(--bg-hover); color: var(--fg); }
.admin-nav-item[aria-selected="true"] { background: var(--brand-tint); color: var(--brand); font-weight: 600; }

.admin-main { min-width: 0; padding: 28px 32px 56px; }
.admin-panel { max-width: 1180px; margin: 0 auto; }
.admin-loading { padding: 40px 0; text-align: center; }
.admin-denied { max-width: 520px; margin: 48px auto; text-align: center; }
.admin-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 16px; margin-bottom: 20px; }
/* The title block takes the panel's full width, like the cards under it; actions wrap below when there is no room. */
.admin-head > div:first-child { flex: 1 1 320px; min-width: 0; }
.admin-head h1 { font-size: clamp(22px, 2.6vw, 26px); margin: 0 0 6px; line-height: 1.2; }
.admin-head p { margin: 0; max-width: none; font-size: clamp(14px, 1.4vw, 15.5px); line-height: 1.6; overflow-wrap: break-word; }
.admin-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.admin-grid-2 > .card { margin-bottom: 0; }
.admin-panel > .card, .admin-panel > .admin-grid-2 { margin-bottom: 16px; }
.reading-example { margin-bottom: 12px; }
.reading-example code { white-space: pre-wrap; overflow-wrap: anywhere; }
.reading-photo { display: block; max-width: 100%; max-height: 320px; margin: 8px 0; background: #fff; border: 1px solid var(--border); border-radius: 6px; }

.admin .card { border-radius: 12px; padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.card-head h2 { margin: 0; font-size: 16px; }
.card-flush { padding: 0 !important; overflow: hidden; }
.card-flush .table th, .card-flush .table td { padding-left: 16px; padding-right: 16px; }
.card-flush > .card-pad { margin: 0; padding: 16px; }
.card-foot { padding: 10px 16px; }
.card-foot:has(> [hidden]:only-child) { display: none; }
.form-band { margin-top: 12px; padding: 14px; border-radius: 10px; background: var(--bg-subtle); border: 1px dashed var(--border); }

.reason-field { margin-bottom: 16px; padding: 12px 14px; border-radius: 10px; background: var(--brand-tint); border: 1px solid var(--border-subtle); }
.reason-field[hidden] { display: none; }
.reason-field input { background: var(--bg); }

/* The overview's figures. */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 0 0 16px; }
.kpi { padding: 16px 18px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border-subtle); box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.kpi dt { font-size: 13px; color: var(--fg-muted); font-weight: 500; }
.kpi dd { margin: 4px 0 2px; font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; overflow-wrap: anywhere; }
.kpi-note { margin: 0; font-size: 12.5px; color: var(--fg-muted); }
.kpi-warn { border-color: var(--warn-border); background: var(--warn-bg); }
.kpi-warn dd { color: var(--warn-fg); }

/* Tables. */
.admin .table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 8px; background: var(--bg-subtle); border-bottom: 1px solid var(--border-subtle); }
.admin .table td { padding: 10px 8px; }
.admin .table tbody tr:hover td { background: var(--bg-subtle); }
.admin .table tbody tr:last-child td { border-bottom: 0; }
.table-compact td { padding-top: 7px !important; padding-bottom: 7px !important; }
.admin .feature-matrix th { text-transform: none; letter-spacing: 0; font-size: 13px; }
.admin .feature-matrix th small { font-weight: 400; }
.meter:has(+ .table-wrap > [hidden]) { margin-bottom: 4px; }
.row-link { cursor: pointer; }
.row-link:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.account-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.account-cell > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.account-cell strong { font-weight: 500; overflow-wrap: anywhere; }

.admin .badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.admin .badge + .badge { margin-left: 4px; }
.badge-ok { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-border) !important; }
.badge-warn { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-border) !important; }
.badge-info { background: var(--brand-tint); color: var(--brand); }
.badge-muted { background: var(--bg-hover); color: var(--fg-muted); }

.admin-search { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border-subtle); }
.admin-search svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--fg-muted); stroke-width: 1.8; stroke-linecap: round; }
.admin-search input { flex: 1; min-width: 0; font: inherit; padding: 8px 4px; border: 0; background: transparent; color: var(--fg); }
.admin-search input:focus { outline: none; }
.admin-search-filter { flex: none; font: inherit; font-size: 13.5px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--fg); cursor: pointer; }
.admin .toolbar .field-inline { flex: 0 1 360px; }
.admin .toolbar .field-fit { flex: 0 1 auto; }
@media (max-width: 640px) { .admin-search { flex-wrap: wrap; } .admin-search input { flex-basis: calc(100% - 30px); } }

.meter { height: 8px; border-radius: 999px; background: var(--bg-hover); overflow: hidden; margin: 4px 0 14px; }
.meter span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--brand); transition: width .3s; }
.meter span.meter-warn { background: #d18a00; }
.meter span.meter-danger { background: var(--danger-fg); }

.library-edit { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.library-edit textarea { font-family: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace; font-size: 13px; }
.field-label { display: block; font-size: 13px; font-weight: 500; color: var(--fg-secondary); margin-bottom: 5px; }
.library-edit .library-preview { margin: 0; min-height: 120px; }
.library-help { margin: 8px 0 0; padding-left: 18px; }
.library-help li { margin: 2px 0; }
/* A question paper in the Library tab's preview, roughly as Word lays it out. */
.paper-preview { text-align: left; color: #111; font-size: 13px; line-height: 1.45; }
.paper-preview p { margin: 0 0 4px; }
.paper-school, .paper-exam, .paper-section, .paper-note, .paper-or { text-align: center; }
.paper-school { font-size: 17px; font-weight: 700; }
.paper-exam, .paper-section, .paper-heading, .paper-or { font-weight: 700; }
.paper-preview .paper-section { margin-top: 12px; }
.paper-note { font-style: italic; }
.paper-fields { display: flex; justify-content: space-between; gap: 12px; }
.paper-instructions { margin: 0 0 8px; padding-left: 22px; }
.paper-preview .paper-question { display: grid; grid-template-columns: 26px 1fr auto; gap: 4px; margin-top: 8px; }
.paper-marks { white-space: nowrap; }
.paper-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 12px; padding-left: 30px; margin-bottom: 4px; }
.paper-part, .paper-text { padding-left: 30px; }

/* Messages: a toast at the top right, over everything. */
.admin-toast { position: fixed; top: 68px; right: 20px; z-index: 120; max-width: min(440px, calc(100vw - 40px)); margin: 0; box-shadow: 0 12px 32px rgba(15, 23, 42, .18); background: var(--bg); }

/* One account: a panel from the right, over a dimmed page. */
.drawer { position: fixed; inset: 0; z-index: 90; display: flex; justify-content: flex-end; background: rgba(15, 23, 42, .45); animation: modal-fade .15s ease-out; }
.drawer[hidden] { display: none; }
.drawer-panel { display: flex; flex-direction: column; width: min(760px, 100%); height: 100%; background: var(--bg); box-shadow: -16px 0 48px rgba(15, 23, 42, .2); animation: drawer-in .2s ease-out; }
.drawer-head { position: relative; display: flex; justify-content: space-between; gap: 12px; padding: 20px 64px 16px 24px; border-bottom: 1px solid var(--border-subtle); }
.drawer-head h2 { margin: 0 0 4px; font-size: 19px; overflow-wrap: anywhere; }
.drawer-head p { margin: 0; }
.drawer-head .modal-close { top: 16px; right: 16px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 24px 40px; }
.drawer-section { padding: 16px 0; border-top: 1px solid var(--border-subtle); }
.drawer-section > h3:first-child { margin-top: 0; }
.drawer .reason-field { margin-bottom: 4px; }
@keyframes drawer-in { from { transform: translateX(32px); opacity: .4; } }
@media (prefers-reduced-motion: reduce) { .drawer, .drawer-panel { animation: none; } }

@media (max-width: 960px) {
  .admin-layout { grid-template-columns: minmax(0, 1fr); }
  .admin-nav { position: sticky; top: 56px; z-index: 15; height: auto; flex-direction: row; overflow-x: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--border-subtle); }
  .admin-nav-item { width: auto; flex: none; white-space: nowrap; }
  .admin-main { padding: 20px 16px 48px; }
  .admin-grid-2, .library-edit { grid-template-columns: minmax(0, 1fr); }
  .admin-who-text, .admin-top-link { display: none; }
}
@media (max-width: 560px) {
  .admin-brand span:not(.admin-brand-tag) { display: none; }
  .admin-head { flex-direction: column; align-items: stretch; }
  .admin-head > div:first-child { flex-basis: auto; }
  .admin-top, .admin-top-actions { gap: 8px; }
  .admin-top { padding: 0 12px; }
  .admin-who { padding-left: 8px; }
  .admin-top .btn { white-space: nowrap; }
  /* Two figures a row, not one per screen. */
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi dd { font-size: 22px; }
  /* Tables scroll sideways in their wrapper instead of breaking emails and dates letter by letter. */
  .admin-main .table td, .admin-main .account-cell strong { overflow-wrap: break-word; }
  .admin-main .table td:last-child { white-space: nowrap; }
  .env-badge { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; letter-spacing: 0; padding: 3px 6px; }
  .admin-brand-tag { flex: none; }
}

/* The desktop app's build: what's new, and a checksum to compare. */
.download-details { margin-top: 8px; }
.download-details summary { cursor: pointer; color: var(--fg-muted, inherit); }
.download-notes { white-space: pre-line; margin: 8px 0; }
.download-sha { word-break: break-all; font-size: 12px; }

/* ---- PDF to LaTeX (pdf.html; desktop/ui/pdf.ts, styled as in the desktop app) ---- */
body.pdf-embedded { min-width: 0; min-height: 0; background: transparent; }
/* The Try page sizes its frame to this page (web/src/pdf.ts), so nothing here may take the frame's height as its own. */
html:has(body.pdf-embedded) { overflow: hidden; scroll-behavior: auto; }
body.pdf-embedded .site-header, body.pdf-embedded .site-footer,
body.pdf-embedded .pdf-app > h1, body.pdf-embedded .pdf-app > .lead,
body.pdf-embedded .pdf-studio .converter-tabs { display: none !important; }
body.pdf-embedded .pdf-app { max-width: none; margin: 0; padding: 14px; }
body.pdf-embedded .pdf-studio { gap: 10px; }
.pdf-studio { display: flex; flex-direction: column; gap: 16px; }
.pdf-studio .tabs-row { margin-bottom: 0; }
a.tab-btn { text-decoration: none; }
.pdf-app .banner { padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--border); display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.pdf-app .banner-info { background: var(--brand-tint); border-color: var(--brand); }
.pdf-app .banner-warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-fg); }
.pdf-app .banner p { margin: 0; flex: 1 1 280px; }
.pdf-app .banner .btn[hidden] { display: none; }
.pdf-app .drop { border: 1.5px dashed var(--brand); border-radius: 18px; background: linear-gradient(145deg, var(--brand-tint), var(--bg) 72%); padding: clamp(30px, 5vw, 54px) 24px; text-align: center; transition: border-color .16s ease, background .16s ease, box-shadow .16s ease, transform .16s ease; }
.pdf-app .drop:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.pdf-app .drop.is-over { border-color: var(--brand); background: var(--brand-tint); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 12%, transparent); transform: translateY(-1px); }
.pdf-app .drop.is-disabled { opacity: .55; pointer-events: none; }
.pdf-app .drop-title { margin: 0; font-size: clamp(19px, 2vw, 23px); font-weight: 700; letter-spacing: -.02em; }
.pdf-app .drop-hint { margin: 9px auto 20px; max-width: 68ch; color: var(--fg-secondary); line-height: 1.65; }
.pdf-app .drop-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.pdf-app .hint { margin: 0; color: var(--fg-muted); font-size: 13px; }
.pdf-job { display: flex; flex-direction: column; gap: 16px; border-radius: 16px; }
.pdf-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pdf-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.pdf-file { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.pdf-options { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; }
.pdf-range { display: inline-flex; align-items: center; gap: 8px; color: var(--fg-secondary); }
.pdf-range input { width: 5.5em; min-height: 40px; font: inherit; padding: 6px 9px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); color: var(--fg); }
.pdf-cost { margin: 0; color: var(--fg-secondary); }
.pdf-cost.is-short { color: var(--danger-fg); }
.pdf-notice p { flex-basis: 100%; }
.pdf-progress-box { display: flex; flex-direction: column; gap: 8px; }
.pdf-progress-box progress { width: 100%; height: 6px; accent-color: var(--brand); border: 0; border-radius: 999px; overflow: hidden; background: color-mix(in srgb, var(--brand) 14%, transparent); }
.pdf-progress-box progress::-webkit-progress-bar { background: color-mix(in srgb, var(--brand) 14%, transparent); border-radius: 999px; }
.pdf-progress-box progress::-webkit-progress-value { background: var(--brand); border-radius: 999px; transition: width .45s ease; }
.pdf-progress-box progress::-moz-progress-bar { background: var(--brand); border-radius: 999px; }

/*
 * Smooth, the same for every conversion: each part comes in softly as it appears (the files, the job,
 * how it's going, the review), and each page's chip changes colour gently, not with a jump.
 */
.pdf-app :is(.pdf-job, .pdf-progress-box, .pdf-results > *):not([hidden]) { animation: pdf-enter .28s ease both; }
@keyframes pdf-enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.pdf-app .pdf-page { transition: background-color .3s ease, border-color .3s ease, color .3s ease; }
.pdf-app .drop { transition: padding .25s ease, min-height .25s ease, background-color .25s ease, border-color .25s ease; }
@media (prefers-reduced-motion: reduce) {
  .pdf-app :is(.pdf-job, .pdf-progress-box, .pdf-results > *):not([hidden]) { animation: none; }
  .pdf-progress-box progress::-webkit-progress-value { transition: none; }
}
.pdf-pages { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.pdf-page { min-width: 2.2em; padding: 2px 6px; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; border: 1px solid var(--border-subtle); border-radius: var(--radius); color: var(--fg-muted); background: var(--bg-subtle); }
.pdf-page.is-reading, .pdf-page.is-converting { border-color: var(--brand); color: var(--brand); background: var(--brand-tint); }
.pdf-page.is-converting { font-weight: 600; }
.pdf-page.is-done { border-color: var(--ok-border); color: var(--ok-fg); background: var(--ok-bg); }
.pdf-page.is-check { border-color: var(--warn-border); color: var(--warn-fg); background: var(--warn-bg); }
.pdf-page.is-failed { border-color: var(--danger-border); color: var(--danger-fg); background: var(--danger-bg); }
.pdf-page.is-here { border-color: var(--ok-border); color: var(--ok-fg); background: var(--bg); border-style: dashed; }
.pdf-check { margin: 4px 0 10px; padding: 8px 10px; border-radius: var(--radius); background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-fg); }
.pdf-check p { margin: 0; }
.pdf-check .hint { margin-top: 6px; color: inherit; opacity: .85; }
.pdf-check-title { font-weight: 600; }
.pdf-check ul { margin: 4px 0 0; padding-left: 18px; }
.pdf-check li { overflow-wrap: anywhere; }
.pdf-modes { margin: 0; padding: 8px 12px 10px; border: 1px solid var(--border-subtle); border-radius: var(--radius); display: grid; gap: 6px; }
.pdf-modes legend { padding: 0 4px; font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-muted); }
.pdf-mode { display: flex; align-items: flex-start; gap: 8px; color: var(--fg-secondary); }
.pdf-mode input { margin-top: 3px; }
.pdf-engine { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 8px; color: var(--fg-secondary); }
.pdf-engine[hidden] { display: none; }
.pdf-engine-label { font-weight: 600; }
.pdf-engine-option { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.pdf-app .results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pdf-history { display: flex; flex-direction: column; gap: 8px; }
.pdf-history h2, .pdf-history p { margin: 0; }
.pdf-history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pdf-history-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 8px 0; border-top: 1px solid var(--border-subtle); }
.pdf-history-list li span { overflow-wrap: anywhere; }
.pdf-app .result { background: var(--bg); border: 1px solid var(--border-subtle); border-left: 3px solid var(--ok-fg); border-radius: var(--radius); padding: 10px 12px; }
.pdf-app .result-head { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.pdf-app .result-summary { margin: 2px 0 8px; color: var(--fg-secondary); }
.pdf-app .result-error { margin: 4px 0 0; color: var(--danger-fg); }
.pdf-app .result-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.pdf-app .result details { margin-top: 8px; color: var(--fg-secondary); }
.pdf-app .result summary { cursor: pointer; }
.pdf-app .result details ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.pdf-app.page { max-width: 1480px; padding: 42px clamp(20px, 4vw, 64px) 72px; }
.pdf-embedded .pdf-app.page { max-width: none; padding: 14px; }
.pdf-app > h1 { margin-bottom: 8px; font-size: clamp(30px, 4vw, 40px); letter-spacing: -.035em; }
.pdf-app > .lead { max-width: 74ch; margin-bottom: 26px; line-height: 1.65; }
.pdf-app .converter-tabs { gap: 7px; padding: 6px; overflow-x: auto; border: 1px solid var(--border-subtle); border-radius: 13px; background: var(--bg-subtle); }
.pdf-app .converter-tabs .tab-btn { flex: 0 0 auto; min-height: 40px; padding: 9px 14px; border: 1px solid transparent; border-radius: 9px; font-weight: 600; }
.pdf-app .converter-tabs .tab-btn[aria-current="page"] { border-color: var(--brand); background: var(--bg); color: var(--brand); box-shadow: 0 1px 3px rgba(15, 23, 42, .08); }
.pdf-app .pdf-job { padding: clamp(16px, 2.5vw, 26px); }
.pdf-app .pdf-modes { padding: 13px 16px 15px; border-radius: 12px; }
.pdf-app .pdf-mode { padding: 5px 0; line-height: 1.55; }
.pdf-app .pdf-options { padding: 4px 0; }
.pdf-app .pdf-cost { padding: 13px 15px; border: 1px solid var(--border-subtle); border-radius: 11px; background: var(--bg-subtle); line-height: 1.55; }
.pdf-app .pdf-notice { padding: 13px 15px; border-radius: 11px; line-height: 1.6; }
.pdf-app .pdf-actions .btn { min-height: 44px; padding-inline: 18px; }
.pdf-app .btn { border-radius: 9px; font-weight: 650; transition: transform .14s ease, box-shadow .14s ease, background .14s ease; }
.pdf-app .btn-primary { box-shadow: 0 2px 5px color-mix(in srgb, var(--brand) 25%, transparent); }
.pdf-app .btn-primary:hover:not(:disabled) { box-shadow: 0 5px 12px color-mix(in srgb, var(--brand) 25%, transparent); transform: translateY(-1px); }
.pdf-app .btn:focus-visible, .pdf-range input:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
/*
 * Printed & typed pages in the Try page's frame: teal and saffron, files first, two choices
 * (who reads, the layout), then converting, then the review with its export bar on top.
 */
/* Its colours are in try-app.css, which pdf.html loads too: this file keeps the product's one palette. */
.pdf-app .btn-primary { background: var(--brand); border-color: var(--brand); }
.pdf-app .btn-primary:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }
.pdf-app .pdf-head .pdf-file { font-size: 15px; }
.pdf-app .pdf-head { gap: 8px; }
.pdf-app .pdf-head .btn { margin-left: auto; }
.pdf-app .pdf-head .pdf-add + .btn { margin-left: 0; }
.pdf-files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pdf-files-item { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--border-subtle); border-radius: 14px; background: var(--bg); box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.pdf-files-kind { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; background: var(--brand-tint); color: var(--brand); font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.pdf-files-kind.is-picture { background: color-mix(in srgb, var(--accent) 16%, var(--bg)); color: color-mix(in srgb, var(--accent) 70%, var(--fg)); }
.pdf-files-about { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pdf-files-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-files-meta { color: var(--fg-muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.pdf-files-ready { flex: none; padding: 3px 10px; border-radius: 999px; background: var(--brand-tint); color: var(--brand); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.pdf-files-remove { flex: none; width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: var(--fg-muted); font-size: 20px; line-height: 1; cursor: pointer; }
.pdf-files-remove:hover:not(:disabled) { background: var(--bg-hover, var(--bg-subtle)); color: var(--danger-fg); }
.pdf-files-remove:disabled { visibility: hidden; }
.pdf-choices { display: flex; flex-wrap: wrap; gap: 12px 16px; }
.pdf-choices .pdf-engine { margin: 0; padding: 5px 6px 5px 16px; border: 1px solid var(--border-subtle); border-radius: 999px; background: var(--bg); gap: 4px; }
.pdf-choices .pdf-engine-label { margin-right: 8px; color: var(--fg-muted); font-size: 11.5px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.pdf-choices .pdf-engine-option { position: relative; gap: 6px; padding: 8px 18px; border-radius: 999px; color: var(--fg-secondary); font-weight: 650; transition: background .15s ease, color .15s ease; }
.pdf-choices .pdf-engine-option input { position: absolute; opacity: 0; pointer-events: none; }
.pdf-choices .pdf-engine-option:hover { color: var(--fg); }
.pdf-choices .pdf-engine-option:has(input:checked) { background: var(--brand); color: #fff; box-shadow: 0 2px 8px color-mix(in srgb, var(--brand) 35%, transparent); }
.pdf-choices .pdf-engine-option:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.pdf-choices .pdf-engine-option:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.pdf-badge { padding: 1px 7px; border-radius: 999px; background: var(--accent); color: #3b2a00; font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
/* Which pages, and the Word copy: a third pill in the same row, shown straight away. */
.pdf-app .pdf-choices .pdf-options { padding: 5px 16px; border: 1px solid var(--border-subtle); border-radius: 999px; background: var(--bg); gap: 6px 18px; }
.pdf-choices .pdf-range input { min-height: 34px; padding: 4px 8px; width: 4.5em; }
.pdf-app .pdf-actions .btn-primary { min-width: 180px; min-height: 48px; border-radius: 999px; font-size: 15px; letter-spacing: .04em; }
.pdf-job.is-running .pdf-choices, .pdf-job.is-running .pdf-cost, .pdf-job.is-running .pdf-notice, .pdf-job.is-running #pdf-processing, .pdf-job.is-running .pdf-head .btn { display: none !important; }
.pdf-job.is-running .pdf-progress-box { gap: 10px; padding: 16px 18px; border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent); border-radius: 14px; background: linear-gradient(180deg, var(--brand-tint), var(--bg)); }
.pdf-progress-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; }
.pdf-progress-row #pdf-status { display: flex; align-items: center; gap: 10px; margin: 0; }
.pdf-job.is-running #pdf-status { font-size: 15px; font-weight: 650; color: var(--fg); }
.pdf-job.is-running #pdf-status::before { content: ""; flex: none; width: 18px; height: 18px; border: 2.5px solid color-mix(in srgb, var(--brand) 25%, transparent); border-top-color: var(--brand); border-radius: 50%; animation: pdf-spin .9s linear infinite; }
.pdf-progress-row #pdf-stop { min-height: 36px; border-radius: 999px; }
.pdf-job.is-running .pdf-progress-box progress { height: 8px; border-radius: 999px; }
.pdf-job.is-running .pdf-actions:not(:has(> :not([hidden]))) { display: none; }
@keyframes pdf-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .pdf-job.is-running #pdf-status::before { animation: none; } }
/* The upload once there are files (the website keeps it above them): one slim bar to add more. */
.pdf-app .drop.is-compact { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 14px 18px; border-radius: 14px; text-align: left; }
.pdf-app .drop.is-compact::before { content: "+"; flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 22px; font-weight: 500; line-height: 1; }
.pdf-app .drop.is-compact .drop-title { flex: 1; min-width: 14em; font-size: 16px; }
.pdf-app .drop.is-compact .drop-hint { display: none; }
.pdf-app .drop.is-compact .drop-actions .btn { min-height: 36px; border-radius: 999px; }
.pdf-review-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.pdf-review-heading { min-width: 0; }
.pdf-review-heading .result-head { margin: 2px 0 0; color: var(--fg-muted); font-size: 14px; font-weight: 600; }
.pdf-review-state { margin: 0; font-size: 20px; font-weight: 750; letter-spacing: -.02em; }
.pdf-review-state.is-done::before { content: "✓"; display: inline-grid; place-items: center; width: 26px; height: 26px; margin-right: 10px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 14px; vertical-align: 2px; }
.pdf-review-new { border-radius: 999px !important; }
.pdf-review-head + .pdf-review-toolbar { justify-content: space-between; }
.pdf-review-head + .pdf-review-toolbar label { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--fg-muted); }
.pdf-review-head + .pdf-review-toolbar .btn-primary { min-width: 170px; border-radius: 999px; letter-spacing: .05em; text-transform: uppercase; }
@media (max-width: 640px) {
  .pdf-files-item { gap: 10px; padding: 10px; }
  .pdf-files-ready { display: none; }
  .pdf-choices .pdf-engine { flex: 1 1 100%; justify-content: space-between; }
  .pdf-app .pdf-choices .pdf-options { flex: 1 1 100%; border-radius: 16px; }
}

@media (max-width: 600px) {
  .pdf-app.page { padding: 28px 14px 48px; }
}
@media (prefers-reduced-motion: reduce) {
  .pdf-app .drop, .pdf-app .btn, .pdf-review-tab, .pdf-review-thumb { transition: none; }
}

/* Admin -> Plans: a plan's highlights, one a line. */
.plan-highlights { min-width: 220px; width: 100%; font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--fg); resize: vertical; }
.plan-pages { display: grid; gap: 4px; }
.plan-pages label { display: flex; align-items: center; justify-content: space-between; gap: 6px; }

/* ---------- tabs become a menu on phones (web/src/mobile-menu.ts) ----------
   A button naming the current section opens the whole list; picking one closes it. */
.mobile-menu-toggle { display: none; align-items: center; gap: 10px; width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--fg); font: inherit; font-size: 15px; font-weight: 600; text-align: left; cursor: pointer; box-shadow: 0 1px 2px rgba(15, 23, 42, .05); }
.mobile-menu-toggle svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mobile-menu-toggle .mobile-menu-hint { color: var(--fg-muted); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.mobile-menu-toggle .mobile-menu-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-menu-toggle .mobile-menu-chevron { transition: transform .15s; }
.mobile-menu-toggle[aria-expanded="true"] { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.mobile-menu-toggle[aria-expanded="true"] .mobile-menu-chevron { transform: rotate(180deg); }
@media (max-width: 760px) { .try-shell .mobile-menu-toggle { display: flex; } }

/* Account: the section links (account.ts). */
@media (max-width: 860px) {
  .account-nav .mobile-menu-toggle { display: flex; }
  .account-nav { position: sticky; top: 72px; z-index: 30; display: block; overflow: visible; margin-bottom: 16px; padding: 0; border: 0; background: transparent; }
  .account-nav:not(.is-menu-open) a { display: none; }
  .account-nav.is-menu-open .account-nav-list { position: absolute; left: 0; right: 0; top: calc(100% + 6px); display: grid; gap: 2px; padding: 6px; border: 1px solid var(--border-subtle); border-radius: 12px; background: var(--bg); box-shadow: 0 16px 36px rgba(15, 23, 42, .16); }
  .account-nav.is-menu-open a { display: block; padding: 11px 12px; white-space: normal; }
  .account-nav.is-menu-open a[href="#delete"] { margin-top: 4px; padding-top: 11px; border-top: 1px solid var(--border-subtle); border-radius: 0 0 9px 9px; }
}

/* Admin: the sections (admin.ts). */
@media (max-width: 960px) {
  .admin-nav .mobile-menu-toggle { display: flex; }
  .admin-nav { position: sticky; top: 56px; z-index: 15; display: block; overflow: visible; padding: 10px 12px; }
  .admin-nav:not(.is-menu-open) .admin-nav-item { display: none; }
  .admin-nav.is-menu-open .admin-nav-list { position: absolute; left: 12px; right: 12px; top: calc(100% - 4px); display: grid; gap: 2px; max-height: calc(100vh - 140px); overflow-y: auto; padding: 6px; border: 1px solid var(--border-subtle); border-radius: 12px; background: var(--bg); box-shadow: 0 16px 36px rgba(15, 23, 42, .16); }
  .admin-nav.is-menu-open .admin-nav-item { display: flex; width: 100%; white-space: normal; }
}

/* Docs: the sidebar is a menu on phones (scripts/docs-site.mjs). */
.docs-mobile-menu { display: none; }
@media (max-width: 860px) {
  .docs-layout > .docs-nav { display: none; }
  .docs-mobile-menu { display: block; position: relative; }
  .docs-mobile-menu > summary { display: flex; list-style: none; }
  .docs-mobile-menu > summary::-webkit-details-marker { display: none; }
  .docs-mobile-menu[open] > summary { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
  .docs-mobile-menu[open] > summary .mobile-menu-chevron { transform: rotate(180deg); }
  .docs-mobile-menu .docs-nav { position: static; display: block; margin-top: 8px; max-height: none; padding: 8px; border: 1px solid var(--border-subtle); border-radius: 12px; background: var(--bg); box-shadow: 0 16px 36px rgba(15, 23, 42, .12); }
  .docs-mobile-menu .docs-nav ul { display: block; }
  .docs-mobile-menu .docs-nav li a, .docs-mobile-menu .docs-home { padding: 10px 12px; }
}

/* The For institutes page's enquiry form (web/src/institutes.ts). */
.enquiry { padding: 28px; margin: 40px 0; scroll-margin-top: 84px; }
.enquiry h2 { margin: 0 0 6px; }
.enquiry form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.enquiry-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 16px; }
.enquiry textarea { resize: vertical; }
.enquiry-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.enquiry .notice { margin: 0; }
/* A field people never see; a bot that fills it is thanked and ignored. */
.enquiry-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
@media (max-width: 600px) { .enquiry { padding: 20px 16px; } }
.enquiry-message { margin: 6px 0 0; max-width: 46ch; white-space: pre-wrap; }

/* The home page's row of smaller tools under the three main features. */
.more-tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 56px; }
.more-tool { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg); color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.more-tool:hover, .more-tool:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.more-tool strong { color: var(--fg); font-size: 15px; }
.more-tool span { color: var(--fg-secondary); font-size: 14px; line-height: 1.5; }

/* The account page's invite link (web/src/account.ts renderInvite). */
.invite-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.invite-link { flex: 1 1 240px; min-width: 0; font: inherit; font-size: 14px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--fg); }

/* "Help TeXConverter read better": the converter pages' popup (src/share-ask.ts). */
.share-ask { width: min(100% - 32px, 520px); max-height: calc(100vh - 32px); padding: 32px 32px 22px; border: 1px solid var(--border-subtle); border-radius: 18px; background: var(--bg); color: var(--fg); box-shadow: 0 24px 64px rgba(15, 23, 42, .28); overflow: auto; }
.share-ask::backdrop { background: rgba(15, 23, 42, .55); backdrop-filter: blur(3px); }
.share-ask-icon { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px; background: var(--brand-tint); color: var(--brand); }
.share-ask h2 { margin: 14px 0 8px; font-size: 22px; line-height: 1.25; }
.share-ask-lead { margin: 0 0 16px; color: var(--fg-secondary); line-height: 1.55; }
.share-ask-points { list-style: none; margin: 0 0 18px; padding: 14px 16px; border-radius: 12px; background: var(--bg-subtle); border: 1px solid var(--border-subtle); display: grid; gap: 10px; }
.share-ask-points li { display: grid; gap: 2px; padding-left: 22px; position: relative; font-size: 14px; line-height: 1.45; color: var(--fg-secondary); }
.share-ask-points li::before { content: ""; position: absolute; left: 2px; top: 5px; width: 10px; height: 6px; border-left: 2px solid var(--ok-fg); border-bottom: 2px solid var(--ok-fg); transform: rotate(-45deg); }
.share-ask-points strong { color: var(--fg); font-weight: 600; }
.share-ask-status { margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--ok-bg); border: 1px solid var(--ok-border); color: var(--ok-fg); font-size: 14px; }
.share-ask-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.share-ask-actions .btn { min-height: 42px; padding-inline: 20px; border-radius: 10px; }
.share-ask-fine { margin: 14px 0 0; font-size: 13px; color: var(--fg-muted); }
@media (max-width: 480px) {
  .share-ask { padding: 26px 18px 18px; }
  .share-ask-actions .btn { flex: 1 1 auto; }
}

/* ---- Home page: every tool, by what it does ---- */
.product-groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.product-group { display: flex; flex-direction: column; gap: 10px; padding: 22px; border: 1px solid var(--border-subtle); border-radius: 18px; background: var(--bg); box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.product-group-title { margin: 0 0 6px; font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--brand); }
.product-link { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 12px; border: 1px solid transparent; color: inherit; text-decoration: none; transition: background .15s, border-color .15s; }
.product-link strong { color: var(--fg); font-size: 15.5px; }
.product-link span { color: var(--fg-muted); font-size: 14px; line-height: 1.45; }
.product-link:hover, .product-link:focus-visible { background: var(--brand-tint); border-color: color-mix(in srgb, var(--brand) 25%, transparent); }
.product-link:hover strong { color: var(--brand); }

/* ---- Home page: real screenshots in a browser frame ---- */
.showcase-wide { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 56px; }
.showcase-wide.showcase-flip { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.screen { margin: 0; border-radius: 14px; overflow: hidden; background: var(--bg); border: 1px solid var(--border-subtle); box-shadow: 0 30px 70px -30px color-mix(in srgb, var(--ink-1) 45%, transparent), 0 8px 24px rgba(15, 23, 42, .08); }
.screen img { display: block; width: 100%; height: auto; }
.screen-bar { display: flex; align-items: center; gap: 12px; padding: 9px 14px; background: var(--bg-subtle); border-bottom: 1px solid var(--border-subtle); }
.screen-bar .mock-dots i { background: var(--border); }
.screen-url { flex: 1; min-width: 0; padding: 3px 12px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border-subtle); color: var(--fg-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.screen-stack { position: relative; padding: 0 0 18% 0; }
.screen-stack .screen-behind { position: absolute; width: 58%; right: -4%; bottom: 0; }
.showcase-cta .btn + .btn { margin-left: 8px; }

/* ---- Home page: why ---- */
.why-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.why { padding: 24px; border-radius: 16px; background: var(--bg-subtle); border: 1px solid var(--border-subtle); border-top: 3px solid var(--brand); }
.why:nth-child(even) { border-top-color: var(--accent); }
.why h3 { margin: 0 0 8px; font-size: 17px; color: var(--fg); }
.why p { margin: 0; color: var(--fg-muted); font-size: 14.5px; line-height: 1.6; }

@media (max-width: 960px) {
  .product-groups, .why-grid { grid-template-columns: minmax(0, 1fr); }
  .showcase-wide, .showcase-wide.showcase-flip { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .showcase-wide.showcase-flip .showcase-copy { order: 0; }
  .screen-stack { padding: 0; }
  .screen-stack .screen-behind { display: none; }
}
@media (min-width: 961px) and (max-width: 1200px) {
  .why-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/*
 * The Matrix / Cases / Aligned-equations size dialog (frontend/src/template-dialog.ts).
 *
 * Shared by the Word pane, the website and the desktop app: each build
 * appends this file to that host's own stylesheet. It uses only the colour
 * tokens all three define (--bg, --fg, --border, --brand...), so it follows
 * each host's light and dark themes without a theme of its own. Sized for the
 * narrowest host, a ~320px Word task pane.
 */
.tpl-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 8px;
  overflow-y: auto;
  background: rgba(0, 0, 0, .38);
}

.tpl-overlay, .tpl-overlay * { box-sizing: border-box; }

.tpl-dialog {
  width: 100%;
  max-width: 400px;
  margin: 0;
  padding: 16px 14px;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 6px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .22);
}

.tpl-title { margin: 0 0 12px; font-size: 16px; font-weight: 600; }

.tpl-top { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }

.tpl-picker-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tpl-picker {
  display: grid;
  grid-template-columns: repeat(8, 14px);
  gap: 2px;
  cursor: pointer;
  user-select: none;
}
.tpl-cell {
  width: 14px;
  height: 14px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--bg-subtle);
}
.tpl-cell.on { background: var(--brand-tint); border-color: var(--brand); }
.tpl-size { margin: 0; font-size: 12px; color: var(--fg-muted); font-variant-numeric: tabular-nums; }

.tpl-side { display: flex; flex-direction: column; gap: 10px; flex: 1; min-width: 120px; }
.tpl-numbers { display: flex; gap: 8px; }
.tpl-number { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--fg-secondary); }
.tpl-number input {
  width: 56px;
  padding: 4px 6px;
  font: inherit;
  font-size: 14px;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius, 4px);
}
.tpl-number input:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

.tpl-preview, .tpl-lines {
  display: flex;
  align-items: stretch;
  gap: 2px;
  min-height: 40px;
  max-width: 100%;
  overflow: hidden;
  color: var(--fg-secondary);
}
.tpl-fence { display: flex; align-items: center; font-size: 26px; line-height: 1; font-family: "Cambria Math", "STIX Two Math", serif; }
.tpl-mini { display: inline-grid; gap: 3px; align-self: center; padding: 2px; }
.tpl-mini i {
  display: block;
  min-width: 10px;
  height: 10px;
  background: var(--fg-muted);
  opacity: .45;
  border-radius: 1px;
}
.tpl-mini i.has-text {
  height: auto;
  background: none;
  opacity: 1;
  font: 10px/1.1 "Cambria Math", "STIX Two Math", serif;
  font-style: normal;
}
.tpl-mini .tpl-rule { display: block; width: 1px; align-self: stretch; background: var(--fg-secondary); margin: 0 1px; }
.tpl-check { display: flex; align-items: center; gap: 6px; margin-top: 12px; font-size: 13px; color: var(--fg-secondary); cursor: pointer; }
.tpl-check input { margin: 0; accent-color: var(--brand); }
.tpl-align-left i { justify-self: start; }
.tpl-align-right i { justify-self: end; }
.tpl-align-center i { justify-self: center; }

.tpl-choices { margin: 12px 0 0; padding: 0; border: 0; min-width: 0; }
.tpl-choices legend { padding: 0; margin-bottom: 4px; font-size: 12px; color: var(--fg-secondary); }
.tpl-seg { display: flex; flex-wrap: wrap; gap: 4px; }
.tpl-seg-item { position: relative; display: inline-flex; }
.tpl-seg-item input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.tpl-seg-item span {
  min-width: 34px;
  padding: 4px 8px;
  text-align: center;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius, 4px);
  background: var(--bg);
  white-space: nowrap;
}
/* ‖ falls back to a colour emoji-like glyph in some UI fonts; brackets are maths. */
.tpl-fences .tpl-seg-item span { font-family: "Cambria Math", "STIX Two Math", Cambria, serif; font-size: 15px; line-height: 18px; }
.tpl-seg-item:hover span { background: var(--bg-hover); }
.tpl-seg-item input:checked + span { background: var(--brand-tint); border-color: var(--brand); color: var(--fg); font-weight: 600; }
.tpl-seg-item input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 1px; }

.tpl-lines { margin-top: 10px; }
.tpl-line-stack { display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.tpl-line { display: flex; gap: 6px; }
.tpl-line i { display: block; width: 48px; height: 10px; border-radius: 1px; background: var(--fg-muted); opacity: .45; }
.tpl-lines-gather .tpl-line { justify-content: center; }
.tpl-hint { margin: 8px 0 0; font-size: 12px; color: var(--fg-muted); }

.tpl-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/*
 * Palette styles every host shares (frontend/src/palette-view.ts): the
 * Formulas tab, where each button is a whole formula drawn above its name.
 * Appended to each host's stylesheet by its build, like template-dialog.css.
 * The selectors name all three hosts' grid and key classes — the pane's
 * .grid/.sym, the website's .try-keys/.try-key, the desktop app's .keys/.key —
 * so they outrank each host's own square-cell layout.
 */
.grid.is-formulas,
.try-keys.is-formulas,
.keys.is-formulas {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  max-height: 320px;
}

.sym.f-key,
.try-key.f-key,
.key.f-key {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  flex-shrink: 0;
  height: auto;
  min-height: 40px;
  padding: 6px 10px;
  gap: 2px;
  text-align: left;
  white-space: normal;
  overflow-x: auto;
  overflow-y: hidden;
}

.f-key .f-math {
  max-width: 100%;
  font-family: "Cambria Math", "STIX Two Math", math;
  font-size: 15px;
  line-height: 1.25;
}
.f-key .f-math math { font-size: 1em; }

.f-key .f-name {
  font-family: inherit;
  font-size: 11px;
  line-height: 1.3;
  color: var(--fg-muted);
}
.f-key:hover .f-name { color: inherit; }

.is-formulas .f-section {
  margin: 8px 2px 2px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.is-formulas .f-section:first-child { margin-top: 2px; }

/* The Favourites tab's panel (frontend/src/favourites-view.ts), under its buttons. */
.fav-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
}
.fav-hint, .fav-status { margin: 0; color: var(--fg-muted); line-height: 1.4; }
.fav-status:empty { display: none; }
.fav-status.is-bad { color: var(--danger-fg); }
.fav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.fav-row {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) minmax(60px, 1.2fr) auto 72px auto;
  align-items: center;
  gap: 4px;
}
.fav-latex {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 11px;
  color: var(--fg-secondary);
}
.fav-input {
  min-width: 0;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
}
.fav-btn {
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  color: var(--fg);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.fav-btn:hover { background: var(--bg-hover); }
.fav-btn.is-recording { border-color: var(--brand); color: var(--brand); }
.fav-primary { border-color: var(--brand); background: var(--brand); color: #fff; }
.fav-primary:hover { background: var(--brand-hover); }
.fav-tools { display: inline-flex; gap: 2px; }
.fav-add { display: flex; gap: 4px; flex-wrap: wrap; }
.fav-add .fav-input { flex: 1 1 140px; }
@media (max-width: 420px) {
  .fav-row { grid-template-columns: 1fr auto; }
  .fav-latex { grid-column: 1 / -1; }
}

/* Explain and Fix with AI, under the preview (frontend/src/ai-assist.ts). */
.ai-assist { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; font-size: 12px; }
.ai-assist[hidden] { display: none; }
.ai-assist-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ai-assist-btn {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  color: var(--fg);
  font: inherit;
  cursor: pointer;
}
.ai-assist-btn:hover:not(:disabled) { background: var(--bg-hover); }
.ai-assist-btn:disabled { opacity: .6; cursor: default; }
.ai-assist-btn[hidden] { display: none; }
.ai-assist-primary { border-color: var(--brand); background: var(--brand); color: #fff; }
.ai-assist-primary:hover:not(:disabled) { background: var(--brand-hover); }
.ai-assist-link { border: 0; background: none; padding: 0; color: var(--brand); font: inherit; cursor: pointer; text-decoration: underline; }
.ai-assist-state { color: var(--fg-muted); }
.ai-assist-answer { padding: 8px 10px; border: 1px solid var(--border-subtle); border-radius: var(--radius); background: var(--bg-subtle); }
.ai-explain { margin: 0 0 6px; line-height: 1.5; color: var(--fg); }
.ai-math math { font-family: "Cambria Math", "STIX Two Math", math; }
.ai-fix { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 6px; }
.ai-fix-side { min-width: 0; }
.ai-fix-title { margin: 0 0 2px; font-weight: 600; color: var(--fg-secondary); }
.ai-fix-latex { display: block; white-space: pre-wrap; word-break: break-word; font-size: 11px; color: var(--fg); }
.ai-fix-math { margin-top: 4px; overflow-x: auto; font-family: "Cambria Math", "STIX Two Math", math; }
.ai-fix-changes { margin: 0 0 6px; padding-left: 18px; color: var(--fg-secondary); line-height: 1.45; }
.ai-assist-own { border-color: var(--brand); color: var(--brand); }
@media (max-width: 360px) { .ai-fix { grid-template-columns: 1fr; } }

/*
 * The equation preview's pieces (frontend/src/preview-math.ts), in every
 * host. A long equation arrives as several <math> elements, cut after its
 * relations and operators; laid out as a wrapping row they flow onto as many
 * lines as the preview's width needs, the way words do. "safe" centring
 * keeps the start of a piece wider than the preview reachable by scrolling
 * instead of pushing it off the left edge.
 */
.math-pieces {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: safe center;
  row-gap: .35em;
  max-width: 100%;
}
.math-piece { display: inline-block; flex: none; }

/*
 * Editing in the preview (frontend/src/preview-edit.ts). The preview is
 * always white paper, in every host and theme, so its highlights are fixed
 * tints of the brand blue; the editor that floats over it takes the host's
 * own colours, with fallbacks for a host that names them differently.
 */
.tc-preview-editable { cursor: text; }
.tc-preview-editable:focus { outline: none; }
.tc-preview-editable:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.tc-preview-editable [data-src] { cursor: pointer; border-radius: 3px; }
.tc-preview-editable .tc-part-hover { background: color-mix(in srgb, var(--brand) 8%, transparent); }
.tc-preview-editable .tc-part-caret { background: color-mix(in srgb, var(--brand) 10%, transparent); box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--brand) 60%, transparent); }
.tc-preview-editable .tc-part-selected { background: color-mix(in srgb, var(--brand) 16%, transparent); box-shadow: 0 0 0 1.5px var(--brand); }

.tc-part-editor {
  position: fixed;
  z-index: 1000;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  color: var(--fg);
  background: var(--bg-raised, var(--bg));
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18), 0 1px 3px rgba(0, 0, 0, .12);
  font: 13px/1.4 "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
}
.tc-part-editor[hidden] { display: none; }
.tc-part-input {
  box-sizing: border-box;
  width: 100%;
  min-height: 30px;
  padding: 5px 8px;
  resize: none;
  overflow-y: auto;
  font: 13px/1.45 "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  color: inherit;
  background: var(--bg-subtle, rgba(127, 127, 127, .06));
  border: 1px solid var(--border);
  border-radius: 4px;
}
.tc-part-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.tc-part-actions { display: flex; gap: 6px; }
.tc-part-actions button {
  flex: 1 1 0;
  padding: 4px 8px;
  font: inherit;
  font-weight: 600;
  color: inherit;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}
.tc-part-actions button:hover:not(:disabled) { background: var(--bg-hover, rgba(127, 127, 127, .1)); }
.tc-part-actions button:disabled { opacity: .45; cursor: default; }
.tc-part-actions button.is-primary { color: #ffffff; background: var(--brand); border-color: var(--brand); }
.tc-part-actions button.is-primary:hover { background: var(--brand-hover); }
.tc-part-hint { margin: 0; font-size: 11.5px; color: var(--fg-muted); }

/*
 * The live suggestion list under a LaTeX box (frontend/src/suggest-view.ts).
 *
 * Shared by the Word pane, the website and the desktop app: each build
 * appends this file to that host's stylesheet. Tokens the website and the
 * desktop app don't define (--bg-raised, --corner, the fonts) fall back to
 * ones all three do, so the list follows each host's light and dark themes.
 *
 * The list overlays what is below the box rather than pushing it down: a
 * panel that grows and shrinks on every keystroke makes the preview and the
 * buttons underneath jump around while you type.
 */
.editor,
.suggest-anchor { position: relative; }

.suggest-anchor > textarea { display: block; width: 100%; box-sizing: border-box; }

.suggest {
  position: absolute;
  z-index: 5;
  top: 100%;
  left: 0;
  right: 0;
  margin: 4px 0 0;
  padding: 4px;
  list-style: none;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-raised, var(--bg));
  border: 1px solid var(--card-border, var(--border));
  border-radius: var(--corner, 8px);
  box-shadow: 0 10px 28px rgba(16, 24, 40, .18);
}

.suggest-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 7px;
  border-radius: var(--corner-sm, 6px);
  cursor: pointer;
  font-size: 12px;
}
.suggest-item:hover { background: var(--bg-hover); }
.suggest-item.is-active { background: var(--brand-tint); }

.suggest-glyph {
  flex: none;
  width: 20px;
  text-align: center;
  font-family: var(--math-font, "Cambria Math", "STIX Two Math", "Latin Modern Math", Cambria, Georgia, serif);
  font-size: 14px;
  color: var(--fg);
}
.suggest-name {
  font-family: var(--mono-font, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace);
  color: var(--fg);
  white-space: nowrap;
}
.suggest-detail {
  margin-left: auto;
  font-size: 11px;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/*
 * The Maths & statistics tables screen (frontend/src/stat-tables-view.ts).
 *
 * Shared by the Word pane, the website and the desktop app: each build
 * appends this file to that host's stylesheet. Only colour tokens all three
 * define, with fallbacks for the ones the pane alone has, so it follows each
 * host's light and dark themes. Sized for the narrowest host, a ~320px pane:
 * the controls wrap and the table scrolls inside its own box.
 */
.st-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 10px;
}

.st-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
  flex: 1 1 140px;
  font-size: 12px;
  color: var(--fg-muted);
}

.st-select {
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--corner-sm, 6px);
}
.st-select:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

.st-preview {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--corner, 8px);
  background: var(--bg);
}
.st-preview:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

.st-table {
  border-collapse: separate;
  border-spacing: 0;
  margin: 0 auto;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}

.st-caption {
  padding: 8px 10px;
  font-weight: 600;
  text-align: center;
  caption-side: top;
}

.st-table th,
.st-table td {
  padding: 3px 8px;
  text-align: center;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

/* The heading rows and the row heads stay in view while the table scrolls. */
.st-table thead th {
  position: sticky;
  z-index: 1;
  background: var(--bg-hover);
  font-weight: 600;
}
.st-table thead tr:first-child th { top: 0; }
.st-table thead tr:nth-child(2) th { top: 23px; }
.st-table tbody th {
  position: sticky;
  left: 0;
  background: var(--bg-hover);
  font-weight: 600;
}
.st-table .st-span { font-weight: 500; color: var(--fg-muted); }
.st-table tbody tr:hover td { background: var(--brand-tint); }

/* Your own table: the caption box, and a grid of boxes to type in. */
.st-text {
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--corner-sm, 6px);
}
.st-text:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

.st-own { margin: 10px auto; border-left: 1px solid var(--border); border-top: 1px solid var(--border); }
.st-own th,
.st-own td { padding: 0; border-right: 1px solid var(--border); }
.st-own tbody th { position: static; background: var(--bg-hover); }
.st-cell {
  width: 110px;
  font: inherit;
  padding: 5px 6px;
  text-align: center;
  color: var(--fg);
  background: transparent;
  border: 0;
}
.st-own th .st-cell { font-weight: 600; }
.st-cell:focus { outline: 2px solid var(--brand); outline-offset: -2px; }
.st-cell-bad { background: rgba(220, 38, 38, 0.14); box-shadow: inset 0 -2px 0 rgb(220, 38, 38); }

.st-hint {
  margin: 0 10px 10px;
  font-size: 12px;
  color: var(--fg-muted);
  text-align: center;
}

/*
 * Editing a diagram on its picture (frontend/src/figure-edit.ts), in the Word
 * pane, on the website and in the desktop app: the outline over what's
 * selected, Undo / Redo under the picture, and the panel holding its LaTeX.
 * Each host's own colours where it has them, these where it doesn't.
 */
.tc-figure-editable { position: relative; }
.tc-figure-editable img { cursor: pointer; user-select: none; -webkit-user-select: none; }
.tc-figure-editable:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.tc-figure-selected {
  position: absolute;
  box-sizing: border-box;
  border: 2px dashed var(--brand);
  border-radius: 6px;
  background: color-mix(in srgb, var(--brand) 6%, transparent);
  pointer-events: none;
}
.tc-figure-selected[hidden] { display: none; }
.tc-figure-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.tc-figure-tools[hidden] { display: none; }
.tc-figure-hint { flex: 1 1 100%; font-size: 12px; color: var(--fg-muted); }
.tc-figure-panel {
  margin: 0 0 10px;
  padding: 8px;
  color: var(--fg);
  background: var(--brand-tint);
  border: 1px solid var(--brand);
  border-radius: 8px;
  font: 13px/1.4 "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
}
.tc-figure-panel[hidden] { display: none; }
.tc-figure-label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.tc-figure-input {
  box-sizing: border-box;
  width: 100%;
  padding: 5px 8px;
  resize: vertical;
  font: 13px/1.45 "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.tc-figure-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.tc-figure-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tc-figure-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font: 600 12.5px/1.4 "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}
.tc-figure-btn[hidden] { display: none; }
.tc-figure-btn:hover:not(:disabled) { background: var(--bg-hover, rgba(127, 127, 127, .1)); }
.tc-figure-btn:disabled { opacity: .45; cursor: default; }
.tc-figure-btn.is-primary { color: #ffffff; background: var(--brand); border-color: var(--brand); }
.tc-figure-btn.is-primary:hover { background: var(--brand-hover); }
.tc-figure-btn svg { flex: none; }
.tc-figure-btn.is-danger { color: var(--danger-fg); }
.tc-figure-btn.is-quiet { border-color: transparent; background: transparent; color: var(--fg-muted); font-weight: 500; }
.tc-figure-note { margin: 6px 0 0; font-size: 12px; color: var(--fg-muted); }
.tc-figure-editable img { -webkit-user-drag: none; }
/* A dot on a point of the part selected: drag it to move that point. */
.tc-figure-handle {
  position: absolute;
  box-sizing: border-box;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  background: #ffffff;
  border: 2px solid var(--brand);
  border-radius: 50%;
  cursor: move;
  touch-action: none;
  z-index: 1;
}
.tc-figure-handle.is-radius { border-radius: 2px; cursor: ew-resize; background: var(--brand); }
.tc-figure-handle[hidden] { display: none; }
/* A finger needs more to land on than the dot it sees. */
.tc-figure-handle::after { content: ""; position: absolute; inset: -6px; }
@media (pointer: coarse) { .tc-figure-handle::after { inset: -12px; } }
.tc-figure-marquee {
  position: absolute;
  box-sizing: border-box;
  border: 1px dashed var(--brand);
  background: color-mix(in srgb, var(--brand) 8%, transparent);
  pointer-events: none;
}
.tc-figure-marquee[hidden] { display: none; }
/* The bar for what's selected: what to do with it, and its style. */
.tc-figure-bar {
  margin: 0 0 8px;
  padding: 8px;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: 13px/1.4 "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
}
.tc-figure-bar[hidden] { display: none; }
.tc-figure-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.tc-figure-count { font-size: 12px; font-weight: 600; color: var(--fg-muted); }
.tc-figure-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tc-figure-row[hidden] { display: none; }
.tc-figure-row + .tc-figure-row { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border-subtle, #e6e6e6); }
/* Each row's name, in a column of its own so the buttons line up beside it, however they wrap. */
.tc-figure-row.is-named { position: relative; padding-left: 50px; }
.tc-figure-row-name { position: absolute; left: 0; top: 6px; font-size: 11.5px; font-weight: 600; color: var(--fg-muted); }
.tc-figure-row + .tc-figure-row .tc-figure-row-name { top: 12px; }
.tc-figure-field { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--fg-muted); }
.tc-figure-field[hidden] { display: none; }
.tc-figure-select {
  padding: 3px 6px;
  font: 12.5px/1.4 "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.tc-figure-select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.tc-figure-status { margin: 6px 0 0; font-size: 12px; color: var(--fg-muted); }
.tc-figure-status:empty { display: none; }
/* The dot above what's selected that turns it. */
.tc-figure-turn {
  position: absolute;
  box-sizing: border-box;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  background: var(--brand);
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--brand);
  cursor: grab;
  touch-action: none;
  z-index: 1;
}
.tc-figure-turn[hidden] { display: none; }
.tc-figure-turn::after { content: ""; position: absolute; inset: -6px; }
@media (pointer: coarse) { .tc-figure-turn::after { inset: -12px; } }
/* Where a dragged point lands on another part's point. */
.tc-figure-snap {
  position: absolute;
  box-sizing: border-box;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid #d13438;
  border-radius: 50%;
  pointer-events: none;
  z-index: 2;
}
.tc-figure-snap[hidden] { display: none; }
/* The grid snapped to, its squares sized and placed by the editor. */
.tc-figure-grid {
  position: absolute;
  pointer-events: none;
  background-image:
    linear-gradient(to right, color-mix(in srgb, var(--brand) 16%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--brand) 16%, transparent) 1px, transparent 1px);
}
.tc-figure-grid[hidden] { display: none; }
.tc-figure-selected.is-group { border-style: solid; }
.tc-figure-editable.is-adding img { cursor: crosshair; }
/* Buttons that belong together, joined into one strip: Select and the shapes, Undo and Redo. */
.tc-figure-group { display: inline-flex; flex-wrap: wrap; align-items: stretch; }
.tc-figure-group .tc-figure-btn { border-radius: 0; margin-left: -1px; }
.tc-figure-group .tc-figure-btn:first-child { border-radius: 4px 0 0 4px; margin-left: 0; }
.tc-figure-group .tc-figure-btn:last-child { border-radius: 0 4px 4px 0; }
.tc-figure-btn[aria-pressed="true"] { position: relative; color: #ffffff; background: var(--brand); border-color: var(--brand); }
.tc-figure-btn[aria-pressed="true"]:hover:not(:disabled) { background: var(--brand-hover); }
/* Asking the AI to change what's selected. */
.tc-figure-ai { flex-wrap: nowrap; }
/* In a narrow column (the Word pane) the shapes keep only their pictures; their names stay as tooltips. */
@media (max-width: 480px) {
  .tc-figure-group .tc-figure-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .tc-figure-group .tc-figure-btn { padding: 5px 8px; }
  .tc-figure-row.is-named { padding-left: 0; }
  .tc-figure-row-name, .tc-figure-row + .tc-figure-row .tc-figure-row-name { position: static; flex-basis: 100%; }
}
.tc-figure-ai[hidden] { display: none; }
.tc-figure-ask {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 8px;
  font: 12.5px/1.4 "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.tc-figure-ask:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.tc-figure-ask:disabled { opacity: .6; }
@media (max-width: 480px) { .tc-figure-ai { flex-wrap: wrap; } .tc-figure-ask { flex-basis: 100%; } }
/* Zoomed in: the picture scrolls inside its box. */
.tc-figure-editable.is-zoomed { overflow: auto; max-height: 70vh; }
/* The More shapes list while one of its shapes is being drawn. */
.tc-figure-select.is-active { color: #ffffff; background: var(--brand); border-color: var(--brand); }
.tc-figure-group .tc-figure-btn span:empty { display: none; }
/* The Place row: x and y of each point, and a radius. */
.tc-figure-num {
  width: 64px;
  padding: 3px 4px;
  font: 12.5px/1.4 "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.tc-figure-num:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.tc-figure-point { margin-right: 6px; }
/* The colour picker opened by "Custom colour…": there, but not seen. */
.tc-figure-bar { position: relative; }
.tc-figure-colour { position: absolute; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none; }

/*
 * The molecule sketcher (frontend/src/chem-sketch.ts) above a chemistry
 * picture, in the Word pane, on the website and in the desktop app. Its
 * buttons are figure-edit.css's; these are its bars and canvas.
 */
.tc-chem { margin: 0 0 10px; font: 13px/1.4 "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif; color: var(--fg); }
.tc-chem[hidden] { display: none; }
.tc-chem-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 6px; }
.tc-chem-bar .tc-figure-btn { min-height: 30px; padding: 3px 8px; }
.tc-chem-el { min-width: 30px; justify-content: center; font-weight: 700; }
.tc-chem-el[data-el="N"] { color: #2f4fd0; }
.tc-chem-el[data-el="O"] { color: #d12b2b; }
.tc-chem-el[data-el="S"] { color: #a68f00; }
.tc-chem-el[data-el="P"] { color: #d9730d; }
.tc-chem-el[data-el="F"], .tc-chem-el[data-el="Cl"] { color: #1e9a3a; }
.tc-chem-el[data-el="Br"] { color: #9b3a1f; }
.tc-chem-el[data-el="I"] { color: #7a2aa8; }
.tc-chem-el sub, .tc-chem-el sup { font-size: 70%; line-height: 0; }
.tc-chem-other { display: inline-flex; gap: 4px; align-items: center; flex: 1 1 180px; max-width: 260px; }
.tc-chem-canvas {
  position: relative;
  height: 340px;
  overflow: hidden;
  color: #1b1b1b;
  background-color: #ffffff;
  background-image: radial-gradient(color-mix(in srgb, var(--brand) 16%, transparent) 1px, transparent 1px);
  background-size: 20px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: crosshair;
  touch-action: none;
}
.tc-chem-canvas:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.tc-chem-canvas[data-tool="select"] { cursor: default; }
.tc-chem-canvas[data-tool="erase"] { cursor: not-allowed; }
.tc-chem-svg { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-select: none; }
.tc-chem-label { font-family: "Segoe UI", Arial, sans-serif; font-weight: 600; }
.tc-chem-label-bg { fill: #ffffff; }
.tc-chem-hover { fill: color-mix(in srgb, var(--brand) 14%, transparent); stroke: var(--brand); stroke-width: 1.5; }
.tc-chem-hover-bond { stroke: color-mix(in srgb, var(--brand) 18%, transparent); }
.tc-chem-picked { fill: color-mix(in srgb, var(--brand) 22%, transparent); }
.tc-chem-ghost { stroke: var(--brand); stroke-dasharray: 5 4; }
.tc-chem-marquee { fill: color-mix(in srgb, var(--brand) 8%, transparent); stroke: var(--brand); stroke-dasharray: 4 3; }
.tc-chem-notice { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 20px; text-align: center; background: rgba(255, 255, 255, .92); }
.tc-chem-notice[hidden] { display: none; }
.tc-chem-notice p { margin: 0; max-width: 420px; color: var(--fg-muted); }
.tc-chem-hint { margin: 6px 0 0; }
/* A chemistry picture has nothing to draw with the shape tools: the sketcher does that. */
.tc-chem-on > .tc-figure-tools { display: none; }
@media (max-width: 480px) {
  .tc-chem-canvas { height: 280px; }
  .tc-chem-bar .tc-figure-group .tc-figure-btn span { position: static; width: auto; height: auto; clip-path: none; }
}

/*
 * The Biology builder (frontend/src/biology-builder-ui.ts) above a diagram's
 * picture, in the Word pane, on the website and in the desktop app. Its
 * buttons are figure-edit.css's.
 */
.tc-bio { margin: 0 0 10px; padding: 8px 10px; border: 1px solid var(--border, #d1d1d1); border-radius: 8px; font: 13px/1.4 "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif; color: var(--fg, #242424); }
.tc-bio[hidden] { display: none; }
.tc-bio > summary { cursor: pointer; font-weight: 600; }
.tc-bio-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0 4px; }
.tc-bio-kind { flex: 1 1 180px; max-width: 280px; min-height: 30px; padding: 3px 6px; border: 1px solid var(--border, #d1d1d1); border-radius: 4px; background: var(--bg, #ffffff); color: inherit; font: inherit; }
.tc-bio-draw { min-height: 30px; padding: 3px 14px; font-weight: 600; }
.tc-bio-help { margin: 4px 0 6px; color: var(--muted, #616161); }
.tc-bio-fields { display: grid; gap: 6px; }
.tc-bio-field { display: grid; gap: 2px; }
.tc-bio-field input, .tc-bio-field textarea { width: 100%; box-sizing: border-box; padding: 4px 6px; border: 1px solid var(--border, #d1d1d1); border-radius: 4px; background: var(--bg, #ffffff); color: inherit; font: 13px/1.4 Consolas, "Cascadia Mono", monospace; resize: vertical; }
.tc-bio-check { display: inline-flex; gap: 6px; align-items: center; }
.tc-bio-message { margin: 6px 0 0; min-height: 1em; }
.tc-bio-message[data-tone="danger"] { color: #b10e1c; }
.tc-bio-message[data-tone="ok"] { color: var(--muted, #616161); }

/*
 * Printed & typed pages: the review of a converted PDF (desktop/ui/pdf.ts,
 * reviewItem). Shared by the desktop app and the website's PDF converter
 * (web/pdf.html, also inside the Try page), so both look the same, and the
 * same as the Try page's photo review (web/try-app.css): the original and the
 * converted page side by side on a wide screen; below 1024px a
 * Converted / Original switch shows one at a time at full width.
 */
.pdf-review-result { padding: clamp(14px, 2.5vw, 24px) !important; border-left: 0 !important; border-top: 3px solid var(--brand) !important; border-radius: 18px !important; box-shadow: 0 6px 22px rgba(15, 23, 42, .06); }
.pdf-review-result > .result-head { font-size: 20px; letter-spacing: -.02em; }
.pdf-review-result > .result-summary { margin: 6px 0 16px; font-size: 14px; }
.pdf-review-result .pdf-check { margin: 12px 0; padding: 13px 15px; border-radius: 12px; line-height: 1.55; }

.pdf-review-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 16px 0 6px; padding: 12px 14px; border: 1px solid var(--border-subtle); border-radius: 16px; background: var(--bg); box-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06); }
.pdf-review-toolbar label { display: inline-flex; align-items: center; gap: 10px; color: var(--fg); font-weight: 650; }
.pdf-review-toolbar .btn { min-height: 42px; padding-inline: 22px; border-radius: 10px; font-weight: 600; }
.pdf-review-format { min-width: min(280px, 70vw); min-height: 42px; padding: 7px 36px 7px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--fg); font: inherit; }
.pdf-review-format:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.pdf-review-status { display: block; min-height: 1.5em; color: var(--fg-secondary); font-size: 13px; line-height: 1.5; }

/* Phones and tablets only: which side shows. */
.pdf-review-compare { display: none; }

.pdf-review-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; align-items: stretch; }
.pdf-review-pane { display: flex; flex-direction: column; min-width: 0; overflow: hidden; border: 1px solid var(--border-subtle); border-radius: 18px; background: var(--bg); box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.pdf-review-pane h3 { margin: 0; padding: 14px 18px; border-bottom: 1px solid var(--border-subtle); color: var(--fg); font-size: 12px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }

/* The original: the page on a light table, thumbnails above it. */
.pdf-review-thumbnails { display: flex; gap: 8px; max-width: 100%; overflow-x: auto; padding: 10px 12px; border-bottom: 1px solid var(--border-subtle); scrollbar-width: thin; }
.pdf-review-thumb { display: grid; flex: 0 0 62px; gap: 4px; justify-items: center; padding: 5px; border: 1px solid var(--border-subtle); border-radius: 10px; background: var(--bg); color: var(--fg-secondary); font: inherit; cursor: pointer; transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
.pdf-review-thumb:hover { border-color: var(--brand); transform: translateY(-1px); }
.pdf-review-thumb:focus-visible, .pdf-review-tab:focus-visible, .pdf-review-compare button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.pdf-review-thumb[aria-pressed="true"] { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-tint); color: var(--brand); }
.pdf-review-thumb img { display: block; width: 48px; height: 64px; object-fit: contain; background: #fff; border-radius: 3px; }
.pdf-review-thumb span { font-size: 11px; font-weight: 650; font-variant-numeric: tabular-nums; }
.pdf-review-original-body { flex: 1; display: flex; flex-direction: column; align-items: center; min-height: 0; height: clamp(460px, calc(var(--outer-vh, 100vh) - 260px), 1100px); padding: 16px; overflow: auto; background:
  repeating-conic-gradient(color-mix(in srgb, var(--fg) 4%, transparent) 0 25%, transparent 0 50%) 0 0 / 20px 20px, var(--bg-subtle); }
.pdf-review-main-image { display: block; max-width: 100%; height: auto; background: #fff; border-radius: 6px; box-shadow: 0 2px 10px rgba(15, 23, 42, .18); }
.pdf-review-page-label { margin: 11px 0 0; color: var(--fg-muted); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* The converted page: a sheet of paper, read from the left. */
.pdf-review-tabs { display: flex; gap: 4px; width: fit-content; margin: 12px 14px 0; padding: 3px; border-radius: 999px; background: var(--bg-subtle); }
.pdf-review-tab { padding: 7px 14px; border: 0; border-radius: 999px; background: transparent; color: var(--fg-secondary); font: inherit; font-size: 13px; font-weight: 550; cursor: pointer; transition: background .15s ease, color .15s ease; }
.pdf-review-tab:hover { color: var(--fg); }
.pdf-review-tab.is-active { background: var(--bg); color: var(--brand); font-weight: 650; box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.pdf-review-preview, .pdf-review-editor { flex: 1; min-height: 0; height: clamp(460px, calc(var(--outer-vh, 100vh) - 300px), 1100px); margin: 12px 14px 14px; border-radius: 12px; }
.pdf-review-preview { overflow: auto; padding: clamp(18px, 2.8vw, 32px); background: var(--bg-subtle); color: var(--fg); font: 16px/1.75 "Cambria Math", Cambria, Georgia, serif; scrollbar-width: thin; }
.pdf-review-preview[hidden], .pdf-review-editor[hidden] { display: none; }
.pdf-review-text { margin: 0 0 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.pdf-review-preview .math-pieces { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 2px; margin: 18px 0; padding: 8px; font-size: 1.15em; }
.pdf-review-preview .math-piece math { max-width: 100%; }
.pdf-review-bad-math { display: block; overflow-wrap: anywhere; color: var(--danger-fg); }
.pdf-review-editor { width: auto; resize: vertical; box-sizing: border-box; padding: 18px 20px; border: 1px solid var(--border-subtle); background: var(--bg); color: var(--fg); font: 13px/1.7 ui-monospace, SFMono-Regular, Consolas, monospace; tab-size: 2; }
.pdf-review-editor:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
@media (prefers-color-scheme: light) {
  .pdf-review-preview { background: #fff; box-shadow: inset 0 0 0 1px var(--border-subtle); color: #111827; }
}

/* Tablets and phones: one side at a time, chosen with the switch. */
@media (max-width: 1024px) {
  .pdf-review-compare { display: flex; gap: 4px; margin-top: 16px; padding: 4px; border: 1px solid var(--border-subtle); border-radius: 999px; background: var(--bg); }
  .pdf-review-compare button { flex: 1 1 0; min-height: 40px; border: 0; border-radius: 999px; background: transparent; color: var(--fg-secondary); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
  .pdf-review-compare button[aria-selected="true"] { background: var(--brand); color: #fff; box-shadow: 0 1px 3px color-mix(in srgb, var(--brand) 35%, transparent); }
  .pdf-review-grid { grid-template-columns: minmax(0, 1fr); margin-top: 12px; }
  .pdf-review-grid[data-show="result"] > .pdf-review-original, .pdf-review-grid[data-show="original"] > .pdf-review-converted { display: none; }
  .pdf-review-original-body, .pdf-review-preview, .pdf-review-editor { height: auto; min-height: calc(var(--outer-vh, 100vh) * 0.6); }
  .pdf-review-original-body { overflow: visible; }
}
@media (max-width: 600px) {
  /* Format and Download after the pages, along the bottom of the screen, under the thumb. */
  .pdf-review-result { display: flex; flex-direction: column; padding: 12px !important; }
  .pdf-review-toolbar, .pdf-review-status { order: 1; }
  .pdf-review-toolbar { position: sticky; bottom: 0; z-index: 5; align-items: stretch; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 24px rgba(15, 23, 42, .1); }
  .pdf-review-toolbar label { align-items: stretch; flex-direction: column; flex: 1 1 100%; gap: 6px; }
  .pdf-review-format { width: 100%; min-width: 0; }
  .pdf-review-toolbar .btn { flex: 1 1 100%; }
  .pdf-review-tabs { width: auto; }
  .pdf-review-tab { flex: 1 1 0; min-height: 36px; }
  .pdf-review-preview { padding: 18px 16px; font-size: 15px; }
  .pdf-review-original-body { padding: 8px; }
  .pdf-review-editor { padding: 14px; }
}
/* The converted page drawn as it prints (desktop/ui/pdf-preview.ts): numbering, options side by side, tables, figures. */
.pdf-review-preview.pv-page { white-space: normal; text-align: left; }
.pv-page .pv-p { margin: 0 0 .7em; overflow-wrap: anywhere; }
.pv-page .pv-h { margin: 1em 0 .5em; font-size: 1.15em; font-weight: 700; line-height: 1.35; }
.pv-page .pv-title { margin: 0 0 .6em; font-size: 1.35em; text-align: center; }
.pv-page .pv-run-in { margin-right: .4em; }
.pv-page .pv-list { margin: .2em 0 .8em; }
.pv-page .pv-item { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: .55em; align-items: baseline; margin: .15em 0; }
.pv-page .pv-label { min-width: 1.6em; font-weight: 600; font-variant-numeric: tabular-nums; }
.pv-page .pv-item-body > .pv-p:last-child, .pv-page .pv-item-body > :last-child { margin-bottom: 0; }
.pv-page .pv-options { display: flex; flex-wrap: wrap; column-gap: 1.2em; row-gap: .25em; margin: .35em 0 .8em; }
.pv-page .pv-options > .pv-item { flex: 1 0 calc(100% / var(--pv-cols, 4) - 1.2em); min-width: max-content; max-width: 100%; margin: 0; grid-template-columns: max-content minmax(0, auto); }
.pv-page .pv-options .pv-label { min-width: 0; font-weight: 500; }
.pv-page .pv-center, .pv-page .pv-figure, .pv-page .pv-table { text-align: center; }
.pv-page .pv-flushright { text-align: right; }
.pv-page .pv-quote, .pv-page .pv-quotation { margin: .5em 1.5em; }
.pv-page .pv-env { margin: .4em 0 .8em; }
.pv-page img.pv-figure { display: block; max-width: 100%; height: auto; margin: .6em auto; background: #fff; border-radius: 4px; }
.pv-page .pv-caption { margin: .3em 0 .8em; font-size: .92em; text-align: center; color: var(--fg-secondary); }
.pv-page .pv-missing { color: var(--fg-muted); font-style: italic; }
.pv-page .pv-table-wrap { max-width: 100%; margin: .4em 0 .9em; overflow-x: auto; }
.pv-page .pv-table-wrap table { border-collapse: collapse; margin: 0 auto; }
.pv-page .pv-table-wrap td { padding: .25em .7em; vertical-align: top; text-align: left; }
.pv-page .pv-table-wrap table.is-ruled td { border: 1px solid var(--border); }
.pv-page .pv-sc { font-variant: small-caps; }
.pv-page .pv-box { padding: 0 .25em; border: 1px solid currentColor; }
.pv-page .pv-footnote { color: var(--fg-secondary); }
.pv-page .pv-math { display: inline; }
/* In a line, an equation flows with the words, breaking between its pieces as a line of text does. */
.pv-page .pv-math .math-pieces { display: inline; margin: 0; padding: 0; font-size: 1.05em; }
.pv-page .pv-math .math-piece { display: inline-block; vertical-align: baseline; }
.pv-page .pv-math.is-display { display: block; margin: .5em 0 .8em; text-align: center; }
.pv-page .pv-math.is-display .math-pieces { display: flex; padding: 4px; }
.pv-page .pv-math.is-editable { border-radius: 5px; cursor: pointer; outline: 1px solid transparent; transition: background .12s ease, outline-color .12s ease; }
.pv-page .pv-math.is-editable:hover { background: var(--brand-tint); outline-color: color-mix(in srgb, var(--brand) 45%, transparent); }
.pv-page .pv-math.is-editable:focus-visible { outline: 2px solid var(--brand); }
.pdf-review-tip { margin: 8px 16px 0; color: var(--fg-muted); font-size: 12.5px; }
.pdf-review-tip[hidden] { display: none; }
.pdf-review-converted ~ .pdf-review-toolbar, .pdf-review-grid + .pdf-review-toolbar { margin-top: 18px; }

/* The equation editor over the preview, and the question before a download (desktop/ui/pdf-math-dialog.ts). */
.pv-dialog { width: min(720px, calc(100vw - 24px)); margin: 0 auto; bottom: auto; padding: 18px 18px 16px; overflow: auto; border: 1px solid var(--border); border-radius: 16px; background: var(--bg); color: var(--fg); box-shadow: 0 18px 50px rgba(15, 23, 42, .28); box-sizing: border-box; }
.pv-dialog::backdrop { background: rgba(15, 23, 42, .45); }
.pv-confirm-dialog { width: min(440px, calc(100vw - 24px)); }
.pv-text-dialog { width: min(720px, calc(100vw - 24px)); }
.pv-text-box { width: 100%; box-sizing: border-box; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--fg); font: 14px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; resize: vertical; }
.pv-text-hint { margin: 6px 0 0; color: var(--fg-muted); font-size: 12.5px; }
.pv-page .pv-text-editable, .try-ocr-typeset.pv-text-editable { cursor: text; }
.pv-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.pv-dialog-title { margin: 0 0 8px; font-size: 18px; font-weight: 700; }
.pv-dialog-head .pv-dialog-title { margin: 0; }
.pv-dialog-x { width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--fg-secondary); font-size: 22px; line-height: 1; cursor: pointer; }
.pv-dialog-x:hover { background: var(--bg-subtle); color: var(--fg); }
.pv-eq-palette { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--border-subtle); border-radius: 12px; background: var(--bg-subtle); }
.pv-eq-groups { padding-bottom: 8px; }
.pv-eq-keys { max-height: 150px; }
.pv-eq-label { display: block; margin: 12px 0 5px; color: var(--fg-secondary); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.pv-eq-dialog .mf { min-height: 84px; }
.pv-eq-latex { display: block; width: 100%; box-sizing: border-box; margin-top: 5px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--fg); font: 13.5px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; text-transform: none; letter-spacing: 0; font-weight: 400; resize: vertical; }
.pv-eq-latex:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.pv-eq-hint { flex: 1 1 260px; margin: 0; color: var(--fg-muted); font-size: 12.5px; line-height: 1.45; }
.pv-confirm-text { margin: 0 0 4px; color: var(--fg-secondary); line-height: 1.55; overflow-wrap: anywhere; }
.pv-dialog-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.pv-dialog-actions .btn { min-width: 96px; }
/* A reader that can't read: the question asked (frontend/src/choice-dialog.ts). */
.pv-choice-dialog { width: min(480px, calc(100vw - 24px)); }
.pv-choice-more { font-size: 13.5px; color: var(--brand); }
@media (max-width: 600px) {
  .pv-page .pv-options > .pv-item { flex-basis: calc(50% - 1.2em); }
  .pv-eq-keys { max-height: 110px; }
  .pv-eq-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) { .pdf-review-thumb { transition: none; } }
.pdf-review-waiting { margin: 24px 16px; color: var(--fg-muted); font-style: italic; }

/*
 * TeXConverter's own visual equation editor (frontend/src/math-field.ts).
 * Shared by every host (scripts/shared-css.mjs); only the colour tokens all
 * hosts define, so it follows their light and dark themes.
 */
.mf { position: relative; display: block; min-height: 64px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--fg); cursor: text; overflow-x: auto; overflow-y: hidden; transition: border-color .12s ease, box-shadow .12s ease; }
.mf.is-focused { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.mf-input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; resize: none; overflow: hidden; pointer-events: none; }
.mf-surface { display: flex; justify-content: center; align-items: center; min-height: 36px; font: 22px/1.25 "Cambria Math", "STIX Two Math", "Latin Modern Math", Cambria, Georgia, serif; white-space: nowrap; user-select: none; -webkit-user-select: none; }
.mf:not(.is-display) .mf-surface { justify-content: flex-start; }

.mf-row { display: inline-block; white-space: nowrap; min-height: 1em; }
.mf-row.is-empty { min-width: .7em; }
.mf-slot { display: inline-block; width: .62em; height: .78em; margin: 0 .04em; border: 1.5px dashed color-mix(in srgb, currentColor 45%, transparent); border-radius: 3px; vertical-align: -.08em; }

.mf-sym { display: inline-block; }
.mf-c-var { font-style: italic; }
.mf-c-num, .mf-c-fn, .mf-c-punct, .mf-c-other, .mf-c-text { font-style: normal; }
.mf-c-op { padding: 0 .22em; }
.mf-c-rel { padding: 0 .3em; }
.mf-c-fn { padding-right: .16em; }
.mf-c-big { font-size: 1.45em; line-height: 1; padding: 0 .1em; vertical-align: -.18em; }
.mf-c-punct + .mf-sym { padding-left: .06em; }
/* A sign that starts a row or follows another sign is unary: no spacing. */
.mf-row > .mf-c-op:first-child, .mf-row > .mf-caret:first-child + .mf-c-op, .mf-c-op + .mf-c-op, .mf-c-rel + .mf-c-op, .mf-c-punct + .mf-c-op, .mf-scripts .mf-c-op, .mf-limits .mf-c-op, .mf-scripts .mf-c-rel, .mf-limits .mf-c-rel { padding: 0; }
.mf-c-var { padding-right: .03em; }
.mf-c-hidden { display: none; }

/* The caret, and a command being typed after \. */
.mf-caret { display: inline-block; width: 0; height: 1.1em; margin: 0 -1px; border-left: 2px solid var(--brand); vertical-align: -.2em; visibility: hidden; }
.mf.is-focused .mf-caret { visibility: visible; animation: mf-blink 1.05s steps(1) infinite; }
.mf-command { display: inline-block; padding: 0 .2em; border-radius: 4px; background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); font: .72em/1.5 ui-monospace, Consolas, monospace; }
@keyframes mf-blink { 50% { visibility: hidden; } }
.mf .is-selected { border-radius: 2px; background: color-mix(in srgb, var(--brand) 22%, transparent); }

/* Fractions. */
.mf-frac { display: inline-flex; align-items: center; vertical-align: middle; padding: 0 .1em; }
.mf-stack { display: inline-flex; flex-direction: column; align-items: center; }
.mf-num, .mf-den { text-align: center; padding: 0 .12em; }
.mf-num { padding-bottom: .08em; border-bottom: .06em solid currentColor; }
.mf-frac.is-binom .mf-num { border-bottom: 0; }
.mf-den { padding-top: .1em; }
.mf-frac .mf-frac, .mf-scripts .mf-frac { font-size: .86em; }

/* Scripts and limits. */
.mf-scripts { display: inline-flex; flex-direction: column; font-size: .68em; line-height: 1.05; margin-left: .03em; }
.mf-scripts.is-sup { vertical-align: .62em; }
.mf-scripts.is-sub { vertical-align: -.38em; }
.mf-scripts.is-both { vertical-align: .55em; }
.mf-scripts.is-both .mf-sup { margin-bottom: .15em; }
.mf-scripts .mf-scripts { font-size: .85em; }
.mf-limits { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin: 0 .1em; }
.mf-over, .mf-under { text-align: center; font-size: .66em; line-height: 1.1; min-height: .4em; }

/* Roots. */
.mf-sqrt { display: inline-flex; align-items: stretch; vertical-align: middle; margin: 0 .06em; }
.mf-index { font-size: .58em; align-self: flex-start; margin-right: -.45em; margin-top: .1em; }
.mf-radical { display: inline-flex; width: .62em; min-height: 1.15em; }
.mf-radical svg { width: 100%; height: 100%; overflow: visible; }
.mf-radicand { padding: .12em .12em 0 .08em; border-top: .06em solid currentColor; align-items: baseline; }

/* Brackets, matrices, accents. */
.mf-fence, .mf-matrix { display: inline-flex; align-items: center; vertical-align: middle; }
.mf-delim { display: inline-block; padding: 0 .04em; line-height: 1; transform-origin: center; font-style: normal; }
.mf-grid { display: inline-grid; column-gap: .9em; row-gap: .25em; align-items: baseline; padding: .1em .25em; }
.mf-cell { text-align: center; }
.mf-env-cases .mf-cell, .mf-env-aligned .mf-cell, .mf-env-align .mf-cell, .mf-env-array .mf-cell { text-align: left; }
.mf-env-aligned .mf-grid, .mf-env-align .mf-grid { column-gap: 0; }
.mf-env-aligned .mf-cell:nth-child(odd), .mf-env-align .mf-cell:nth-child(odd) { text-align: right; }
.mf-accent { display: inline-block; position: relative; padding-top: .28em; vertical-align: baseline; }
.mf-mark { position: absolute; left: 0; right: 0; top: -.12em; text-align: center; font-size: .8em; line-height: 1; font-style: normal; pointer-events: none; }
.mf-accent-overline > .mf-row, .mf-accent-bar > .mf-row { border-top: .06em solid currentColor; }
.mf-accent-overline > .mf-mark, .mf-accent-bar > .mf-mark { display: none; }
.mf-accent-underline > .mf-row { border-bottom: .06em solid currentColor; }
.mf-style.is-text, .mf-mathrm, .mf-operatorname { font-style: normal; }
.mf-style.is-text .mf-sym, .mf-mathrm .mf-c-var, .mf-operatorname .mf-c-var { font-style: normal; }
.mf-style.is-text .mf-row { white-space: pre; font-family: Cambria, Georgia, serif; }
.mf-mathbf, .mf-textbf, .mf-boldsymbol, .mf-bm { font-weight: 700; }
.mf-mathbf .mf-c-var { font-style: normal; }
.mf-mathcal .mf-c-var, .mf-mathscr .mf-c-var { font-family: "Segoe Script", "Apple Chancery", cursive; font-style: normal; }
.mf-mathbb .mf-c-var { font-style: normal; }
.mf-raw { display: inline-block; padding: 0 .1em; border-radius: 4px; background: color-mix(in srgb, currentColor 6%, transparent); vertical-align: middle; }
.mf-raw .math-pieces { display: inline-flex; margin: 0; padding: 0; }
.mf-raw.is-code { font: .6em ui-monospace, Consolas, monospace; }

@media (prefers-reduced-motion: reduce) { .mf.is-focused .mf-caret { animation: none; } }

/* How a page is read (desktop/ui/pdf.ts) and who reads it: the same choice cards and "Read by" pill on every host, matching the Try page's photo choice. */
.pdf-modes { gap: 8px; }
.pdf-modes .pdf-mode { padding: 10px 12px; border: 1px solid var(--border-subtle); border-radius: 10px; background: var(--bg); line-height: 1.5; cursor: pointer; transition: border-color .12s ease, background .12s ease; }
.pdf-modes .pdf-mode:hover { border-color: var(--brand); }
.pdf-modes .pdf-mode:has(input:checked) { border-color: var(--brand); background: var(--brand-tint, var(--bg-subtle)); }
.pdf-modes .pdf-mode:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.pdf-modes .pdf-mode input { accent-color: var(--brand); }
.pdf-modes .pdf-engine { display: inline-flex; flex-wrap: wrap; align-items: center; justify-self: start; gap: 4px; margin-top: 2px; padding: 4px; border: 1px solid var(--border-subtle); border-radius: 999px; background: var(--bg); }
.pdf-modes .pdf-engine[hidden] { display: none; }
.pdf-engine-label { padding: 0 8px 0 10px; color: var(--fg-muted); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.pdf-engine-option { position: relative; padding: 6px 14px; border-radius: 999px; color: var(--fg-secondary); font-weight: 600; cursor: pointer; }
.pdf-engine-option:hover { background: var(--bg-hover); color: var(--fg); }
.pdf-engine-option input { position: absolute; opacity: 0; pointer-events: none; }
.pdf-engine-option:has(input:checked) { background: var(--brand); color: #fff; }
.pdf-engine-option:has(input:focus-visible) { outline: 3px solid var(--brand); outline-offset: 2px; }
.pdf-engine-option:has(input:disabled) { opacity: .45; cursor: not-allowed; }
.pdf-engine-option:has(input:disabled):hover { background: transparent; color: var(--fg-secondary); }
/* Not enough AI credits (frontend/src/credits-offer.ts). */
.credits-offer { display: grid; gap: 10px; margin: 10px 0; padding: 14px 16px; border: 1px solid var(--warn-border, var(--border-subtle)); border-radius: 12px; background: var(--warn-bg, var(--bg-subtle)); color: var(--fg); line-height: 1.5; }
.credits-offer[hidden] { display: none; }
.credits-offer p { margin: 0; }
.credits-offer-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.credits-offer-actions .btn { text-decoration: none; }
