/* Speak web app. Tokens match the extension (data/interface/index.css): electric blue → orange
   on deep navy, light by default, dark via prefers-color-scheme or html[data-theme]. Mobile first. */
:root {
  color-scheme: light;
  --brand-blue: #2F7BFF;
  --brand-orange: #FF6A2B;
  --brand-navy: #0E1730;
  --gradient: linear-gradient(90deg, #2F7BFF 0%, #8B6CF0 55%, #FF6A2B 100%);
  --gradient-hover: linear-gradient(90deg, #2468E6 0%, #7A5BE0 55%, #F05A1C 100%);

  --background: #F5F7FB;
  --card: #FFFFFF;
  --popover: #FFFFFF;
  --foreground: #0E1730;
  --muted: #EEF1F7;
  --muted-hover: #E4E8F1;
  --muted-foreground: #5F6B85;
  --subtle-foreground: #8D97AD;
  --border: #E2E6EF;
  --input: #D5DBE7;
  --ring: #2F7BFF;

  --accent: #2F7BFF;
  --accent-hover: #1F68E8;
  --accent-foreground: #FFFFFF;
  --accent-soft: rgba(47, 123, 255, 0.10);
  --accent-soft-2: rgba(47, 123, 255, 0.18);
  --accent-text: #1F5FD6;
  --orange: #FF6A2B;
  --orange-soft: rgba(255, 106, 43, 0.14);
  --orange-text: #B4420F;
  --success: #16A34A;
  --success-soft: rgba(22, 163, 74, 0.12);
  --success-text: #15803D;
  --danger: #E5484D;
  --rec: #E5484D;
  --warn: #D99A2B;

  --hl-line: rgba(47, 123, 255, 0.08);
  --hl-line-bar: #2F7BFF;
  --hl-word-bg: #FFE1D1;
  --hl-word-fg: #8A2E07;
  --hl-sentence-bg: #DCE8FF;
  --hl-sentence-fg: #12357A;

  --toast-bg: #0E1730;
  --toast-fg: #F4F6FB;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-full: 999px;
  --shadow-xs: 0 1px 2px rgba(14, 23, 48, 0.05);
  --shadow-sm: 0 1px 3px rgba(14, 23, 48, 0.08), 0 1px 2px rgba(14, 23, 48, 0.04);
  --shadow-lg: 0 12px 32px -8px rgba(14, 23, 48, 0.28), 0 4px 10px -4px rgba(14, 23, 48, 0.12);
  --focus-ring: 0 0 0 2px var(--card), 0 0 0 4px var(--ring);

  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --tap: 44px;
  --tabbar-h: 64px;
  --top-h: 61px; /* header height on wide screens: the Reader's column heads stick under it */
  --gutter: 16px;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%238D97AD' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --background: #0A1124; --card: #101A34; --popover: #131F3D; --foreground: #E8EDF8;
    --muted: #17233F; --muted-hover: #1E2C4D; --muted-foreground: #9AA6C2; --subtle-foreground: #6E7A97;
    --border: #213052; --input: #2A3B62; --ring: #4B8DFF;
    --accent: #3A8DFF; --accent-hover: #5A9FFF; --accent-soft: rgba(58, 141, 255, 0.14); --accent-soft-2: rgba(58, 141, 255, 0.24); --accent-text: #8DB8FF;
    --orange-soft: rgba(255, 106, 43, 0.18); --orange-text: #FFB089;
    --success-soft: rgba(34, 197, 94, 0.16); --success-text: #6EE7A0;
    --hl-line: rgba(58, 141, 255, 0.12); --hl-line-bar: #3A8DFF;
    --hl-word-bg: rgba(255, 106, 43, 0.32); --hl-word-fg: #FFE3D4;
    --hl-sentence-bg: rgba(58, 141, 255, 0.28); --hl-sentence-fg: #DCE8FF;
    --toast-bg: #E8EDF8; --toast-fg: #0E1730;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.30);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.40), 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 14px 36px -8px rgba(0, 0, 0, 0.60), 0 4px 12px -4px rgba(0, 0, 0, 0.40);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #0A1124; --card: #101A34; --popover: #131F3D; --foreground: #E8EDF8;
  --muted: #17233F; --muted-hover: #1E2C4D; --muted-foreground: #9AA6C2; --subtle-foreground: #6E7A97;
  --border: #213052; --input: #2A3B62; --ring: #4B8DFF;
  --accent: #3A8DFF; --accent-hover: #5A9FFF; --accent-soft: rgba(58, 141, 255, 0.14); --accent-soft-2: rgba(58, 141, 255, 0.24); --accent-text: #8DB8FF;
  --orange-soft: rgba(255, 106, 43, 0.18); --orange-text: #FFB089;
  --success-soft: rgba(34, 197, 94, 0.16); --success-text: #6EE7A0;
  --hl-line: rgba(58, 141, 255, 0.12); --hl-line-bar: #3A8DFF;
  --hl-word-bg: rgba(255, 106, 43, 0.32); --hl-word-fg: #FFE3D4;
  --hl-sentence-bg: rgba(58, 141, 255, 0.28); --hl-sentence-fg: #DCE8FF;
  --toast-bg: #E8EDF8; --toast-fg: #0E1730;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.30);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.40), 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 14px 36px -8px rgba(0, 0, 0, 0.60), 0 4px 12px -4px rgba(0, 0, 0, 0.40);
}

/* ═══ Base ═══ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  background: var(--background);
  color: var(--foreground);
  font: 15px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
button, select, input, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
::selection { background: var(--accent-soft-2); }
[hidden] { display: none !important; }
* { scrollbar-width: thin; scrollbar-color: var(--input) transparent; }
h2 { font-size: 18px; margin: 0 0 4px; }
.muted { color: var(--muted-foreground); }
.note { color: var(--muted-foreground); font-size: 13px; margin: 8px 0 0; }
kbd { font: 12px var(--font-mono); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: var(--muted); }
code { font: 600 16px var(--font-mono); letter-spacing: .1em; }

/* ═══ Controls ═══ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 14px;
  font-size: 14px; font-weight: 600; line-height: 1.2; text-decoration: none; white-space: nowrap;
  color: var(--foreground); background: var(--card);
  border: 1px solid var(--input); border-radius: var(--radius); cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms;
}
.btn:hover { background: var(--muted); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn.primary { background: var(--gradient); border-color: transparent; color: #fff; }
.btn.primary:hover { background: var(--gradient-hover); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { min-height: 36px; padding: 0 10px; font-size: 13px; }
.btn.icon { padding: 0; width: var(--tap); }
.btn.block { width: 100%; }
.btn.big { min-height: 52px; font-size: 16px; padding: 0 24px; }
.btn small { font-weight: 500; opacity: .85; }
.btn.on { background: var(--accent-soft-2); border-color: var(--accent); color: var(--accent-text); }
.icon-btn {
  display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); flex-shrink: 0;
  border: 0; border-radius: var(--radius); background: transparent; color: var(--muted-foreground); cursor: pointer; font-size: 16px;
}
.icon-btn:hover { background: var(--muted); color: var(--foreground); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .ic-moon { fill: currentColor; stroke: none; }
.ic-sun { display: none; }
:root[data-theme="dark"] .ic-sun { display: block; }
:root[data-theme="dark"] .ic-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ic-sun { display: block; }
  :root:not([data-theme="light"]) .ic-moon { display: none; }
}
.link { color: var(--accent-text); font-weight: 600; text-decoration: none; background: none; border: 0; padding: 0; cursor: pointer; font-size: inherit; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--subtle-foreground); font-weight: 500; text-decoration: underline; display: block; margin: 8px auto 0; min-height: var(--tap); }
.link.danger:hover { color: var(--danger); }
select, input[type=text], input[type=password], input[type=number], input[type=email], input[type=search], input:not([type]) {
  min-height: var(--tap); min-width: 0; width: 100%;
  font-size: 16px; /* 16px stops iOS from zooming on focus */
  background: var(--card); color: var(--foreground);
  border: 1px solid var(--input); border-radius: var(--radius); padding: 0 12px;
}
select { appearance: none; -webkit-appearance: none; padding-right: 30px; background: var(--card) var(--chevron) no-repeat right 12px center; text-overflow: ellipsis; }
select:focus-visible, input:focus-visible, textarea:focus-visible { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px var(--accent-soft-2); }
input[type=range] { width: 100%; accent-color: var(--accent); min-height: 32px; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; }
.field { display: grid; gap: 4px; min-width: 0; font-size: 13px; color: var(--muted-foreground); font-weight: 600; }
.field b { color: var(--foreground); font-variant-numeric: tabular-nums; }
.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); cursor: pointer; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.tight { gap: 4px; flex-wrap: nowrap; }
.row > input { flex: 1 1 160px; width: auto; }
.grid2 { display: grid; gap: 12px; grid-template-columns: 1fr; }
.sec-label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--subtle-foreground); margin: 18px 0 8px; }
.sec-label:first-child { margin-top: 0; }
.chip {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: var(--radius-full);
  border: 1px solid var(--border); background: var(--card); color: var(--foreground); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip:hover, .goal-chip:hover { border-color: var(--accent); }
.goal-chip.done { background: var(--success-soft); border-color: transparent; color: var(--success-text); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 16px; }
.chips span { font-size: 12px; padding: 3px 10px; border-radius: var(--radius-full); background: var(--muted); color: var(--muted-foreground); }

/* ═══ Header and tabs ═══ */
.top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  padding: 8px var(--gutter); padding-top: max(8px, env(safe-area-inset-top));
  background: var(--background);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--foreground); text-decoration: none; font-weight: 800; font-size: 18px; letter-spacing: -.01em; min-height: var(--tap); }
.brand img { border-radius: 7px; display: block; }
.top-end { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.top .goal-chip { display: none; }
.account-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 0 12px; max-width: 150px;
  border: 1px solid var(--input); border-radius: var(--radius-full); background: var(--card); color: var(--foreground); font-size: 14px; font-weight: 600; cursor: pointer;
}
.account-btn img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; margin-left: -6px; background: var(--muted); }
.account-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-btn.in { padding: 0 12px 0 8px; }

/* Phones: tab bar along the bottom */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px -8px rgba(14, 23, 48, .15);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: transparent; color: var(--muted-foreground); font-size: 12px; font-weight: 600; cursor: pointer; min-width: 0;
}
.tab-ic { font-size: 20px; line-height: 1; filter: grayscale(1); opacity: .75; }
.tab[aria-selected="true"] { color: var(--accent-text); }
.tab[aria-selected="true"] .tab-ic { filter: none; opacity: 1; }
.tab[aria-selected="true"]::after { content: ""; display: block; width: 24px; height: 3px; border-radius: 2px; background: var(--gradient); margin-top: 2px; }

main { padding: 16px var(--gutter) calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px); }
.panel { margin: 0 auto; display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.panel > * { min-width: 0; }
.panel.narrow { max-width: 760px; }
.panel.wide { max-width: 1240px; }

/* ═══ Cards ═══ */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.card.pad { padding: 16px; }
details.card > summary { cursor: pointer; padding: 0 16px; min-height: 52px; display: flex; align-items: center; font-weight: 700; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: ""; margin-left: auto; width: 10px; height: 10px; background: var(--chevron) no-repeat center; transition: transform 150ms; }
details[open].card > summary::after { transform: rotate(180deg); }
.ext-note { margin: 0; font-size: 13px; color: var(--muted-foreground); text-align: center; padding: 0 8px; }

/* ═══ Dictate ═══ */
.controls { display: flex; align-items: center; gap: 14px; padding: 16px; }
.mic {
  width: 64px; height: 64px; border-radius: 50%; border: 0; cursor: pointer; flex-shrink: 0;
  background: var(--gradient); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 18px -6px rgba(47, 123, 255, .6);
  transition: transform .1s;
}
.mic:active { transform: scale(.96); }
.mic:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.mic svg { width: 28px; height: 28px; }
body[data-state="recording"] .mic { background: var(--rec); box-shadow: none; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--rec) 45%, transparent); } 50% { box-shadow: 0 0 0 12px transparent; } }
.status { flex: 1; min-width: 0; }
.status b { display: block; font-size: 16px; }
.status small { color: var(--muted-foreground); font-size: 13px; }
.lang-pill { display: none; font-size: 12px; font-weight: 600; color: var(--muted-foreground); background: var(--muted); border-radius: var(--radius-full); padding: 4px 10px; white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.kbd-only { display: none; }
.quota { padding: 12px 16px; border-top: 1px solid var(--border); display: grid; gap: 6px; font-size: 13px; }
.quota-head, .quota-foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.quota-head span:first-child { font-weight: 700; }
#quotaUsed { font-variant-numeric: tabular-nums; }
.quota-foot { color: var(--muted-foreground); }
.gauge { height: 8px; border-radius: var(--radius-full); background: var(--muted); overflow: hidden; }
.gauge-fill { height: 100%; width: 0; background: var(--gradient); border-radius: var(--radius-full); transition: width .4s; }
.quota[data-level="warn"] .gauge-fill { background: var(--warn); }
.quota[data-level="full"] .gauge-fill { background: var(--rec); }
.limit { padding: 16px; border-top: 1px solid var(--border); display: grid; gap: 8px; justify-items: start; background: color-mix(in srgb, var(--rec) 8%, var(--card)); }
.limit span { color: var(--muted-foreground); font-size: 14px; }
.unsupported { display: none; padding: 14px 16px; border-top: 1px solid var(--border); background: var(--accent-soft); font-size: 14px; }
.unsupported b { display: block; margin-bottom: 2px; }
.unsupported span { color: var(--muted-foreground); }
body[data-unsupported] .unsupported { display: grid; }
body[data-unsupported] .quota, body[data-unsupported] .limit { display: none; }
/* Paid plans: no nudges, no upgrade links, no ad slot */
body[data-paid] [data-free-only], body[data-paid] .ad-slot { display: none !important; }

/* Time-saved meter (FR-4.x) */
.meter { padding: 12px 16px; display: grid; gap: 8px; }
.meter-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.meter-stats > div { display: grid; min-width: 0; }
.meter-stats b { font-size: 18px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meter-stats > div:first-child b { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.meter-stats small { font-size: 11.5px; color: var(--muted-foreground); line-height: 1.25; }
.meter-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--subtle-foreground); border-top: 1px solid var(--border); padding-top: 8px; }
.meter-foot .link { font-size: 13px; }

/* Mic level meter */
.level { height: 4px; margin-top: 6px; border-radius: var(--radius-full); background: var(--muted); overflow: hidden; max-width: 220px; }
.level span { display: block; height: 100%; background: var(--gradient); transform: scaleX(0); transform-origin: left center; transition: transform 60ms linear; }

/* Polish notices, the upgrade prompt, the display ad slot */
.polish-note { padding: 10px 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted-foreground); }
.polish-note.warn { background: color-mix(in srgb, var(--warn) 12%, var(--card)); color: var(--foreground); }
.polish-note.info { background: var(--accent-soft); color: var(--foreground); }
/* Translate after I speak: the note with "Show original", and the text before translation */
.tr-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.tr-bar span { min-width: 0; overflow-wrap: anywhere; }
.tr-original { margin: 0; padding: 10px 16px; border-top: 1px solid var(--border); background: var(--muted); color: var(--muted-foreground); font-size: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.upsell { padding: 14px 16px; border-top: 1px solid var(--border); display: grid; gap: 8px; justify-items: start; background: var(--orange-soft); }
.upsell span { color: var(--muted-foreground); font-size: 14px; }
.ad-slot { border-top: 1px solid var(--border); padding: 12px 16px 14px; display: grid; gap: 6px; }
.ad-card { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px dashed var(--input); border-radius: var(--radius); background: var(--muted); }
.ad-card .ad-tag { margin-top: 2px; }
.ad-card-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.ad-card-sponsor { font-size: 14px; }
.ad-card-text { margin: 0; font-size: 13px; color: var(--muted-foreground); line-height: 1.45; }
.ad-card .ad-more { margin: -6px -6px 0 0; }
.ad-card-foot { font-size: 12px; color: var(--subtle-foreground); text-align: right; }
.ad-card-foot a { color: var(--accent-text); font-weight: 600; }

/* AdSense lives in a sandboxed iframe from another origin (never in this document) */
.ad-frame-body { width: 100%; }
.ad-frame { display: block; width: 100%; height: 100px; border: 0; background: transparent; }
.turnstile-box { padding: 12px 16px; border-top: 1px solid var(--border); }
/* One-time questions: adopt this device's dictations, clear it after signing out */
.prompt { display: grid; gap: 10px; border-color: var(--accent); background: var(--accent-soft); font-size: 14px; }
/* A shared link: one big Play (the tap browsers need before they speak) loads the article and starts reading */
.prompt-play { justify-content: center; align-items: center; }
.prompt-play #rd_incomingYes { min-width: 160px; min-height: 52px; font-size: 18px; }
@media (max-width: 420px) { .brand span { font-size: 15px; line-height: 1.15; } }
@media (max-width: 359px) { .brand span { display: none; } }

/* History search, item actions */
.hist-count { color: var(--subtle-foreground); font-weight: 600; margin-left: 6px; }
.hist-bar { display: flex; gap: 8px; padding: 0 16px 12px; }
.hist-bar input { flex: 1 1 auto; }
.hist-bar .btn { flex: 0 0 auto; min-height: var(--tap); }
.hist-meta { display: flex; flex-wrap: wrap; gap: 0 8px; color: var(--muted-foreground); font-size: 12px; }
.hist-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.hist-actions .btn { min-height: 34px; font-size: 12.5px; padding: 0 10px; }
.hist-note { padding: 0 16px 16px; margin: 0; }
.hist-note:empty { display: none; }
.editor { border-top: 1px solid var(--border); }
#text {
  display: block; width: 100%; min-height: 38vh; resize: vertical; border: 0; outline: none; background: transparent;
  color: var(--foreground); font-size: 17px; line-height: 1.6; padding: 16px;
}
.interim { color: var(--subtle-foreground); font-style: italic; padding: 0 16px 12px; min-height: 1.6em; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--border); }
.actions .btn { padding: 0 8px; }
.actions .btn.icon { width: auto; }
@media (min-width: 720px) { .label-sm { display: none; } }
.history { list-style: none; margin: 0; padding: 0 16px 16px; display: grid; gap: 8px; }
.history li { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; min-height: var(--tap); }
.history li:hover { border-color: var(--accent); }
.history li.empty { cursor: default; color: var(--muted-foreground); }
.history time { display: block; color: var(--muted-foreground); font-size: 12px; }
.history p { margin: 2px 0 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }

/* ═══ Reader ═══ */
#rd_input, #rd_reader { display: grid; gap: 12px; min-width: 0; }
.rd-bar { display: grid; gap: 12px; padding: 12px 16px; grid-template-columns: 1fr; }
.rd-bar-end { display: flex; gap: 8px; flex-wrap: wrap; }
.rd-bar-end .btn { flex: 1 1 auto; }
.rd-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
.rd-col { display: flex; flex-direction: column; overflow: hidden; }
.rd-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.rd-head-group { display: flex; gap: 6px; align-items: center; flex: 1 1 auto; justify-content: flex-end; min-width: 0; }
.rd-head-group select { width: auto; flex: 1 1 120px; max-width: 200px; min-height: 36px; font-size: 14px; }
.rd-col textarea {
  display: block; width: 100%; min-height: 28vh; resize: vertical; border: 0; background: transparent; padding: 12px 16px;
  color: var(--foreground); font-size: 16px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere;
}
.rd-col textarea:focus-visible { box-shadow: none; }
.rd-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: space-between; }
.seg { display: inline-flex; background: var(--muted); border-radius: var(--radius); padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted-foreground); font-size: 13px; font-weight: 600; padding: 0 10px; min-height: 38px; border-radius: 7px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--foreground); box-shadow: var(--shadow-xs); }
#rd_reader[data-single] .seg { display: none; }

/* Phones: each pair stacks — the translation sits right under its line */
.rd-split { display: grid; grid-template-columns: 1fr; align-content: start; font-size: 17px; line-height: 1.6; }
.rd-split > .rd-line:last-child { border-bottom: 0; }
.rd-col-head { display: none; }
.rd-line {
  display: block; padding: 10px 16px 2px; cursor: pointer; overflow-wrap: anywhere; min-height: 1.6em;
  transition: background 100ms, color 100ms, box-shadow 100ms;
}
.rd-line[data-pane="target"] { color: var(--muted-foreground); padding: 0 16px 12px; border-bottom: 1px solid var(--border); font-size: 15px; }
.rd-split[data-view="source"] .rd-line[data-pane="target"],
.rd-split[data-view="target"] .rd-line[data-pane="source"] { display: none; }
.rd-split[data-view="source"] .rd-line[data-pane="source"],
.rd-split[data-view="target"] .rd-line[data-pane="target"],
.rd-split[data-single] .rd-line[data-pane="source"] { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.rd-split[data-view="target"] .rd-line[data-pane="target"] { color: var(--foreground); font-size: 17px; }
.rd-split[data-single] .rd-line[data-pane="target"] { display: none; }
@media (hover: hover) { .rd-line:hover { background: var(--hl-line); } }
@media (hover: none) {
  /* Long-press picks a word, so keep the system's text-selection menu out of the way */
  .rd-line { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
}
.rd-line.active { background: var(--hl-line); color: var(--foreground); box-shadow: inset 3px 0 0 var(--hl-line-bar); }
.rd-word, .rd-sentence, .rd-pick { border-radius: 3px; padding: 0 2px; margin: 0 -2px; }
.rd-word { background: var(--hl-word-bg); color: var(--hl-word-fg); }
.rd-sentence { background: var(--hl-sentence-bg); color: var(--hl-sentence-fg); }
.rd-pick { background: var(--accent); color: #fff; }
.rd-controls {
  position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); z-index: 10;
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 12px; flex-wrap: wrap; box-shadow: var(--shadow-lg);
  border-radius: 28px;
}
/* Simple player (owner request): one bold Play, round secondary buttons, no next / previous */
.rd-controls .ctrl:not(.primary) { border-radius: var(--radius-full); padding: 0 12px; }
.rd-controls .ctrl.primary { border-radius: var(--radius-full); padding: 0 22px; font-size: 16px; }
.ctrl {
  min-height: var(--tap); min-width: var(--tap); padding: 0 10px; border-radius: var(--radius);
  border: 1px solid var(--input); background: var(--card); color: var(--foreground); font-size: 15px; font-weight: 600; cursor: pointer;
}
.ctrl:hover { background: var(--muted); }
.ctrl.primary { background: var(--gradient); color: #fff; border-color: transparent; flex: 0 0 auto; min-width: 120px; }
.rd-hint { flex-basis: 100%; text-align: center; font-size: 12px; color: var(--subtle-foreground); }
/* Reading speed, with the player controls (owner request) */
.rd-speed { display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 0 6px; font-size: 13px; font-weight: 600; color: var(--muted-foreground); }
.rd-speed b { color: var(--foreground); min-width: 3ch; display: inline-block; }
.rd-speed input { width: 110px; }
/* "Fetching the article…" under Generate */
.rd-status { margin: 0; text-align: center; font-size: 14px; font-weight: 600; color: var(--accent-text); }

/* Word popup: a bottom sheet on phones, a popover on wide screens */
#wordpop {
  position: fixed; z-index: 60; left: 8px; right: 8px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px);
  background: var(--popover); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 14px 16px; display: grid; gap: 6px;
}
.pop-word { font-weight: 800; font-size: 20px; overflow-wrap: anywhere; }
.pop-tr { color: var(--muted-foreground); font-size: 16px; overflow-wrap: anywhere; }
#wordpop .row .btn { flex: 1 1 auto; }

/* ═══ Coach ═══ */
.coach { padding: 24px 16px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.coach p { margin: 0; max-width: 520px; }
.coach-count { display: grid; justify-items: center; line-height: 1; margin: 8px 0; }
.coach-count span { font-size: 72px; font-weight: 800; font-variant-numeric: tabular-nums; background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.coach-count small { color: var(--muted-foreground); font-size: 13px; margin-top: 6px; }
.coach-last { min-height: 1.5em; font-weight: 600; overflow-wrap: anywhere; }
.coach-last.hit { color: var(--orange-text); }
.coach-last.clean { color: var(--success-text); }
.coach-interim { min-height: 1.5em; color: var(--subtle-foreground); font-style: italic; overflow-wrap: anywhere; }
body[data-coach="on"] #coachBtn { background: var(--rec); }

/* ═══ Friends ═══ */
.goal-pick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.goal-pick .btn { width: var(--tap); padding: 0; }
.goal-pick span { color: var(--muted-foreground); }
.goal-summary { margin-top: 12px; font-weight: 700; }
.week { display: flex; gap: 6px; margin-top: 12px; }
.week span { flex: 1; text-align: center; font-size: 12px; font-weight: 700; color: var(--subtle-foreground); padding: 8px 0; border-radius: var(--radius-sm); background: var(--muted); }
.week span.met { background: var(--success); color: #fff; }
.week span.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.fb {
  width: 100%; min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 16px; font-weight: 700; color: #fff; background: #1877F2; border: 0; border-radius: var(--radius); cursor: pointer;
}
.fb svg { width: 22px; height: 22px; }
.fb:hover { background: #166FE5; }
.fb:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.fb:disabled { opacity: .6; cursor: default; }
.signin-row > input { flex: 1 1 200px; }
.signin-row .btn { flex: 1 1 auto; }
#otp { font-family: var(--font-mono); letter-spacing: .3em; }
.or { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--subtle-foreground); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.plan-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; padding: 10px 12px; border-radius: var(--radius); background: var(--muted); font-size: 14px; }
.me { display: flex; align-items: center; gap: 10px; }
.me img, .friend img { width: 36px; height: 36px; border-radius: 50%; background: var(--muted); object-fit: cover; flex-shrink: 0; border: 1px solid var(--border); }
#meName { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--accent-soft); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 10px; }
.invite code { font-size: 20px; }
.add-friend { margin: 10px 0 0; }
.add-friend input { text-transform: uppercase; font-family: var(--font-mono); letter-spacing: .08em; }
.friend { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); min-height: 52px; }
.friend:last-child { border-bottom: 0; }
.friend-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-stat { white-space: nowrap; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.friend.met .friend-stat { color: var(--success-text); font-weight: 700; }
.friend .icon-btn:hover { color: var(--danger); }
.board-note { color: var(--muted-foreground); font-size: 13px; padding: 8px 0 0; }
/* Board: Today | This week, the rank line, two-line rows (name, then the numbers), the big count */
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.board-rank { font-weight: 700; padding: 8px 12px; margin-bottom: 4px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent-text); }
.friend-who { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.friend-who .friend-stat { white-space: normal; font-size: 12.5px; overflow-wrap: anywhere; }
.friend.met .friend-who .friend-stat { font-weight: 600; }
.friend.me .friend-name { font-weight: 700; }
.friend-count { flex-shrink: 0; min-width: 32px; text-align: right; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.board-empty { display: grid; gap: 8px; justify-items: start; margin-top: 10px; padding: 12px; border: 1px dashed var(--input); border-radius: var(--radius); }
.board-empty p { margin: 0; color: var(--muted-foreground); font-size: 14px; }

/* ═══ Sheets: full screen on phones, a dialog / side drawer on wide screens ═══ */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(7, 12, 28, .45); display: flex; }
.sheet-card { background: var(--card); width: 100%; height: 100%; display: flex; flex-direction: column; min-width: 0; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 8px 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); border-bottom: 1px solid var(--border); min-height: 60px;
}
.sheet-head strong { font-size: 16px; min-width: 0; }
.sheet-body { flex: 1; overflow-y: auto; padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.vocab-item { display: flex; align-items: center; gap: 4px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.vocab-text { flex: 1; min-width: 0; display: grid; }
.vocab-word { font-weight: 700; overflow-wrap: anywhere; }
.vocab-tr { color: var(--muted-foreground); font-size: 14px; overflow-wrap: anywhere; }
.vocab-empty { color: var(--muted-foreground); text-align: center; padding: 32px 8px; }

/* ═══ What each feature does: ⓘ buttons, the ⓘ sheet, the ? panel list, the first-run tour ═══ */
/* ⓘ sits inside each tab's own card, beside what it explains (owner request) */
.info-btn {
  display: inline-grid; place-items: center; flex: 0 0 auto; width: 36px; height: 36px; min-height: 36px; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius-full); background: var(--card);
  color: var(--accent-text); font-size: 17px; font-weight: 600; line-height: 1; cursor: pointer;
}
.controls .info-btn, .rd-tools .info-btn { margin-left: auto; }
.info-btn.corner { position: absolute; top: 10px; right: 10px; }
.coach { position: relative; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.sec-head .sec-label { margin: 0; }
.info-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.info-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.feature-row { display: grid; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; line-height: 1.5; }
.feature-row:last-child { border-bottom: 0; }
.feature-row b { color: var(--foreground); }
.feature-row span { color: var(--muted-foreground); }
.help-features { padding: 0 16px 4px; }
.help-features .feature-row { font-size: 13px; padding: 6px 0; }
.feature-group { font-size: 12px; font-weight: 700; color: var(--accent-text); padding-top: 10px; }
.help-features .feature-group + .feature-row { padding-top: 2px; }
.help-tour { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 12px 16px 0; padding: 10px 12px; border-radius: var(--radius); background: var(--accent-soft); font-size: 13px; color: var(--accent-text); }
/* The ⓘ sheet is short: a bottom sheet on phones */
.sheet.info { align-items: flex-end; }
.sheet.info .sheet-card { height: auto; max-height: 85vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow-lg); }
.sheet.info .sheet-head { padding-top: 8px; }

.tour {
  position: fixed; inset: 0; z-index: 55; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(7, 12, 28, .45); animation: toast-in 160ms ease-out;
}
.tour-card {
  width: 100%; max-height: 88vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--popover); color: var(--foreground); border: 1px solid var(--border); border-bottom: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow-lg);
  padding: 8px 16px max(16px, env(safe-area-inset-bottom));
}
.tour-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tour-step { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--subtle-foreground); }
.tour-head .icon-btn { margin-right: -8px; }
.tour-title { display: flex; align-items: center; gap: 10px; font-size: 20px; margin: 0 0 4px; }
.tour-ic { font-size: 26px; line-height: 1; }
.tour-body .feature-row { font-size: 15px; }
.tour-body .feature-row span { color: var(--foreground); }
.tour-dots { display: flex; justify-content: center; gap: 6px; margin: 10px 0 12px; }
.tour-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--input); }
.tour-dots span.on { width: 20px; border-radius: var(--radius-full); background: var(--gradient); }
.tour-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tour-gap { flex: 1; }
.tour-actions .btn { min-height: var(--tap); }

/* ═══ Toasts ═══ */
#toasts {
  position: fixed; z-index: 70; left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top) + 64px); width: min(420px, calc(100% - 32px));
  display: grid; gap: 8px; pointer-events: none;
}
.toast { background: var(--toast-bg); color: var(--toast-fg); border-radius: var(--radius); padding: 10px 14px; font-size: 14px; box-shadow: var(--shadow-lg); animation: toast-in 160ms ease-out; text-align: center; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

/* ═══ Shortcuts & help side panel (Alt+H) — ported from the extension's index.css ═══ */
#help_btn { position: relative; }
#help_btn > summary { list-style: none; font-weight: 800; font-size: 17px; }
#help_btn > summary::-webkit-details-marker { display: none; }
#help_btn[open] > summary { background: var(--muted); color: var(--foreground); }
/* The sticky header's blur and stacking would trap the fixed panel: lift both while it's open */
.top:has(#help_btn[open]) { z-index: 65; -webkit-backdrop-filter: none; backdrop-filter: none; }
.shortcuts-list {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 65;
  width: min(360px, 100vw); overflow-y: auto; overscroll-behavior: contain;
  background: var(--popover); border-left: 1px solid var(--border); box-shadow: -12px 0 32px -12px rgba(14, 23, 48, .35);
  padding: 0 0 max(16px, env(safe-area-inset-bottom));
  animation: drawer-in 160ms ease-out;
}
@keyframes drawer-in { from { transform: translateX(16px); opacity: 0; } }
.shortcuts-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 8px 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--popover); border-bottom: 1px solid var(--border); font-size: 16px; font-weight: 700;
}
.shortcuts-tip { margin: 12px 16px 0; padding: 10px 12px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent-text); font-size: 13px; line-height: 1.5; }
.shortcuts-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--subtle-foreground); padding: 14px 16px 4px; }
.shortcuts-title ~ .shortcuts-title { margin-top: 4px; border-top: 1px solid var(--border); }
.shortcut-row { display: flex; align-items: center; gap: 10px; padding: 4px 16px; font-size: 13px; }
.shortcut-row > kbd {
  flex-shrink: 0; min-width: 108px; max-width: 140px; padding: 3px 6px; text-align: center; white-space: normal;
  font: 600 11.5px/1.3 var(--font-mono); color: var(--foreground); background: var(--muted);
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: var(--radius-sm);
}
.shortcut-row > span { color: var(--muted-foreground); min-width: 0; }
.shortcuts-tip kbd, .shortcut-row span kbd { font-size: 11px; padding: 0 4px; background: var(--card); }
body[data-touch] .keys-only { display: none; }
@media (hover: none) { .keys-only { display: none; } }

/* Key tips: letter badges drawn over buttons while Alt is held (keytips.js) */
.keytips-layer { position: fixed; inset: 0; pointer-events: none; z-index: 200; }
.keytip {
  position: fixed; min-width: 18px; height: 18px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  font: 700 11px/1 var(--font-mono); color: #FFFFFF; background: var(--brand-navy);
  border: 1px solid var(--brand-blue); border-radius: 4px; box-shadow: var(--shadow-sm);
  animation: keytip-in 90ms ease-out;
}
.keytip.global { background: var(--gradient); border-color: transparent; }
@keyframes keytip-in { from { opacity: 0; transform: translateY(2px); } }

/* ═══ Audio ad bar (free plan, ads.js) — same look as .ad-bar in the extension's index.css ═══ */
.ad-bar {
  position: fixed; z-index: 45; left: 0; right: 0; margin: 0 auto;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 10px);
  width: min(520px, calc(100vw - 2 * var(--gutter)));
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 10px;
  background: var(--popover); color: var(--foreground);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  animation: toast-in 160ms ease-out;
}
.ad-tag {
  flex-shrink: 0; padding: 3px 7px; border-radius: var(--radius-sm);
  background: #FFC83D; color: #0E1730; font: 800 11px/1.2 var(--font-sans); letter-spacing: .06em; text-transform: uppercase;
}
.ad-text { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.ad-sponsor { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-sub { font-size: 12px; color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-time:not(:empty)::before { content: " · "; }
.ad-sub a { color: var(--accent-text); font-weight: 600; }
.ad-more { flex-shrink: 0; display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 8px; border-radius: var(--radius); font-size: 13px; font-weight: 600; color: var(--accent-text); text-decoration: none; }
.ad-more:hover { background: var(--accent-soft); }
.ad-skip {
  flex-shrink: 0; min-width: 86px; min-height: var(--tap); padding: 0 12px;
  font-size: 13px; font-weight: 700; border: 1px solid var(--input); border-radius: var(--radius); background: var(--card); cursor: pointer;
}
.ad-skip:hover:not(:disabled) { background: var(--muted); }
.ad-skip:disabled { cursor: default; color: var(--subtle-foreground); }
/* The Reader's controls stick to the bottom too: lift them above the bar while an ad runs */
html[data-ad] main { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 96px); }
html[data-ad] .rd-controls { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 80px); }
.ads-note { font-size: 12px; }
@media (max-width: 400px) { .ad-more { padding: 0 4px; } .ad-skip { min-width: 72px; padding: 0 8px; } .ad-spons { display: none; } }

/* ═══ Mobile anchor banner (§6 slot b, ads.anchor): a reserved strip above the tab bar, < 768 px only ═══ */
:root { --anchor-h: 62px; }
.ad-anchor {
  position: fixed; z-index: 39; left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  height: var(--anchor-h); display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 8px;
  background: var(--card); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px -10px rgba(14, 23, 48, .2);
}
.ad-anchor-slot { width: 320px; height: 50px; flex-shrink: 1; min-width: 0; overflow: hidden; }
.ad-frame.ad-frame-320x50 { width: 320px; height: 50px; }
.ad-anchor-side { display: grid; justify-items: center; gap: 4px; flex-shrink: 0; }
.ad-anchor-remove { font-size: 11px; font-weight: 600; color: var(--accent-text); white-space: nowrap; }
/* The strip is reserved: ads.anchor adds a spacer of its height at the end of <main> while it's up, and
   scrolling into view clears it */
.ad-anchor-spacer { display: block; }
@media (min-width: 768px) { .ad-anchor-spacer { display: none; } }
html[data-anchor] { scroll-padding-bottom: calc(var(--tabbar-h) + var(--anchor-h) + 8px); }
html[data-anchor] .ad-bar { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--anchor-h) + 10px); }
html[data-anchor] .rd-controls { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--anchor-h) + 8px); }
body[data-paid] .ad-anchor { display: none !important; }
@media (min-width: 720px) {
  .ad-anchor { bottom: 0; }
  html[data-anchor] { scroll-padding-bottom: calc(var(--anchor-h) + 8px); }
}
@media (min-width: 768px) { .ad-anchor { display: none !important; } }

/* Framed by one of our /for/ pages (frame-guard.js): no account, billing, delete or checkout in the frame,
   "Open the full app" instead. Framed by anything else: blank while it breaks out. */
.framed-only { display: none !important; }
html[data-framed] .framed-only { display: inline-flex !important; align-items: center; }
html[data-framed] #accountBtn, html[data-framed] #signedOut, html[data-framed] #signedIn, html[data-framed] #billing,
html[data-framed] #deleteData, html[data-framed] #upsellSignin, html[data-framed] #adoptBox, html[data-framed] #privDelBox,
html[data-framed] #plansSheet, html[data-framed] [data-plan], html[data-framed] [data-checkout],
html[data-framed] [data-ads-upgrade] { display: none !important; }
html[data-frame-blocked] body { display: none !important; }

/* Reader tools (phone first): Paste & read, Clear, and the detected source language. Big touch targets,
   one row that wraps instead of scrolling sideways. */
.rd-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.rd-tool { min-height: var(--tap); padding: 0 16px; font-size: 15px; }
.rd-tools #rd_paste { flex: 1 1 160px; }
.rd-tools #rd_clear { flex: 0 1 auto; }
.rd-tools #rd_share { flex: 0 1 auto; }
/* "Source: <host> ↗" above both Reader views, for an article from a link */
.rd-source-line { margin: 0; min-width: 0; font-size: 13px; color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-source-line a { color: var(--accent-text); font-weight: 600; text-decoration: none; }
.rd-source-line a:hover { text-decoration: underline; }
/* Share menu (a .sheet.info): the post that goes out, then one button per network */
.share-post { margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius); background: var(--muted); color: var(--foreground); font-size: 14px; overflow-wrap: anywhere; }
.share-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.rd-detected { flex: 1 1 100%; order: 1; font-size: 13px; color: var(--muted-foreground); }
.rd-detected b { color: var(--foreground); }
.rd-controls .ctrl { min-height: var(--tap); min-width: var(--tap); }
@media (min-width: 720px) {
  .rd-detected { flex: 0 1 auto; margin-left: auto; order: 0; }
  .rd-tools #rd_paste { flex: 0 0 auto; }
  .rd-tools .rd-detected:not([hidden]) ~ .info-btn { margin-left: 0; }
}

/* Collapsible settings (owner request): on phones a one-line summary, ≥44 px, that opens the controls;
   on desktop (≥768 px) always open, summary hidden, same layout as before */
.rd-settings { min-width: 0; }
.rd-settings-sum {
  display: flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 0 4px; cursor: pointer;
  font-weight: 600; font-size: 14px; list-style: none; border-radius: var(--radius); min-width: 0;
}
.rd-settings-sum::-webkit-details-marker { display: none; }
.rd-settings-sum::before { content: "⚙"; }
.rd-settings-sum::after { content: "▾"; margin-left: auto; color: var(--subtle-foreground); transition: transform .15s; }
.rd-settings[open] > .rd-settings-sum::after { transform: rotate(180deg); }
.rd-settings-sum:focus-visible { box-shadow: var(--focus-ring); outline: none; }
.rd-settings-sum span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.rd-settings-body { display: grid; gap: 12px; padding-top: 8px; min-width: 0; }
@media (min-width: 768px) {
  .rd-settings-sum { display: none; }
  .rd-settings-body { padding-top: 0; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: end; }
}
@media (min-width: 720px) { .rd-bar { grid-template-columns: minmax(0, 1fr) auto !important; } }

/* History banner (§6 slot e) and the plan picker */
.hist-ad { border-top: 0; padding: 4px 0 0; }
.ad-card-small .ad-frame { height: 60px; }
.plans-list { display: grid; gap: 12px; }
.plan-opt { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.plan-opt small { display: block; }
.seats-field { width: 96px; }
.seats-field input { width: 100%; }

/* ═══ Tablet and up ═══ */
/* Touch screens: every control at least 44px tall */
@media (pointer: coarse) {
  .btn.small, .chip, .seg button, .rd-head-group select { min-height: var(--tap); }
  .info-btn { width: var(--tap); height: var(--tap); }
}
@media (min-width: 720px) {
  :root { --gutter: 24px; }
  .top { background: color-mix(in srgb, var(--background) 88%, transparent); -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px); }
  .top { gap: 16px; }
  .tabs {
    position: static; height: auto; padding: 0; display: flex; gap: 2px;
    background: var(--muted); border: 0; border-radius: var(--radius); box-shadow: none; padding: 3px;
  }
  .tab { flex-direction: row; gap: 6px; min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 8px; }
  .tab-ic { font-size: 16px; }
  .tab[aria-selected="true"] { background: var(--card); color: var(--foreground); box-shadow: var(--shadow-xs); }
  .tab[aria-selected="true"]::after { display: none; }
  main { padding: 24px var(--gutter) 48px; }
  .actions { display: flex; flex-wrap: wrap; }
  .actions .btn.icon { width: var(--tap); margin-left: auto; }
  .lang-pill { display: inline-block; }
  .grid2 { grid-template-columns: 1fr 1fr; }
  .rd-bar { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; align-items: end; }
  .rd-bar-end .btn { flex: 0 0 auto; }
  .rd-grid { grid-template-columns: 1fr 1fr; }
  .rd-col textarea { min-height: 46vh; }
  /* Two aligned columns: one grid row per pair */
  .rd-split { grid-template-columns: 1fr 1fr; font-size: 16px; }
  .rd-col-head {
    display: block; position: sticky; top: var(--top-h); z-index: 2; padding: 8px 16px;
    font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--subtle-foreground);
    background: var(--muted); border-bottom: 1px solid var(--border);
  }
  .rd-col-head:first-child { border-right: 1px solid var(--border); border-top-left-radius: var(--radius-lg); }
  .rd-col-head:nth-child(2) { border-top-right-radius: var(--radius-lg); }
  .rd-split[data-view="source"] .rd-col-head:first-child, .rd-split[data-single] .rd-col-head:first-child { border-top-right-radius: var(--radius-lg); }
  .rd-split[data-view="target"] .rd-col-head:nth-child(2) { border-top-left-radius: var(--radius-lg); }
  .rd-line, .rd-line[data-pane="target"] { padding: 6px 16px 14px; border-bottom: 1px solid var(--border); font-size: inherit; }
  .rd-line[data-pane="source"] { border-right: 1px solid var(--border); }
  .rd-split[data-view="source"], .rd-split[data-view="target"], .rd-split[data-single] { grid-template-columns: 1fr; font-size: 17px; max-width: 820px; margin: 0 auto; width: 100%; }
  .rd-split[data-view="source"] .rd-col-head:nth-child(2), .rd-split[data-single] .rd-col-head:nth-child(2),
  .rd-split[data-view="target"] .rd-col-head:first-child { display: none; }
  .rd-split[data-view] .rd-col-head:first-child, .rd-split[data-view="source"] .rd-line, .rd-split[data-single] .rd-line { border-right: 0; }
  .rd-split[data-view="both"]:not([data-single]) .rd-col-head:first-child, .rd-split[data-view="both"]:not([data-single]) .rd-line[data-pane="source"] { border-right: 1px solid var(--border); }
  /* Player controls centred under the text (owner request): a pill in the middle, the hint under it */
  .rd-controls { bottom: 16px; width: fit-content; max-width: 100%; margin-left: auto; margin-right: auto; padding: 8px 14px; }
  .ctrl.primary { min-width: 140px; }
  #wordpop { left: auto; right: auto; bottom: auto; width: 280px; }
  #toasts { top: auto; bottom: 24px; }
  .ad-bar { bottom: 24px; }
  html[data-ad] #toasts { bottom: 96px; }
  html[data-ad] main { padding-bottom: 120px; }
  html[data-ad] .rd-controls { bottom: 92px; }
  .sheet { align-items: center; justify-content: center; padding: 24px; }
  .sheet-card { max-width: 560px; height: auto; max-height: calc(100vh - 48px); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
  .sheet-head { padding-top: 8px; }
  .sheet.side { padding: 0; justify-content: flex-end; align-items: stretch; }
  .sheet.side .sheet-card { max-width: 380px; max-height: none; height: 100%; border-radius: 0; }
  .sheet.info { align-items: center; }
  .sheet.info .sheet-card { max-width: 480px; border-radius: var(--radius-lg); }
  .tour { align-items: center; padding: 24px; }
  .tour-card { max-width: 460px; border-bottom: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 20px 20px; }
}
@media (min-width: 720px) and (hover: hover) { .kbd-only { display: inline; } }
@media (min-width: 720px) and (pointer: coarse) {
  :root { --top-h: 67px; }
  .tab { min-height: var(--tap); }
}
@media (min-width: 1100px) {
  .top .goal-chip { display: inline-flex; }
  .rd-split { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
