/*
 * Supercut — hand-written stylesheet, no framework.
 *
 * Priorities, in order: density, legibility of long verbatim text, and an
 * unmistakable visual difference between "fine", "check this" and "do not use
 * this". The people using it read transcripts all day on a laptop, so the type
 * is small but the line length in the reading columns is not.
 */

:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --ink: #17181a;
  --ink-2: #55585e;
  --ink-3: #85898f;
  --line: #d9dade;
  --line-2: #ebecef;
  --accent: #1f4fd8;
  --accent-ink: #ffffff;
  --ok: #14713d;
  --ok-bg: #e4f4ea;
  --warn: #8a5a00;
  --warn-bg: #fdf1da;
  --bad: #a0182a;
  --bad-bg: #fbe5e7;
  --confidential-bg: #3a0d14;
  --confidential-ink: #ffd9de;
  --radius: 5px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a;
    --panel: #1e2024;
    --ink: #e8e9ec;
    --ink-2: #a7abb3;
    --ink-3: #7c818a;
    --line: #33363c;
    --line-2: #26282d;
    --accent: #6c93ff;
    --accent-ink: #0f1114;
    --ok: #6fd39b;
    --ok-bg: #17301f;
    --warn: #e8b45c;
    --warn-bg: #302512;
    --bad: #ff8a96;
    --bad-bg: #351317;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
}

[x-cloak] { display: none !important; }

/* ------------------------------------------------------------- chrome --- */

.confidential {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--confidential-bg);
  color: var(--confidential-ink);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  padding: 5px 10px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 25px;
  z-index: 30;
}

.brand { font-weight: 700; letter-spacing: -0.01em; text-decoration: none; color: var(--ink); }
.topbar nav { display: flex; gap: 16px; margin-right: auto; }
.topbar nav a { color: var(--ink-2); text-decoration: none; padding: 2px 0; border-bottom: 2px solid transparent; }
.topbar nav a:hover { color: var(--ink); }
.topbar nav a.on { color: var(--ink); border-bottom-color: var(--accent); }
.signout { margin: 0; }

main { max-width: 1360px; margin: 0 auto; padding: 20px; }
main.centered { display: flex; justify-content: center; padding-top: 8vh; }

/* -------------------------------------------------------------- type ---- */

h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
h2.section { font-size: 13px; text-transform: uppercase; letter-spacing: 0.07em;
             color: var(--ink-3); margin: 24px 0 8px; }
a { color: var(--accent); }
code { font-family: var(--mono); font-size: 0.92em; background: var(--line-2);
       padding: 1px 4px; border-radius: 3px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.hint { color: var(--ink-3); font-size: 12px; margin: 2px 0 6px; }
.err { color: var(--bad); background: var(--bad-bg); border: 1px solid var(--bad);
       border-radius: var(--radius); padding: 8px 10px; margin: 8px 0; }
.empty { color: var(--ink-2); padding: 28px; text-align: center;
         border: 1px dashed var(--line); border-radius: var(--radius); }

.pagehead { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.pagehead-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inline { display: inline; margin: 0; }

/* ------------------------------------------------------------- alarm ---- */

.alarm {
  background: var(--bad);
  color: #fff;
  font-weight: 650;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  letter-spacing: 0.02em;
}

/* -------------------------------------------------------------- chips --- */

.chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--line-2);
  color: var(--ink-2);
  white-space: nowrap;
  vertical-align: 1px;
}
.chip.ok, .chip.s-done, .chip.lvl-info { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.chip.warn, .chip.s-running, .chip.s-queued, .chip.lvl-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.chip.bad, .chip.s-error, .chip.lvl-error { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.chip.gem { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.chip.via { text-transform: uppercase; letter-spacing: 0.05em; }

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

.btn {
  font: inherit;
  font-weight: 550;
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  line-height: 1.4;
}
.btn:hover { border-color: var(--ink-3); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn-quiet { background: transparent; color: var(--ink-2); }
.btn-sm { padding: 3px 8px; font-size: 12px; }
.linkish { background: none; border: 0; color: var(--accent); cursor: pointer;
           font: inherit; padding: 0; text-decoration: underline; }

/* ------------------------------------------------------------- inputs --- */

input[type=text], input[type=password], input[type=search], select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 8px;
  width: 100%;
  /* Text inputs carry an intrinsic min-width of about 170px, which is wider
     than several of the grid tracks they sit in. Without this they push their
     column open and overlap the next one. */
  min-width: 0;
}
textarea { font-family: var(--mono); font-size: 12.5px; line-height: 1.55; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { font-size: 12px; color: var(--ink-2); display: block; margin-bottom: 3px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
         color: var(--ink); margin: 0; }
.check input { width: auto; }
.inline-label { margin: 0; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-top: 10px; }
.field { min-width: 120px; }
.field.grow { flex: 1 1 260px; position: relative; }

/* -------------------------------------------------------------- cards --- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.centered-card { max-width: 460px; margin: 8vh auto; text-align: center; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .split { grid-template-columns: minmax(0, 1fr); } }

.login { width: 340px; }
.login h1 { margin-bottom: 4px; }
.login label { margin-top: 12px; }
.login .btn { width: 100%; margin-top: 14px; }

/* -------------------------------------------------------------- table --- */

table.grid { width: 100%; border-collapse: collapse; background: var(--panel);
             border: 1px solid var(--line); border-radius: var(--radius); }
table.grid th { text-align: left; font-size: 11px; text-transform: uppercase;
                letter-spacing: 0.06em; color: var(--ink-3); font-weight: 650;
                padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.grid td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid td.num, table.grid th.num { text-align: right; font-family: var(--mono); }
table.grid td.title a { font-weight: 600; text-decoration: none; }
table.grid td.title a:hover { text-decoration: underline; }
table.dense td, table.dense th { padding: 5px 8px; font-size: 12.5px; }
.quote-cell { max-width: 420px; }
tr.row-bad td { background: var(--bad-bg); }
tr.row-warn td { background: var(--warn-bg); }
tr.notes td { padding-top: 0; }
ul.issues { margin: 2px 0; padding-left: 0; list-style: none; }
ul.issues li { font-size: 12px; margin: 2px 0; }

/* ------------------------------------------------------------ preview --- */

.preview { min-height: 120px; }
.preview-head h2 { margin: 0 0 4px; font-size: 15px; }
.preview-box { border: 1px solid var(--line); border-radius: var(--radius);
               padding: 8px 10px; background: var(--bg); }
.excerpt-preview:empty { display: none; }
.excerpt-preview { margin-top: 10px; }

/* -------------------------------------------------------------- clips --- */

ol.clips { list-style: none; margin: 0; padding: 0; }
li.clip {
  display: grid;
  /* Every flexible track is minmax(0, …): the default `auto` floor lets an
     input's intrinsic width push a column wider than its share. */
  grid-template-columns: 22px 26px minmax(0, 200px) 160px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}
@media (max-width: 1100px) {
  li.clip { grid-template-columns: 22px 26px minmax(0, 1fr) auto; }
  li.clip .clip-text { grid-column: 1 / -1; }
}
li.clip.flagged { border-left: 3px solid var(--warn); }
li.clip.sortable-ghost { opacity: 0.4; }
li.clip.sortable-chosen { box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18); }
li.clip.saving { outline: 2px solid var(--accent); outline-offset: -1px; }
li.clip.empty { display: block; text-align: center; color: var(--ink-2); }

.clip-handle { cursor: grab; color: var(--ink-3); font-size: 17px; line-height: 1.2; user-select: none; }
.clip-pos { font-family: var(--mono); color: var(--ink-3); font-size: 13px; }
.clip-src .bates { font-weight: 650; text-decoration: none; }
.clip-src .fn { font-size: 11.5px; color: var(--ink-2); overflow: hidden;
                text-overflow: ellipsis; white-space: nowrap; }
.clip-time { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 8px; }
.clip-time label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; }
.clip-time .dur { grid-column: 1 / -1; font-size: 12px; color: var(--ink-2); }
input.tc { font-family: var(--mono); padding: 3px 6px; font-size: 12.5px; }

.clip-text { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
@media (max-width: 1400px) { .clip-text { grid-template-columns: minmax(0, 1fr); } }
.pane-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em;
              color: var(--ink-3); margin-bottom: 3px; }
.quote { font-size: 13px; }
.excerpt { font-size: 13px; color: var(--ink-2); }
.excerpt.bad { color: var(--bad); }
.law { margin-top: 3px; }

/* ------------------------------------------------------------- status --- */

.status-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.progress { height: 8px; background: var(--line-2); border-radius: 999px;
            overflow: hidden; margin: 10px 0 4px; }
.progress .bar { height: 100%; background: var(--accent); transition: width 0.4s ease; }
.output video, video.player { width: 100%; max-height: 62vh; background: #000;
                              border-radius: var(--radius); margin-top: 8px; }
.output .btn { margin-top: 8px; }

details.log summary { cursor: pointer; color: var(--ink-2); font-size: 13px; }
ol.events { list-style: none; margin: 10px 0 0; padding: 0; font-size: 12.5px; }
ol.events li { display: flex; gap: 8px; padding: 3px 0; border-top: 1px solid var(--line-2); }
ol.events li .msg { color: var(--ink); }

/* ------------------------------------------------------ autocomplete --- */

.ac-results { position: absolute; z-index: 20; left: 0; right: 0; background: var(--panel);
              border: 1px solid var(--line); border-radius: var(--radius);
              max-height: 300px; overflow: auto; box-shadow: 0 6px 20px rgba(0,0,0,0.12); }
.ac-results:empty { display: none; }
ul.ac-list { list-style: none; margin: 0; padding: 0; }
.ac-item { display: block; width: 100%; text-align: left; background: none; border: 0;
           border-bottom: 1px solid var(--line-2); padding: 6px 10px; cursor: pointer;
           font: inherit; color: var(--ink); }
.ac-item:hover { background: var(--line-2); }
.ac-item .fn { display: block; font-size: 11.5px; color: var(--ink-2); }
.ac-empty { padding: 8px 10px; }
.chosen { margin: 6px 0 0; font-size: 12.5px; }

/* -------------------------------------------------------------- video --- */

.fn-full { font-family: var(--mono); font-size: 12px; color: var(--ink-2); margin: 0 0 12px; }
.video-split { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
dl.kv { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 0;
        margin: 0; background: var(--panel); border: 1px solid var(--line);
        border-radius: var(--radius); overflow: hidden; }
dl.kv dt { padding: 6px 10px; font-size: 12px; color: var(--ink-2);
           border-bottom: 1px solid var(--line-2); background: var(--bg); }
dl.kv dd { padding: 6px 10px; margin: 0; border-bottom: 1px solid var(--line-2);
           overflow-wrap: anywhere; }
dl.kv dt:last-of-type, dl.kv dd:last-of-type { border-bottom: 0; }

.note-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.note-body { font-size: 13px; }
ul.counterparts { list-style: none; margin: 0; padding: 0; }
ul.counterparts li { display: flex; gap: 8px; align-items: center; padding: 6px 0;
                     border-top: 1px solid var(--line-2); }
ul.counterparts .fn { font-size: 11.5px; color: var(--ink-2); overflow: hidden;
                      text-overflow: ellipsis; white-space: nowrap; }

.transcript { max-height: 74vh; overflow: auto; background: var(--panel);
              border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
p.seg { margin: 0 0 7px; font-size: 13px; }
p.seg.hit { background: var(--warn-bg); border-left: 3px solid var(--warn);
            padding: 4px 6px; margin-left: -6px; border-radius: 3px; }
.tcbtn { font-family: var(--mono); font-size: 11.5px; background: none; border: 0;
         color: var(--accent); cursor: pointer; padding: 0 5px 0 0; }
.spk { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
       color: var(--ink-3); margin-right: 5px; }

/* ------------------------------------------------------------- search --- */

.searchbar .row { margin-top: 0; }
.resultcount { margin: 0 0 10px; }
.hit { padding: 10px 14px; }
.hit-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 5px; }
.hit-head .bates { font-weight: 650; text-decoration: none; }
.hit-context { margin: 0 0 8px; font-size: 13px; }
.hit-context .ctx { color: var(--ink-3); }
.hit-context .match { background: var(--warn-bg); padding: 1px 2px; border-radius: 2px; }
.addwrap { border-top: 1px solid var(--line-2); padding-top: 7px; }
form.addjob { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
form.addjob label { margin: 0; }
form.addjob select { width: auto; max-width: 320px; padding: 3px 6px; font-size: 12.5px; }
.added { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12.5px; }

/* -------------------------------------------------------------- misc ---- */

/* An auto margin absorbs free space before flex-grow gets a look in, so the
   page heads that carry a growing title box turn it off. */
.pagehead.wide .pagehead-actions { margin-left: 0; }
.titlebox { display: flex; align-items: center; gap: 8px; flex: 1 1 380px; min-width: 0; }
.title-input { font-size: 19px; font-weight: 650; border-color: transparent;
               background: transparent; padding: 4px 6px; flex: 1 1 auto; }
.title-input:hover { border-color: var(--line); }
.savemark { font-size: 11px; color: var(--ok); }
.addclip { margin-top: 0; }
