/* autoTag portal. Quiet panels and type; the funscript heat map is the one loud element. */

:root {
  --paper: #f2f3f6;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --ink: #161922;
  --ink-2: #3b4150;
  --muted: #677084;
  --line: #e2e5eb;
  --line-strong: #cbd0da;
  --brand: #c81d6b;
  --brand-hover: #aa1459;
  --brand-soft: #fbe7f0;
  --on-brand: #ffffff;
  --ok: #0d7f57;
  --ok-soft: #e1f3ea;
  --warn: #9a5800;
  --warn-soft: #fcefd9;
  --bad: #c0282b;
  --bad-soft: #fbe5e5;
  --run: #2353d1;
  --run-soft: #e5ecfc;
  --heat-empty: #e5e8ee;
  --focus: 0 0 0 3px color-mix(in srgb, var(--brand) 28%, transparent);
  --r-panel: 14px;
  --r-control: 9px;
  --font: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15171d;
    --surface: #1d2028;
    --surface-2: #232733;
    --ink: #eef0f5;
    --ink-2: #c9cedb;
    --muted: #949cae;
    --line: #2d323e;
    --line-strong: #3d4352;
    --brand: #e0558f;
    --brand-hover: #ec74a6;
    --brand-soft: #3b1f2c;
    --on-brand: #1a0d13;
    --ok: #45c592;
    --ok-soft: #173327;
    --warn: #e9a540;
    --warn-soft: #36290f;
    --bad: #f0706f;
    --bad-soft: #3b1c1d;
    --run: #7d9ff5;
    --run-soft: #1c2742;
    --heat-empty: #2a2e39;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 14.5px/1.5 var(--font);
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 0.92em; }
.nowrap { white-space: nowrap; }

/* ------------------------------------------------------------ shell */

.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }

.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 22px;
  padding: 22px 14px 16px;
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; text-decoration: none; }
.brand svg { width: 28px; height: 28px; flex: none; }
.brand b { font-size: 17px; font-weight: 650; letter-spacing: -0.015em; }
.brand span { color: var(--muted); font-size: 13px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav h3 { margin: 16px 10px 6px; font-size: 12.5px; font-weight: 550; color: var(--muted); }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--r-control);
  color: var(--ink-2); text-decoration: none; font-weight: 500;
}
.nav a svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.nav a:hover { background: color-mix(in srgb, var(--surface) 60%, transparent); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.nav a[aria-current="page"] svg { color: var(--brand); }

.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); }
.who { display: flex; flex-direction: column; margin-bottom: 10px; min-width: 0; }
.who b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span { color: var(--muted); font-size: 13px; }
.side-foot .links { display: flex; gap: 6px; flex-wrap: wrap; }

main { padding: 30px 40px 72px; max-width: 1280px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head > div { min-width: 0; }
h1 { margin: 0; font-size: 28px; line-height: 1.15; font-weight: 650; letter-spacing: -0.022em; overflow-wrap: anywhere; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.crumb { display: inline-block; margin-bottom: 8px; color: var(--muted); text-decoration: none; font-size: 13.5px; }
.crumb:hover { color: var(--ink); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------ panels */

.stack { display: grid; gap: 20px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.cols.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
.panel-head a { color: var(--muted); font-size: 13.5px; text-decoration: none; }
.panel-head a:hover { color: var(--ink); }
.panel-body { padding: 18px; }
.panel-body.flush { padding: 0; }
.empty { padding: 28px 18px; color: var(--muted); text-align: center; }
.empty b { display: block; color: var(--ink); font-weight: 600; margin-bottom: 2px; }

/* The balance: the one number a client comes for. */
.balance { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 20px 40px; align-items: end; padding: 22px 22px 20px; }
.balance .big { font-size: 46px; line-height: 1; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.balance .big small { font-size: 16px; font-weight: 500; letter-spacing: 0; color: var(--muted); margin-left: 6px; }
.balance .hint { margin-top: 8px; color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px 24px; margin: 0; }
.balance .facts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.facts div { min-width: 0; }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 2px 0 0; font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

dl.details { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 9px 20px; margin: 0; }
dl.details dt { color: var(--muted); }
dl.details dd { margin: 0; overflow-wrap: anywhere; }

/* ------------------------------------------------------------ tables */

.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted);
  padding: 9px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap;
}
table.list th:first-child { padding-left: 18px; }
table.list td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list td:first-child { padding-left: 18px; }
table.list tr:last-child td { border-bottom: 0; }
table.list .num { text-align: right; }
table.list tr.link { cursor: pointer; }
table.list tr.link:hover td { background: var(--surface-2); }
table.list tr.link:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.job-name { font-weight: 550; overflow-wrap: anywhere; }
.job-name small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }
.amount.plus { color: var(--ok); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type="search"] { max-width: 280px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.seg button { border: 0; background: none; padding: 5px 11px; border-radius: 7px; font-weight: 500; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13.5px; }

/* ------------------------------------------------------------ status, progress, heat */

.pill { display: inline-flex; align-items: center; gap: 7px; padding: 2px 10px 2px 8px; border-radius: 999px; font-size: 12.5px; font-weight: 550; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.queued { background: var(--surface-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.pill.running { background: var(--run-soft); color: var(--run); }
.pill.running::before { animation: pulse 1.4s ease-in-out infinite; }
.pill.done { background: var(--ok-soft); color: var(--ok); }
.pill.failed { background: var(--bad-soft); color: var(--bad); }
.pill.off { background: var(--warn-soft); color: var(--warn); }
@keyframes pulse { 50% { opacity: .25; } }

.progress { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; margin-top: 6px; width: 100%; max-width: 160px; }
.progress i { display: block; height: 100%; background: var(--run); border-radius: 2px; }

/* The funscript heat map: average stroke speed along the video, in the colours script makers know. */
.heat { display: block; height: 8px; min-width: 120px; border-radius: 4px; background: var(--heat-empty); }
.heat.tall { height: 14px; border-radius: 5px; }

/* ------------------------------------------------------------ charts */

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 160px; overflow: visible; }
.chart .bar { fill: var(--brand); pointer-events: none; }
.chart .bar-hit { fill: transparent; }
.chart .bar-hit:hover + .bar, .chart .bar.on { fill: var(--brand-hover); }
.chart .axis { stroke: var(--line-strong); stroke-width: 1; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.tip {
  position: absolute; pointer-events: none; transform: translate(-50%, calc(-100% - 8px));
  background: var(--ink); color: var(--surface); padding: 5px 9px; border-radius: 7px; font-size: 12.5px; white-space: nowrap;
}

/* ------------------------------------------------------------ controls */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--r-control);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 550; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.danger { color: var(--bad); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn.quiet:hover { color: var(--ink); background: var(--surface-2); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: default; }

.field { display: grid; gap: 6px; }
.field > span { font-weight: 550; font-size: 13.5px; }
.field small { color: var(--muted); font-size: 12.5px; }
input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="search"], select {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-control); background: var(--surface);
}
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.form { display: grid; gap: 16px; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.error { color: var(--bad); font-size: 13.5px; }
.error:empty { display: none; }

/* ------------------------------------------------------------ dialog and toast */

dialog {
  border: 0; padding: 0; border-radius: 16px; width: min(480px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink);
  box-shadow: 0 30px 80px rgba(10, 12, 18, .28), 0 0 0 1px var(--line);
}
dialog::backdrop { background: rgba(12, 14, 20, .45); }
dialog[open] { animation: rise .16s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.dialog-head { padding: 20px 22px 0; }
.dialog-head h2 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.dialog-head p { margin: 6px 0 0; color: var(--muted); }
.dialog-body { padding: 18px 22px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 22px 20px; }

.secret {
  display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-control);
}
.secret code { flex: 1; font-family: var(--mono); font-size: 14px; overflow-wrap: anywhere; user-select: all; }
.secret + .secret { margin-top: 8px; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2); animation: rise .16s ease-out; max-width: calc(100vw - 32px);
}

/* ------------------------------------------------------------ login */

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(400px, 100%); }
.login-card .brand { padding: 0; margin-bottom: 26px; }
.login-card .brand b { font-size: 19px; }
.login-card h1 { font-size: 24px; margin-bottom: 6px; }
.login-card > p { margin: 0 0 22px; color: var(--muted); }
.login-card .panel { padding: 22px; }
.login-card .btn.primary { width: 100%; height: 40px; }
.login-heat { height: 6px; border-radius: 3px; margin: 0 0 26px; animation: sweep 1.6s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes sweep { from { clip-path: inset(0 100% 0 0 round 3px); } to { clip-path: inset(0 0 0 0 round 3px); } }

/* ------------------------------------------------------------ player (always dark: it sits around video) */

.player {
  --p-bg: #0f1116; --p-line: #262a35; --p-text: #e9ecf2; --p-muted: #8e96a8;
  --heat-empty: #232733;
  background: var(--p-bg); color: var(--p-text); border-radius: var(--r-panel); overflow: hidden;
  border: 1px solid var(--line);
}
.player .stage { position: relative; background: #000; display: flex; justify-content: center; }
.player video { display: block; max-width: 100%; max-height: 58vh; }
.player .boxes { position: absolute; pointer-events: none; }
.player .note { padding: 10px 16px; color: var(--p-muted); font-size: 13px; border-bottom: 1px solid var(--p-line); }
.player .overview { position: relative; padding: 14px 16px 6px; cursor: pointer; }
.player .overview .heat { background: #232733; }
.player .acts { position: relative; height: 6px; margin-top: 4px; border-radius: 3px; overflow: hidden; background: #232733; }
.player .acts i { position: absolute; top: 0; bottom: 0; }
.player .head { position: absolute; top: 10px; bottom: 2px; width: 2px; margin-left: -1px; background: #fff; border-radius: 1px; box-shadow: 0 0 0 1px rgba(0,0,0,.5); pointer-events: none; }
.player canvas.curve { display: block; width: 100%; height: 230px; cursor: crosshair; }
.player .controls { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--p-line); flex-wrap: wrap; }
.player .play {
  width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--brand); color: #fff;
  display: grid; place-items: center; cursor: pointer; flex: none;
}
.player .play svg { width: 16px; height: 16px; }
.player .time { font-variant-numeric: tabular-nums; min-width: 110px; }
.player .time span { color: var(--p-muted); }
.player .ctl { height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--p-line); background: transparent; color: var(--p-text); cursor: pointer; }
.player .ctl:hover { background: #1b1e26; }
.player .spacer { flex: 1; }
.player .legend { display: flex; gap: 14px; color: var(--p-muted); font-size: 12.5px; flex-wrap: wrap; }
.player .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; margin-right: 5px; }
.player .info { padding: 0 16px 14px; color: var(--p-muted); font-size: 13px; min-height: 42px; }
.player .info b { color: var(--p-text); font-weight: 550; }

.heat-scale { display: flex; align-items: center; gap: 8px; color: var(--p-muted); font-size: 12px; }
.heat-scale .heat { min-width: 0; width: 90px; height: 6px; }

/* ------------------------------------------------------------ job log */

ol.log { list-style: none; margin: 0; padding: 4px 0; }
ol.log li { position: relative; display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 14px; padding: 8px 18px 8px 18px; }
ol.log li::before {
  content: ""; position: absolute; left: 101px; top: 15px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--line-strong);
}
ol.log li::after { content: ""; position: absolute; left: 104px; top: 26px; bottom: -11px; width: 1px; background: var(--line); }
ol.log li:last-child::after { display: none; }
ol.log time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; padding-top: 1px; }
ol.log span { padding-left: 18px; overflow-wrap: anywhere; }
ol.log li.error span { color: var(--bad); }
ol.log li.error::before { background: var(--bad); }
ol.log li.done::before { background: var(--ok); }

/* ------------------------------------------------------------ small screens */

@media (max-width: 1180px) {
  .balance .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .cols, .cols.even { grid-template-columns: minmax(0, 1fr); }
  main { padding: 24px 24px 64px; }
}
@media (max-width: 760px) {
  .shell { display: block; }
  .side {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 12px;
    padding: 12px 16px 8px; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .brand span { display: none; }
  .nav { order: 3; flex-direction: row; width: calc(100% + 8px); margin: 0 -4px; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav h3 { display: none; }
  .nav a { white-space: nowrap; }
  .side-foot { margin: 0 0 0 auto; padding: 0; border: 0; display: flex; align-items: center; }
  .side-foot .who { display: none; }
  main { padding: 20px 16px 56px; }
  h1 { font-size: 24px; }
  .balance { grid-template-columns: minmax(0, 1fr); }
  .balance .big { font-size: 40px; }
  .form .row { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .player canvas.curve { height: 180px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
