/* Figtree, Medmastery's typeface (SIL Open Font License, see fonts/OFL.txt) */
@font-face {
  font-family: "Figtree";
  src: url("fonts/Figtree-VariableFont_wght.woff2") format("woff2");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}

/* Design tokens, taken from medmastery.com */
:root {
  --navy: #243b53;        /* headings, strong text, outlines */
  --slate: #334f68;       /* nav, secondary headings */
  --text: #476480;        /* body text */
  --muted: #7d93a8;
  --line: #dde7ee;
  --bg: #f5f9fb;          /* app background */
  --panel: #ffffff;
  --tint: #e5eff4;        /* chips, cards */
  --tint-strong: #d3e4ee;
  --blue: #31aed8;        /* brand accent, category labels */
  --green: #5dbd78;
  --yellow: #ffc666;      /* primary actions */
  --yellow-hover: #ffb93d;
  --on-yellow: #243b53;
  --pink: #fc9a9a;
  --sky: #87d4ed;
  --orange: #e89a3c;
  --red: #e25c5c;
  --hl: #ffe3ad;          /* the word being spoken */
  --hl-text: #243b53;
  --shadow: 0 1px 2px rgba(36, 59, 83, .06), 0 8px 24px rgba(36, 59, 83, .08);
  --radius: 16px;
  --radius-lg: 25px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --navy: #f0f5f9; --slate: #c9d8e4; --text: #b4c6d6; --muted: #7f97ad; --line: #26425c;
    --bg: #0e2135; --panel: #132b44; --tint: #1b3a58; --tint-strong: #22496c;
    --blue: #4cc3ea; --hl: rgba(255, 198, 102, .32); --hl-text: #fff6e3;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --navy: #f0f5f9; --slate: #c9d8e4; --text: #b4c6d6; --muted: #7f97ad; --line: #26425c;
  --bg: #0e2135; --panel: #132b44; --tint: #1b3a58; --tint-strong: #22496c;
  --blue: #4cc3ea; --hl: rgba(255, 198, 102, .32); --hl-text: #fff6e3;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

/* --- base ------------------------------------------------------------------------ */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 "Figtree", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { color: var(--navy); margin: 0; line-height: 1.2; }
button, select, input { font: inherit; color: inherit; }
kbd {
  font: 600 12px "Figtree", sans-serif; color: var(--navy); background: var(--tint);
  border-radius: 6px; padding: 1px 6px;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pad { padding: 14px 16px; }
.err { color: var(--red); margin: 0; }
.spacer { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* Small uppercase label, like the course categories on medmastery.com */
.eyebrow {
  display: block; font-size: 12px; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; color: var(--blue);
}
.gradient-text {
  background: linear-gradient(to right, var(--blue), var(--green));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
/* The light-blue-to-pink framed box used for feature sections on the site */
.feature {
  border: 6px solid transparent; border-radius: var(--radius-lg);
  background: linear-gradient(var(--panel), var(--panel)) padding-box,
              linear-gradient(to right, var(--sky), var(--pink)) border-box;
}

/* --- buttons: pills, like the site ---------------------------------------------- */

button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 999px; padding: 7px 16px; cursor: pointer; font-weight: 600; font-size: 14px;
  background: transparent; color: var(--navy); border: 2px solid var(--navy);
  transition: background .15s, border-color .15s, color .15s, transform .05s;
  white-space: nowrap;
}
button:hover:not(:disabled) { background: var(--tint); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--yellow); border-color: var(--yellow); color: var(--on-yellow); }
button.primary:hover:not(:disabled) { background: var(--yellow-hover); border-color: var(--yellow-hover); }
button.secondary { border-width: 2px; }
button.ghost { border-color: transparent; color: var(--slate); padding-left: 10px; padding-right: 10px; }
button.ghost:hover:not(:disabled) { background: var(--tint); }
.linkish { border: none; padding: 0; color: var(--blue); font-weight: 700; background: none; }
.linkish:hover:not(:disabled) { background: none; text-decoration: underline; }
.icon-btn { width: 40px; height: 40px; padding: 0; border: none; background: var(--tint); color: var(--navy); flex: none; }
.icon-btn:hover:not(:disabled) { background: var(--tint-strong); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }

/* --- fields ------------------------------------------------------------------------ */

.field {
  width: 100%; background: var(--panel); color: var(--navy);
  border: 2px solid var(--line); border-radius: 12px; padding: 9px 14px;
  transition: border-color .15s;
}
.field::placeholder { color: var(--muted); }
.field:focus { outline: none; border-color: var(--blue); }
.field.pill { border-radius: 999px; background: var(--tint); border-color: transparent; }
.field.pill:focus { background: var(--panel); border-color: var(--blue); }
select.field { width: auto; cursor: pointer; padding-right: 10px; font-weight: 600; }

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

.top {
  display: flex; align-items: center; gap: 14px; padding: 12px 24px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; }
.brand-app {
  font-weight: 700; font-size: 17px; color: var(--navy);
  padding-left: 14px; border-left: 2px solid var(--line);
}
.logo { height: 26px; width: auto; display: block; }
.logo.dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo.light { display: none; }
  :root:not([data-theme="light"]) .logo.dark { display: block; }
}
:root[data-theme="dark"] .logo.light { display: none; }
:root[data-theme="dark"] .logo.dark { display: block; }
.badge {
  background: var(--tint); color: var(--navy); font-weight: 700; font-size: 13px;
  border-radius: 999px; padding: 3px 12px 3px 10px; display: inline-flex; align-items: center; gap: 6px;
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); animation: pulse 1.2s infinite; }
.who:not(:empty) {
  font-weight: 600; color: var(--navy); background: var(--tint);
  border-radius: 999px; padding: 4px 14px;
}

/* --- layout ------------------------------------------------------------------------- */

.layout { flex: 1; display: flex; min-height: 0; }
.side {
  width: 340px; flex: none; display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-right: 1px solid var(--line);
}
.side-pickers { padding: 18px 16px 12px; display: grid; gap: 10px; }
.combo { position: relative; }
.combo .field { padding-left: 40px; }
.field-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.combo-list {
  position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 6px);
  max-height: 60vh; overflow: auto; padding: 6px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.combo-list .sec { padding: 10px 10px 4px; font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--blue); }
.combo-list .opt { padding: 7px 10px; border-radius: 10px; cursor: pointer; color: var(--navy); }
.combo-list .opt.hl, .combo-list .opt:hover { background: var(--tint); }
.combo-list .opt.cur { font-weight: 700; }
.combo-list .none { padding: 12px; color: var(--muted); }

.batch {
  margin: 0 16px 8px; padding: 12px; border-radius: var(--radius); background: var(--tint);
  display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 13px;
}
.batch .muted { color: var(--slate); }

.list { overflow: auto; flex: 1; padding: 0 8px 12px; }
.group {
  display: flex; align-items: center; gap: 8px; padding: 16px 8px 6px;
  font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--blue);
}
.group span { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.35; }
.group button {
  font-size: 12px; padding: 2px 10px; border-width: 0; background: var(--tint); color: var(--navy);
  text-transform: none; letter-spacing: 0;
}
.group button:hover:not(:disabled) { background: var(--tint-strong); }
.vid {
  display: flex; align-items: center; justify-content: flex-start; gap: 10px; width: 100%; text-align: left;
  border: none; border-radius: 10px; padding: 7px 10px; background: transparent;
  color: var(--navy); font-weight: 500; font-size: 14px;
}
.vid:hover:not(:disabled) { background: var(--bg); }
.vid.on { background: var(--tint); font-weight: 700; }
.vid .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vid .pct { font-size: 12px; color: var(--muted); font-weight: 600; }

.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; border: 2px solid color-mix(in srgb, var(--muted) 70%, transparent); display: inline-block; }
.dot.done { background: var(--green); border-color: var(--green); }
.dot.done.otter { background: var(--panel); border-color: var(--green); border-width: 3px; }
.dot.srt { border-color: var(--blue); border-width: 3px; }
.dot.run { background: var(--blue); border-color: var(--blue); animation: pulse 1.2s infinite; }
.dot.changed { background: var(--orange); border-color: var(--orange); }
.dot.fit, .dot.err { background: var(--red); border-color: var(--red); }
@keyframes pulse { 50% { opacity: .35; } }

.srtall { padding: 14px 16px; border-top: 1px solid var(--line); }
.srtall button { width: 100%; }
.srtall p { margin: 8px 2px 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.empty { margin: auto; padding: 24px; width: min(560px, 100%); }
.empty .feature { padding: 36px 40px; }
.empty h1 { font-size: 40px; font-weight: 700; margin-bottom: 10px; }
.empty p { font-size: 17px; margin: 0 0 20px; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; color: var(--slate); }
.legend li { display: flex; align-items: center; gap: 10px; }

#work { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.bar {
  display: flex; gap: 16px 24px; align-items: flex-start; flex-wrap: wrap;
  padding: 18px 28px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.title { flex: 1; min-width: 260px; display: grid; gap: 2px; }
.vname { font-size: 22px; font-weight: 600; letter-spacing: .1px; word-break: break-all; }
.meta { font-size: 13px; color: var(--muted); }
.notice { font-size: 13px; margin-top: 6px; padding: 8px 12px; border-radius: 10px; }
.notice.warn { background: color-mix(in srgb, var(--orange) 14%, transparent); color: var(--navy); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.savestate {
  border: none; padding: 7px 12px; min-width: 170px; justify-content: flex-start;
  background: var(--tint); color: var(--slate); font-size: 13px;
}
.savestate:disabled { opacity: 1; cursor: default; }
.savestate.saved { color: var(--green); }
.savestate.pending { color: var(--orange); }
.savestate.error { color: var(--red); }
.savestate.pending:hover, .savestate.error:hover { background: var(--tint-strong); }
.spin {
  display: inline-block; width: 13px; height: 13px; flex: none;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- player ------------------------------------------------------------------------- */

.split { flex: 1; display: grid; grid-template-columns: minmax(320px, 44%) 1fr; min-height: 0; }
.player { padding: 24px; overflow: auto; display: grid; gap: 16px; align-content: start; border-right: 1px solid var(--line); }
.player-card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.player video { width: 100%; background: #000; display: block; aspect-ratio: 16 / 9; }
video::cue { font-family: "Figtree", sans-serif; font-weight: 500; background: rgba(16, 32, 52, .82); color: #fff; }
.pctl { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 12px; }
.seg { display: inline-flex; background: var(--tint); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: none; padding: 6px 12px; font-size: 13px; gap: 3px; }
.seg button svg { width: 15px; height: 15px; }
.seg button:hover:not(:disabled) { background: var(--panel); }
.seg .play { background: var(--navy); color: var(--panel); min-width: 74px; }
.seg .play:hover:not(:disabled) { background: var(--slate); }

.options { display: grid; gap: 10px; padding: 0 4px; }
.toggle { display: flex; align-items: center; gap: 10px; color: var(--slate); font-size: 14px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle span {
  width: 36px; height: 20px; flex: none; border-radius: 999px; background: var(--tint-strong);
  position: relative; transition: background .15s;
}
.toggle span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--panel); transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.toggle input:checked + span { background: var(--blue); }
.toggle input:checked + span::after { transform: translateX(16px); }
.toggle input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.tips { background: var(--tint); border-radius: var(--radius); padding: 14px 16px; font-size: 13px; color: var(--slate); }
.tips p { margin: 6px 0 0; }

/* --- editor ------------------------------------------------------------------------- */

.editor-wrap { overflow: auto; min-height: 0; padding: 32px 40px 40vh; background: var(--panel); }
.editor {
  max-width: 720px; margin: 0 auto; outline: none; color: var(--navy);
  font-size: 18px; line-height: 1.8; white-space: pre-wrap;
}
.editor p { margin: 0 0 1.1em; }
.editor .w { border-radius: 4px; cursor: text; padding: 1px 0; transition: background .08s; }
.editor .w.act { background: var(--hl); color: var(--hl-text); box-shadow: 0 0 0 2px var(--hl); }
.editor.showlow .w.low { text-decoration: underline wavy var(--orange) 1.5px; text-underline-offset: 4px; }

.tpanel { max-width: 560px; margin: 32px auto; padding: 28px; display: grid; gap: 14px; text-align: center; }
.tpanel h3 { font-size: 20px; font-weight: 600; }
.srtinfo { display: grid; gap: 12px; padding: 16px; border-radius: var(--radius); background: var(--tint); text-align: left; color: var(--slate); }
.srtinfo p { margin: 0; }
.tpanel.has-srt #transcribeBtn { background: transparent; border-color: var(--navy); color: var(--navy); }
.tpanel.has-srt #transcribeBtn:hover:not(:disabled) { background: var(--tint); }
.progress { height: 8px; background: var(--tint); border-radius: 999px; overflow: hidden; }
.progress div { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(to right, var(--blue), var(--green)); transition: width .4s; }

/* --- dialogs & toast ----------------------------------------------------------------- */

dialog {
  color: var(--text); width: min(400px, 92vw); padding: 32px;
  border: 6px solid transparent; border-radius: var(--radius-lg);
  background: linear-gradient(var(--panel), var(--panel)) padding-box,
              linear-gradient(to right, var(--sky), var(--pink)) border-box;
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(16, 32, 52, .45); backdrop-filter: blur(2px); }
dialog form { display: grid; gap: 14px; }
dialog h2 { font-size: 26px; font-weight: 700; }
dialog .logo { height: 28px; justify-self: start; }
dialog label { display: grid; gap: 6px; font-weight: 600; color: var(--navy); font-size: 14px; }
dialog#prevDlg { width: min(760px, 94vw); }
.prev {
  white-space: pre-wrap; max-height: 60vh; overflow: auto; margin: 0; padding: 16px;
  background: var(--bg); border-radius: var(--radius); font: 15px/1.7 "Figtree", sans-serif; color: var(--navy);
}

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 20;
  background: var(--navy); color: var(--panel); font-weight: 600; font-size: 14px;
  padding: 10px 20px; border-radius: 999px; max-width: 90vw; box-shadow: var(--shadow);
}

/* --- narrow screens ------------------------------------------------------------------ */

@media (max-width: 980px) {
  /* One scrolling page instead of side-by-side panes */
  html, body { height: auto; }
  body { display: block; }
  .layout, .main, #work { display: block; }
  .side { width: auto; border-right: none; border-bottom: 1px solid var(--line); }
  .list { max-height: 45vh; }
  .split { display: block; }
  .editor-wrap { overflow: visible; padding-bottom: 80px; }
  .player { border-right: none; border-bottom: 1px solid var(--line); padding: 16px; }
  .bar { padding: 14px 16px; }
  .actions { justify-content: flex-start; }
  .editor-wrap { padding: 20px 16px 40vh; }
  .top { padding: 10px 16px; }
  .brand-app { font-size: 15px; }
}
