:root { --bg:#0f0f10; --panel:#1b1b1d; --fg:#f2f2f2; --muted:#9a9a9f; --accent:#ff0000; --cap-size:clamp(17px, 4.4vw, 30px); }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font-family: system-ui, -apple-system, sans-serif; }
/* While a dialog is open the page behind it does not scroll. The scrollbar's space stays reserved so nothing jumps sideways. */
html { scrollbar-gutter: stable; }
html:has(dialog[open]) { overflow: hidden; }
dialog { overscroll-behavior: contain; }
/* keep every page out of the notch margins of a phone held sideways (they are 0 elsewhere) */
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
/* Header bar (<wt-header>, header.js): logo in the middle, account and language on the right. */
.top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: 72px; padding: 0 24px; border-bottom: 1px solid #2e2e33; background: var(--bg); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; }
.brand-name { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.brand-name b { color: var(--accent); font-weight: 700; }
.top-right { justify-self: end; display: flex; align-items: center; gap: 20px; }
.account { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; color: #fff; }
.account .link { padding: 6px 2px; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; text-decoration: none; }
.account .who { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-weight: 500; }
.account .link:hover { text-decoration: underline; }
.account .sep { color: var(--muted); }
.top .lang-menu { position: relative; flex: none; width: 160px; max-width: none; }
.top .lang-menu input { width: 100%; height: 40px; padding: 0 34px 0 14px; border-radius: 10px; border: 1px solid #2e2e33; background: var(--panel); color: #d6d6da; font-size: 15px; font-weight: 500; cursor: pointer; }
.top .lang-menu .chev { position: absolute; right: 12px; top: 12px; color: var(--muted); pointer-events: none; }
.top .lang-menu ul { left: auto; right: 0; width: 300px; max-width: calc(100vw - 24px); }
@media (max-width: 640px) {
  .top { grid-template-columns: 1fr auto; height: 64px; padding: 0 12px; }
  .top-left, .account .sep, .account .signup, .account .who { display: none; }
  .brand { justify-self: start; }
  .brand-name { font-size: 20px; }
  .brand img { width: 28px; height: 28px; }
  .top-right { gap: 8px; }
  .top .lang-menu { width: 124px; }
}

/* the footer stays at the bottom of the window on short pages */
body { min-height: 100dvh; display: flex; flex-direction: column; }
main { width: 100%; flex: 1 0 auto; max-width: 960px; margin: 0 auto; padding: 16px 16px 64px; }
/* Footer bar (<wt-footer>, footer.js): like the header, with the border on top; just the copyright line, centred. */
.bottom { display: flex; justify-content: center; align-items: center; height: 72px; padding: 0 24px; border-top: 1px solid #2e2e33; background: var(--bg); color: var(--muted); font-size: 14px; }
@media (max-width: 640px) {
  .bottom { height: 64px; padding: 0 12px; font-size: 12px; }
}
form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
/* the link box has a chain-link icon inside it, on the left */
.url-field { position: relative; display: flex; flex: 1 1 240px; min-width: 0; }
.url-field input[type=text] { flex: 1; padding-left: 44px; }
/* the link box and Load Video are one piece: no gap, the inner corners square, the outer corners rounded */
#form { gap: 0; flex-wrap: nowrap; }
.url-field input[type=text] { border-radius: 8px 0 0 8px; }
#form button[type=submit] { border-radius: 0 8px 8px 0; flex: none; }
.load-go { display: inline-flex; align-items: center; justify-content: center; width: 64px; padding: 0; } /* an arrow instead of the words Load Video, like the mock-up in How It Works */
.url-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: #9a9a9f; pointer-events: none; }
input[type=text] { flex: 1 1 240px; min-width: 0; padding: 12px; border-radius: 8px; border: 1px solid #333; background: var(--panel); color: var(--fg); font-size: 16px; }
button { padding: 11px 14px; border-radius: 8px; border: 0; background: var(--accent); color: #00101f; font-weight: 600; font-size: 15px; cursor: pointer; }
#translate, #translate2, #fs { display: inline-flex; align-items: center; gap: 8px; }
#form button[type=submit], #fs { color: #fff; } /* white text on the red Load Video and Fullscreen buttons */
#translate, #translate2 { background: #fff; } /* the two Generate Translation buttons are white (dark text from `button`) */
#translate:hover:not(:disabled), #translate2:hover:not(:disabled) { background: #e8e8ea; }
#fs { margin-left: auto; flex: none; } /* always the last item of the toolbar, pushed to its right end */
button.secondary { background: var(--panel); color: var(--fg); border: 1px solid #333; }

/* The stage holds the video and the captions drawn over it, so both go fullscreen together. */
#stage { position: relative; display: flex; flex-direction: column; width: 100%; background: #000; }
#video { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; }
#player, #player iframe { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Captions sit above YouTube's control bar (about 56px tall); taps pass through to the player. */
#captions { position: absolute; left: 5%; right: 5%; bottom: calc(60px + var(--cap-lift, 0) * 1%); pointer-events: none; text-align: center; color: #fff; font-size: var(--cap-size); line-height: 1.35; white-space: pre-line; }
#captions .cap { padding: 1px 8px; border-radius: 4px; background: rgba(0,0,0,.6); box-decoration-break: clone; -webkit-box-decoration-break: clone; text-shadow: 0 0 3px #000; }
#captions .second { font-size: .82em; color: #e4e4e7; }
#captions.hidden { visibility: hidden; }

/* The fullscreen box is stretched from the four edges (inset: 0), not sized with 100vw / 100dvh: on an iPhone held sideways
   100vw is wider than the area the page really gets (the notch side), which pushed the video to the right. */
#stage:fullscreen, #stage.pseudo-fs { position: fixed; inset: 0; z-index: 9999; width: auto; height: auto; overflow: hidden; --cap-size: clamp(18px, 3.2vw, 38px);
  /* the video frame stays inside the safe area: a frame that overlaps the notch margins makes the YouTube player shift its picture */
  padding: env(safe-area-inset-top) var(--fs-pad-x, env(safe-area-inset-right)) env(safe-area-inset-bottom) var(--fs-pad-x, env(safe-area-inset-left)); }
#stage:fullscreen #video, #stage.pseudo-fs #video { flex: 1; aspect-ratio: auto; min-height: 0; }

#translate-row, #second-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
#translate-row[hidden], #second-row[hidden] { display: none; }
#size-row { margin-top: 12px; }
#size-row:has(button[hidden]) { display: none !important; } /* both buttons show together, after subtitles exist */
#size-row .size-buttons { display: flex; gap: 10px; }
#size-row .row-label { color: var(--muted); font-size: 14px; }
#translate-row label, #second-row label { color: var(--muted); font-size: 14px; }
.combobox input { width: 100%; padding: 11px 12px; border-radius: 8px; border: 1px solid #333; background: var(--panel); color: var(--fg); font-size: 16px; }
.combobox input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.combobox { position: relative; flex: 1 1 260px; max-width: 360px; }
.combobox ul { position: absolute; z-index: 20; top: 100%; left: 0; right: 0; margin: 4px 0 0; padding: 4px; list-style: none; max-height: min(340px, 45vh); overflow-y: auto; background: var(--panel); border: 1px solid #333; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.combobox ul.up { top: auto; bottom: 100%; margin: 0 0 4px; }
.combobox ul[hidden] { display: none; }
.combobox [role=option] { padding: 10px; border-radius: 6px; cursor: pointer; font-size: 15px; }
.combobox [role=option].active { background: #2b3342; }
.combobox [role=option][aria-selected=true] { color: var(--accent); }
.combobox .native { color: var(--muted); }
.combobox .group { padding: 8px 10px 4px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
#translate:disabled, #translate2:disabled { opacity: .55; cursor: default; }
/* the button that is working shows a spinner in place of the sparkle, at full strength; the other one just dims */
.btn-spinner { display: none; width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(0,16,31,.3); border-top-color: currentColor; animation: spin .8s linear infinite; }
#translate.busy:disabled, #translate2.busy:disabled { opacity: 1; }
button.busy .btn-spinner { display: inline-block; }
button.busy .sparkle { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn-spinner { animation-duration: 2.4s; } }

dialog { max-width: min(420px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 20px; border: 1px solid #333; border-radius: 12px; background: var(--panel); color: var(--fg); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin: 0 0 8px; font-size: 17px; }
dialog p { margin: 0 0 16px; color: var(--muted); font-size: 15px; line-height: 1.4; }
dialog form { text-align: right; }

#toolbar { display: flex; align-items: center; gap: 12px; margin-top: 10px; font-size: 13px; }
/* the links wrap onto their own lines when the row is narrow, so Fullscreen never has to leave it */
.help-links { display: flex; flex-wrap: wrap; gap: 4px 18px; flex: 1 1 0; min-width: 0; }
/* a button that looks like a link: it opens a dialog, so it is a button for keyboards and screen readers */
.linklike { padding: 0; border: 0; background: none; color: var(--muted); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.linklike:hover, .linklike:focus-visible { color: var(--fg); }
.help-dialog .shot { position: relative; margin-bottom: 14px; border: 2px solid #fff; border-radius: 8px; overflow: hidden; user-select: none; -webkit-user-select: none; }
.help-dialog .shot img { display: block; width: 100%; height: auto; pointer-events: none; }
/* the hand points up at the CC button (at 54 % across, 76 % down the picture): its fingertip is the top of the finger */
.help-dialog .pointer { position: absolute; left: 53.75%; top: 75%; width: 10.5%; height: auto; transform: translateX(-43.75%); pointer-events: none; filter: drop-shadow(0 2px 3px rgba(0,0,0,.5)); animation: nudge 1.2s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: translate(-43.75%, 0); } 50% { transform: translate(-43.75%, -5px); } }
@media (prefers-reduced-motion: reduce) { .help-dialog .pointer { animation: none; } }
.help-dialog p { margin: 0 0 16px; color: var(--fg); font-size: 15px; line-height: 1.45; }
.help-dialog p b { font-weight: 700; }
.help-dialog form { text-align: right; }

#status { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
#status:empty { display: none; }
#debug { margin-top: 6px; color: var(--muted); font-size: 13px; font-family: ui-monospace, monospace; }
@media (max-width: 520px) { main { padding: 10px; } }

/* when "Enable double subtitles" scrolls the second row into view, leave some air below it */
#second-row { scroll-margin-bottom: 48px; }

/* Wide screens: both language rows use the same three columns, so the boxes and the buttons line up vertically whatever
   the label's length (the label column is as wide as the longest label shown). Narrow screens keep the wrapping rows. */
@media (min-width: 641px) {
  #lang-rows { display: grid; grid-template-columns: auto minmax(0, 360px) auto; column-gap: 10px; justify-content: start; }
  #lang-rows > div { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: center; }
  #lang-rows > div[hidden] { display: none; }
  #lang-rows .combobox { flex: none; max-width: none; }
  #lang-rows button { justify-self: start; }
  #lang-rows .size-buttons { grid-column: 2 / -1; }
}

/* Narrow screens: each row is the label on its own line, then the box and the button, the same in both rows. */
@media (max-width: 640px) {
  #lang-rows > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; align-items: center; margin-top: 12px; }
  #lang-rows > div[hidden] { display: none; }
  #lang-rows label, #lang-rows .row-label { grid-column: 1 / -1; }
  #lang-rows .size-buttons { grid-column: 1 / -1; }
  #lang-rows .combobox { flex: none; max-width: none; }
}

/* Fullscreen on a phone held upright: the video keeps its shape in the middle of the screen and the subtitles go in the
   black space just under it, larger, instead of on top of the picture (the up/down buttons then move them down/up). */
@media (orientation: portrait) {
  #stage:fullscreen, #stage.pseudo-fs { justify-content: center; --cap-size: clamp(18px, 5.2vw, 30px); }
  #stage:fullscreen #video, #stage.pseudo-fs #video { flex: none; aspect-ratio: 16 / 9; }
  #stage:fullscreen #captions, #stage.pseudo-fs #captions { bottom: auto; top: calc(50% + 100vw * 9 / 32 + 14px - var(--cap-lift, 0) * 1%); }
}

/* Use-case cards (<wt-use-cases>, use-cases.js): a title and a grid of rounded dark cards, 3 / 2 / 1 across. */

#use-cases[hidden] { display: none; }
.use-cases h2 b { color: var(--accent); font-weight: inherit; }
.use-cases h2 { margin: 0 0 28px; font-size: 28px; line-height: 1.2; color: var(--fg); }
.use-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.use-card { padding: 26px 26px 28px; border: 1px solid #2e2e33; border-radius: 18px; background: #151516; }
.use-icon { display: block; margin-bottom: 16px; color: #fff; }
.use-card h3 { margin: 0 0 8px; font-size: 19px; line-height: 1.3; color: #fff; }
.use-card p { margin: 0; font-size: 16px; line-height: 1.6; color: var(--muted); }
@media (max-width: 860px) { .use-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .use-grid { grid-template-columns: 1fr; gap: 14px; } .use-cases h2, 
/* How It Works (<wt-steps>, steps.js): three rows, text on the left and a drawn mock-up of the interface on the right. */
/* the home-page sections are separated by the same divider line */
#steps-block, #use-cases { margin-top: 40px; padding-top: 28px; border-top: 1px solid #2e2e33; }
#steps-block[hidden] { display: none; }
.steps h2 { margin: 0 0 24px; font-size: 28px; line-height: 1.2; color: var(--fg); }
.step-list { list-style: none; margin: 0; padding: 0; }
.step { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: 40px; align-items: center; margin-bottom: 28px; }
.step-num { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 1px solid #2e2e33; border-radius: 10px; background: #151516; color: #fff; font-weight: 700; }
.step-copy h3 { margin: 22px 0 10px; font-size: 30px; line-height: 1.15; color: #fff; }
.step-copy p { margin: 0; max-width: 34ch; font-size: 17px; line-height: 1.55; color: var(--muted); }
.step-panel { display: flex; flex-direction: column; justify-content: center; gap: 16px; min-height: 250px; padding: 28px; border-radius: 26px; background: #1c1c1e; overflow: hidden; }
.mock-icon { display: inline-flex; color: #9a9a9f; }
/* 1: paste */
.mock-input { display: flex; align-items: center; gap: 12px; padding: 0 0 0 16px; height: 56px; border: 1.5px solid var(--accent); border-radius: 14px; background: #151516; color: #fff; font-size: 17px; white-space: nowrap; overflow: hidden; }
.mock-typed { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.mock-caret { display: inline-block; width: 2px; height: 1.1em; margin-left: 2px; vertical-align: text-bottom; background: #fff; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.mock-go { display: inline-flex; align-items: center; justify-content: center; align-self: stretch; width: 64px; background: var(--accent); color: #fff; }
.mock-card { display: flex; gap: 16px; align-items: center; width: 72%; padding: 14px; border: 1px solid #2e2e33; border-radius: 16px; background: #151516; }
.mock-thumb { flex: none; width: 76px; height: 48px; border-radius: 8px; background: #26262a; }
.mock-lines { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.mock-lines i { display: block; height: 8px; border-radius: 4px; background: #2e2e33; }
.mock-lines i:last-child { width: 55%; }
/* 2: choose a language */
.mock-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.mock-select { flex: 1 1 200px; display: flex; align-items: center; justify-content: space-between; gap: 10px; height: 48px; padding: 0 14px; border: 1.5px solid var(--accent); border-radius: 12px; background: #151516; color: #fff; font-size: 16px; }
.mock-select svg { color: #9a9a9f; }
.mock-generate { display: inline-flex; align-items: center; gap: 8px; height: 48px; padding: 0 18px; border-radius: 12px; background: #fff; color: #00101f; font-weight: 600; font-size: 15px; white-space: nowrap; }
.mock-list { list-style: none; margin: 0; padding: 6px; width: min(100%, 330px); border: 1px solid #2e2e33; border-radius: 14px; background: #151516; }
.mock-list li { padding: 10px 12px; border-radius: 8px; color: #d6d6da; font-size: 15px; }
.mock-list li em { font-style: normal; color: var(--muted); }
.mock-list li.on { background: #2b3342; color: #fff; }
/* 3: watch */
.mock-player { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: radial-gradient(circle at 35% 30%, #3a3f4a, #14151a 70%); }
.mock-play { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 44px; border-radius: 12px; background: var(--accent); color: #fff; }
.mock-subs { position: absolute; left: 6%; right: 6%; bottom: 12%; display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; }
.mock-subs span { padding: 1px 8px; border-radius: 4px; background: rgba(0,0,0,.65); color: #fff; font-size: 15px; line-height: 1.35; }
.mock-subs .second { font-size: 12.5px; color: #e4e4e7; }
.mock-tools { display: flex; gap: 8px; }
.mock-tools b { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; height: 36px; padding: 0 10px; border: 1px solid #333; border-radius: 9px; background: #151516; color: #fff; font-size: 14px; }
@media (prefers-reduced-motion: reduce) { .mock-caret { animation: none; } }
@media (max-width: 760px) {
  .step { grid-template-columns: 1fr; gap: 20px; margin-bottom: 36px; }
  .step-copy h3 { font-size: 26px; margin-top: 16px; }
  .step-copy p { max-width: none; }
  .step-panel { min-height: 0; padding: 20px; }
  .steps h2 { font-size: 22px; }
}
