/* Kadr — a single dark surface, on purpose: this is a tool that sits next to an
   edit timeline, and edit software is dark. Every colour is declared explicitly so
   the page never borrows a host theme. */

:root {
  --ground: #0D0D0F;
  --surface: #161619;
  --raised: #1E1E23;
  --line: #2A2A31;
  --line-soft: #212127;
  --ink: #E9E8E5;
  --muted: #8B8B93;
  --dim: #62626A;
  --rec: #FF5A3C;
  --rec-dim: #7A2A1C;
  --ok: #5FBF8A;
  --warn: #E5B23C;

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --radius: 4px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--rec); outline-offset: 2px; }

/* ─────────────────────────────  top bar  ───────────────────────────── */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand__mark {
  width: 18px; height: 13px;
  border: 2px solid var(--rec);
  border-radius: 2px;
  position: relative;
  flex: none;
}
.brand__mark::after {
  content: "";
  position: absolute;
  inset: 3px;
  background: var(--rec);
  border-radius: 50%;
}

.brand__name { font-weight: 700; letter-spacing: -.01em; font-size: 15px; }
.brand__tag {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
  letter-spacing: .04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 700px) { .brand__tag { display: none; } }

.bar__right { display: flex; gap: 6px; flex: none; }

/* ─────────────────────────────  buttons  ───────────────────────────── */

.btn {
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 12px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #26262c; border-color: #3a3a43; }
.btn:disabled { opacity: .38; cursor: default; }

.btn--primary { background: var(--rec); border-color: var(--rec); color: #170704; font-weight: 600; }
.btn--primary:hover:not(:disabled) { background: #ff6f55; border-color: #ff6f55; }

.btn--ghost { background: transparent; }

/* ─────────────────────────────  layout  ───────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 1px;
  background: var(--line);
  min-height: calc(100vh - 45px);
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.board {
  background: var(--ground);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* ────────────────────────────  project head  ──────────────────────── */

.project {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.project__title {
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 700;
  letter-spacing: -.02em;
  padding: 2px 0;
}
.project__title:hover, .project__title:focus { border-bottom-color: var(--line); outline: none; }
.project__title:focus { border-bottom-color: var(--rec); }

.project__logline {
  background: none;
  border: none;
  color: var(--muted);
  padding: 2px 0;
  border-bottom: 1px solid transparent;
}
.project__logline:hover, .project__logline:focus { border-bottom-color: var(--line); outline: none; }
.project__logline::placeholder { color: var(--dim); }

.project__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 20px;
}

.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field > span { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--dim); }
.field select, .field input {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px 8px;
  min-width: 0;
}
.field--num input { width: 80px; }
.field--check { flex-direction: row; align-items: center; gap: 6px; align-self: flex-end; padding-bottom: 6px; }
.field--check span { font-size: 11px; text-transform: none; letter-spacing: 0; color: var(--muted); }

.runtime { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 200px; }
.runtime__nums { display: flex; align-items: baseline; gap: 6px; }
.runtime__nums span:first-child { font-size: 22px; font-weight: 600; }
.runtime__unit { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; margin-right: 10px; }
.runtime__nums span:last-child { font-size: 22px; font-weight: 600; color: var(--rec); }
.runtime__target { font-size: 11px; color: var(--dim); }

.meter {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.meter::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--fill, 0%);
  background: var(--ok);
  transition: width .25s ease, background .25s;
}
.meter[data-state="near"]::after { background: var(--warn); }
.meter[data-state="over"]::after { background: var(--rec); }

.project__actions { display: flex; flex-wrap: wrap; gap: 6px; }
.project__actions select {
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 10px;
  cursor: pointer;
}

/* ─────────────────────────────  shots  ───────────────────────────── */

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.empty h2 { margin: 0; font-size: 17px; font-weight: 600; }
.empty p { margin: 0; color: var(--muted); max-width: 46ch; }
.empty__agent { font-size: 13px; color: var(--dim); }
.empty__agent em { color: var(--muted); }

.shots { display: flex; flex-direction: column; gap: 8px; }

.shot {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color .2s, background .2s;
}

.shot--touched {
  border-color: var(--rec);
  background: #1c1310;
  animation: pulse 2.4s ease-out;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 90, 60, .38); }
  100% { box-shadow: 0 0 0 14px rgba(255, 90, 60, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .shot--touched { animation: none; }
  .meter::after { transition: none; }
}

.shot__head { display: flex; align-items: center; gap: 10px; }

.shot__index {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1px 6px;
  color: var(--muted);
}
.shot__tc { font-size: 11px; color: var(--dim); }

.shot__moves { margin-left: auto; display: flex; gap: 2px; }
.shot__moves button {
  background: none;
  border: 1px solid transparent;
  border-radius: 2px;
  color: var(--dim);
  cursor: pointer;
  width: 24px;
  height: 22px;
  line-height: 1;
  padding: 0;
}
.shot__moves button:hover:not(:disabled) { color: var(--ink); border-color: var(--line); background: var(--raised); }
.shot__moves button:disabled { opacity: .25; cursor: default; }
.shot__moves button[data-act="del"]:hover { color: var(--rec); border-color: var(--rec-dim); }

.shot__desc {
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  font-size: 15px;
  font-weight: 500;
  padding: 2px 0;
  width: 100%;
}
.shot__desc:hover { border-bottom-color: var(--line); }
.shot__desc:focus { border-bottom-color: var(--rec); outline: none; }

.shot__row { display: flex; flex-wrap: wrap; gap: 12px; }

.shot textarea, .shot__notes {
  background: var(--ground);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 6px 8px;
  width: 100%;
  resize: vertical;
  color: var(--muted);
}
.shot textarea:focus, .shot__notes:focus { color: var(--ink); border-color: var(--line); outline: none; }
.shot textarea::placeholder, .shot__notes::placeholder { color: var(--dim); }
.shot__notes { font-size: 13px; }

.composer { display: flex; gap: 6px; }
.composer input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 12px;
  min-width: 0;
}
.composer input::placeholder { color: var(--dim); }

/* ─────────────────────────────  panel  ───────────────────────────── */

.panel {
  background: var(--surface);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
}

.panel__block { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.panel__block--grow { flex: 1; min-height: 160px; }

.panel__title {
  margin: 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--dim);
  font-weight: 600;
}
.panel__hint { margin: 0; font-size: 12px; color: var(--dim); }

.status {
  border: 1px solid var(--line);
  border-left: 2px solid var(--dim);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--ground);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.status[data-state="on"] { border-left-color: var(--ok); }
.status[data-state="off"] { border-left-color: var(--warn); }
.status strong { font-size: 13px; }
.status p { margin: 0; font-size: 12px; color: var(--muted); }
.status code, .tools code {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--raised);
  padding: 1px 4px;
  border-radius: 2px;
  word-break: break-all;
}

.tools summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 0;
}
.tools__list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: grid;
  gap: 3px;
}

.activity {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-height: 0;
}

.event {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 8px;
  padding: 6px 8px;
  background: var(--ground);
  border-left: 2px solid var(--line);
  font-size: 12px;
  align-items: baseline;
}
.event--agent { border-left-color: var(--rec); }
.event--human { border-left-color: var(--dim); }
.event--idle { display: block; color: var(--dim); border-left-color: transparent; }

.event__who { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
.event--agent .event__who { color: var(--rec); }
.event__body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.event__label { overflow-wrap: anywhere; }
.event__detail { font-size: 11px; color: var(--dim); overflow-wrap: anywhere; }
.event__time { font-size: 10px; color: var(--dim); }

.export-row { display: flex; gap: 6px; }
.export-row select {
  flex: 1;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 8px;
  min-width: 0;
}

/* ─────────────────────────────  dialogs  ───────────────────────────── */

.dialog {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 20px;
  width: min(560px, calc(100vw - 32px));
  max-height: 85vh;
}
.dialog--wide { width: min(760px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(0, 0, 0, .66); }

.dialog h2 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.dialog__hint, .dialog__summary { margin: 0 0 12px; color: var(--muted); font-size: 13px; }

.dialog textarea {
  width: 100%;
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
}

.dialog__actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 12px; }

.report { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.report li { color: var(--muted); }
.report li::marker { color: var(--rec); }
.report .ok { color: var(--ok); }
.report .ok::marker { color: var(--ok); }

/* ─────────────────────────────  toast  ───────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--raised);
  border: 1px solid var(--rec);
  border-radius: var(--radius);
  padding: 9px 16px;
  font-size: 13px;
  z-index: 50;
  max-width: min(460px, calc(100vw - 32px));
}

/* ─────────────────────────────  sandbox  ───────────────────────────── */

.status[data-state="mock"] { border-left-color: var(--warn); }
.status a { color: var(--rec); }

.sandbox {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: min(420px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--warn);
  border-radius: 6px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .55);
  z-index: 40;
  display: flex;
  flex-direction: column;
  max-height: min(60vh, 560px);
}

.sandbox__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.sandbox__badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .12em;
  color: #241a05;
  background: var(--warn);
  padding: 2px 6px;
  border-radius: 2px;
}

.sandbox__note { font-size: 11px; color: var(--dim); flex: 1; min-width: 0; }

.sandbox__close {
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
}
.sandbox__close:hover { color: var(--ink); }

.sandbox__body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.sandbox__controls { display: flex; gap: 6px; }
.sandbox__controls select {
  flex: 1;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 8px;
  font-family: var(--mono);
  font-size: 12px;
  min-width: 0;
}

.sandbox__desc { margin: 0; font-size: 12px; color: var(--muted); }

.sandbox textarea {
  width: 100%;
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  font-family: var(--mono);
  font-size: 12px;
  resize: vertical;
}

.sandbox__out {
  margin: 0;
  background: var(--ground);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 9px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 220px;
  overflow-y: auto;
}
