/*
 * AccentBuddy — shared chrome.
 *
 * Loaded AFTER vendor/bootstrap-1.4.0.custom.css. Three jobs:
 *   1. Lobster face for the Lobster wordmark (topbar brand + landing hero).
 *   2. Page wrapper + topbar layout.
 *   3. A few 2026-feel overrides on top of the 2011 Bootstrap base —
 *      modern focus rings, motion-reduce, sane line-height, monospace
 *      family for transcripts/codes.
 */

/* Lobster, self-hosted — no Google Fonts import. Keeps a third-party origin
   off the critical path and works in Worker preview contexts. The two WOFF2
   subsets are vendored under /vendor; each @font-face carries Google's stock
   Lobster unicode-range so the browser only downloads the script it needs. */
@font-face {
  font-family: 'Lobster';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/vendor/lobster-v32-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Lobster';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/vendor/lobster-v32-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* --- Bootstrap 1.4's 13px body is too small for 2026 reading. --- */
body {
  font-size: 15px;
  line-height: 1.55;
  background: #fff;
  color: #1f1f1f;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Tighten Bootstrap 1.4's heading line-heights — they're set for 13px body. */
h1, h2, h3, h4, h5, h6 { line-height: 1.2; }

/* Better focus indicator than Bootstrap 1.4's 1px dotted outline. */
:focus-visible {
  outline: 2px solid #0064cd;
  outline-offset: 2px;
  border-radius: 2px;
}
.btn:focus { outline: none; }
.btn:focus-visible {
  outline: 2px solid #0064cd;
  outline-offset: 2px;
}

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

/* Monospace stack used for IPA, codes, short-code, MCP URLs. */
.mono, code, pre {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

/* --- Page chrome. --- */
.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}
.page--wide { max-width: 860px; }
.page--auth { max-width: 28rem; }

/* --- Top bar overrides for Bootstrap 1.4's .topbar. ----------------------
   We lean on the vendor styles for the dark gradient bar, then drop the
   float layout for a flex inner that aligns to .page's 720px column, and
   rewire the brand to wear the Lobster face. Buttons stay stock — the
   topbar uses real .btn and .btn.primary, not bespoke chrome.
   ------------------------------------------------------------------------ */
.topbar {
  position: static;            /* vendor default is fixed; we sit in flow */
  margin-bottom: 1.5rem;
}
.topbar .fill { height: 40px; }
.topbar-inner {                /* aligns to .page max-width (720px) */
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1rem;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Brand: Lobster, sized to read in a 40px bar. Vendor brand styles use
   float + margin-left:-20px + padding — we reset all of it for flex. */
.topbar .brand {
  float: none;
  margin: 0;
  padding: 0 18px 0 0;
  line-height: 1;
  font-family: 'Lobster', Georgia, serif;
  font-weight: 400;
  font-size: 24px;
  letter-spacing: 0;
}
.topbar .brand:hover { background: transparent; color: #fff; }

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.topbar-who {
  color: #bfbfbf;
  font-size: 12.5px;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
  padding: 0 6px;
  line-height: 1;
  white-space: nowrap;
  max-width: none;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-who strong { color: #fff; font-weight: 500; }

/* Dark-bar-friendly <select>. Vendor styles only target <input>; we mirror
   the same translucent pill shape for <select> so the language picker
   reads as part of the bar instead of a stark white pill. */
.topbar select {
  font: inherit;
  font-size: 12px;
  padding: 4px 22px 4px 8px;
  background: rgba(255, 255, 255, 0.08) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%23ddd' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat right 7px center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
  line-height: 1;
}
.topbar select:hover {
  background-color: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.2);
}
.topbar select:focus {
  outline: none;
  background-color: rgba(255, 255, 255, 0.18);
  border-color: rgba(120, 180, 230, 0.6);
}
.topbar select option {
  color: #1a1a1a;
  background: #fff;
}

/* Forms drop their default float in our flex row. */
.topbar form {
  float: none;
  margin: 0;
  display: inline-flex;
  align-items: center;
}
.topbar .btn { margin: 0; }

/* --- Landing hero — the one piece of Lobster flourish. --- */
.lobster {
  font-family: 'Lobster', Georgia, serif;
  font-weight: 400;
}
.hero-unit h1.lobster {
  font-size: 64px;
  letter-spacing: -1px;
  line-height: 1.0;
  color: #1a1a1a;
  text-shadow: 0 1px 0 rgba(255,255,255,0.6);
  margin-bottom: 0.4rem;
}

/* Utility helpers. */
.muted { color: #777; }
.tiny  { font-size: 0.85rem; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  font-weight: 600;
  color: #777;
}
.stack-sm > * + * { margin-top: 0.5rem; }
.stack-md > * + * { margin-top: 1rem; }
.stack-lg > * + * { margin-top: 1.75rem; }

/* Tighten Bootstrap 1.4's chunky <input>/<select> a hair. */
input[type="text"], input[type="email"], input[type="search"], textarea {
  font: inherit;
}

/* --- Landing page (visitor + signed-in) ---------------------------------
   Ported from design-ref/landing-visitor.html + landing-signedin.html
   per-page <style> blocks. The two design files carry identical landing
   CSS; production links one mockup.css everywhere, so these live here.
   Selectors are landing-scoped, so other pages ignore them.
   ------------------------------------------------------------------------ */

/* Visitor↔signed-in split for the unified `/` page. Only the landing sets
   `body[data-state]`, so these rules never match login / error / wait. */
body[data-state="signed-in"] [data-visibility="visitor"] { display: none; }
body[data-state="visitor"] [data-visibility="signed-in"] { display: none; }

/* Hero refinements over Bootstrap 1.4's .hero-unit. */
.hero-unit {
  padding: 44px 36px 38px;
  background: linear-gradient(180deg, #f8f8f4 0%, #f0f0ea 100%);
  border: 1px solid #e5e3da;
}
.hero-unit .hero-sub {
  font-size: 17px;
  font-weight: 400;
  color: #444;
  max-width: 36em;
  margin-top: 0.6rem;
  line-height: 1.5;
}
.hero-cta-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 1.4rem;
}
.hero-cta-row .btn { margin: 0; }
.hero-cta-hint { color: #666; font-size: 0.88rem; }

/* Example output well. */
.example-section { margin-top: 2.5rem; }
.example-eyebrow {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.example-well { padding: 1rem 1.1rem 1.05rem; }
.example-well dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 1rem;
  row-gap: 0.55rem;
  margin: 0;
}
.example-well dt {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #777;
  padding-top: 0.1em;
}
.example-well dd { margin: 0; color: #1f1f1f; text-wrap: pretty; }
.example-well dd em { font-style: italic; color: #1a1a1a; }
.example-well .quote { font-size: 1.05rem; line-height: 1.4; font-weight: 500; }

/* 3-step loop strip. */
.loop-strip {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 0.6rem;
  align-items: stretch;
  margin: 1.5rem 0 0;
}
.loop-step {
  padding: 1.05rem 1.1rem;
  background: #fafafa;
  border: 1px solid #ececec;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  position: relative;
}
.loop-step::before {
  content: attr(data-step);
  position: absolute;
  top: 0.65rem;
  right: 0.7rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.72rem;
  color: #aaa;
  font-weight: 600;
}
.loop-actor {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #777;
  font-weight: 700;
}
.loop-title { font-weight: 600; font-size: 1.1rem; line-height: 1.15; }
.loop-color-record  { color: #c43c35; }
.loop-color-analyze { color: #0064cd; }
.loop-color-guide   { color: #46a546; }
.loop-sub { font-size: 0.9rem; color: #555; line-height: 1.4; text-wrap: pretty; }
.loop-sep {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c0c0c0;
  font-size: 1.4rem;
  font-weight: 300;
  user-select: none;
}

/* MCP section. */
.mcp-section { margin-top: 2.75rem; }
.url-row { display: flex; align-items: stretch; gap: 0.5rem; margin: 0.85rem 0 0; }
.url-row code {
  flex: 1;
  padding: 0.6rem 0.8rem;
  background: #f5f5f5;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
  user-select: all;
  color: #1a1a1a;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}
.url-row .btn { white-space: nowrap; min-width: 4.5rem; }
.url-row .btn.copied {
  background-color: #57a957 !important;
  background-image: none !important;
  color: #fff !important;
  text-shadow: none;
}

.setup-details {
  margin-top: 1rem;
  border: 1px solid #ececec;
  border-radius: 6px;
  background: #fafafa;
  padding: 0;
}
.setup-details summary {
  cursor: pointer;
  padding: 0.7rem 0.95rem;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.setup-details summary::-webkit-details-marker { display: none; }
.setup-details summary::after {
  content: "+";
  color: #999;
  font-weight: 400;
  font-size: 1.2rem;
  line-height: 1;
}
.setup-details[open] summary::after { content: "−"; }
.setup-details summary:hover { background: #f4f4f4; }
.setup-details .setup-body {
  padding: 0.4rem 0.95rem 1rem;
  border-top: 1px solid #ececec;
  background: #fff;
  border-radius: 0 0 6px 6px;
}
.setup-body h4 { margin: 1rem 0 0.4rem; font-size: 0.95rem; }
.setup-body h4:first-child { margin-top: 0.6rem; }
.setup-body ol { padding-left: 1.25rem; margin: 0.4rem 0; }
.setup-body ol li { margin-bottom: 0.2rem; }
.setup-body pre {
  background: #1f1f1f;
  color: #f5f5f5;
  padding: 0.75rem 0.9rem;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.45;
  border: 0;
}
.setup-body pre code { background: transparent; padding: 0; color: inherit; }

/* Footer. */
footer.site-footer {
  margin-top: 3rem;
  padding-top: 1.1rem;
  border-top: 1px solid #ececec;
  text-align: center;
  color: #777;
  font-size: 0.9rem;
}
footer.site-footer a { color: #0064cd; }

/* Mobile breakpoint. */
@media (max-width: 640px) {
  .page { padding: 1rem 0.875rem 3rem; }
  .hero-unit { padding: 28px 22px !important; }
  .hero-unit h1.lobster { font-size: 44px; }
  .topbar-inner { padding: 0 0.875rem; gap: 0.35rem; }
  .topbar .brand { font-size: 21px; padding-right: 8px; }
  .topbar-who {
    display: none;             /* save horizontal room */
  }
  .example-well dl { grid-template-columns: 1fr; row-gap: 0.15rem; }
  .example-well dt { margin-top: 0.55rem; }
  .example-well dt:first-of-type { margin-top: 0; }
  .loop-strip { grid-template-columns: 1fr; gap: 0.5rem; }
  .loop-sep { transform: rotate(90deg); font-size: 1.2rem; padding: 0.1rem 0; }
}

/* --- Auth pages (login, telegram-wait, error) ----------------------------
   All three sit inside `.page.page--auth` under the shared topbar. Ported
   from design-ref/{login,telegram-wait,error}.html — the demo-only state
   switcher in the prototype is dropped (the live page polls). */

.auth-intro h1 {
  font-size: 1.7rem;
  letter-spacing: -0.01em;
  margin: 0 0 0.35rem;
}
.auth-intro p {
  margin: 0;
  color: #555;
}

/* "Continue as" card — shown when a session cookie already exists. */
.continue-as {
  margin-top: 1.5rem;
  padding: 0.95rem 1rem 1rem;
  background: #f5f5f5;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.continue-as .who-line {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.7rem;
}
.continue-as .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #0064cd;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.continue-as .who-text {
  font-size: 0.92rem;
  color: #1f1f1f;
  line-height: 1.3;
  word-break: break-word;
}
.continue-as .who-text strong { display: block; }
.continue-as form { margin: 0; }
.continue-as .btn { width: 100%; }
.continue-as .switch-line {
  margin: 0.7rem 0 0;
  font-size: 0.85rem;
  color: #777;
  text-align: center;
}

/* Provider sign-in stack. */
.signin-stack {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 1.5rem 0 0;
}
.signin-stack .btn {
  width: 100%;
  text-align: center;
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
}
.auth-glyph {
  display: inline-flex;
  width: 1.05rem;
  height: 1.05rem;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

/* Bootstrap 1.4 doesn't ship a Telegram-blue button; mimic the .btn.primary
   gradient style so it looks native. Used by the login + telegram-wait pages. */
.btn.telegram {
  color: #fff;
  background-color: #0088cc;
  background-image: linear-gradient(180deg, #2eaae0 0%, #0088cc 100%);
  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
}
.btn.telegram:hover {
  color: #fff;
  background-color: #0072aa;
  background-position: 0 -15px;
}

.legal {
  margin-top: 1.5rem;
  font-size: 0.82rem;
  color: #888;
  line-height: 1.5;
  text-align: center;
}
.legal a { color: #0064cd; }

/* telegram-wait: large full-width deep-link button. */
.deep-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(180deg, #2eaae0 0%, #0088cc 100%);
  color: #fff;
  text-decoration: none;
  border-radius: 5px;
  text-align: center;
  font-weight: 600;
  font-size: 1rem;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-bottom-color: rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
  margin: 1.25rem 0 0;
  transition: background-position 0.1s linear;
}
.deep-link:hover {
  color: #fff;
  background-position: 0 -15px;
}
.deep-link-label { word-break: break-all; }

/* "or, on a different device" divider. */
.or-divider {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1.7rem 0 0.85rem;
  color: #777;
  font-size: 0.85rem;
}
.or-divider::before, .or-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e5e5e5;
}
.or-divider em { font-style: normal; color: #555; }

/* Short code — big, monospaced, copyable. */
.short-code-block { text-align: center; }
.short-code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 2.1rem;
  letter-spacing: 0.4em;
  padding: 0.9rem 0.5rem 0.9rem 0.9rem; /* extra-left to balance tracking */
  background: #f5f5f5;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  font-weight: 600;
  color: #1a1a1a;
  user-select: all;
  display: block;
}

/* Polling status block. */
.wait-status {
  margin-top: 1.6rem;
  padding: 0.8rem 0.9rem;
  background: #f5f5f5;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  color: #555;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}
.wait-status[data-state="error"] {
  background: #fddfde;
  border-color: #fbc7c6;
  color: #8a2925;
}
.wait-status[data-state="error"] a {
  color: #8a2925;
  font-weight: 600;
  text-decoration: underline;
}
.spinner {
  display: inline-block;
  width: 0.95em;
  height: 0.95em;
  border: 2px solid #d6d6d6;
  border-top-color: #0088cc;
  border-radius: 50%;
  animation: tspin 0.85s linear infinite;
  flex: 0 0 auto;
}
@keyframes tspin { to { transform: rotate(360deg); } }

/* error page. */
.error-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fddfde;
  color: #c43c35;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.4rem;
  margin: 0 0 1rem;
}
.error-title {
  margin: 0 0 0.9rem;
  font-size: 1.55rem;
  letter-spacing: -0.01em;
}
.alert-message.error { margin: 0 0 1.5rem; }
.error-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* ============================================================
   Recorder billing panel — balance bar (four states) + promo pane.
   Ported from design-ref/app-v2.html. The recorder fragment keeps the
   #balance / #topup-btn / #promo-* ids that recorder.js binds to; these
   rules dress the surrounding design structure. The fourth state, `empty`,
   is set client-side by recorder.js on a no_credits frame.
   ============================================================ */
.balance-panel { margin-bottom: 1.1rem; }
.balance-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem 0.65rem 0.95rem;
  background: #f5f5f5;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  margin-bottom: 0;
}
.balance-bar.has-promo-open {
  border-bottom: 0;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
.balance-text {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: #1f1f1f;
  font-weight: 500;
}
.balance-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #46a546;
  box-shadow: 0 0 0 2px rgba(70, 165, 70, 0.18);
  flex: 0 0 auto;
}
.balance-bar[data-state="free"]     .balance-dot { background: #f89406; box-shadow: 0 0 0 2px rgba(248, 148, 6, 0.18); }
.balance-bar[data-state="cooldown"] .balance-dot { background: #999;    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08); }
.balance-bar[data-state="empty"]    .balance-dot { background: #c43c35; box-shadow: 0 0 0 2px rgba(196, 60, 53, 0.22); }
.balance-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.balance-bar .btn { white-space: nowrap; }
/* No-credits emphasis flipped on by recorder.js; selector keeps the #id so the
   hook is unambiguous regardless of the .balance-topup utility class. */
#topup-btn[data-emphasis="true"], .balance-topup[data-emphasis="true"] {
  background: #c43c35;
  border-color: #a52822;
  box-shadow: 0 0 0 3px rgba(196, 60, 53, 0.25);
  font-weight: 600;
}
.promo-toggle {
  font: inherit;
  font-size: 0.82rem;
  background: transparent;
  border: 0;
  color: #0064cd;
  cursor: pointer;
  padding: 0.25rem 0.45rem;
  border-radius: 3px;
  white-space: nowrap;
}
.promo-toggle:hover { text-decoration: underline; }
.promo-toggle::before { content: "+ "; color: #999; }
.promo-toggle[aria-expanded="true"] { color: #555; }
.promo-toggle[aria-expanded="true"]::before { content: "\2212 "; }
.promo-pane {
  background: #f5f5f5;
  border: 1px solid #e5e5e5;
  border-top: 1px dashed rgba(0, 0, 0, 0.10);
  border-radius: 0 0 6px 6px;
  padding: 0.55rem 0.85rem 0.7rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.promo-pane[hidden] { display: none; }
.promo-pane .promo-form {
  display: flex;
  gap: 0.45rem;
  margin: 0;
  max-width: 26rem;
}
.promo-pane .promo-form input[type="text"] {
  flex: 1;
  padding: 0.42rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font: inherit;
  font-size: 0.92rem;
}
.promo-pane .promo-form input[type="text"]:focus {
  outline: none;
  border-color: #0064cd;
  box-shadow: 0 0 0 3px rgba(0, 100, 205, 0.16);
}
.promo-result {
  font-size: 0.85rem;
  margin-top: 0.4rem;
  color: #777;
  min-height: 1.1em;
}
.promo-result[data-state="ok"]    { color: #2e7d32; }
.promo-result[data-state="error"] { color: #c43c35; }

/* ============================================================
   RESULT PANEL v2 — prose-first, Sounds + Prosody split, server-rendered
   Praat-styled pitch chart (SVG, not canvas). Ported from
   design-ref/app-v2.html; shared by the live WS result and history detail.
   ============================================================ */
.v2-panel { margin-top: 0.5rem; }

/* Headline: the user's sentence, large, treated like a literary object. */
.result-transcript {
  font-size: 2.1rem;
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: #1a1a1a;
  margin: 0 0 0.45rem;
  text-wrap: pretty;
}
@media (max-width: 640px) { .result-transcript { font-size: 1.6rem; } }
.result-transcript .tx-word {
  cursor: pointer;
  padding: 0 0.05em;
  border-radius: 3px;
  transition: background 0.1s linear;
  position: relative;
}
.result-transcript .tx-word:hover { background: #fff7d6; }
.result-transcript .tx-word.has-issue {
  text-decoration: wavy underline #c43c35;
  text-decoration-skip-ink: none;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}
.result-transcript .tx-word.is-playing { background: #d4e6fb; }
.result-ipa {
  color: #777;
  font-size: 1.05rem;
  margin: 0 0 0.55rem;
  letter-spacing: 0.01em;
}
.result-headline-meta { margin: 0; font-size: 0.88rem; color: #555; }

/* Scrubber: single source of audio truth for the panel. */
.result-scrubber {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1rem 0 0;
  padding: 0.55rem 0.7rem;
  background: #f5f5f5;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.result-scrubber audio { display: none; }
.scrub-play {
  width: 2.1rem; height: 2.1rem;
  border-radius: 50%;
  border: 1px solid #bbb;
  background: linear-gradient(180deg, #fff, #ececec);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
  padding: 0;
  color: #1a1a1a;
}
.scrub-play:hover { background: linear-gradient(180deg, #fafafa, #e0e0e0); }
.scrub-play svg { display: block; }
.scrub-track {
  flex: 1;
  height: 6px;
  background: #ddd;
  border-radius: 3px;
  position: relative;
  cursor: pointer;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.08);
}
.scrub-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  background: #0064cd;
  border-radius: 3px;
}
.scrub-thumb {
  position: absolute;
  top: 50%; left: 0%;
  width: 13px; height: 13px;
  background: #fff;
  border: 2px solid #0064cd;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}
.scrub-time {
  font-size: 0.85rem;
  color: #555;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 5.5em;
  text-align: right;
}
.audio-trim-note {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: #8a6d3b;
  font-style: italic;
}

/* Prose summary: the headline answer. No box, no h-rule. */
.result-summary {
  margin: 1rem 0 0;
  font-size: 1rem;
  line-height: 1.55;
  color: #1f1f1f;
  text-wrap: pretty;
}
.result-summary strong { font-weight: 600; }
.result-summary em { font-style: italic; font-weight: 500; color: #1a1a1a; }

/* Sections: Sounds + Prosody. */
.section-sounds, .section-prosody { margin-top: 1.5rem; }
.section-sounds > .page-header,
.section-prosody > .page-header { margin-bottom: 0.7rem; }
.section-sounds > .page-header h3,
.section-prosody > .page-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.section-header-meta {
  float: right;
  font-size: 0.85rem;
  color: #777;
  font-weight: 400;
  padding-top: 0.15em;
}

/* Per-word boxes (reuse .specimen-words / .word hooks). */
.specimen-words {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  padding: 0.65rem 0.7rem;
  background: #fafafa;
  border: 1px solid #ececec;
  border-radius: 6px;
}
.word {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 0.32rem 0.55rem 0.4rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  min-width: 3rem;
  color: #1f2937;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}
.word.has-issues {
  border-color: #c43c35;
  color: #c43c35;
  background: #fef2f2;
}
.word-spell { font-size: 0.78rem; color: #777; line-height: 1; }
.word.has-issues .word-spell { color: #c43c35; opacity: 0.85; }
.word-ipa { font-size: 1.05rem; font-weight: 500; margin-top: 0.18rem; line-height: 1.1; }
.word-ipa.is-mismatch .ipa-said { color: #c43c35; }
.word-ipa .ipa-target { color: #2e7d32; }
.word-ipa .ipa-target::before { content: "\2192 "; color: #999; }
.sound-issues {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.sound-issues li {
  padding: 0.5rem 0.65rem 0.55rem 2rem;
  background: #fef2f2;
  border: 1px solid #f4d1cf;
  border-radius: 5px;
  position: relative;
  font-size: 0.93rem;
  line-height: 1.4;
  color: #5a1f1c;
}
.sound-issues li::before {
  content: "!";
  position: absolute;
  left: 0.6rem;
  top: 0.62rem;
  width: 1rem; height: 1rem;
  background: #c43c35;
  color: #fff;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.sound-issues .issue-word { font-weight: 700; color: #c43c35; margin-right: 0.2rem; }
.sounds-no-issues {
  margin: 0.65rem 0 0;
  padding: 0.5rem 0.7rem;
  background: #e8efe5;
  color: #2e7d32;
  border-radius: 4px;
  font-size: 0.92rem;
  font-weight: 500;
}
.sounds-no-issues::before { content: "\2713"; font-weight: 700; margin-right: 0.45rem; }

/* Prosody chart — server-rendered SVG (scales to width, aspect preserved). */
.prosody-chart {
  background: #fbf5dc;
  border: 1px solid #dccf99;
  border-radius: 5px;
  padding: 0.6rem 0.7rem 0.4rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.prosody-svg { display: block; width: 100%; height: auto; }
.prosody-grid { stroke: rgba(140, 120, 60, 0.18); stroke-width: 1; }
.prosody-bound { stroke: rgba(140, 120, 60, 0.35); stroke-width: 1; stroke-dasharray: 2 3; }
.prosody-hz, .prosody-word {
  fill: #9a8754;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px;
}
.prosody-contour {
  stroke: #1a1a1a;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.prosody-dot { fill: #1a1a1a; }
.prosody-chips {
  margin: 1rem 0 0;
  padding: 0.85rem 0 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.7rem 1.1rem;
  border-top: 1px solid #ececec;
}
@media (max-width: 640px) { .prosody-chips { grid-template-columns: 1fr 1fr; } }
.prosody-chips li { display: flex; flex-direction: column; gap: 0.1rem; }
.prosody-chips .chip-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #777;
  font-weight: 700;
}
.prosody-chips .chip-value {
  font-size: 1.05rem;
  font-weight: 600;
  color: #1a1a1a;
  font-variant-numeric: tabular-nums;
}
.prosody-chips .chip-value .chip-unit { font-weight: 400; font-size: 0.85em; color: #555; margin-left: 0.15em; }

/* All-measurements disclosure table. */
.all-measurements {
  margin-top: 1.1rem;
  border-top: 1px solid #ececec;
  padding-top: 0.5rem;
}
.all-measurements > summary {
  cursor: pointer;
  color: #0064cd;
  font-size: 0.9rem;
  padding: 0.3rem 0;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 600;
}
.all-measurements > summary::-webkit-details-marker { display: none; }
.all-measurements > summary::before {
  content: "\25b8";
  display: inline-block;
  color: #999;
  transition: transform 0.15s ease;
  width: 0.8em;
}
.all-measurements[open] > summary::before { transform: rotate(90deg); }
.all-measurements .meas-wrap { overflow-x: auto; }
.all-measurements table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-size: 0.88rem;
}
.all-measurements th, .all-measurements td {
  padding: 0.4rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid #ececec;
}
.all-measurements th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: #777;
  border-bottom: 2px solid #ddd;
  background: #fafafa;
  white-space: nowrap;
}
.all-measurements th.num, .all-measurements td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.all-measurements tbody tr:nth-child(even) { background: #fafafa; }
.all-measurements tbody tr.row-issue td:first-child { color: #c43c35; font-weight: 600; }
.all-measurements tbody tr.row-pause td { color: #999; font-style: italic; }
.all-measurements .label.warning {
  font-size: 0.65rem;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  background: #fbeec9;
  color: #8a6d3b;
}

/* Compare-to-native row: compact .tts-player variant injected between the
   scrubber and the prose. Dialect toggles + speed cycle play native audio via
   the existing /api/tts route; the backing <audio> is hidden. */
.tts-player.compare-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem 0.6rem;
  padding: 0.5rem 0.7rem;
  background: #eef3fb;
  border: 1px solid #d6e2f3;
  border-radius: 6px;
  margin-top: 0.5rem;
}
.tts-player.compare-row audio { display: none; }
.tts-player.compare-row .compare-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #1f3a6b;
  font-weight: 700;
  flex: 0 0 auto;
}
.tts-player.compare-row .tts-play {
  width: 1.85rem; height: 1.85rem;
  border-radius: 50%;
  border: 1px solid #5a8ac0;
  background: linear-gradient(180deg, #fff, #eaf0fa);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  color: #1f3a6b;
  flex: 0 0 auto;
}
.tts-player.compare-row .tts-play:hover {
  background: linear-gradient(180deg, #fafafa, #d6e2f3);
}
.tts-player.compare-row .tts-play.is-playing {
  background: linear-gradient(180deg, #d1e8ff, #a6cdf5);
  animation: tts-pulse 1.2s ease-in-out infinite;
}
@keyframes tts-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 100, 205, 0.25); }
  50%      { box-shadow: 0 0 0 4px rgba(0, 100, 205, 0.10); }
}
.tts-player.compare-row .tts-player-title {
  font-size: 0.92rem;
  color: #1f3a6b;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  min-width: 0;
}
.tts-player.compare-row .tts-row { margin: 0; display: inline-flex; gap: 0.25rem; }
.tts-player.compare-row .tts-row-dialects.compact-dialects button {
  min-width: 1.8rem;
  padding: 0.2rem 0.45rem;
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid transparent;
  border-radius: 4px;
  color: #1f1f1f;
  cursor: pointer;
}
.tts-player.compare-row .tts-row-dialects.compact-dialects button[data-active="true"] {
  background: #d1fae5;
  border-color: #a7e6c4;
}
.tts-player.compare-row .tts-row-speed button {
  font-variant-numeric: tabular-nums;
  min-width: 2.8rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid #c0d2e8;
  border-radius: 4px;
  color: #1f3a6b;
  cursor: pointer;
}
.tts-player.compare-row button:focus-visible {
  outline: 2px solid #0064cd;
  outline-offset: 1px;
}
@media (max-width: 640px) {
  .tts-player.compare-row .compare-label,
  .tts-player.compare-row .tts-player-title { flex-basis: 100%; }
}

/* Squiggle popover: floats above a flagged transcript word (created on demand
   by result-panel.js). Issue text + "hear yours"; no "hear target". */
.squiggle-popover {
  position: absolute;
  max-width: 22rem;
  padding: 0.65rem 0.8rem 0.7rem;
  background: #1a1a1a;
  color: #fff;
  border-radius: 5px;
  font-size: 0.9rem;
  line-height: 1.4;
  z-index: 50;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.13s ease, transform 0.13s ease;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}
.squiggle-popover.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.squiggle-popover::before {
  content: "";
  position: absolute;
  top: -5px;
  left: var(--arrow-x, 1rem);
  width: 10px; height: 10px;
  background: #1a1a1a;
  transform: rotate(45deg);
}
.squiggle-popover .pop-word {
  font-weight: 700;
  color: #ffb4b0;
  font-size: 0.83rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}
.squiggle-popover .pop-issue { font-weight: 500; }
.squiggle-popover .pop-actions {
  margin-top: 0.55rem;
  display: flex;
  gap: 0.8rem;
  font-size: 0.85rem;
}
.squiggle-popover .pop-actions a { color: #79c0ff; text-decoration: none; }
.squiggle-popover .pop-actions a:hover { text-decoration: underline; }
@media (prefers-reduced-motion: reduce) {
  .squiggle-popover { transition: none; }
  .tts-player.compare-row .tts-play.is-playing { animation: none; }
}
