/* ----------------------------------------------------------------------
   ytscribe — Apple-flavoured dark UI
   Tokens map to Apple's system colors so light/dark feel native.
---------------------------------------------------------------------- */

:root {
  --bg: #000;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --surface-3: #3a3a3c;
  --border: rgba(84, 84, 88, 0.55);
  --text: #f5f5f7;
  --text-dim: rgb(174, 174, 178);
  --text-faint: rgba(235, 235, 245, 0.40);
  --accent: rgb(255, 69, 58);
  --accent-hover: rgb(255, 102, 92);
  --link: rgb(10, 132, 255);
  --green: rgb(48, 209, 88);
  --shadow-pop: 0 10px 28px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.3);
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fbfbfd;
    --surface: #ffffff;
    --surface-2: #f2f2f7;
    --surface-3: #e5e5ea;
    --border: rgba(60, 60, 67, 0.18);
    --text: #1d1d1f;
    --text-dim: rgb(60, 60, 67);
    --text-faint: rgba(60, 60, 67, 0.30);
    --accent: rgb(255, 59, 48);
    --accent-hover: rgb(216, 50, 41);
    --link: rgb(0, 122, 255);
    --green: rgb(40, 205, 65);
    --shadow-pop: 0 10px 28px rgba(0, 0, 0, 0.10), 0 2px 6px rgba(0, 0, 0, 0.06);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
        "Helvetica Neue", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 1.25rem 5rem;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.92em;
}

h1, h2, h3 { letter-spacing: -0.022em; line-height: 1.1; margin: 0; }
h1 { font-weight: 700; }
h2 { font-weight: 600; }

::selection { background: var(--accent); color: white; }

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

.site-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(28, 28, 30, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  position: sticky;
  top: 0;
  z-index: 50;
}
@media (prefers-color-scheme: light) {
  .site-header { background: rgba(251, 251, 253, 0.72); }
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  line-height: 1;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { text-decoration: none; opacity: 0.85; }

.brand-mark { display: block; flex-shrink: 0; color: var(--text); }
.brand-mark-y {
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-weight: 700;
  font-size: 18px;
  fill: currentColor;
}
.brand-mark-dot { fill: var(--accent); }

.brand-wordmark {
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand-dot { color: var(--accent); }

.site-footer {
  text-align: center;
  padding: 2rem 1rem 3rem;
  color: var(--text-faint);
  font-size: 0.875rem;
}

/* ---------- hero / home ---------- */

.hero {
  text-align: center;
  padding: 4rem 0 3rem;
}
.hero h1 {
  font-size: clamp(2.5rem, 7vw, 4.25rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.75rem;
}
.hero .lede {
  font-size: 1.375rem;
  color: var(--text-dim);
  margin: 0 0 3rem;
  letter-spacing: -0.01em;
  font-weight: 400;
}

.swap-demo {
  display: flex;
  justify-content: center;
  margin: 0 auto 2.5rem;
}
.swap-line {
  display: inline-flex;
  align-items: baseline;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.95rem 1.25rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: clamp(0.92rem, 2.4vw, 1.0625rem);
  letter-spacing: -0.005em;
  word-break: break-all;
  max-width: min(100%, 560px);
}
.swap-target {
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
  position: relative;
}
.swap-target.swap-deleting { color: var(--text-dim); font-weight: 500; }
.swap-target.swap-active::after {
  content: "";
  display: inline-block;
  width: 0.06em;
  height: 1em;
  background: var(--accent);
  vertical-align: -0.14em;
  margin-left: 0.05em;
  animation: cursor-blink 1s step-end infinite;
}
.swap-target.swap-done::after {
  background: var(--text-faint);
  animation: cursor-blink 2s step-end infinite;
}
.swap-suffix { color: var(--text); }

.try-link { display: inline-flex; gap: 0.5rem; align-items: center; }

/* ---------- bookmarklet section ---------- */

.bookmarklet {
  margin: 4rem auto 0;
  max-width: 560px;
  text-align: center;
}
.bookmarklet h2 {
  font-size: clamp(1.4rem, 3vw, 1.75rem);
  font-weight: 600;
  letter-spacing: -0.022em;
  margin-bottom: 0.6rem;
}
.bookmarklet-lede { color: var(--text-dim); margin-bottom: 1.5rem; }
.bookmarklet-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  text-decoration: none;
  background: #0c0c0d;
  color: #f4f2ee;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 0.7rem 1.1rem 0.7rem 0.85rem;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 6px 18px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.bookmarklet-btn:hover {
  background: #15151a;
  transform: translateY(-1px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 10px 22px rgba(0, 0, 0, 0.45);
  text-decoration: none;
}
.bookmarklet-btn:active { cursor: grabbing; transform: translateY(0); }
.bookmarklet-btn .brand-mark { color: #f4f2ee; }
.bookmarklet-btn .brand-mark-y { fill: #f4f2ee; }
.bookmarklet-btn .brand-mark-dot { fill: #ff5b4a; }
.bookmarklet-btn .brand-wordmark { color: #f4f2ee; font-size: 15px; }
.bookmarklet-btn .brand-dot { color: #ff5b4a; }
.bookmarklet-help {
  margin-top: 1.75rem;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.1rem;
}
.bookmarklet-help summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--text-dim);
  font-size: 0.9rem;
}
.bookmarklet-help[open] summary { color: var(--text); margin-bottom: 0.75rem; }
.bookmarklet-help ol {
  padding-left: 1.25rem;
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.7;
}
.bookmarklet-help ol li { margin-bottom: 0.4rem; }
.bookmarklet-note {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-faint);
}
.btn-link {
  background: transparent;
  border: 0;
  color: var(--link);
  padding: 0;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-link:hover { background: transparent; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--surface-2);
  color: var(--text);
  border: 0;
  border-radius: var(--radius-md);
  padding: 0.6rem 1.1rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: white;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary.copied { background: var(--green); }

/* ---------- player + transcript header ---------- */

.player-frame {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: black;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-pop);
}
.player-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.video-title {
  font-size: clamp(1.4rem, 3vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.022em;
  margin: 1.5rem 0 0.4rem;
}
.video-meta {
  color: var(--text-dim);
  margin: 0 0 2rem;
  font-size: 0.875rem;
}
.video-meta .dot { margin: 0 0.5rem; color: var(--text-faint); }

/* ---------- action bar (sticky) ---------- */

.action-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: rgba(28, 28, 30, 0.85);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.625rem 0.75rem;
  margin-bottom: 1.75rem;
  position: sticky;
  top: calc(1.25rem + 1px);
  z-index: 30;
}
@media (prefers-color-scheme: light) {
  .action-bar { background: rgba(255, 255, 255, 0.85); }
}

/* split copy button */
.copy-group { position: relative; display: inline-flex; }
.copy-group .copy-main {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  padding-right: 0.875rem;
}
.copy-group .copy-caret {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 0.6rem 0.7rem;
  border-left: 1px solid rgba(255, 255, 255, 0.18);
}
.copy-group.open .copy-caret svg { transform: rotate(180deg); }
.copy-caret svg { transition: transform 0.18s ease; }

.copy-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.35rem;
  box-shadow: var(--shadow-pop);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.copy-menu[hidden] { display: none; }
.copy-menu button {
  background: transparent;
  border: 0;
  color: var(--text);
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.copy-menu button:hover { background: var(--surface-2); }
.copy-menu .menu-title { font-size: 0.95rem; font-weight: 500; }
.copy-menu .menu-hint { font-size: 0.78rem; color: var(--text-faint); }

/* view toggle */
.view-toggle {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 2px;
}
.view-btn {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  border-radius: 8px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.view-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.25); }

/* language picker */
.lang-picker {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-dim);
  font-size: 0.875rem;
}
.lang-picker .lang-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-faint); }
.lang-picker select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.875rem;
}

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

.transcript-view { display: none; }
.transcript-view.active { display: block; }

#transcript-paragraphs p {
  margin: 0 0 1.4rem;
  line-height: 1.7;
  font-size: 1.0625rem;
  letter-spacing: -0.005em;
}
#transcript-timestamped pre {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.92rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  color: var(--text);
}

/* ---------- ad slot ---------- */

.ad-slot {
  margin: 3rem 0 1rem;
  min-height: 90px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
}

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

.error { text-align: center; padding: 5rem 1rem; }
.error h1 { font-size: 2rem; margin-bottom: 0.75rem; letter-spacing: -0.025em; }
.error-detail { color: var(--text-dim); font-size: 1.125rem; }
.error-video { color: var(--text-faint); margin-top: 1.25rem; font-size: 0.9rem; }

/* ---------- loading skeleton ---------- */

.loader { padding: 5rem 1rem 6rem; }
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.5rem;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 720ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  margin: 0;
  font-size: 1rem;
  color: var(--text-dim);
  line-height: 1.7;
}
.loading-url {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.95rem;
}
.loading-error {
  text-align: center;
  padding: 2rem 1rem;
}
.loading-error h2 { font-size: 1.4rem; margin-bottom: 0.5rem; }
.loading-error p { color: var(--text-dim); margin-bottom: 1.5rem; }

/* ---------- fade-in cascade for transcript paragraphs ---------- */

.fade-cascade.cascading > * {
  opacity: 0;
  animation: fadeInUp 520ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  animation-delay: calc(var(--i, 0) * 45ms + 80ms);
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .fade-cascade.cascading > * { opacity: 1; animation: none; }
  .spinner { animation-duration: 2s; }
}

/* The whole transcript shell fades in once it lands. */
.shell-enter {
  opacity: 0;
  animation: shellIn 420ms ease-out forwards;
}
@keyframes shellIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- typewriter ---------- */

.typewriter {
  display: inline-block;
}
.typewriter::after {
  content: "";
  display: inline-block;
  width: 0.06em;
  height: 1em;
  margin-left: 0.08em;
  background: var(--accent);
  vertical-align: -0.12em;
  animation: cursor-blink 1s step-end infinite;
}
.typewriter.done::after {
  background: var(--text-faint);
  animation: cursor-blink 2s step-end infinite;
}
@keyframes cursor-blink { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .typewriter::after { animation: none; }
}

/* ---------- utility ---------- */

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