/* ==========================================================================
   ClearPaste styles
   ========================================================================== */

:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --text: #0f1b2d;
  --muted: #5a6a80;
  --border: #e2e8f1;
  --border-strong: #cbd5e3;
  --primary: #0b5cad;
  --primary-hover: #094c90;
  --primary-soft: #e8f1fc;
  --primary-ink: #ffffff;
  --accent: #ffd400;
  --mark: #fff4bf;
  --mark-line: #e0a800;
  --shadow-sm: 0 1px 2px rgba(15, 27, 45, .06);
  --shadow: 0 1px 2px rgba(15, 27, 45, .05), 0 8px 24px -8px rgba(15, 27, 45, .12);
  --shadow-lg: 0 2px 4px rgba(15, 27, 45, .04), 0 24px 48px -16px rgba(11, 60, 120, .28);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --scale: 1;
  --line: 1.6;
  --letter: normal;
  --word: normal;

  /* Icon tints */
  --blue: #0b5cad;   --blue-bg: #e6f0fb;
  --green: #15803d;  --green-bg: #e6f6ec;
  --orange: #c2410c; --orange-bg: #fff0e5;
  --purple: #6d28d9; --purple-bg: #f1eafd;
  --pink: #be185d;   --pink-bg: #fde8f1;
  --teal: #0f766e;   --teal-bg: #e2f5f3;
}

html.contrast {
  --bg: #000;
  --surface: #000;
  --surface-2: #0d0d0d;
  --text: #fff;
  --muted: #e5e5e5;
  --border: #fff;
  --border-strong: #fff;
  --primary: #ffd400;
  --primary-hover: #ffe45c;
  --primary-soft: #1a1a1a;
  --primary-ink: #000;
  --mark: #3a3200;
  --mark-line: #ffd400;
  --shadow-sm: none; --shadow: none; --shadow-lg: none;
  --blue: #9cc9ff; --blue-bg: #000;
  --green: #8dffb0; --green-bg: #000;
  --orange: #ffb37a; --orange-bg: #000;
  --purple: #d6c2ff; --purple-bg: #000;
  --pink: #ffa8cf; --pink-bg: #000;
  --teal: #8ff5ea; --teal-bg: #000;
}

html.dyslexia {
  --font: Verdana, "Trebuchet MS", "Noto Sans", sans-serif;
  --font-display: Verdana, "Trebuchet MS", sans-serif;
  --line: 1.9;
  --letter: .035em;
  --word: .14em;
}

/* Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: calc(16.5px * var(--scale)); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: var(--line);
  letter-spacing: var(--letter);
  word-spacing: var(--word);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; margin: 0; }
p { margin: 0; }
a { color: var(--primary); }
button, select, input, textarea { font: inherit; letter-spacing: inherit; word-spacing: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }

.i {
  width: 1.15em; height: 1.15em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -.2em;
}

.skip {
  position: absolute; left: -9999px; top: 8px; z-index: 50;
  background: var(--accent); color: #000; padding: 8px 14px; border-radius: 8px; font-weight: 700;
}
.skip:focus { left: 8px; }

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

:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.hero :focus-visible { outline-color: var(--accent); }

kbd {
  display: inline-block; font-family: inherit; font-weight: 700; font-size: .82em; line-height: 1.4;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-bottom-width: 3px; border-radius: 7px;
  padding: .05em .5em; min-width: 1.9em; text-align: center;
}

/* Hero ------------------------------------------------------------------ */
.hero {
  color: #fff;
  background:
    radial-gradient(circle at 88% 0%, rgba(255, 255, 255, .16) 0, transparent 38%),
    radial-gradient(circle at 5% 110%, rgba(255, 212, 0, .20) 0, transparent 42%),
    linear-gradient(135deg, #0b5cad 0%, #083f7a 100%);
  padding-bottom: 120px;
}
html.contrast .hero { background: #000; }

.nav { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 18px; padding-bottom: 18px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-family: var(--font-display); font-weight: 800; font-size: 1.35rem; letter-spacing: -.01em; }
.logo { width: 36px; height: 36px; }

.view-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.size-group { display: inline-flex; align-items: center; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .22); border-radius: 999px; padding: 2px; }
.size-group .tool { border: 0; background: transparent; }
.tool-label { font-weight: 700; font-size: .9rem; padding: 0 2px; opacity: .9; }
.tool {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 38px; height: 38px; padding: 0 10px;
  color: #fff; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 999px; font-size: .88rem; font-weight: 600;
  transition: background .15s;
}
.tool:hover { background: rgba(255, 255, 255, .22); }
.tool[aria-pressed="true"] { background: #fff; color: var(--blue); border-color: #fff; }
html.contrast .tool { background: #000; border-color: #fff; }
html.contrast .tool[aria-pressed="true"] { background: var(--accent); color: #000; }

.hero-copy { padding-top: 34px; max-width: 820px; margin-left: 0; }
.hero-copy.wrap { margin: 0 auto; max-width: 1160px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .85rem; font-weight: 600; letter-spacing: .02em;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .22);
  padding: 5px 12px; border-radius: 999px; margin-bottom: 18px;
}
.hero h1 { font-size: clamp(2rem, 4.4vw, 3.25rem); font-weight: 800; letter-spacing: -.025em; max-width: 780px; }
.hero h1 .hl { color: var(--accent); }
.lede { font-size: 1.12rem; margin-top: 14px; max-width: 660px; color: rgba(255, 255, 255, .88); }

/* Composer -------------------------------------------------------------- */
.composer {
  position: relative; z-index: 2;
  margin-top: -88px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  padding: 22px 24px 18px;
}
.composer-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.composer-head h2 { font-size: 1.2rem; font-weight: 700; }
.keys-hint { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .9rem; }

.input-wrap { position: relative; }
textarea {
  display: block; width: 100%; min-height: 230px; resize: vertical;
  padding: 16px 18px;
  color: var(--text); background: var(--surface-2);
  border: 2px solid var(--border); border-radius: 14px;
  font-size: 1rem; line-height: 1.6;
  transition: border-color .15s, background .15s;
}
textarea:hover { border-color: var(--border-strong); }
textarea:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 4px var(--primary-soft); }
textarea.dragover { border-style: dashed; border-color: var(--primary); background: var(--primary-soft); }

.empty-hint {
  position: absolute; inset: 0; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: var(--muted); text-align: center;
}
.input-wrap.has-text .empty-hint { display: none; }
.big-keys { display: flex; align-items: center; gap: 10px; font-size: 1.6rem; color: var(--muted); margin-bottom: 4px; }
.big-keys kbd { font-size: 1.1rem; padding: .25em .7em; box-shadow: var(--shadow-sm); }
.empty-hint p { font-weight: 600; }
.empty-hint .small { font-weight: 400; opacity: .85; }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.composer-tools { display: flex; justify-content: space-between; align-items: center; gap: 10px 16px; flex-wrap: wrap; margin-top: 12px; }
.count { color: var(--muted); font-size: .9rem; margin-left: 4px; }
.samples { font-size: .9rem; }
.sample {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  font-size: .88rem; font-weight: 600;
  transition: border-color .15s, background .15s, color .15s;
}
.sample .i { color: var(--primary); }
.sample:hover { border-color: var(--primary); background: var(--primary-soft); }

.composer-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border);
}

.select-field {
  position: relative; display: inline-flex; align-items: center;
}
.select-field > .i { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
select {
  appearance: none; -webkit-appearance: none;
  height: 44px; padding: 0 36px 0 14px;
  color: var(--text); background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235a6a80' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: .95rem; font-weight: 600;
}
.select-field select { padding-left: 38px; }
select:hover { border-color: var(--primary); }

.segmented {
  display: inline-flex; gap: 2px; margin: 0; padding: 3px;
  border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface-2);
}
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 9px;
  font-size: .92rem; font-weight: 600; color: var(--muted);
  transition: background .15s, color .15s;
}
.segmented input:checked + span { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); outline: 1px solid var(--border); }
.segmented input:focus-visible + span { outline: 3px solid var(--primary); }

.hint { color: var(--muted); font-size: .86rem; margin-top: 12px; }
.hint strong { color: var(--text); font-weight: 600; }

.status { min-height: 1.4em; margin-top: 8px; font-weight: 600; font-size: .95rem; }
.status:empty { margin-top: 0; min-height: 0; }
.status.error { color: #b42318; }
html.contrast .status.error { color: #ff9b9b; }
.status.busy::before {
  content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px;
  border: 2px solid var(--primary); border-right-color: transparent; border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: .95rem; font-weight: 600; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.soft { background: var(--primary-soft); color: var(--primary); }
.btn.soft:hover { background: color-mix(in srgb, var(--primary-soft) 70%, var(--primary) 12%); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn.ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn.big { height: 50px; padding: 0 26px; font-size: 1.05rem; border-radius: 12px; box-shadow: 0 6px 16px -6px rgba(11, 92, 173, .55); }
html.contrast .btn.big { box-shadow: none; }
.btn[disabled] { opacity: .7; cursor: progress; }
.btn.loading .i { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
html.contrast .btn.soft, html.contrast .btn.ghost { border-color: #fff; color: #fff; background: #000; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  transition: border-color .15s, color .15s;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }

/* How it works ---------------------------------------------------------- */
.how { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 22px; }
.how-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm);
}
.how-card h3 { font-size: 1rem; margin: 12px 0 4px; }
.how-card p { color: var(--muted); font-size: .9rem; line-height: 1.5; }
.how-icon, .ci {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  border-radius: 10px;
}
.how-icon { width: 40px; height: 40px; font-size: 1.15rem; }
.ci { width: 32px; height: 32px; font-size: 1rem; border-radius: 9px; }
.c-blue { color: var(--blue); background: var(--blue-bg); }
.c-green { color: var(--green); background: var(--green-bg); }
.c-orange { color: var(--orange); background: var(--orange-bg); }
.c-purple { color: var(--purple); background: var(--purple-bg); }
.c-pink { color: var(--pink); background: var(--pink-bg); }
.c-teal { color: var(--teal); background: var(--teal-bg); }
html.contrast .how-icon, html.contrast .ci { border: 1px solid currentColor; }

/* Results --------------------------------------------------------------- */
.results { margin-top: 32px; scroll-margin-top: 12px; }

.results-bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 0; margin-bottom: 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent;
}
.results-bar.stuck { border-bottom-color: var(--border); }
html.contrast .results-bar { background: #000; }
.results-title h2 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.015em; }
.results-title h2:focus { outline: none; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .8rem; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary);
}
.badge.subtle { background: var(--surface); color: var(--muted); border: 1px solid var(--border); font-weight: 600; }
.badge:empty { display: none; }

.toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.speak-group { display: inline-flex; align-items: center; }
.speak-group .btn { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.speak-group .rate { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: 0; height: 44px; font-weight: 600; }
#speakBtn[aria-pressed="true"] { background: #b42318; }
html.contrast #speakBtn[aria-pressed="true"] { background: var(--accent); }

/* Readability */
.readability {
  display: grid; grid-template-columns: auto auto auto 1fr; align-items: center; gap: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 20px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.readability:empty { display: none; }
.rl-item { display: flex; align-items: center; gap: 12px; }
.rl-grade {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 54px; height: 54px; padding: 0 8px; border-radius: 14px;
  font-family: var(--font-display); font-weight: 800; font-size: 1.35rem;
}
.rl-item.before .rl-grade { background: var(--orange-bg); color: var(--orange); }
.rl-item.after .rl-grade { background: var(--green-bg); color: var(--green); }
.rl-text { display: flex; flex-direction: column; line-height: 1.3; }
.rl-text small { color: var(--muted); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.rl-text strong { font-size: 1rem; }
.rl-arrow { color: var(--muted); font-size: 1.3rem; }
.rl-gain { justify-self: end; text-align: right; }
.rl-gain strong { display: block; font-size: 1.05rem; color: var(--green); }
.rl-gain span { color: var(--muted); font-size: .85rem; }

/* Two-column layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.layout.no-side { grid-template-columns: minmax(0, 1fr); }
.layout.no-side .col-side { display: none; }
.col-main, .col-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.col-side { position: sticky; top: 84px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px;
}
.card-title { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; font-weight: 700; margin-bottom: 12px; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card-title-row .card-title { margin-bottom: 0; }

.summary-card {
  background: linear-gradient(135deg, var(--primary-soft), var(--surface) 70%);
  border-color: color-mix(in srgb, var(--primary) 18%, var(--border));
}
html.contrast .summary-card { background: #000; }
.summary p { font-size: 1.1rem; line-height: 1.6; }
.summary p + p { margin-top: 10px; }

.warn-card { border-color: color-mix(in srgb, var(--orange) 30%, var(--border)); background: linear-gradient(180deg, var(--orange-bg), var(--surface) 80%); }
html.contrast .warn-card { background: #000; }
.warn-card .list li { font-weight: 500; }

/* Progress */
.progress-label { font-size: .85rem; font-weight: 700; color: var(--green); background: var(--green-bg); padding: 3px 10px; border-radius: 999px; }
.progress { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; margin: -2px 0 8px; }
.progress span { display: block; height: 100%; width: 0; background: var(--green); border-radius: 99px; transition: width .3s ease; }
html.contrast .progress { background: #3a3a3a; }

/* Lists */
.list, .checklist, .kv { list-style: none; margin: 0; padding: 0; }
.list li, .kv li { padding: 9px 0; border-top: 1px solid var(--border); font-size: .96rem; line-height: 1.5; }
.list li:first-child, .kv li:first-child { border-top: 0; padding-top: 0; }
.list li:last-child, .kv li:last-child { padding-bottom: 0; }
.kv strong { display: block; font-size: 1rem; }
.kv span { display: block; color: var(--muted); font-size: .88rem; line-height: 1.45; margin-top: 2px; }
/* Contacts as tap targets */
.list.contacts { display: flex; flex-direction: column; gap: 8px; }
.list.contacts li { border: 0; padding: 0; }
.contact {
  display: flex; align-items: center; gap: 10px; min-height: 44px;
  padding: 8px 12px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); text-decoration: none; font-weight: 600;
  word-break: break-word; transition: border-color .15s, background .15s;
}
.contact:hover { border-color: var(--teal); background: var(--teal-bg); }
.contact .i { color: var(--teal); }
.contact-tag {
  margin-left: auto; flex: none; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); background: var(--surface); border: 1px solid var(--border); padding: 1px 8px; border-radius: 999px;
}
.contact-tag.urgent { color: #b42318; border-color: #f4b4ad; background: #fff1f0; }
html.contrast .contact-tag.urgent { color: #ff9b9b; background: #000; border-color: #ff9b9b; }

/* Dates, money and medicines */
#dates strong {
  display: inline-block; font-size: .95rem; color: var(--blue); background: var(--blue-bg);
  padding: 2px 10px; border-radius: 8px; margin-bottom: 4px;
}
#money strong { color: var(--green); font-size: 1.12rem; }
.meds strong { color: var(--text); }
.meds span { color: var(--text); opacity: .8; }

/* Warnings get a marker */
.warn-card .list li { position: relative; padding-left: 18px; }
.warn-card .list li::before {
  content: ""; position: absolute; left: 2px; top: 1.05em; width: 7px; height: 7px; border-radius: 50%; background: var(--orange);
}
.warn-card .list li:first-child::before { top: .55em; }

/* First line of the summary stands out */
.summary p:first-child { font-weight: 600; font-size: 1.15rem; }

.checklist li + li { margin-top: 6px; }
.checklist label {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer;
  transition: background .15s, border-color .15s;
}
.checklist label:hover { border-color: var(--border-strong); background: var(--surface-2); }
.checklist input {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 22px; height: 22px; margin: 1px 0 0; border-radius: 7px;
  border: 2px solid var(--border-strong); background: var(--surface);
  display: grid; place-items: center; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.checklist input::after {
  content: ""; width: 6px; height: 11px; margin-top: -2px;
  border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) scale(0);
  transition: transform .15s;
}
.checklist input:checked { background: var(--green); border-color: var(--green); }
.checklist input:checked::after { transform: rotate(45deg) scale(1); }
html.contrast .checklist input::after { border-color: #000; }
.checklist input:checked + span { text-decoration: line-through; color: var(--muted); }
.checklist label:has(input:checked) { background: var(--green-bg); border-color: transparent; }
.checklist.compact label { padding: 7px 10px; }
.checklist.compact li + li { margin-top: 4px; }

/* Plain document */
.tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.tabs button {
  border: 0; background: transparent; color: var(--muted);
  height: 32px; padding: 0 12px; border-radius: 7px; font-size: .85rem; font-weight: 600;
}
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); outline: 1px solid var(--border); }
#plainHint { margin: -4px 0 14px; }
.compare { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.compare.side { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.plain { font-size: 1.02rem; line-height: 1.75; }
.plain p + p { margin-top: 12px; }
.plain.original { color: var(--muted); }
.compare.side .plain.original { border-left: 3px solid var(--border); padding-left: 18px; }
.compare.side .plain::before, .compare.side .plain.original::before {
  display: block; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px;
}
.compare.side .plain::before { content: "Plain words"; color: var(--green); }
.compare.side .plain.original::before { content: "Original"; color: var(--muted); }

mark.swap {
  background: color-mix(in srgb, var(--mark) 75%, transparent); color: inherit;
  border-bottom: 2px dotted var(--mark-line);
  border-radius: 3px 3px 0 0; padding: 0 1px; cursor: help;
}
mark.swap:hover, mark.swap:focus { background: color-mix(in srgb, var(--mark) 60%, var(--mark-line) 40%); outline: none; }
mark.swap.demo { cursor: default; }

/* Glossary */
#glossaryCard { padding: 0; }
#glossaryCard details { padding: 18px 22px; }
#glossaryCard summary { list-style: none; cursor: pointer; margin: 0; }
#glossaryCard summary::-webkit-details-marker { display: none; }
#glossaryCard summary::after {
  content: ""; margin-left: auto; width: 10px; height: 10px;
  border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg); transition: transform .2s;
}
#glossaryCard details[open] summary::after { transform: rotate(-135deg); }
#glossaryCard details[open] summary { margin-bottom: 14px; }
.pill { font-size: .78rem; font-weight: 700; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); padding: 1px 9px; border-radius: 999px; }
.glossary { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin: 0; }
.glossary div { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.glossary dt { font-weight: 700; font-size: .92rem; }
.glossary dd { margin: 2px 0 0; color: var(--muted); font-size: .9rem; line-height: 1.45; }

.disclaimer { color: var(--muted); font-size: .85rem; margin: 20px 0 0; text-align: center; }

.speaking { box-shadow: 0 0 0 3px var(--primary), var(--shadow) !important; }

/* Dialog ---------------------------------------------------------------- */
dialog {
  border: 1px solid var(--border); border-radius: 20px; padding: 0;
  max-width: 480px; width: calc(100% - 32px);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(8, 22, 42, .5); backdrop-filter: blur(3px); }
dialog form { padding: 22px 24px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.dialog-head h2 { font-size: 1.25rem; }
.dialog-head .icon-btn { width: 36px; height: 36px; border: 0; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; font-weight: 600; font-size: .92rem; }
.field input {
  height: 44px; padding: 0 12px; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-weight: 400;
}
.field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); background: var(--surface); }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* Toast ----------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #0f1b2d; color: #fff; padding: 11px 18px; border-radius: 12px;
  font-weight: 600; font-size: .95rem; box-shadow: var(--shadow-lg);
  transition: opacity .2s, transform .2s; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
html.contrast .toast { background: var(--accent); color: #000; }

.footer { color: var(--muted); font-size: .85rem; text-align: center; padding-top: 36px; padding-bottom: 32px; }

/* Responsive ------------------------------------------------------------ */
@media (max-width: 1000px) {
  .how { grid-template-columns: repeat(2, 1fr); }
  .layout { grid-template-columns: minmax(0, 1fr) 320px; }
}

@media (max-width: 820px) {
  .wrap { padding: 0 16px; }
  .hero { padding-bottom: 104px; }
  .hero-copy { padding-top: 18px; }
  .tool.wide span { display: none; }
  .composer { padding: 18px 16px 14px; border-radius: 18px; }
  .composer-foot > .btn.big { width: 100%; }
  .composer-foot > .row { width: 100%; }
  .readability { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; padding: 14px 16px; }
  .rl-item { gap: 8px; }
  .rl-grade { min-width: 46px; height: 46px; font-size: 1.15rem; }
  .rl-gain { grid-column: 1 / -1; justify-self: start; text-align: left; }

  /* Single column: flatten both columns so cards can be ordered by importance. */
  .layout, .layout.no-side { display: flex; flex-direction: column; gap: 14px; }
  .col-main, .col-side { display: contents; }
  .layout.no-side .col-side { display: contents; }
  #summaryCard { order: 1; } #warningsCard { order: 2; } #actionsCard { order: 3; }
  #datesCard { order: 4; } #moneyCard { order: 5; } #documentsCard { order: 6; }
  #medicinesCard { order: 7; } #contactsCard { order: 8; } #plainCard { order: 9; } #glossaryCard { order: 10; }
  .compare.side { grid-template-columns: minmax(0, 1fr); }
  .compare.side .plain.original { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: 16px; }
  .results-bar { position: static; }
}

@media (max-width: 520px) {
  .how { grid-template-columns: 1fr; }
  .composer-tools { flex-direction: column; align-items: flex-start; }
  .card { padding: 16px; }
  .results-title h2 { font-size: 1.3rem; }
}

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

@media print {
  .hero, .composer, .how, .toolbar, .footer, .tabs, #plainHint, .toast { display: none !important; }
  body { background: #fff; }
  .results { margin-top: 0; }
  .results-bar { position: static; }
  .layout { display: block; }
  .col-side { position: static; }
  .card { box-shadow: none; break-inside: avoid; margin-bottom: 12px; }
  #glossaryCard details > *:not(summary) { display: grid !important; }
}
