/* ==================================================================
   YouTube Transcriber — stylesheet
   Themed with semantic tokens. Light is the default; dark is applied
   by [data-theme="dark"] on <html>, set before paint by an inline
   script so there is no flash of the wrong theme.
   ================================================================== */

/* ------------------------------ tokens ------------------------------ */

:root {
  color-scheme: light;

  --bg: #fbfbfd;
  --bg-subtle: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eff1f5;
  --border: #e5e7ec;
  --border-strong: #d3d7e0;

  --text: #14161b;
  --text-muted: #5a6070;
  /* Darkened from #878da0 so small uppercase labels clear 4.5:1 on white. */
  --text-subtle: #6b7280;

  --accent: #d92d20;
  --accent-hover: #b9251a;
  --accent-fg: #ffffff;
  /* Backgrounds for solid accent buttons. Kept separate from --accent because
     a colour that reads well as text on a surface often fails as a background
     behind white text. Both are verified by test/contrast.test.js. */
  --accent-solid: #d92d20;
  --accent-solid-hover: #b9251a;
  --accent-soft: rgba(217, 45, 32, 0.09);
  --accent-ring: rgba(217, 45, 32, 0.28);

  --success: #0b6b34;
  --success-soft: rgba(11, 107, 52, 0.1);
  --warn: #7d5300;
  --warn-soft: rgba(125, 83, 0, 0.1);
  --info: #0b5cad;
  --info-soft: rgba(11, 92, 173, 0.1);

  --mark-bg: rgba(250, 204, 21, 0.42);

  --shadow-sm: 0 1px 2px rgba(16, 20, 30, 0.06);
  --shadow-md: 0 2px 4px rgba(16, 20, 30, 0.05), 0 8px 20px -6px rgba(16, 20, 30, 0.1);
  --shadow-lg: 0 4px 8px rgba(16, 20, 30, 0.06), 0 16px 40px -10px rgba(16, 20, 30, 0.16);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --max-width: 1040px;
  --speed: 140ms;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0b0c10;
  --bg-subtle: #101218;
  --surface: #14161d;
  --surface-2: #191c24;
  --surface-3: #1f232c;
  --border: #252934;
  --border-strong: #343a49;

  --text: #eceef4;
  --text-muted: #9ba1b2;
  /* Lightened from #6d7385 so small text clears 4.5:1 on the dark surfaces. */
  --text-subtle: #8b93a7;

  --accent: #f2555a;
  --accent-hover: #ff6b70;
  --accent-fg: #ffffff;
  /* Bright red is fine as text on a dark surface but only 3.4:1 behind white
     text, so solid buttons use a deeper shade. */
  --accent-solid: #d43a3f;
  --accent-solid-hover: #c1363b;
  --accent-soft: rgba(242, 85, 90, 0.13);
  --accent-ring: rgba(242, 85, 90, 0.32);

  --success: #3fb950;
  --success-soft: rgba(63, 185, 80, 0.13);
  --warn: #d8a336;
  --warn-soft: rgba(216, 163, 54, 0.13);
  --info: #58a6ff;
  --info-soft: rgba(88, 166, 255, 0.13);

  --mark-bg: rgba(216, 163, 54, 0.34);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.3), 0 8px 20px -6px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.35), 0 16px 40px -10px rgba(0, 0, 0, 0.65);
}

/* ------------------------------ reset ------------------------------ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--speed) ease, color var(--speed) ease;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

svg {
  display: block;
}

.wrap {
  width: min(var(--max-width), 100% - 2.5rem);
  margin-inline: auto;
}

.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;
}

.muted {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ------------------------------ skip link ------------------------------ */

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  z-index: 200;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 550;
  text-decoration: none;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

/* Applied by script instead of an inline style, so the CSP needs no
   'unsafe-inline' for styles. */
.is-hidden {
  display: none !important;
}

/**
 * `display` on a class beats the browser's `[hidden]` rule, because both have
 * the same specificity and author styles load later. Without this, any element
 * that sets `display` would ignore its own `hidden` attribute.
 */
[hidden] {
  display: none !important;
}

code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--surface-3);
  padding: 0.12em 0.38em;
  border-radius: 5px;
}

/* Focus is always visible, and never ugly. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid var(--bg);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-subtle);
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.brand-name {
  display: block;
  font-size: 1.0625rem;
  font-weight: 650;
  letter-spacing: -0.014em;
  line-height: 1.2;
  white-space: nowrap;
}

.brand-tagline {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.3;
  white-space: nowrap;
}

.brand-mark {
  width: 34px;
  height: 24px;
  border-radius: 7px;
  background: var(--accent);
  position: relative;
  flex: none;
  box-shadow: var(--shadow-sm);
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 0;
  height: 0;
  border-left: 9px solid var(--accent-fg);
  border-top: 5.5px solid transparent;
  border-bottom: 5.5px solid transparent;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: none;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--speed), color var(--speed), border-color var(--speed);
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* The header is tight on small screens, and a signed-in chip plus the theme
   toggle is already two controls. The balance lives in the menu, which is
   reachable on every screen size. */
@media (max-width: 640px) {

}

/* Show the icon for the theme you would switch *to*. */
[data-theme="dark"] .icon-moon,
[data-theme="light"] .icon-sun {
  display: none;
}

/* ------------------------------ banner ------------------------------ */

.banner {
  background: var(--warn-soft);
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  color: var(--warn);
  padding: 0.6rem 1.25rem;
  font-size: 0.8125rem;
  text-align: center;
}

/* ------------------------------ layout ------------------------------ */

main {
  padding: 1.75rem 0 3rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* ------------------------------ form ------------------------------ */

.form-panel {
  padding: 1.25rem;
}

.field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-bottom: 0.5rem;
}

textarea,
input[type="text"],
input[type="search"],
select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
  font-size: 0.9375rem;
  transition: border-color var(--speed), box-shadow var(--speed), background var(--speed);
}

textarea {
  font-family: var(--mono);
  font-size: 0.8438rem;
  line-height: 1.65;
  resize: vertical;
  min-height: 104px;
}

textarea::placeholder,
input::placeholder {
  color: var(--text-subtle);
}

textarea:focus,
input:focus,
select:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

select {
  appearance: none;
  cursor: pointer;
  padding-right: 2.2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23878da0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.85rem;
  margin-top: 1rem;
}

.control label {
  display: block;
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-bottom: 0.4rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.15rem;
}

.status {
  font-size: 0.8438rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.status.is-error {
  color: var(--accent);
}

.status.is-ok {
  color: var(--success);
}

.field-help {
  margin-top: 0.45rem;
  font-size: 0.8125rem;
  color: var(--text-subtle);
}

/* ------------------------------ bot protection ------------------------------ */

.captcha-slot {
  display: flex;
  justify-content: center;
  margin-top: 1.15rem;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.captcha-error {
  font-size: 0.8125rem;
  color: var(--accent);
  text-align: center;
}

/* ------------------------------ plan ------------------------------ */

/* ------------------------------ collection job ------------------------------ */

.card.job {
  border-color: color-mix(in srgb, var(--info) 32%, var(--border));
}

.card.job.is-done {
  border-color: color-mix(in srgb, var(--success) 38%, var(--border));
}

.card.job.is-error {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

.job-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem 0.55rem;
}

.job-meta {
  min-width: 0;
}

.job-body {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0 1.15rem 1.15rem;
}

.progress-track {
  height: 8px;
  border-radius: 99px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  overflow: hidden;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: 99px;
  background: var(--accent-solid);
  transition: width 260ms ease;
}

.card.job.is-done .progress-fill {
  background: var(--success);
}

.job-status {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.hint {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-subtle);
}

kbd {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.1rem 0.35rem;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-muted);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  font-weight: 550;
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--speed), border-color var(--speed), color var(--speed), transform 60ms;
  box-shadow: var(--shadow-sm);
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--text-subtle);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.btn.primary {
  background: var(--accent-solid);
  border-color: var(--accent-solid);
  color: var(--accent-fg);
  font-weight: 600;
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-solid-hover);
  border-color: var(--accent-solid-hover);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-muted);
}

.btn.ghost:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.btn.small {
  font-size: 0.8125rem;
  padding: 0.4rem 0.7rem;
}

/* ------------------------------ toolbar ------------------------------ */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 62px;
  z-index: 30;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex: 1 1 260px;
}

.search {
  position: relative;
  flex: 1 1 auto;
}

.search svg {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-subtle);
  pointer-events: none;
}

.search input {
  padding-left: 2.1rem;
  font-size: 0.875rem;
  padding-block: 0.45rem;
}

.toolbar-right {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* ------------------------------ results hint ------------------------------ */

/* Points the user at the transcripts below the tool. Because `.results-hint`
   sets `display`, the global `[hidden]` rule is what actually hides it. */
.results-hint {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
  padding: 0.6rem 0.95rem;
  border: 1px solid color-mix(in srgb, var(--success) 35%, var(--border));
  border-radius: var(--radius);
  background: var(--success-soft);
  color: var(--success);
  font-size: 0.875rem;
  font-weight: 600;
}

.results-hint-arrow {
  font-size: 1.05rem;
  line-height: 1;
  animation: nudge-down 1.5s ease-in-out infinite;
}

@keyframes nudge-down {
  0%,
  100% {
    transform: translateY(-2px);
  }
  50% {
    transform: translateY(3px);
  }
}

#results {
  scroll-margin-top: 5.5rem;
}

/* ------------------------------ resume bar ------------------------------ */

/* Shown when a collection had more videos than one run covers. It has to be
   visible without shouting: the run succeeded, there is simply more of it. */
.resume-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  padding: 0.7rem 0.95rem;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.resume-text {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.resume-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

/* ------------------------------ empty state ------------------------------ */

.empty {
  text-align: center;
  padding: 2.5rem 1.5rem 2.75rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.empty-icon {
  width: 46px;
  height: 46px;
  margin: 0 auto 0.9rem;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
}

.empty-icon svg {
  width: 24px;
  height: 24px;
}

.empty h2 {
  font-size: 1.0625rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin-bottom: 0.35rem;
}

.empty > p {
  color: var(--text-muted);
  font-size: 0.875rem;
  max-width: 46ch;
  margin: 0 auto;
}

.empty-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.85rem;
  margin-top: 1.75rem;
  text-align: left;
}

.empty-item {
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.empty-item h3 {
  font-size: 0.8125rem;
  font-weight: 650;
  margin-bottom: 0.2rem;
}

.empty-item p {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ------------------------------ cards ------------------------------ */

.results {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.card.is-error {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

.card-head {
  display: flex;
  gap: 0.9rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
}

.thumb {
  width: 116px;
  height: 65px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  flex: none;
  border: 1px solid var(--border);
}

.card-meta {
  min-width: 0;
  flex: 1;
}

.card-title {
  font-size: 1rem;
  font-weight: 620;
  letter-spacing: -0.01em;
  line-height: 1.35;
  margin-bottom: 0.25rem;
  overflow-wrap: anywhere;
}

.card-sub {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.55rem;
  overflow-wrap: anywhere;
}

.card-sub a {
  color: var(--info);
  text-decoration: none;
}

.card-sub a:hover {
  text-decoration: underline;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.badge {
  font-size: 0.6875rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  padding: 0.17rem 0.5rem;
  border-radius: 99px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-muted);
  white-space: nowrap;
}

.badge.auto {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 35%, transparent);
  background: var(--warn-soft);
}

.badge.manual {
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 35%, transparent);
  background: var(--success-soft);
}

.badge.cached {
  color: var(--info);
  border-color: color-mix(in srgb, var(--info) 35%, transparent);
  background: var(--info-soft);
}

/* Third-party translation, so it is clear YouTube did not do it. */
.badge.translated {
  color: var(--info);
  border-color: color-mix(in srgb, var(--info) 45%, transparent);
  background: var(--info-soft);
}

.card-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.6rem 1.15rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.segmented {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.segmented :is(button, a) {
  font-size: 0.8125rem;
  font-weight: 550;
  padding: 0.32rem 0.7rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--speed), color var(--speed);
}

.segmented :is(button, a):hover {
  color: var(--text);
  background: var(--surface-2);
}

.segmented :is(button, a).active {
  background: var(--accent-solid);
  color: var(--accent-fg);
  font-weight: 600;
}

/* ------------------------------ dropdown ------------------------------ */

.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 200px;
  padding: 0.3rem;
  display: none;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 50;
}

/* Bridges the 6px gap so moving the pointer from the button onto the menu does
   not cross a dead zone and close it. */
.dropdown-menu::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -8px;
  height: 8px;
}

/* Opens on hover, on keyboard focus, and on click. Hover is scoped to devices
   that actually have a pointer, because a tap leaves a sticky :hover behind on
   touch screens and the menu would never close. */
.dropdown:focus-within > .dropdown-menu,
.dropdown.is-open > .dropdown-menu {
  display: flex;
}

@media (hover: hover) {
  .dropdown:hover > .dropdown-menu {
    display: flex;
  }
}

.dropdown-menu button {
  text-align: left;
  font-size: 0.8438rem;
  padding: 0.45rem 0.6rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.dropdown-menu button:hover {
  background: var(--accent-solid);
  color: var(--accent-fg);
}

/* ------------------------------ transcript ------------------------------ */

.transcript {
  max-height: 400px;
  overflow-y: auto;
  padding: 1.05rem 1.15rem;
  font-size: 0.9375rem;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  scrollbar-width: thin;
}

.transcript mark {
  background: var(--mark-bg);
  color: inherit;
  border-radius: 3px;
  padding: 0 0.1em;
}

.transcript .ts {
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--info);
  user-select: none;
}

.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1.15rem 0.65rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-subtle);
}

/* ------------------------------ error card ------------------------------ */

.error-body {
  padding: 1rem 1.15rem 1.15rem;
}

.error-msg {
  font-weight: 550;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.error-hint {
  font-size: 0.8438rem;
  color: var(--text-muted);
}

.attempts {
  list-style: none;
  margin: 0.8rem 0 0;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-subtle);
}

.attempts li + li {
  margin-top: 0.2rem;
}

/* ------------------------------ diagnostics ------------------------------ */

.diag {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 1.15rem;
  box-shadow: var(--shadow-sm);
}

.diag > summary {
  cursor: pointer;
  padding: 0.8rem 0;
  font-size: 0.875rem;
  font-weight: 550;
  color: var(--text-muted);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.diag > summary::-webkit-details-marker {
  display: none;
}

.diag > summary::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform var(--speed);
}

.diag[open] > summary::before {
  transform: rotate(90deg);
}

.diag > summary:hover {
  color: var(--text);
}

.diag-body {
  padding: 0.2rem 0 1.15rem;
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
}

.diag-controls {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.diag-controls input {
  flex: 1 1 320px;
}

.diag-output {
  margin-top: 0.85rem;
}

.diag-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.diag-table th,
.diag-table td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.diag-table th {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
  font-weight: 650;
}

.diag-table td:last-child {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pill {
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.14rem 0.45rem;
  border-radius: 99px;
}

.pill.ok {
  color: var(--success);
  background: var(--success-soft);
}

.pill.fail {
  color: var(--accent);
  background: var(--accent-soft);
}

.health {
  margin-top: 1rem;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-subtle);
  white-space: pre-wrap;
}

/* ------------------------------ feedback ------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.75rem;
  transform: translate(-50%, 1.25rem);
  max-width: min(90vw, 460px);
  padding: 0.6rem 1.15rem;
  border-radius: 99px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.65s linear infinite;
  flex: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.skeleton {
  height: 132px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 37%, var(--surface) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: 0 0;
  }
}

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

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0 2.75rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  font-size: 0.8125rem;
  color: var(--text-subtle);
}

.footer-inner > p {
  max-width: 62ch;
}

/* The description takes its own line; contact and copyright share the next. */
.footer-inner > p:first-child {
  flex: 1 1 100%;
}

.footer-contact a {
  color: var(--info);
  text-decoration: none;
}

.footer-contact a:hover {
  text-decoration: underline;
}

/* ------------------------------ site nav ------------------------------ */

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex: 1 1 auto;
  justify-content: center;
}

.site-nav a {
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 550;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--speed), color var(--speed);
}

.site-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.site-nav a.is-current {
  color: var(--text);
  background: var(--surface-2);
}

/* ------------------------------ page prose ------------------------------ */

.hero {
  padding-top: 0.5rem;
}

.eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.6rem;
}

.hero h1 {
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-bottom: 0.7rem;
  max-width: 22ch;
}

.lede {
  font-size: 1.0625rem;
  color: var(--text-muted);
  max-width: 62ch;
  line-height: 1.6;
}

main h2 {
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.018em;
  margin-bottom: 0.6rem;
}

main h3 {
  font-size: 1rem;
  font-weight: 620;
  margin-bottom: 0.3rem;
}

main p {
  color: var(--text-muted);
  max-width: 68ch;
}

main p + p {
  margin-top: 0.7rem;
}

main section + section {
  margin-top: 2rem;
}

main a {
  color: var(--info);
}

/* ------------------------------ flow ------------------------------ */

.flow-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  counter-reset: step;
}

.flow-steps li {
  position: relative;
  padding: 1rem 1.1rem 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.flow-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  margin-bottom: 0.35rem;
}

.flow-steps strong {
  font-size: 0.9375rem;
}

.flow-steps span:last-child {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ------------------------------ cards ------------------------------ */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.85rem;
}

.cards-2 {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.feature-card,
.info-card {
  display: block;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--speed), transform var(--speed), box-shadow var(--speed);
}

.feature-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.feature-card h3 {
  color: var(--text);
}

.feature-card p,
.info-card p {
  font-size: 0.8438rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* ------------------------------ comparison table ------------------------------ */

.compare {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.compare th,
.compare td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.compare thead th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  background: var(--surface-2);
}

.compare tbody th {
  font-weight: 550;
  color: var(--text);
}

.compare td {
  color: var(--text-muted);
}

.compare tbody tr:last-child th,
.compare tbody tr:last-child td {
  border-bottom: none;
}

.compare .yes {
  color: var(--success);
  font-weight: 550;
}

.compare .no {
  color: var(--text-subtle);
}

/* ------------------------------ lists ------------------------------ */

.checklist,
.steps {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--text-muted);
  max-width: 68ch;
}

.checklist li,
.steps li {
  margin-bottom: 0.45rem;
  line-height: 1.6;
}

.checklist strong,
.steps strong {
  color: var(--text);
}

/* ------------------------------ callout ------------------------------ */

.callout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  padding: 1.1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.9rem;
}

.callout h3 {
  color: var(--text);
}

.callout p {
  font-size: 0.875rem;
}

/* ------------------------------ faq ------------------------------ */

.faq-list {
  margin: 0;
  border-top: 1px solid var(--border);
}

.faq-list dt {
  font-weight: 600;
  color: var(--text);
  padding: 1rem 0 0.3rem;
  border-top: 1px solid var(--border);
  margin-top: -1px;
}

.faq-list dt:first-child {
  border-top: none;
}

.faq-list dd {
  margin: 0 0 1rem;
  color: var(--text-muted);
  max-width: 68ch;
  line-height: 1.6;
}

/* ------------------------------ related ------------------------------ */

.related-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.7rem;
}

.related-list a {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.8rem 0.95rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--speed);
}

.related-list a:hover {
  border-color: var(--accent);
}

.related-list strong {
  font-size: 0.9rem;
  color: var(--text);
}

.related-list span {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ------------------------------ mode switch ------------------------------ */

.mode-switch {
  margin-bottom: 1.1rem;
}

.mode-switch-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.segmented-lg {
  width: 100%;
}

.segmented-lg :is(button, a) {
  flex: 1;
  text-align: center;
  padding: 0.5rem 0.8rem;
  font-size: 0.875rem;
  text-decoration: none;
}

.mode-option {
  white-space: nowrap;
  text-decoration: none;
}

.tool-wrap {
  scroll-margin-top: 5rem;
}

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

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  padding-bottom: 1.5rem;
}

.footer-group h2 {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-bottom: 0.6rem;
}

.footer-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-group li + li {
  margin-top: 0.35rem;
}

.footer-group a {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
}

.footer-group a:hover {
  color: var(--text);
  text-decoration: underline;
}

.footer-group .muted {
  font-size: 0.8125rem;
  line-height: 1.55;
}

.footer-group .muted + .muted {
  margin-top: 0.6rem;
}

.footer-legal {
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text-subtle);
}

/* ------------------------------ responsive ------------------------------ */

@media (max-width: 860px) {
  .brand-tagline {
    display: none;
  }

  .site-nav {
    overflow-x: auto;
    scrollbar-width: none;
  }

  .site-nav::-webkit-scrollbar {
    display: none;
  }
}

@media (max-width: 640px) {
  .wrap {
    width: calc(100% - 1.5rem);
  }

  .thumb {
    width: 84px;
    height: 47px;
  }

  .card-tools {
    flex-direction: column;
    align-items: stretch;
  }

  .segmented {
    width: 100%;
  }

  .segmented :is(button, a) {
    flex: 1;
  }

  .card-actions .btn {
    flex: 1;
  }

  .toolbar {
    position: static;
  }

  .hint {
    display: none;
  }
}

/* Very narrow phones. The thumbnail is the first thing to go: at this width the
   title and badges carry all the meaning, and the image just squeezes them. */
@media (max-width: 380px) {
  .wrap {
    width: calc(100% - 1rem);
  }

  .form-panel,
  .card-head,
  .card-tools,
  .transcript,
  .card-foot {
    padding-inline: 0.85rem;
  }

  .thumb {
    display: none;
  }

  .actions .btn {
    flex: 1 1 100%;
  }

  .empty {
    padding: 1.75rem 1rem 2rem;
  }

  .toolbar-right .btn {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
