/* ===================================================
   LISTENING STUDIO
   A calm, task-first workspace for YouTube dictation.
   The selectors intentionally support both the original
   ytd-* markup and the revised Listening Studio structure.
   =================================================== */

.ytd-page .ytd-suggestions { grid-column:1/-1; min-width:0; padding:24px; border:1px solid var(--ytd-line); border-radius:14px; background:var(--ytd-surface); }
.ytd-suggestions-heading { display:flex; justify-content:space-between; align-items:center; gap:16px; margin-bottom:12px; }
.ytd-page .ytd-suggestions-heading h2 { margin:7px 0 0; font-size:21px; color:var(--text-primary); }
.ytd-suggestions-heading>span { flex-shrink:0; font-size:12px; color:var(--text-muted); }
.ytd-page .ytd-suggestions-note { max-width:900px; color:var(--text-secondary); font-size:12px; line-height:1.8; margin-bottom:20px; }
.ytd-video-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:18px; }
.ytd-page .ytd-video-card { overflow:hidden; min-width:0; border:1px solid var(--ytd-line); border-radius:12px; background:var(--ytd-surface-raised); display:flex; flex-direction:column; }
.ytd-video-thumb { display:block; width:100%; height:auto; aspect-ratio:16/9; object-fit:cover; background:var(--ytd-surface-soft); }
.ytd-video-copy { display:flex; flex:1; flex-direction:column; align-items:flex-start; padding:18px; }
.ytd-page .ytd-video-topic { font-size:10px; letter-spacing:.04em; color:var(--ytd-brand); font-weight:700; }
.ytd-page .ytd-video-copy h3 { color:var(--text-primary); font-size:16px; line-height:1.5; margin:10px 0 8px; }
.ytd-page .ytd-video-copy p { color:var(--text-secondary); font-size:12px; line-height:1.8; margin:0 0 14px; }
.ytd-page .ytd-video-source { color:var(--text-secondary); font-size:11px; text-decoration:underline; text-underline-offset:3px; margin-top:auto; margin-bottom:15px; }
.ytd-page .ytd-video-start { width:100%; justify-content:center; font-size:12px; min-height:40px; }
@media(max-width:1040px){.ytd-video-grid{grid-template-columns:repeat(2,minmax(0,1fr));}}
@media(max-width:600px){.ytd-page .ytd-suggestions{padding:16px;}.ytd-video-grid{grid-template-columns:1fr;}.ytd-suggestions-heading{align-items:flex-start;flex-direction:column;gap:8px;}}

.ytd-page .ytd-check-status{padding:12px 14px;border-radius:9px;background:var(--ytd-brand-subtle);color:var(--text-secondary);font-size:12px;line-height:1.7;margin-bottom:16px;border:1px solid var(--ytd-line)}
.ytd-page .ytd-check-status[data-state=unavailable]{background:var(--ytd-surface-soft);border-style:dashed}
.ytd-page .ytd-check-status[data-state=ready]{border-color:var(--ytd-brand);color:var(--text-primary)}
.ytd-page .ytd-attempt-range{font-size:11px;color:var(--text-secondary);line-height:1.6;margin:0 0 15px}
.ytd-page #ytd-user-input{min-height:145px;line-height:1.8;font-size:17px}
.ytd-page .ytd-advanced-reference{border:0;background:none;color:var(--text-secondary);font-size:11px;text-decoration:underline;text-underline-offset:3px;cursor:pointer;padding:15px 0 0}
.ytd-page .ytd-manual-warning,.ytd-page .ytd-result-caveat{font-size:11px;color:var(--text-secondary);line-height:1.7;margin:12px 0}
.ytd-page .ytd-result-summary{font:500 12px/1.7 inherit;color:var(--text-secondary);margin:10px 0 15px}
.ytd-page .ytd-submitted-details{font-size:12px;color:var(--text-secondary);padding-top:12px}
.ytd-page .ytd-submitted-details summary{cursor:pointer;margin-bottom:10px}
.ytd-page .ytd-inline-correction{font-size:16px;line-height:2}
.ytd-page #ytd-check-button:disabled{opacity:.5;cursor:not-allowed}
.ytd-page #ytd-check-button kbd{background:transparent;color:inherit;border:1px solid currentColor;padding:2px 5px;border-radius:4px;font-size:10px;opacity:.8}

.ytd-page {
  --ytd-surface: var(--bg-card);
  --ytd-surface-raised: var(--bg-secondary);
  --ytd-surface-soft: var(--bg-card-hover);
  --ytd-line: var(--border);
  --ytd-line-strong: var(--border-hover);
  --ytd-brand: var(--accent);
  --ytd-brand-strong: var(--accent-2);
  --ytd-brand-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --ytd-brand-subtle: color-mix(in srgb, var(--accent) 8%, transparent);
  --ytd-success-soft: color-mix(in srgb, var(--success) 14%, transparent);
  --ytd-warning-soft: color-mix(in srgb, var(--warning) 14%, transparent);
  --ytd-danger-soft: color-mix(in srgb, var(--danger) 14%, transparent);
  --ytd-danger-line: color-mix(in srgb, var(--danger) 50%, var(--border));
  --ytd-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  --ytd-focus-ring: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(20px, 3.5vw, 42px) clamp(16px, 3vw, 32px) 48px;
  color: var(--text-primary);
}

html[data-theme="light"] .ytd-page {
  --ytd-brand: var(--accent);
  --ytd-brand-strong: var(--accent-2);
  --ytd-shadow: 0 7px 20px rgba(31, 41, 37, 0.08);
}

/* --- Heading / introduction ------------------------------------------------ */

.ytd-hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
  padding: clamp(22px, 4vw, 36px);
  border: 1px solid var(--ytd-line);
  border-radius: 22px;
  background:
    radial-gradient(circle at 100% 0%, var(--ytd-brand-soft), transparent 32%),
    linear-gradient(135deg, var(--ytd-surface-raised), var(--ytd-surface));
  box-shadow: var(--ytd-shadow);
}

.ytd-hero::after {
  content: '';
  position: absolute;
  right: -70px;
  bottom: -95px;
  width: 240px;
  height: 240px;
  border: 1px solid var(--ytd-line);
  border-radius: 50%;
  opacity: 0.65;
  pointer-events: none;
}

.ytd-page .page-title,
.ytd-hero-title {
  max-width: 760px;
  margin: 0;
  color: var(--text-primary);
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  -webkit-text-fill-color: currentColor;
  font-size: clamp(1.7rem, 3.2vw, 2.55rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.ytd-page .page-sub,
.ytd-hero > p:not(.ytd-eyebrow) {
  max-width: 720px;
  margin: 10px 0 0;
  color: var(--text-secondary);
  font-size: clamp(0.88rem, 1.35vw, 1rem);
  line-height: 1.65;
}

.ytd-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 9px;
  color: var(--ytd-brand);
  font-size: 0.71rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1.2;
  text-transform: uppercase;
}

.ytd-eyebrow .material-icons {
  font-size: 16px;
}

.ytd-hero-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.ytd-hero-steps > * {
  display: inline-flex;
  align-items: flex-start;
  gap: 9px;
  min-height: 74px;
  padding: 11px;
  border: 1px solid var(--ytd-line);
  border-radius: 12px;
  background: var(--ytd-surface-soft);
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.25;
}

.ytd-hero-steps > * > span:first-child,
.ytd-step > span:first-child {
  display: grid;
  flex: none;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: var(--ytd-brand-soft);
  color: var(--ytd-brand);
  font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
  font-size: 0.67rem;
  font-weight: 800;
}

.ytd-hero-steps b,
.ytd-hero-steps small {
  display: block;
}

.ytd-hero-steps b {
  color: var(--text-primary);
  font-size: 0.77rem;
}

.ytd-hero-steps small {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.42;
}

.ytd-hero-steps .material-icons {
  color: var(--ytd-brand);
  font-size: 16px;
}

.ytd-stepper {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ytd-step {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--ytd-line);
  border-radius: 999px;
  background: var(--ytd-surface-soft);
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.25;
}

.ytd-step.active,
.ytd-step[aria-current="step"] {
  border-color: var(--ytd-line-strong);
  background: var(--ytd-brand-soft);
  color: var(--text-primary);
}

/* Preserve a composed hero when the legacy title is still used on its own. */
.ytd-page > .page-title,
.ytd-page > .page-sub {
  text-align: left;
}

.ytd-page > .page-sub {
  margin-bottom: 22px;
}

/* --- Setup ----------------------------------------------------------------- */

.ytd-setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(250px, 0.65fr);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 24px;
}

/* The existing controller restores this section with inline display:block.
   Keep its hide/show behaviour while restoring the intended grid afterwards. */
#ytd-setup-only.ytd-setup-grid[style*="display: block"] {
  display: grid !important;
}

.ytd-setup-card,
.ytd-guide-card,
.ytd-panel,
.ytd-player-panel,
.ytd-workbench,
.ytd-result-panel,
.ytd-page #ytd-setup-only.card:not(.ytd-setup-grid) {
  min-width: 0;
  border: 1px solid var(--ytd-line);
  border-radius: 18px;
  background: var(--ytd-surface);
  box-shadow: var(--ytd-shadow);
}

.ytd-setup-card,
.ytd-guide-card,
.ytd-panel,
.ytd-workbench,
.ytd-result-panel,
.ytd-page #ytd-setup-only.card:not(.ytd-setup-grid) {
  padding: clamp(18px, 2.5vw, 26px);
}

.ytd-page #ytd-setup-only.card:not(.ytd-setup-grid) {
  margin-bottom: 24px;
}

.ytd-history-panel {
  grid-column: 1 / -1;
  margin-top: 0;
  padding: clamp(18px, 2.5vw, 24px);
  border: 1px solid var(--ytd-line);
  border-radius: 18px;
  background: var(--ytd-surface);
  box-shadow: var(--ytd-shadow);
}

.ytd-page .section-title,
.ytd-guide-card h2,
.ytd-panel > h2,
.ytd-workbench > h2 {
  margin-bottom: 14px;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 750;
  letter-spacing: -0.015em;
}

.ytd-page .section-title .material-icons,
.ytd-guide-card h2 .material-icons,
.ytd-panel > h2 .material-icons,
.ytd-workbench > h2 .material-icons {
  color: var(--ytd-brand);
}

.ytd-card-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--ytd-brand);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1.2;
  text-transform: uppercase;
}

.ytd-card-kicker .material-icons {
  font-size: 16px;
}

.ytd-card-copy,
.ytd-panel-copy {
  margin: -3px 0 16px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.58;
}

.ytd-field-label {
  display: block;
  margin-bottom: 7px;
  color: var(--text-primary);
  font-size: 0.77rem;
  font-weight: 700;
  line-height: 1.35;
}

.ytd-input-help {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 0.73rem;
  line-height: 1.45;
}

.ytd-input-help .material-icons {
  flex: none;
  margin-top: 1px;
  color: var(--ytd-brand);
  font-size: 15px;
}

.ytd-url-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
  padding: 6px;
  border: 1px solid var(--ytd-line);
  border-radius: 14px;
  background: var(--ytd-surface-raised);
}

.ytd-url-input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid transparent;
  border-radius: 9px;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.35;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.ytd-url-input::placeholder,
.ytd-textarea::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

.ytd-url-input:hover {
  background: var(--ytd-surface-soft);
}

.ytd-url-input:focus,
.ytd-url-input:focus-visible {
  border-color: var(--ytd-line-strong);
  background: var(--ytd-surface-soft);
  box-shadow: var(--ytd-focus-ring);
}

.ytd-url-input.error {
  border-color: var(--danger);
  background: var(--ytd-danger-soft);
  animation: ytd-shake 0.38s ease;
}

.ytd-url-bar .btn,
.ytd-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding-inline: 16px;
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 700;
}

.ytd-page .btn-primary {
  border-color: var(--ytd-brand-strong);
  background: var(--ytd-brand-strong);
  box-shadow: 0 5px 14px rgba(7, 80, 125, 0.26);
}

.ytd-page .btn-primary:hover {
  border-color: var(--ytd-brand);
  background: var(--ytd-brand);
  box-shadow: 0 8px 20px rgba(7, 80, 125, 0.3);
}

.ytd-page .btn-danger {
  min-height: 44px;
  border-color: var(--ytd-danger-line);
  background: transparent;
  color: var(--danger);
}

.ytd-page .btn-danger:hover {
  border-color: var(--danger);
  background: var(--ytd-danger-soft);
}

.ytd-page .ytd-secondary-action {
  border-color: var(--ytd-line);
  background: var(--ytd-surface);
  color: var(--text-secondary);
}

.ytd-page .ytd-secondary-action:hover {
  border-color: var(--ytd-line-strong);
  background: var(--ytd-brand-subtle);
  color: var(--text-primary);
}

.ytd-guide-card {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(145deg, var(--ytd-brand-subtle), transparent 52%),
    var(--ytd-surface);
}

.ytd-guide-card > .material-icons:first-child {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 16px;
  border-radius: 12px;
  background: var(--ytd-brand-soft);
  color: var(--ytd-brand);
  font-size: 22px;
}

.ytd-guide-card p,
.ytd-guide-card li,
.ytd-page #ytd-setup-only > p {
  color: var(--text-secondary);
  font-size: 0.83rem;
  line-height: 1.6;
}

.ytd-guide-card ul,
.ytd-guide-card ol {
  display: grid;
  gap: 9px;
  margin: 14px 0 0;
  padding-left: 19px;
}

.ytd-guide-card li::marker {
  color: var(--ytd-brand);
  font-weight: 800;
}

.ytd-guide-list {
  list-style: none;
  padding-left: 0 !important;
}

.ytd-guide-list li {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.ytd-guide-list .material-icons {
  display: grid;
  flex: none;
  place-items: center;
  width: 23px;
  height: 23px;
  margin-top: -1px;
  border-radius: 7px;
  background: var(--ytd-brand-soft);
  color: var(--ytd-brand);
  font-size: 15px;
}

/* --- Practice workspace ---------------------------------------------------- */

.ytd-practice {
  animation: ytd-fade-in 0.28s ease;
}

.ytd-practice-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.ytd-practice-header h2,
.ytd-practice-header h3 {
  color: var(--text-primary);
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  letter-spacing: -0.025em;
}

.ytd-practice-header p {
  margin-top: 5px;
  color: var(--text-secondary);
  font-size: 0.84rem;
  line-height: 1.5;
}

.ytd-back-link {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--ytd-line);
  border-radius: 9px;
  outline: none;
  background: var(--ytd-surface);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}

.ytd-back-link:hover {
  border-color: var(--ytd-line-strong);
  background: var(--ytd-brand-subtle);
  color: var(--text-primary);
}

.ytd-back-link .material-icons {
  font-size: 17px;
}

.ytd-session-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.ytd-session-meta > * {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 31px;
  padding: 5px 9px;
  border: 1px solid var(--ytd-line);
  border-radius: 999px;
  background: var(--ytd-surface-soft);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 650;
  white-space: nowrap;
}

.ytd-session-meta .material-icons {
  color: var(--ytd-brand);
  font-size: 15px;
}

.ytd-practice-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.ytd-practice-grid > * {
  min-width: 0;
}

.ytd-player-panel {
  overflow: hidden;
  padding: 0;
}

.ytd-panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.ytd-panel-heading > div:first-child {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.ytd-panel-heading h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 0.93rem;
  font-weight: 760;
  letter-spacing: -0.015em;
  line-height: 1.35;
}

.ytd-panel-heading h3 small {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.ytd-panel-step {
  display: grid;
  flex: none;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--ytd-line-strong);
  border-radius: 8px;
  background: var(--ytd-brand-soft);
  color: var(--ytd-brand);
  font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
  font-size: 0.67rem;
  font-weight: 800;
}

.ytd-panel-note {
  max-width: 180px;
  color: var(--text-muted);
  font-size: 0.69rem;
  line-height: 1.4;
  text-align: right;
}

.ytd-player-panel > .ytd-panel-heading {
  padding: 18px 18px 14px;
}

.ytd-player-panel .ytd-controls {
  margin: 0;
  border-width: 1px 0 0;
  border-radius: 0;
  box-shadow: none;
}

.ytd-workbench {
  display: grid;
  gap: 14px;
}

.ytd-panel {
  display: grid;
  gap: 10px;
}

.ytd-control-hint {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0;
  padding: 13px 16px 16px;
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

.ytd-control-hint kbd {
  min-width: 37px;
  padding: 2px 5px;
  border: 1px solid var(--ytd-line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--ytd-surface-soft);
  color: var(--text-secondary);
  font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}

/* --- Automatic pause -------------------------------------------------------
   A compact listen → type loop: learners choose an interval or their own
   end-of-sentence markers, then focus on listening instead of the pause key. */

.ytd-auto-pause-card {
  margin: 0;
  padding: 14px 18px 15px;
  border-top: 1px solid var(--ytd-line);
  background:
    linear-gradient(90deg, var(--ytd-brand-subtle), transparent 70%),
    var(--ytd-surface);
}

.ytd-auto-pause-heading,
.ytd-auto-pause-heading > div:first-child {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ytd-auto-pause-heading {
  justify-content: space-between;
}

.ytd-auto-pause-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 33px;
  height: 33px;
  border: 1px solid var(--ytd-line-strong);
  border-radius: 10px;
  background: var(--ytd-brand-soft);
  color: var(--ytd-brand);
  font-size: 18px;
}

.ytd-auto-pause-heading h4 {
  margin: 0;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 760;
  line-height: 1.32;
}

.ytd-auto-pause-heading p {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.68rem;
  line-height: 1.4;
}

.ytd-switch {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  width: 42px;
  height: 25px;
  cursor: pointer;
}

.ytd-switch > input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.ytd-switch-track {
  position: relative;
  display: block;
  width: 42px;
  height: 25px;
  border: 1px solid var(--ytd-line);
  border-radius: 999px;
  background: var(--ytd-surface-raised);
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.ytd-switch-track::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--text-muted);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.18s ease, background var(--transition);
}

.ytd-switch > input:checked + .ytd-switch-track {
  border-color: var(--ytd-brand);
  background: var(--ytd-brand-strong);
}

.ytd-switch > input:checked + .ytd-switch-track::after {
  transform: translateX(17px);
  background: #fff;
}

.ytd-switch > input:focus-visible + .ytd-switch-track {
  box-shadow: var(--ytd-focus-ring);
}

.ytd-auto-pause-options {
  display: grid;
  grid-template-columns: minmax(145px, 0.85fr) minmax(108px, 0.48fr) minmax(0, 1.45fr);
  align-items: end;
  gap: 9px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--ytd-line);
  border-radius: 11px;
  background: var(--ytd-surface-raised);
}

.ytd-auto-pause-field {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--text-secondary);
  font-size: 0.69rem;
  font-weight: 680;
  line-height: 1.3;
}

.ytd-auto-pause-field > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#ytd-auto-pause-mode,
#ytd-auto-pause-seconds,
#ytd-pause-markers {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--ytd-line);
  border-radius: 8px;
  outline: none;
  background: var(--ytd-surface);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.76rem;
  line-height: 1.2;
}

#ytd-auto-pause-mode {
  padding: 6px 27px 6px 8px;
}

#ytd-auto-pause-seconds {
  min-width: 0;
  padding: 6px 7px;
  text-align: center;
}

#ytd-pause-markers {
  padding: 6px 8px;
}

#ytd-auto-pause-mode:focus,
#ytd-auto-pause-mode:focus-visible,
#ytd-auto-pause-seconds:focus,
#ytd-auto-pause-seconds:focus-visible,
#ytd-pause-markers:focus,
#ytd-pause-markers:focus-visible {
  border-color: var(--ytd-brand);
  box-shadow: var(--ytd-focus-ring);
}

.ytd-duration-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 34px;
  overflow: hidden;
  border: 1px solid var(--ytd-line);
  border-radius: 8px;
  background: var(--ytd-surface);
}

.ytd-duration-input:focus-within {
  border-color: var(--ytd-brand);
  box-shadow: var(--ytd-focus-ring);
}

.ytd-duration-input #ytd-auto-pause-seconds {
  min-width: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.ytd-duration-input em {
  padding: 0 8px 0 6px;
  color: var(--text-muted);
  font-size: 0.67rem;
  font-style: normal;
  font-weight: 650;
  line-height: 1;
}

.ytd-auto-pause-card[data-mode="interval"] .ytd-auto-pause-markers-field,
.ytd-auto-pause-card[data-mode="interval"] .ytd-pause-markers-help {
  display: none;
}

.ytd-auto-pause-card[data-mode="markers"] .ytd-auto-pause-interval-field {
  display: none;
}

.ytd-auto-pause-card[data-mode="markers"] .ytd-auto-pause-markers-field {
  grid-column: 2 / -1;
}

.ytd-auto-pause-status {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 9px 0 0;
  color: var(--ytd-brand);
  font-size: 0.7rem;
  font-weight: 680;
  line-height: 1.45;
}

.ytd-auto-pause-status::before {
  content: 'auto_awesome';
  flex: none;
  margin-top: -1px;
  font-family: 'Material Icons';
  font-size: 15px;
  font-weight: normal;
}

.ytd-pause-markers-help {
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px dashed var(--ytd-line);
  color: var(--text-muted);
  font-size: 0.67rem;
  line-height: 1.45;
}

.ytd-pause-markers-help strong {
  color: var(--text-secondary);
  font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
  font-size: 0.65rem;
}

.ytd-auto-pause-card:has(#ytd-auto-pause-toggle:not(:checked)) .ytd-auto-pause-options,
.ytd-auto-pause-card:has(#ytd-auto-pause-toggle:not(:checked)) .ytd-auto-pause-status,
.ytd-auto-pause-card:has(#ytd-auto-pause-toggle:not(:checked)) .ytd-pause-markers-help {
  opacity: 0.52;
}

/* --- Compact answer and instant check ------------------------------------ */

.ytd-user-panel {
  gap: 8px;
}

.ytd-user-panel .ytd-panel-heading {
  margin-bottom: 1px;
}

.ytd-answer-sheet {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--ytd-line);
  border-radius: 12px;
  background: var(--ytd-surface-soft);
}

.ytd-answer-pane {
  display: grid;
  gap: 8px;
}

.ytd-answer-pane[hidden],
.ytd-inline-reference[hidden],
.ytd-quick-check-hint[hidden],
.ytd-compact-actions[hidden] {
  display: none !important;
}

.ytd-answer-sheet > .ytd-field-label {
  margin: 0;
}

.ytd-user-panel .ytd-textarea {
  min-height: 156px;
}

.ytd-answer-sheet .ytd-textarea-meta {
  margin-top: 1px;
}

.ytd-inline-reference {
  display: grid;
  gap: 7px;
  margin: 7px 0 2px;
  padding: 12px;
  border: 1px solid var(--ytd-line);
  border-radius: 12px;
  background: var(--ytd-surface-soft);
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

/* The answer and the reference are one exercise sheet.  They remain two
   fields because one is the learner's attempt and the other is the answer
   key used for scoring. */
.ytd-answer-sheet .ytd-inline-reference,
.ytd-answer-sheet .ytd-inline-reference.has-reference {
  margin: 3px 0 0;
  padding: 10px 0 0;
  border: 0;
  border-top: 1px dashed var(--ytd-line-strong);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.ytd-answer-sheet[data-mode="reference"] .ytd-inline-reference,
.ytd-answer-sheet[data-mode="reference"] .ytd-inline-reference.has-reference {
  margin: 0;
  padding: 0;
  border-top: 0;
}

.ytd-inline-reference.has-reference {
  border-color: color-mix(in srgb, var(--success) 42%, var(--ytd-line));
  background: var(--ytd-success-soft);
}

.ytd-inline-reference-heading,
.ytd-reference-meta,
.ytd-reference-meta > span {
  display: flex;
  align-items: center;
}

.ytd-inline-reference-heading {
  justify-content: space-between;
  gap: 10px;
}

.ytd-inline-reference-heading .ytd-field-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.ytd-inline-reference-heading .material-icons,
.ytd-reference-meta .material-icons {
  color: var(--ytd-brand);
  font-size: 16px;
}

.ytd-reference-status {
  flex: none;
  padding: 3px 7px;
  border: 1px solid var(--ytd-line);
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--ytd-surface);
  font-size: 0.64rem;
  font-weight: 700;
  line-height: 1.3;
}

.ytd-reference-status[data-state="saved"] {
  border-color: color-mix(in srgb, var(--success) 38%, var(--ytd-line));
  color: var(--success);
}

.ytd-reference-status[data-state="required"],
.ytd-reference-status[data-state="error"] {
  border-color: var(--ytd-danger-line);
  color: var(--danger);
}

.ytd-inline-reference .transcript-area {
  min-height: 88px;
  background: var(--ytd-surface);
  font-size: 0.78rem;
  line-height: 1.55;
}

.ytd-answer-sheet .ytd-inline-reference .transcript-area {
  min-height: 76px;
}

.ytd-inline-reference .transcript-area.needs-reference {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent);
}

.ytd-reference-meta {
  justify-content: space-between;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.65rem;
  line-height: 1.4;
}

.ytd-reference-actions,
.ytd-reference-ready,
.ytd-reference-ready > span {
  display: flex;
  align-items: center;
}

.ytd-reference-actions {
  gap: 10px;
}

.ytd-reference-save {
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid color-mix(in srgb, var(--ytd-brand) 70%, var(--ytd-line));
  border-radius: 8px;
  background: var(--ytd-brand);
  color: #fff;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 800;
  cursor: pointer;
}

.ytd-reference-save:hover {
  filter: brightness(1.08);
}

.ytd-reference-ready {
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--ytd-line-strong);
  color: var(--text-muted);
  font-size: 0.68rem;
}

.ytd-reference-ready > span {
  gap: 6px;
}

.ytd-reference-ready .material-icons {
  color: var(--success);
  font-size: 17px;
}

.ytd-reference-ready button {
  padding: 3px 0;
  border: 0;
  background: transparent;
  color: var(--ytd-brand);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.ytd-reference-meta > span {
  gap: 5px;
}

.ytd-reference-clear {
  flex: none;
  padding: 3px 0;
  border: 0;
  background: transparent;
  color: var(--ytd-brand);
  font: inherit;
  font-size: 0.66rem;
  font-weight: 700;
  cursor: pointer;
}

.ytd-reference-clear:hover {
  color: var(--danger);
  text-decoration: underline;
}

.ytd-quick-check-hint,
.ytd-enter-check {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 2px 0 0;
  padding: 8px 10px;
  border: 1px solid var(--ytd-line);
  border-radius: 9px;
  background: var(--ytd-brand-subtle);
  color: var(--text-secondary);
  font-size: 0.71rem;
  line-height: 1.45;
}

.ytd-quick-check-hint .material-icons,
.ytd-enter-check .material-icons {
  flex: none;
  margin-top: 1px;
  color: var(--ytd-brand);
  font-size: 16px;
}

.ytd-quick-check-hint kbd,
.ytd-enter-check kbd {
  display: inline-block;
  min-width: 38px;
  padding: 1px 4px;
  border: 1px solid var(--ytd-line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--ytd-surface);
  color: var(--text-primary);
  font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
  font-size: 0.65rem;
  font-weight: 750;
  line-height: 1.25;
  text-align: center;
}

.ytd-compact-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 2px 0 0;
}

.ytd-compact-actions .btn,
#ytd-quick-check-btn {
  min-height: 39px;
  padding: 8px 11px;
  border-radius: 9px;
  font-size: 0.77rem;
}

.ytd-transcript-panel {
  gap: 8px;
}

.ytd-transcript-panel .ytd-panel-copy {
  margin: -1px 0 3px;
}

.ytd-transcript-panel #ytd-transcript-wrapper {
  padding-top: 3px;
}

/* --- Player and listening controls ---------------------------------------- */

.ytd-player-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 220px;
  overflow: hidden;
  margin-bottom: 18px;
  padding-bottom: 0;
  border: 1px solid var(--ytd-line);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 35%, rgba(79, 179, 229, 0.1), transparent 45%),
    #08111e;
  box-shadow: var(--ytd-shadow);
}

.ytd-player-panel .ytd-player-wrap {
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.ytd-player-wrap iframe,
.ytd-player-wrap #ytd-yt-player,
.ytd-player-wrap #ytd-yt-player iframe {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  border: 0;
}

.ytd-player-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  color: #b6c9d9;
  font-size: 0.9rem;
  text-align: center;
}

.ytd-player-placeholder .material-icons {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border: 1px solid rgba(182, 201, 217, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.055);
  color: #e6f3fb;
  font-size: 30px;
}

.ytd-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px;
  border: 1px solid var(--ytd-line);
  border-radius: 14px;
  background: var(--ytd-surface);
  box-shadow: 0 7px 22px rgba(0, 0, 0, 0.09);
}

.ytd-controls .material-icons {
  font-size: 19px;
  line-height: 1;
}

.ytd-ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 40px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  outline: none;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background var(--transition), transform var(--transition);
  white-space: nowrap;
}

.ytd-controls > .ytd-ctrl-btn:first-child {
  min-width: 42px;
  background: var(--ytd-brand-strong);
  color: #fff;
}

.ytd-ctrl-btn:hover {
  border-color: var(--ytd-line-strong);
  background: var(--ytd-brand-soft);
  color: var(--text-primary);
}

.ytd-controls > .ytd-ctrl-btn:first-child:hover {
  background: var(--ytd-brand);
  color: #fff;
}

.ytd-ctrl-btn:active {
  transform: translateY(1px);
}

.ytd-ctrl-btn.active {
  border-color: var(--ytd-line-strong);
  background: var(--ytd-brand-soft);
  color: var(--ytd-brand);
  box-shadow: inset 0 0 0 1px rgba(79, 179, 229, 0.12);
}

.ytd-ctrl-divider {
  width: 1px;
  height: 26px;
  margin: 0 2px;
  background: var(--ytd-line);
}

.ytd-advanced-controls {
  position: relative;
  flex: none;
  margin-left: auto;
}

.ytd-advanced-controls > summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 40px;
  padding: 7px 10px;
  border: 1px solid var(--ytd-line);
  border-radius: 9px;
  background: var(--ytd-surface-raised);
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 680;
  line-height: 1;
  cursor: pointer;
  list-style: none;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}

.ytd-advanced-controls > summary::-webkit-details-marker {
  display: none;
}

.ytd-advanced-controls > summary::after {
  content: 'expand_more';
  color: var(--text-muted);
  font-family: 'Material Icons';
  font-size: 16px;
  transition: transform 0.18s ease;
}

.ytd-advanced-controls[open] > summary {
  border-color: var(--ytd-line-strong);
  background: var(--ytd-brand-soft);
  color: var(--ytd-brand);
}

.ytd-advanced-controls[open] > summary::after {
  transform: rotate(180deg);
}

.ytd-advanced-controls > summary:focus-visible {
  outline: none;
  box-shadow: var(--ytd-focus-ring);
}

.ytd-advanced-controls .material-icons {
  font-size: 17px;
}

.ytd-loop-controls {
  position: absolute;
  z-index: 5;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  min-width: 154px;
  padding: 6px;
  border: 1px solid var(--ytd-line);
  border-radius: 11px;
  background: var(--ytd-surface-raised);
  box-shadow: var(--ytd-shadow);
}

.ytd-loop-controls .ytd-ctrl-btn {
  justify-content: flex-start;
  width: 100%;
  min-height: 36px;
  padding: 6px 8px;
  font-size: 0.73rem;
}

.ytd-speed-label {
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
}

.ytd-loop-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  margin-bottom: 16px;
  padding: 9px 12px;
  border: 1px solid var(--ytd-line-strong);
  border-radius: 11px;
  background: var(--ytd-brand-subtle);
  color: var(--ytd-brand);
  font-size: 0.81rem;
  font-weight: 650;
  animation: ytd-fade-in 0.25s ease;
}

.ytd-loop-indicator.visible {
  display: flex;
}

.ytd-loop-indicator .material-icons {
  font-size: 19px;
}

/* --- Dictation inputs ------------------------------------------------------ */

.ytd-section-label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  margin-bottom: 8px;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0.01em;
}

.ytd-section-label > .material-icons {
  flex: none;
  color: var(--ytd-brand);
  font-size: 18px;
}

.ytd-textarea-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.ytd-textarea {
  display: block;
  width: 100%;
  min-height: 156px;
  padding: 12px 14px;
  border: 1px solid var(--ytd-line);
  border-radius: 12px;
  outline: none;
  background: var(--ytd-surface-raised);
  color: var(--text-primary);
  caret-color: var(--ytd-brand);
  font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
  font-size: 0.88rem;
  font-variant-ligatures: none;
  line-height: 1.75;
  resize: vertical;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.ytd-textarea:hover {
  border-color: var(--ytd-line-strong);
}

.ytd-textarea:focus,
.ytd-textarea:focus-visible {
  border-color: var(--ytd-brand);
  background: var(--ytd-surface);
  box-shadow: var(--ytd-focus-ring);
}

.ytd-textarea.transcript-area {
  min-height: 104px;
  font-size: 0.82rem;
  line-height: 1.65;
}

#ytd-user-input {
  border-color: var(--ytd-line-strong);
  min-height: 156px;
}

.ytd-collapse-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding: 5px 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  outline: none;
  background: transparent;
  color: var(--ytd-brand);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}

.ytd-collapse-toggle:hover {
  border-color: var(--ytd-line);
  background: var(--ytd-brand-subtle);
}

.ytd-collapse-toggle .material-icons {
  font-size: 17px;
  transition: transform 0.2s ease;
}

.ytd-collapse-toggle.open .material-icons {
  transform: rotate(180deg);
}

.ytd-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 16px 0 20px;
}

/* --- Results --------------------------------------------------------------- */

.ytd-diff-result,
.ytd-result-panel {
  padding: clamp(18px, 2.5vw, 24px);
  border: 1px solid var(--ytd-line);
  border-radius: 16px;
  background: var(--ytd-surface);
  box-shadow: var(--ytd-shadow);
}

.ytd-diff-result {
  color: var(--text-primary);
  font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
  font-size: 0.88rem;
  line-height: 2;
  overflow-wrap: anywhere;
  animation: ytd-fade-in 0.3s ease;
}

.ytd-diff-result .ytd-section-label {
  margin-bottom: 0;
}

.ytd-result-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.ytd-result-time {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ytd-brand);
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 0.67rem;
  font-weight: 750;
  line-height: 1.4;
}

.ytd-result-time .material-icons {
  font-size: 15px;
}

.ytd-timed-answer {
  margin-bottom: 14px;
  padding: 11px 12px;
  border: 1px solid color-mix(in srgb, var(--ytd-brand) 38%, var(--ytd-line));
  border-radius: 10px;
  background: var(--ytd-brand-subtle);
}

.ytd-timed-answer > span {
  display: block;
  margin-bottom: 5px;
  color: var(--ytd-brand);
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ytd-timed-answer > p {
  margin: 0;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.65;
}

.ytd-word {
  display: inline;
  padding: 2px 4px;
  border-radius: 4px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.ytd-word.correct {
  border-bottom: 2px solid var(--success);
  background: var(--ytd-success-soft);
  color: var(--success);
}

.ytd-word.wrong {
  border-bottom: 2px solid var(--danger);
  background: var(--ytd-danger-soft);
  color: var(--danger);
}

.ytd-word.missing {
  border-bottom: 2px dotted var(--warning);
  background: var(--ytd-warning-soft);
  color: var(--warning);
  font-style: italic;
}

.ytd-word.extra {
  border-bottom: 2px solid var(--danger);
  background: var(--ytd-danger-soft);
  color: var(--danger);
  opacity: 0.85;
}

.ytd-diff-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 0.72rem;
}

.ytd-comparison-row {
  display: grid;
  grid-template-columns: minmax(104px, 0.24fr) minmax(0, 1fr);
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--ytd-line);
}

.ytd-comparison-row > strong {
  color: var(--text-secondary);
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  line-height: 1.5;
  text-transform: uppercase;
}

.ytd-comparison-row > div {
  min-width: 0;
  line-height: 2.05;
}

.ytd-comparison-row em {
  color: var(--text-muted);
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 0.76rem;
}

@media (max-width: 560px) {
  .ytd-result-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .ytd-comparison-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}

.ytd-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--ytd-line);
  border-radius: 16px;
  background: var(--ytd-surface);
  box-shadow: var(--ytd-shadow);
  animation: ytd-fade-in 0.3s ease;
}

.ytd-stat-item {
  display: flex;
  flex: 1 1 96px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 86px;
  gap: 4px;
  padding: 12px 10px;
  border-right: 1px solid var(--ytd-line);
  text-align: center;
}

.ytd-stat-item:last-child {
  border-right: 0;
}

.ytd-stat-value {
  color: var(--text-primary);
  font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
  font-size: clamp(1.08rem, 2vw, 1.38rem);
  font-weight: 700;
  line-height: 1.1;
}

.ytd-stat-value.good { color: var(--success); }
.ytd-stat-value.bad { color: var(--danger); }
.ytd-stat-value.neutral { color: var(--ytd-brand); }

.ytd-stat-label {
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 750;
  letter-spacing: 0.075em;
  line-height: 1.2;
  text-transform: uppercase;
}

/* --- History --------------------------------------------------------------- */

.ytd-history {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--ytd-line);
}

.ytd-history-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 750;
}

.ytd-history-title .material-icons {
  color: var(--ytd-brand);
  font-size: 19px;
}

.ytd-history-list {
  display: grid;
  gap: 9px;
}

.ytd-history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 68px;
  padding: 9px;
  border: 1px solid var(--ytd-line);
  border-radius: 12px;
  outline: none;
  background: var(--ytd-surface-soft);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}

.ytd-history-item:hover {
  border-color: var(--ytd-line-strong);
  background: var(--ytd-brand-subtle);
  transform: translateY(-1px);
}

.ytd-history-thumb {
  width: 76px;
  height: 44px;
  flex: none;
  border: 1px solid var(--ytd-line);
  border-radius: 8px;
  background: #101926;
  object-fit: cover;
}

.ytd-history-info {
  flex: 1;
  min-width: 0;
}

.ytd-history-info-title {
  overflow: hidden;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ytd-history-info-meta {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 0.71rem;
  line-height: 1.35;
}

.ytd-history-score {
  flex: none;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.ytd-history-score.good {
  background: var(--ytd-success-soft);
  color: var(--success);
}

.ytd-history-score.medium {
  background: var(--ytd-warning-soft);
  color: var(--warning);
}

.ytd-history-score.bad {
  background: var(--ytd-danger-soft);
  color: var(--danger);
}

.ytd-history-delete {
  display: grid;
  flex: none;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  outline: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.ytd-history-delete:hover {
  border-color: var(--ytd-danger-line);
  background: var(--ytd-danger-soft);
  color: var(--danger);
}

.ytd-history-delete .material-icons {
  font-size: 18px;
}

.ytd-empty-history {
  padding: 18px;
  border: 1px dashed var(--ytd-line);
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
}

/* A history panel in the revised setup grid is a first-class surface, not a
   continuation of the compact legacy history block. */
.ytd-history-panel {
  margin-top: 0;
  padding: clamp(18px, 2.5vw, 24px);
  border: 1px solid var(--ytd-line);
  border-radius: 18px;
  background: var(--ytd-surface);
  box-shadow: var(--ytd-shadow);
}

/* --- Keyboard accessibility and motion ------------------------------------ */

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

.ytd-page button:focus-visible,
.ytd-page input:focus-visible,
.ytd-page textarea:focus-visible,
.ytd-history-item:focus-visible {
  outline: 3px solid var(--ytd-brand);
  outline-offset: 3px;
}

@keyframes ytd-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

@keyframes ytd-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

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

/* --- Responsive ------------------------------------------------------------ */

@media (max-width: 920px) {
  .ytd-setup-grid,
  .ytd-practice-grid {
    grid-template-columns: 1fr;
  }

  .ytd-session-meta {
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  .ytd-page {
    padding-top: 20px;
    padding-bottom: 34px;
  }

  .ytd-hero {
    padding: 21px 18px;
    border-radius: 17px;
  }

  .ytd-hero::after {
    right: -100px;
    bottom: -120px;
  }

  .ytd-hero-steps {
    grid-template-columns: 1fr;
  }

  .ytd-panel-note {
    display: none;
  }

  .ytd-url-bar {
    grid-template-columns: 1fr;
  }

  .ytd-url-bar .btn {
    width: 100%;
  }

  .ytd-practice-header {
    display: grid;
    gap: 10px;
  }

  .ytd-player-wrap {
    min-height: 0;
    border-radius: 14px;
  }

  .ytd-controls {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    padding: 8px;
  }

  .ytd-ctrl-btn {
    width: 100%;
    min-height: 44px;
    padding: 7px 5px;
  }

  .ytd-ctrl-divider {
    grid-column: 1 / -1;
    width: auto;
    height: 1px;
    margin: 1px 0;
  }

  .ytd-speed-label {
    display: none;
  }

  .ytd-advanced-controls {
    grid-column: 1 / -1;
    width: 100%;
    margin-left: 0;
  }

  .ytd-advanced-controls > summary {
    width: 100%;
  }

  .ytd-loop-controls {
    left: 0;
    right: auto;
    width: min(100%, 236px);
  }

  .ytd-auto-pause-card {
    padding: 12px 13px;
  }

  .ytd-auto-pause-heading {
    align-items: flex-start;
  }

  .ytd-auto-pause-heading p {
    max-width: 290px;
  }

  .ytd-auto-pause-options {
    grid-template-columns: minmax(0, 1fr) minmax(104px, 0.55fr);
    gap: 8px;
    margin-top: 10px;
    padding: 8px;
  }

  .ytd-auto-pause-markers-field {
    grid-column: 1 / -1;
  }

  .ytd-auto-pause-card[data-mode="markers"] .ytd-auto-pause-options {
    grid-template-columns: 1fr;
  }

  .ytd-auto-pause-card[data-mode="markers"] .ytd-auto-pause-markers-field {
    grid-column: auto;
  }

  .ytd-textarea {
    min-height: 136px;
    font-size: 0.84rem;
  }

  .ytd-user-panel .ytd-textarea,
  #ytd-user-input {
    min-height: 136px;
  }

  .ytd-textarea.transcript-area {
    min-height: 96px;
  }

  .ytd-quick-check-hint,
  .ytd-enter-check {
    padding: 8px 9px;
  }

  .ytd-inline-reference-heading,
  .ytd-reference-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .ytd-reference-status {
    white-space: normal;
  }

  .ytd-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .ytd-actions .btn {
    width: 100%;
  }

  .ytd-stat-item {
    flex-basis: 33.333%;
    min-height: 74px;
    border-bottom: 1px solid var(--ytd-line);
  }

  .ytd-stat-item:nth-child(3n) {
    border-right: 0;
  }

  .ytd-stat-item:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .ytd-history-item {
    gap: 9px;
  }

  .ytd-history-thumb {
    width: 62px;
    height: 38px;
  }
}

@media (max-width: 390px) {
  .ytd-hero-steps,
  .ytd-stepper {
    display: grid;
    grid-template-columns: 1fr;
  }

  .ytd-hero-steps > *,
  .ytd-step {
    width: 100%;
  }

  .ytd-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ytd-auto-pause-heading h4 {
    font-size: 0.75rem;
  }

  .ytd-auto-pause-heading p {
    font-size: 0.65rem;
  }

  .ytd-auto-pause-options {
    grid-template-columns: 1fr;
  }

  .ytd-stat-item {
    flex-basis: 50%;
  }

  .ytd-stat-item:nth-child(3n) {
    border-right: 1px solid var(--ytd-line);
  }

  .ytd-stat-item:nth-child(even) {
    border-right: 0;
  }

  .ytd-stat-item:nth-last-child(-n + 2) {
    border-bottom: 1px solid var(--ytd-line);
  }

  .ytd-stat-item:last-child {
    border-bottom: 0;
  }
}

/* ===================================================
   EDITORIAL STUDIO SKIN
   Restrained ink-and-brass styling: flat surfaces,
   fewer nested cards, and one non-semantic accent.
   =================================================== */

#page-yt-dictation { background: var(--bg-primary); }

.ytd-page .ytd-hero {
  overflow: visible;
  padding: clamp(24px, 3vw, 34px) clamp(22px, 3vw, 34px);
  border: 1px solid var(--ytd-line);
  border-left: 3px solid var(--ytd-brand);
  border-radius: 12px;
  background: var(--ytd-surface);
  box-shadow: none;
}

.ytd-page .ytd-hero::after {
  display: none;
}

.ytd-page .page-title,
.ytd-page .ytd-hero-title {
  font-family: 'Literata', Georgia, serif;
  font-size: clamp(1.8rem, 3vw, 2.65rem);
  font-weight: 700;
  letter-spacing: -0.035em;
}

.ytd-page .ytd-eyebrow,
.ytd-page .ytd-card-kicker {
  color: var(--ytd-brand);
  letter-spacing: 0.14em;
}

.ytd-page .ytd-hero-steps {
  gap: 0;
  margin-top: 24px;
  border-top: 1px solid var(--ytd-line);
}

.ytd-page .ytd-hero-steps > * {
  min-height: 70px;
  padding: 14px 16px 4px;
  border: 0;
  border-right: 1px solid var(--ytd-line);
  border-radius: 0;
  background: transparent;
}

.ytd-page .ytd-hero-steps > *:first-child {
  padding-left: 0;
}

.ytd-page .ytd-hero-steps > *:last-child {
  border-right: 0;
}

.ytd-page .ytd-hero-steps > * > span:first-child,
.ytd-page .ytd-step > span:first-child {
  border: 1px solid var(--ytd-line-strong);
  border-radius: 5px;
  background: transparent;
}

.ytd-page .ytd-setup-grid {
  gap: 14px;
}

.ytd-page .ytd-setup-card,
.ytd-page .ytd-guide-card,
.ytd-page .ytd-history-panel,
.ytd-page .ytd-panel,
.ytd-page .ytd-player-panel,
.ytd-page .ytd-result-panel,
.ytd-page .ytd-stats {
  border-color: var(--ytd-line);
  border-radius: 12px;
  background: var(--ytd-surface);
  box-shadow: none;
}

.ytd-page .ytd-guide-card {
  background: var(--ytd-surface-raised);
}

.ytd-page .section-title,
.ytd-page .ytd-guide-card h2,
.ytd-page .ytd-practice-header h2 {
  font-family: 'Literata', Georgia, serif;
  font-weight: 700;
}

.ytd-page .ytd-guide-list .material-icons {
  border: 1px solid var(--ytd-line);
  border-radius: 5px;
  background: transparent;
}

.ytd-page .ytd-url-bar {
  padding: 4px;
  border-radius: 9px;
  background: var(--ytd-surface-raised);
}

.ytd-page .ytd-url-input {
  border-radius: 6px;
}

.ytd-page .btn,
.ytd-page .ytd-ctrl-btn,
.ytd-page .ytd-back-link,
.ytd-page .ytd-reference-save,
.ytd-page .ytd-advanced-controls > summary {
  border-radius: 7px;
  box-shadow: none;
  transform: none;
}

.ytd-page .btn-primary,
.ytd-page .ytd-url-bar .btn-primary,
.ytd-page #ytd-check-button,
.ytd-page .ytd-reference-save,
.ytd-page .ytd-controls > .ytd-ctrl-btn:first-child {
  border-color: var(--ytd-brand);
  background: var(--ytd-brand);
  color: #1d1b14;
  box-shadow: none;
}

.ytd-page .btn-primary:hover,
.ytd-page .ytd-url-bar .btn-primary:hover,
.ytd-page #ytd-check-button:hover,
.ytd-page .ytd-reference-save:hover,
.ytd-page .ytd-controls > .ytd-ctrl-btn:first-child:hover {
  border-color: var(--ytd-brand-strong);
  background: var(--ytd-brand-strong);
  color: #17150f;
  box-shadow: none;
  filter: none;
}

html[data-theme="light"] .ytd-page .btn-primary,
html[data-theme="light"] .ytd-page .ytd-url-bar .btn-primary,
html[data-theme="light"] .ytd-page #ytd-check-button,
html[data-theme="light"] .ytd-page .ytd-reference-save,
html[data-theme="light"] .ytd-page .ytd-controls > .ytd-ctrl-btn:first-child {
  color: #fffdf7;
}

.ytd-page .ytd-practice-header {
  align-items: center;
  margin-bottom: 18px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--ytd-line);
}

.ytd-page .ytd-practice-header > div:nth-child(2) {
  flex: 1;
}

.ytd-page .ytd-session-meta > * {
  border-radius: 6px;
  background: transparent;
}

.ytd-page .ytd-practice-grid {
  grid-template-columns: minmax(0, 1.4fr) minmax(360px, 0.8fr);
  gap: 16px;
}

.ytd-page .ytd-player-panel {
  background: var(--ytd-surface);
}

.ytd-page .ytd-player-panel > .ytd-panel-heading {
  padding: 16px 18px;
  border-bottom: 1px solid var(--ytd-line);
}

.ytd-page .ytd-panel-step {
  border-radius: 5px;
  background: transparent;
}

.ytd-page .ytd-player-wrap {
  background: #0c0e0c;
}

.ytd-page .ytd-player-placeholder {
  color: #aaa698;
}

.ytd-page .ytd-player-placeholder .material-icons {
  border-color: #393b35;
  border-radius: 8px;
  background: #181b18;
  color: var(--ytd-brand);
}

.ytd-page .ytd-auto-pause-card {
  padding: 15px 18px;
  background: var(--ytd-surface-raised);
}

.ytd-page .ytd-auto-pause-icon {
  border-radius: 6px;
  background: transparent;
}

.ytd-page .ytd-auto-pause-options {
  border-radius: 8px;
  background: var(--ytd-surface);
}

.ytd-page .ytd-auto-pause-field select,
.ytd-page .ytd-auto-pause-field input,
.ytd-page .ytd-duration-input {
  border-radius: 6px;
}

.ytd-page .ytd-controls {
  gap: 4px;
  padding: 8px 10px;
  border-color: var(--ytd-line);
  background: var(--ytd-surface);
}

.ytd-page .ytd-ctrl-btn:hover,
.ytd-page .ytd-advanced-controls[open] > summary {
  border-color: var(--ytd-line-strong);
  background: var(--ytd-brand-subtle);
  color: var(--text-primary);
}

.ytd-page .ytd-ctrl-btn.active {
  border-color: var(--ytd-line-strong);
  background: var(--ytd-brand-soft);
  color: var(--ytd-brand);
  box-shadow: none;
}

.ytd-page .ytd-control-hint {
  padding-top: 11px;
  border-top: 1px solid var(--ytd-line);
}

.ytd-page .ytd-workbench {
  gap: 12px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.ytd-page .ytd-stepper {
  gap: 0;
  padding: 0 4px;
  border-bottom: 1px solid var(--ytd-line);
}

.ytd-page .ytd-step {
  min-height: 42px;
  padding: 8px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
}

.ytd-page .ytd-step.active,
.ytd-page .ytd-step[aria-current="step"] {
  border-bottom-color: var(--ytd-brand);
  background: transparent;
  color: var(--text-primary);
}

.ytd-page .ytd-user-panel {
  padding: 18px;
}

.ytd-page .ytd-answer-sheet {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.ytd-page .ytd-textarea {
  border-radius: 8px;
  background: var(--ytd-surface-raised);
}

.ytd-page #ytd-user-input {
  border-color: var(--ytd-line);
}

.ytd-page .ytd-textarea:hover {
  border-color: var(--ytd-line-strong);
}

.ytd-page .ytd-reference-ready {
  border-top-color: var(--ytd-line);
}

.ytd-page .ytd-quick-check-hint {
  margin: 0;
  padding: 9px 0 0;
  border: 0;
  border-top: 1px solid var(--ytd-line);
  border-radius: 0;
  background: transparent;
}

.ytd-page .ytd-diff-result,
.ytd-page .ytd-stats {
  margin-top: 0;
}

.ytd-page .ytd-timed-answer {
  border-radius: 8px;
  background: var(--ytd-brand-subtle);
}

.ytd-page .ytd-word {
  border-radius: 3px;
}

.ytd-page .ytd-stat-item {
  min-height: 76px;
}

.ytd-page .ytd-history-item {
  border-radius: 8px;
  background: var(--ytd-surface-raised);
}

html[data-theme="light"] body:has(#page-yt-dictation.active) .sidebar-link.active {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border)) !important;
  background: color-mix(in srgb, var(--accent) 11%, var(--bg-card)) !important;
  color: var(--accent) !important;
}

html[data-theme="light"] body:has(#page-yt-dictation.active) .sidebar-link.active::before {
  background: var(--accent) !important;
}

@media (max-width: 1040px) {
  .ytd-page .ytd-practice-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .ytd-page .ytd-hero-steps {
    border-top: 0;
  }

  .ytd-page .ytd-hero-steps > * {
    padding: 11px 0;
    border-right: 0;
    border-top: 1px solid var(--ytd-line);
  }

  .ytd-page .ytd-practice-header {
    align-items: flex-start;
  }

  .ytd-page .ytd-stepper {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .ytd-page .ytd-step {
    justify-content: center;
  }
}
