:root{
  --aud-bg:#edf7ff;
  --aud-panel:#ffffff;
  --aud-panel-soft:#f7fbff;
  --aud-text:#10203f;
  --aud-muted:#64748b;
  --aud-border:rgba(148,163,184,.28);
  --aud-shadow:0 26px 70px rgba(15,23,42,.10);
  --aud-blue:#0ea5e9;
  --aud-blue-dark:#0369a1;
  --aud-green:#16a34a;
  --aud-red:#dc2626;
}

html.wsa-night-mode{
  color-scheme:dark;
}

*{
  box-sizing:border-box;
}

body.audioscript-body{
  margin:0;
  min-height:100vh;
  font-family:Inter, Manrope, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color:var(--aud-text);
  background:
    linear-gradient(135deg, rgba(14,165,233,.12), rgba(34,197,94,.10)),
    var(--aud-bg);
}

html.wsa-night-mode body.audioscript-body{
  --aud-bg:#06111f;
  --aud-panel:rgba(13,22,40,.94);
  --aud-panel-soft:rgba(15,27,49,.92);
  --aud-text:#e5eefb;
  --aud-muted:#a8b8cf;
  --aud-border:rgba(148,163,184,.22);
  --aud-shadow:0 28px 80px rgba(0,0,0,.34);
  background:
    linear-gradient(135deg, rgba(14,165,233,.16), rgba(34,197,94,.08)),
    var(--aud-bg);
}

button,
select,
textarea,
a{
  font:inherit;
}

a{
  color:inherit;
}

button:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible{
  outline:3px solid rgba(14,165,233,.42);
  outline-offset:3px;
}

.hidden{
  display:none !important;
}

.audioscript-shell{
  width:min(1180px, calc(100% - 32px));
  margin:0 auto;
  padding:22px 0 46px;
}

.audioscript-topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  margin-bottom:18px;
}

.audioscript-back,
.audioscript-topbar-link,
.audioscript-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:42px;
  border:1px solid var(--aud-border);
  border-radius:12px;
  padding:10px 14px;
  font-weight:850;
  text-decoration:none;
  background:var(--aud-panel);
  color:var(--aud-text);
  cursor:pointer;
}

.audioscript-topbar-title{
  font-weight:950;
  letter-spacing:.02em;
}

.audioscript-app{
  display:flex;
  flex-direction:column;
  gap:18px;
}

.audioscript-hero,
.audioscript-panel{
  border:1px solid var(--aud-border);
  border-radius:22px;
  background:var(--aud-panel);
  box-shadow:var(--aud-shadow);
}

.audioscript-hero{
  display:grid;
  grid-template-columns:minmax(0, 1fr) 360px;
  gap:22px;
  padding:28px;
  overflow:hidden;
}

.audioscript-kicker{
  color:var(--aud-blue-dark);
  font-size:12px;
  font-weight:950;
  letter-spacing:.14em;
  text-transform:uppercase;
}

html.wsa-night-mode .audioscript-kicker{
  color:#7dd3fc;
}

.audioscript-hero h1,
.audioscript-section-head h2,
.audioscript-practice-head h2{
  margin:8px 0 0;
  font-weight:950;
  letter-spacing:0;
  line-height:1.04;
  color:var(--aud-text);
}

.audioscript-hero h1{
  max-width:760px;
  font-size:clamp(34px, 5vw, 58px);
}

.audioscript-hero p{
  max-width:740px;
  margin:14px 0 0;
  color:var(--aud-muted);
  font-size:16px;
  line-height:1.65;
}

.audioscript-global-reward,
.audioscript-reward-status{
  display:inline-flex;
  align-items:center;
  width:fit-content;
  max-width:100%;
  margin-top:16px;
  border:1px solid rgba(14,165,233,.26);
  border-radius:999px;
  padding:9px 12px;
  background:rgba(14,165,233,.10);
  color:var(--aud-blue-dark);
  font-size:13px;
  font-weight:900;
}

html.wsa-night-mode .audioscript-global-reward,
html.wsa-night-mode .audioscript-reward-status{
  color:#bae6fd;
  background:rgba(14,165,233,.16);
}

.audioscript-reward-status{
  display:flex;
  width:100%;
  border-radius:14px;
  margin-top:14px;
  justify-content:center;
  text-align:center;
}

.audioscript-hero-stats{
  display:grid;
  grid-template-columns:1fr;
  gap:12px;
}

.audioscript-hero-stats div,
.audioscript-result-stats div{
  border:1px solid var(--aud-border);
  border-radius:18px;
  padding:16px;
  background:var(--aud-panel-soft);
}

.audioscript-hero-stats strong,
.audioscript-result-stats strong{
  display:block;
  color:var(--aud-text);
  font-size:30px;
  font-weight:950;
  line-height:1;
}

.audioscript-hero-stats span,
.audioscript-result-stats span{
  display:block;
  margin-top:6px;
  color:var(--aud-muted);
  font-size:12px;
  font-weight:850;
  text-transform:uppercase;
  letter-spacing:.10em;
}

.audioscript-panel{
  padding:22px;
}

.audioscript-section-head,
.audioscript-practice-head,
.audioscript-textarea-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
}

.audioscript-section-head.compact{
  align-items:center;
}

.audioscript-section-head h2{
  font-size:28px;
}

.audioscript-status{
  color:var(--aud-muted);
  font-size:13px;
  font-weight:800;
  text-align:right;
}

.audioscript-grid{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:14px;
  margin-top:18px;
}

.audioscript-test-card{
  display:block;
  width:100%;
  min-height:178px;
  text-align:left;
  border:1px solid var(--aud-border);
  border-radius:18px;
  padding:18px;
  background:linear-gradient(145deg, rgba(14,165,233,.08), rgba(255,255,255,.94));
  color:var(--aud-text);
  box-shadow:0 18px 40px rgba(15,23,42,.07);
  cursor:pointer;
  transition:transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

html.wsa-night-mode .audioscript-test-card{
  background:linear-gradient(145deg, rgba(14,165,233,.14), rgba(15,27,49,.96));
}

.audioscript-test-card:hover{
  transform:translateY(-2px);
  border-color:rgba(14,165,233,.45);
  box-shadow:0 24px 54px rgba(14,165,233,.14);
}

.audioscript-card-source{
  display:inline-flex;
  align-items:center;
  border-radius:999px;
  padding:5px 9px;
  background:rgba(14,165,233,.12);
  color:var(--aud-blue-dark);
  font-size:11px;
  font-weight:950;
  text-transform:uppercase;
  letter-spacing:.12em;
}

html.wsa-night-mode .audioscript-card-source{
  color:#bae6fd;
}

.audioscript-test-card h3{
  margin:14px 0 8px;
  font-size:20px;
  font-weight:950;
}

.audioscript-test-card p{
  margin:0;
  color:var(--aud-muted);
  font-size:14px;
  line-height:1.5;
}

.audioscript-card-meta{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-top:16px;
}

.audioscript-card-meta span{
  border:1px solid var(--aud-border);
  border-radius:999px;
  padding:6px 9px;
  color:var(--aud-muted);
  font-size:12px;
  font-weight:850;
  background:rgba(255,255,255,.55);
}

html.wsa-night-mode .audioscript-card-meta span{
  background:rgba(255,255,255,.04);
}

.audioscript-practice{
  display:flex;
  flex-direction:column;
  gap:16px;
}

.audioscript-practice-head h2{
  font-size:32px;
}

.audioscript-player-card,
.audioscript-dictation-card,
.audioscript-diff-card{
  border:1px solid var(--aud-border);
  border-radius:18px;
  padding:18px;
  background:var(--aud-panel-soft);
}

.audioscript-track-field{
  display:flex;
  flex-direction:column;
  gap:7px;
  margin-bottom:14px;
}

.audioscript-track-field label,
.audioscript-textarea-head label{
  color:var(--aud-text);
  font-size:13px;
  font-weight:950;
  text-transform:uppercase;
  letter-spacing:.11em;
}

.audioscript-track-field select{
  width:100%;
  min-height:44px;
  border:1px solid var(--aud-border);
  border-radius:12px;
  padding:9px 12px;
  background:var(--aud-panel);
  color:var(--aud-text);
  font-weight:800;
}

#audioPlayer{
  width:100%;
  display:block;
}

.audioscript-textarea-head{
  align-items:center;
  margin-bottom:10px;
}

#dictationCount{
  color:var(--aud-muted);
  font-size:13px;
  font-weight:850;
}

#dictationInput{
  width:100%;
  resize:vertical;
  border:1px solid var(--aud-border);
  border-radius:16px;
  padding:16px;
  background:var(--aud-panel);
  color:var(--aud-text);
  line-height:1.7;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.35);
}

#dictationInput::placeholder{
  color:color-mix(in srgb, var(--aud-muted) 72%, transparent);
}

.audioscript-alert{
  min-height:22px;
  margin-top:10px;
  color:var(--aud-red);
  font-size:13px;
  font-weight:850;
}

.audioscript-actions{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:12px;
}

.audioscript-btn{
  transition:transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.audioscript-btn:hover{
  transform:translateY(-1px);
}

.audioscript-btn.primary{
  border-color:transparent;
  background:linear-gradient(90deg, #0284c7, #22c55e);
  color:#fff;
  box-shadow:0 16px 30px rgba(14,165,233,.22);
}

.audioscript-btn.secondary{
  background:var(--aud-panel);
}

.audioscript-results{
  display:flex;
  flex-direction:column;
  gap:16px;
}

.audioscript-result-stats{
  display:grid;
  grid-template-columns:repeat(4, minmax(0, 1fr));
  gap:12px;
}

.audioscript-compare-grid,
.audioscript-diff-grid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:14px;
}

.audioscript-compare-grid section,
.audioscript-diff-grid section{
  min-width:0;
  border:1px solid var(--aud-border);
  border-radius:18px;
  padding:16px;
  background:var(--aud-panel-soft);
}

.audioscript-compare-grid h3,
.audioscript-diff-card h3,
.audioscript-diff-grid h4{
  margin:0 0 12px;
  font-size:16px;
  font-weight:950;
  color:var(--aud-text);
}

.audioscript-diff-card h3{
  margin:6px 0 0;
}

.audioscript-diff-grid h4{
  font-size:14px;
  text-transform:uppercase;
  letter-spacing:.10em;
}

.audioscript-text-output{
  min-height:240px;
  max-height:520px;
  overflow:auto;
  white-space:pre-wrap;
  margin:0;
  color:var(--aud-text);
  font-family:"SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size:13px;
  line-height:1.65;
}

.audioscript-protected{
  -webkit-user-select:none;
  user-select:none;
  -webkit-touch-callout:none;
  cursor:default;
}

.audioscript-protected::selection,
.audioscript-protected *::selection{
  background:transparent;
}

.audioscript-protected-badge{
  display:inline-flex;
  align-items:center;
  margin-left:8px;
  border:1px solid rgba(14,165,233,.26);
  border-radius:999px;
  padding:4px 8px;
  color:var(--aud-blue-dark);
  background:rgba(14,165,233,.10);
  font-size:10px;
  font-weight:950;
  letter-spacing:.10em;
  text-transform:uppercase;
  vertical-align:middle;
}

html.wsa-night-mode .audioscript-protected-badge{
  color:#bae6fd;
  background:rgba(14,165,233,.16);
}

#dictationInput[readonly]{
  opacity:.82;
  cursor:not-allowed;
}

.audioscript-diff-output{
  max-height:360px;
  overflow:auto;
  color:var(--aud-text);
  font-size:14px;
  line-height:2.05;
}

.audioscript-diff-word{
  display:inline-block;
  margin:0 4px 6px 0;
  border-radius:7px;
  padding:2px 6px;
  background:rgba(148,163,184,.14);
}

.audioscript-diff-word.match{
  background:rgba(22,163,74,.14);
  color:#15803d;
}

.audioscript-diff-word.miss{
  background:rgba(220,38,38,.13);
  color:#b91c1c;
}

.audioscript-diff-word.extra{
  background:rgba(245,158,11,.17);
  color:#b45309;
}

html.wsa-night-mode .audioscript-diff-word.match{
  color:#86efac;
}

html.wsa-night-mode .audioscript-diff-word.miss{
  color:#fca5a5;
}

html.wsa-night-mode .audioscript-diff-word.extra{
  color:#fcd34d;
}

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

@media (max-width: 980px){
  .audioscript-hero{
    grid-template-columns:1fr;
  }

  .audioscript-hero-stats,
  .audioscript-result-stats{
    grid-template-columns:repeat(2, minmax(0, 1fr));
  }

  .audioscript-grid{
    grid-template-columns:repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px){
  .audioscript-shell{
    width:min(100% - 24px, 1180px);
    padding-top:14px;
  }

  .audioscript-topbar,
  .audioscript-section-head,
  .audioscript-practice-head,
  .audioscript-textarea-head{
    flex-direction:column;
    align-items:stretch;
  }

  .audioscript-topbar-title{
    order:-1;
  }

  .audioscript-back,
  .audioscript-topbar-link,
  .audioscript-btn{
    width:100%;
  }

  .audioscript-hero,
  .audioscript-panel{
    border-radius:18px;
    padding:18px;
  }

  .audioscript-hero h1{
    font-size:34px;
  }

  .audioscript-hero-stats,
  .audioscript-result-stats,
  .audioscript-grid,
  .audioscript-compare-grid,
  .audioscript-diff-grid{
    grid-template-columns:1fr;
  }

  .audioscript-status{
    text-align:left;
  }
}
