/* Subtitle font: Avenir Next Bold where the device has it (Apple), otherwise Nunito Sans Bold (OFL). */
@font-face { font-family: "LK Sans"; font-weight: 700; font-display: block;
  src: local("AvenirNext-Bold"), local("Avenir Next Bold"), url("fonts/NunitoSans-Bold-vietnamese.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: "LK Sans"; font-weight: 700; font-display: block;
  src: local("AvenirNext-Bold"), local("Avenir Next Bold"), url("fonts/NunitoSans-Bold-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "LK Sans"; font-weight: 700; font-display: block;
  src: local("AvenirNext-Bold"), local("Avenir Next Bold"), url("fonts/NunitoSans-Bold-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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  color-scheme: dark;
  --bg: #000; --fg: #f2f2f2; --dim: #8c8c8c; --hi: #ffe000; --ui: #1a1a1a; --line: #333;
  --said: #ffe000;   /* the spoken words: the highlight chosen in Settings (app.js applyHighlight) */
  --em: 24px;                       /* main subtitle size; set from the panel size by app.js */
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body { font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; touch-action: manipulation; }
button, input, select { font: inherit; color: inherit; }
button { padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--ui); cursor: pointer; }
button:active { background: #333; }
button.primary { background: var(--hi); color: #000; border-color: var(--hi); font-weight: 600; }
button:disabled { opacity: 0.4; cursor: default; }
button.danger { background: #4a1616; color: #ffc9c9; border-color: #6e2222; font-weight: 600; }
a { color: var(--fg); }

/* ---------------------------------------------------------------- welcome */
.welcome { max-width: 560px; margin: 0 auto; padding: max(28px, env(safe-area-inset-top)) 16px 28px; }
.welcome h1 { font-size: 28px; margin: 0 0 6px; }
.intro, .hint, .foot { color: var(--dim); }
.pickers { display: grid; gap: 12px; margin: 22px 0 12px; }
.pick { display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: 14px; border: 1px solid var(--line); background: #0e0e0e; cursor: pointer; }
.pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pick:focus-within { outline: 2px solid var(--hi); }
.pick-step { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #222; font-weight: 700; }
.pick.done .pick-step { background: var(--hi); color: #000; }
.pick-name { color: var(--dim); word-break: break-word; }
.pick.done .pick-name { color: var(--fg); }
.problems:not(:empty) { margin: 12px 0; padding: 12px 14px; border-radius: 12px; background: #2a1414; color: #ffb4b4; }
.problems p { margin: 0 0 6px; } .problems p:last-child { margin: 0; }
.welcome .primary { width: 100%; padding: 14px; font-size: 18px; margin-top: 6px; }
body.dragging .welcome { outline: 3px dashed var(--hi); outline-offset: -10px; }
.recent h2 { font-size: 15px; font-weight: 600; color: var(--dim); margin: 22px 0 8px; }
.recent-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.recent-list li { display: flex; gap: 8px; }
.recent-open { flex: 1; min-width: 0; display: grid; gap: 2px; text-align: left; padding: 12px 14px; border-radius: 14px; background: #0e0e0e; }
/* a long name takes two lines, then ends in … (names without spaces break anywhere) */
.recent-title, .lib-title { font-weight: 600; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  overflow: hidden; overflow-wrap: anywhere; }
.recent-meta { color: var(--dim); font-size: 13px; }
.recent-del { flex: none; width: 44px; padding: 0; border-radius: 14px; color: var(--dim); background: #0e0e0e; }
.linkish { padding: 0; border: 0; background: none; color: var(--fg); text-decoration: underline; border-radius: 0; }
@media (hover: none) and (pointer: coarse) { .drop { display: none; } }   /* phones and tablets can't drop files */

/* ---------------------------------------------------------------- the Dropbox library: folders of videos with their state */
.library h2, .local-head { font-size: 15px; font-weight: 600; color: var(--dim); margin: 22px 0 8px; }
.lib-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.lib-links { display: flex; gap: 14px; }
.lib-head .linkish { font-size: 14px; color: var(--dim); }
.lib-search { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #000; font-size: 16px; }
.lib-note { margin: 6px 0 8px; }
.lib-list { display: grid; gap: 8px; }
.lib-folder { border: 1px solid var(--line); border-radius: 14px; background: #0e0e0e; }
.lib-folder > summary { padding: 12px 14px; cursor: pointer; font-weight: 600; overflow-wrap: anywhere; }
.lib-count { color: var(--dim); font-weight: 400; }
.lib-items { list-style: none; margin: 0; padding: 0 6px 6px; display: grid; gap: 4px; }
.lib-item { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; text-align: left; padding: 10px; border: 0; border-radius: 10px; background: #161616; }
.lib-item .lib-title { grid-column: 1 / -1; }   /* the whole width for the name; the state goes on the line below */
.lib-item .badge { grid-row: 2; grid-column: -2; }
.lib-meta { grid-row: 2; grid-column: 1; align-self: center; color: var(--dim); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* select mode: a circle to tick in front of each file, and the Delete bar kept in view at the bottom */
.lib-item.picking { grid-template-columns: auto minmax(0, 1fr) auto; }
.lib-item.picking .lib-title { grid-column: 2 / -1; }
.lib-item.picking .lib-meta { grid-column: 2; }
.lib-tick { grid-row: 1 / span 2; grid-column: 1; align-self: center; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #555; }
.lib-item[aria-pressed="true"] { background: #2a2410; }
.lib-item[aria-pressed="true"] .lib-tick { border-color: var(--hi); background: var(--hi) no-repeat center / 14px
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.2 3L13 4.5' fill='none' stroke='%23000' stroke-width='2.4'/%3E%3C/svg%3E"); }
.lib-pick { position: sticky; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 2; display: flex; align-items: center; gap: 10px;
  margin-top: 10px; padding: 8px 8px 8px 16px; border-radius: 14px; background: #222; box-shadow: 0 6px 24px rgba(0,0,0,.6); }
.lib-pick[hidden] { display: none; }
.lib-pick span { flex: 1; min-width: 0; }
.del-list { margin: 0 0 10px; padding-left: 20px; overflow-wrap: anywhere; max-height: 40vh; overflow: auto; }
.del-list li { margin: 3px 0; }
.del-list .more { list-style: none; color: var(--dim); }
.badge { align-self: center; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: #1d3320; color: #9be3a4; }
.badge.busy { background: #363010; color: var(--hi); }
.badge.bad { background: #3a1818; color: #ffb4b4; }
.badge.none { background: #222; color: var(--dim); }

/* ---------------------------------------------------------------- getting a transcript: on the start screen, over the
   empty subtitle area (the video plays meanwhile), and in settings */
.get { display: grid; gap: 8px; }
.get[hidden] { display: none; }
.get > p { margin: 0; }
.welcome .get { margin: 0 0 12px; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: #0e0e0e; }
.get-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.get-actions button { flex: 1 1 auto; }
.welcome .get .primary { width: auto; margin: 0; padding: 9px 14px; font-size: 16px; }
.get-error { color: #ffb4b4; overflow-wrap: anywhere; }
.get progress { width: 100%; height: 8px; accent-color: var(--hi); }
.live-checking { color: var(--dim); }
.wait { position: absolute; inset: 0; overflow: auto; place-content: center; padding: 24px max(16px, 6%); text-align: center;
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; user-select: text; -webkit-user-select: text; }
.wait .get-actions { justify-content: center; }
.wait .get-actions button { flex: 0 1 auto; }

/* ---------------------------------------------------------------- player
   Portrait: video on top, subtitles below. Landscape: video left, subtitles right. app.js sets
   --video-size (the video's height in portrait, its width in landscape) from the viewer's split. */
.player { position: fixed; inset: 0; display: grid; grid-template-columns: 100%;
  grid-template-rows: var(--video-size, 56.25vw) minmax(0, 1fr) auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); background: var(--bg); }
.player[hidden] { display: none; }
.video-box { position: relative; width: 100%; height: 100%; min-width: 0; min-height: 0; background: #000; }
.flash { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 10px 18px; border-radius: 14px;
  background: rgba(0, 0, 0, 0.65); color: #fff; font: 600 26px/1.2 -apple-system, BlinkMacSystemFont, sans-serif;
  white-space: nowrap; opacity: 0; transition: opacity 0.25s; pointer-events: none; }
.flash.show { opacity: 1; transition: none; }
.video-box video { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; }
/* a recording: its cover art over a blurred copy that fills the area, or the bars (taps go through to the video) */
.cover, .viz { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cover[hidden], .viz[hidden] { display: none; }
.cover { overflow: hidden; background: #000; }
.cover-back { position: absolute; inset: -12%; width: 124%; height: 124%; object-fit: cover; filter: blur(32px) brightness(0.45) saturate(1.2); }
.cover-art { position: absolute; inset: 0; width: 100%; height: 100%; padding: 5%; object-fit: contain; filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.55)); }
.panel { position: relative; overflow: hidden; min-width: 0; min-height: 0; font-family: "LK Sans", Avenir Next, sans-serif; font-weight: 700;
  user-select: none; -webkit-user-select: none; }
@media (orientation: landscape) {
  .player { grid-template-columns: var(--video-size, 60%) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .video-box { grid-column: 1; grid-row: 1; }
  .panel { grid-column: 2; grid-row: 1; }
  .bar { grid-column: 1 / -1; }
}

/* the handle between video and subtitles: along the panel's top edge, or its left edge in landscape */
.splitter { position: absolute; z-index: 1; top: 0; left: 0; right: 0; height: 20px; cursor: row-resize; touch-action: none; }
.splitter::after { content: ""; position: absolute; top: 6px; left: 50%; width: 44px; height: 4px; margin-left: -22px;
  border-radius: 2px; background: #3a3a3a; }
.splitter:hover::after, .splitter.dragging::after { background: var(--hi); }
@media (orientation: landscape) {
  .splitter { right: auto; bottom: 0; width: 20px; height: auto; cursor: col-resize; }
  .splitter::after { top: 50%; left: 6px; width: 4px; height: 44px; margin: -22px 0 0; }
}

/* subtitle panel: the same proportions as the burned vertical video, in em of the main text */
.cur, .ctx { position: absolute; left: 0; right: 0; text-align: center; white-space: nowrap; }
.line { display: block; line-height: 1.3717; }
.cur { top: 50%; transform: translateY(-50%); font-size: var(--em); color: #fff; }
.cur .on { color: var(--said); }
.ctx { font-size: calc(var(--em) * 0.7957); color: var(--dim); }
.prev { bottom: calc(50% + var(--em) * 3.3335); }
.next { top: calc(50% + var(--em) * 3.3335); }
.w { cursor: pointer; border-radius: 4px; }
.editing .w { text-decoration: underline dotted 2px; text-underline-offset: 0.18em; }

/* ---------------------------------------------------------------- control bar: two rows, arranged by the viewer */
.bar { display: flex; flex-direction: column; gap: 6px; padding: 6px 10px calc(8px + env(safe-area-inset-bottom)); background: #0b0b0b; border-top: 1px solid #1c1c1c; }
.bar-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; }
.bar-row:empty { display: none; }
.bar .icon { min-width: 42px; padding: 8px 10px; }
.bar .play { min-width: 54px; font-size: 18px; }
.bar .back { font-size: 24px; line-height: 1; padding: 5px 12px 7px; }
.bar .chip { padding: 7px 10px; font-size: 14px; white-space: nowrap; }
.bar .chip[aria-pressed="true"] { background: var(--hi); color: #000; border-color: var(--hi); }
.bar .icon svg { display: block; width: 18px; height: 18px; margin: 0 auto; }
.progress { flex: 1 1 160px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.progress input[type=range] { flex: 1; min-width: 60px; accent-color: var(--hi); }
.time { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--dim); white-space: nowrap; }
@media (max-width: 430px) { .bar { padding-left: 6px; padding-right: 6px; } .bar-row { gap: 4px; } .bar .icon { min-width: 36px; padding: 8px 4px; } .bar .chip { padding: 7px 6px; } }
@media (max-width: 360px) { .bar .icon { min-width: 32px; padding: 8px 4px; } .bar .chip { padding: 7px 4px; font-size: 13px; } .bar .play { min-width: 44px; } }

/* arranging: tap a part of the bar to select it, then move it with the panel's buttons */
.arrange { display: grid; gap: 8px; padding: 4px 0 8px; border-bottom: 1px solid #222; }
.arrange[hidden], .arrange-hidden[hidden] { display: none; }
.arrange-hint { margin: 0; font-size: 14px; }
.arrange-moves { display: flex; flex-wrap: wrap; gap: 6px; }
.arrange-moves button { flex: 1 1 auto; padding: 8px 10px; }
.arrange-hidden { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--dim); font-size: 13px; }
.arrange-hidden .chip { padding: 5px 9px; font-size: 13px; }
.arranging .bar-row > * { outline: 1px dashed #555; outline-offset: 2px; }
.arranging .bar-row > .selected { outline: 2px solid var(--hi); }
.arranging .bar-row input { pointer-events: none; }

/* ---------------------------------------------------------------- dialogs, toast, update banner */
dialog { width: min(480px, calc(100vw - 24px)); max-height: calc(100vh - 24px); border: 1px solid var(--line); border-radius: 16px; background: #111; color: var(--fg); padding: 18px; }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { margin: 0 0 10px; font-size: 20px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 12px; padding: 10px 12px; }
legend { padding: 0 6px; color: var(--dim); }
input[type=range] { accent-color: var(--hi); }
#sync, #split, #speedRange, #hiStrength { width: 100%; }
select, #editorText { width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: #000; }
#editorText { font: 700 22px "LK Sans", sans-serif; }
.small { color: var(--dim); font-size: 13px; margin: 6px 0 0; }
.small.top { margin: 0 0 8px; }
.row { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.row button { flex: none; margin-top: 4px; }
.stepper { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stepper button { min-width: 44px; padding: 6px 10px; font-size: 20px; line-height: 1; }
.stepper input, #speedNum { width: 84px; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: #000; text-align: center; font-size: 18px; }
.speed-row { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.speed-row select { flex: 1; width: auto; }
.range-ends { position: relative; height: 20px; margin: 2px 10px 12px; color: var(--dim); font-size: 13px; }
.range-ends span { position: absolute; top: 0; }
.range-ends span:first-child { left: -10px; }
.range-ends span:last-child { right: -10px; }
.range-ends .one { left: 53.7%; transform: translateX(-50%); }   /* 1× on the logarithmic slider */
/* the highlight: color swatches (the last one opens a color picker), then full color and soft, each with a sample */
.swatches { display: grid; grid-template-columns: repeat(7, minmax(24px, 34px)); gap: 10px; margin: 2px 0 12px; }   /* one row, even on a phone */
.swatch { position: relative; aspect-ratio: 1; cursor: pointer; }
.swatch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.swatch span { display: block; width: 100%; height: 100%; border-radius: 50%; pointer-events: none;
  background: var(--c, conic-gradient(#ff5b5b, #ffe000, #4ade80, #38bdf8, #a78bfa, #f472b6, #ff5b5b)); }
.swatch.chosen span { outline: 2px solid #fff; outline-offset: 3px; }
.swatch input:focus-visible + span { outline: 2px solid var(--hi); outline-offset: 3px; }
.hi-looks { display: grid; gap: 12px; margin: 0 0 6px; }
.hi-look { display: grid; gap: 6px; cursor: pointer; }
.hi-name { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.hi-name input { margin: 0; accent-color: var(--hi); }
.hi-name output { color: var(--dim); }
.hi-sample { display: block; padding: 10px 12px; border-radius: 10px; background: #000; color: #fff; text-align: center;
  font: 700 18px/1.35 "LK Sans", Avenir Next, sans-serif; text-wrap: balance; }
.fix-list { list-style: none; margin: 0 0 8px; padding: 0; max-height: 30vh; overflow: auto; }
.fix-list li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px solid #1c1c1c; }
.fix-list li button { padding: 2px 8px; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; }
.dialog-buttons .left { margin-right: auto; }
.field { display: block; margin: 10px 0 0; color: var(--dim); font-size: 14px; }
.field input { display: block; width: 100%; margin-top: 4px; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: #000; color: var(--fg); font-size: 16px; }
.status:not(:empty) { color: var(--fg); }
.toast { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100vw - 32px);
  padding: 10px 14px; border-radius: 12px; background: #222; color: var(--fg); box-shadow: 0 6px 24px rgba(0,0,0,.5); z-index: 10; }
.toast button { margin-left: 10px; padding: 4px 10px; }
.update { position: fixed; top: calc(8px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); padding: 8px 12px; border-radius: 12px;
  background: var(--hi); color: #000; z-index: 11; white-space: nowrap; }
.update button { margin-left: 8px; padding: 4px 10px; background: #000; color: var(--hi); border: 0; }
/* an upload running while no box on screen shows it */
.transfer { position: fixed; top: calc(8px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); max-width: calc(100vw - 32px);
  display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 14px; border-radius: 12px; background: #222; color: var(--fg);
  box-shadow: 0 6px 24px rgba(0,0,0,.5); z-index: 10; font-size: 14px; white-space: nowrap; }
.transfer[hidden] { display: none; }
.transfer span { overflow: hidden; text-overflow: ellipsis; }
.transfer button { padding: 4px 10px; }

/* ---------------------------------------------------------------- touch lock: nothing under it takes a touch, and a touch shows
   the slider; the lock has to be slid to the right end (app.js setLocked) */
.lock { position: fixed; inset: 0; z-index: 20; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.lock[hidden] { display: none; }
.player.locked .bar { opacity: 0.3; }
.unlock { position: absolute; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom)); width: min(340px, calc(100% - 32px)); height: 62px;
  transform: translateX(-50%); border-radius: 31px; background: rgba(24, 24, 24, 0.94); border: 1px solid #444;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.7); opacity: 0; visibility: hidden; transition: opacity 0.4s, visibility 0.4s; }
.unlock.show { opacity: 1; visibility: visible; transition: opacity 0.15s; }
.unlock-text { position: absolute; inset: 0; display: grid; place-items: center; padding: 0 52px 0 64px; color: #bbb; font-size: 16px; }
.unlock-end { position: absolute; right: 20px; top: 50%; width: 24px; height: 24px; margin-top: -12px; color: #9be3a4; }
.unlock-knob { position: absolute; left: 5px; top: 5px; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%;
  background: var(--hi); color: #000; cursor: grab; touch-action: none; }
.unlock-knob svg { width: 24px; height: 24px; }
.unlock-knob.back { transition: transform 0.25s ease-out; }
.unlock-knob:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
