/* ============================================================
   DOCKET — night-shift signal desk for a small crew.
   Terminal-utilitarian: near-black field, amber phosphor,
   mono data voice, one accent, semantic status ink.
   ============================================================ */

@font-face {
  font-family: 'IBM Plex Mono';
  src: url('assets/ibm-plex-mono.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'DM Sans';
  src: url('assets/dm-sans.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0B0F0C;
  --surface: #101511;
  --surface-2: #161D17;
  --line: #26302A;
  --line-soft: #1B231D;
  --ink: #E9EFE6;
  --muted: #9DAD9F;
  --dim: #7E9084;
  --amber: #FFB000;
  --amber-ink: #1A1305;
  --st-todo: #9BB0C4;
  --st-in-progress: #FFB000;
  --st-blocked: #FF6B57;
  --st-done: #43D68C;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
body::after { /* faint phosphor scanlines */
  content: '';
  position: fixed;
  inset: 0;
  z-index: 99;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(233, 239, 230, 0.024) 0 1px,
    transparent 1px 3px
  );
}
button, input, select { font: inherit; color: inherit; }
html.locked { overflow: hidden; }

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  height: 100dvh;
  animation: boot 260ms ease-out 1;
}
@keyframes boot { from { opacity: 0; } }

.vh {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- status ink ---------- */
.st-todo { color: var(--st-todo); }
.st-in-progress { color: var(--st-in-progress); }
.st-blocked { color: var(--st-blocked); }
.st-done { color: var(--st-done); }
.st-todo-tx { color: var(--st-todo); }
.st-in-progress-tx { color: var(--st-in-progress); }
.st-blocked-tx { color: var(--st-blocked); }
.st-done-tx { color: var(--st-done); }

/* ---------- focus ---------- */
:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}
button:focus, select:focus, input:focus {
  outline: 1px solid var(--amber);
  outline-offset: 1px;
}
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}
.row-card:focus-visible { outline-offset: -2px; }
.detail-title:focus {
  outline: 2px solid var(--amber);
  outline-offset: 6px;
}

/* ---------- blinking prompt cursor ---------- */
.cursor {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  margin-left: 5px;
  vertical-align: -0.15em;
  background: var(--amber);
  animation: blink 1.1s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 8px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand {
  margin: 0;
  font: 700 17px/1 var(--mono);
  letter-spacing: 0.16em;
  display: flex;
  align-items: center;
}
.brand-mark { color: var(--amber); margin-right: 7px; }
.brand .cursor { width: 0.5em; height: 0.9em; }
.topbar-sub {
  margin: 0;
  font: 400 10.5px/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}
.counts { margin-left: auto; display: flex; gap: 8px; }
.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 3px;
  font: 400 10.5px/1 var(--mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 180ms var(--ease), color 180ms var(--ease);
}
.chip .glyph { font-size: 12px; }
.chip-n {
  color: var(--dim);
  font-weight: 700;
  transition: color 180ms var(--ease);
}
.chip.is-active {
  border-color: var(--amber);
  color: var(--ink);
}
.chip.is-active .chip-n { color: var(--amber); }
.clock {
  margin: 0;
  font: 400 12.5px/1 var(--mono);
  letter-spacing: 0.1em;
  color: var(--muted);
  min-width: 8ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- two panes ---------- */
.panels {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(360px, 33vw, 460px);
  min-height: 0;
}

/* ---------- list pane ---------- */
.list-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-right: 1px solid var(--line);
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.ctl { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ctl.grow { flex: 1; }
.ctl.grow .input { flex: 1; width: 100%; }
.ctl-label {
  font: 500 11px/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  white-space: nowrap;
}
.input {
  height: 44px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  font: 400 13px var(--mono);
  color: var(--ink);
  min-width: 0;
  transition: border-color 180ms var(--ease), background-color 180ms var(--ease);
}
.input::placeholder { color: var(--dim); }
.input::-webkit-search-cancel-button { -webkit-appearance: none; }
select.input {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239DAD9F' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}
select.input option { color: #0B0F0C; background-color: #FFFFFF; }
.readout {
  margin: 0;
  font: 400 10.5px/1.4 var(--mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--dim);
  white-space: nowrap;
}

/* ---------- rows ---------- */
.rows-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.rows { list-style: none; margin: 0; padding: 0; }
.row-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  min-height: 56px;
  padding: 9px 20px 9px 14px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  cursor: pointer;
  transition: background-color 170ms var(--ease);
}
.glyph {
  width: 22px;
  text-align: center;
  font: 400 15px/1 var(--mono);
  transition: transform 170ms var(--ease);
}
.row-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.row-title {
  font: 500 13.5px/1.35 var(--mono);
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-title mark {
  background: none;
  color: var(--amber);
  border-bottom: 1px solid var(--amber);
}
.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font: 400 10.5px/1.3 var(--mono);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--dim);
}
.row-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  font: 400 10.5px/1 var(--mono);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--dim);
}
.prio { color: var(--dim); }
.p-hi { color: var(--ink); font-weight: 700; }
.row.is-open .row-card {
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 var(--amber);
}

/* ---------- key hints footer ---------- */
.keyhints {
  display: flex;
  gap: 20px;
  padding: 10px 20px;
  border-top: 1px solid var(--line-soft);
  font: 400 10.5px/1 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
}
kbd {
  font: inherit;
  color: var(--muted);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 2px 5px;
  margin-right: 3px;
}

/* ---------- empty state ---------- */
.empty {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 12px;
  padding: 64px 24px 72px;
}
.empty[hidden] { display: none; }
.empty-glyph { margin: 0; font: 400 34px/1 var(--mono); color: var(--dim); }
.empty-title { margin: 0; font: 700 15px/1.3 var(--mono); color: var(--ink); }
.empty-desc { margin: 0; max-width: 44ch; font: 400 13px/1.6 var(--sans); color: var(--muted); }
.btn {
  min-height: 44px;
  padding: 13px 22px;
  background: var(--amber);
  color: var(--amber-ink);
  border: 0;
  border-radius: 3px;
  font: 700 11.5px var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: filter 160ms var(--ease), transform 120ms var(--ease);
}

/* ---------- inspector ---------- */
.inspector {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  padding: 20px 22px 24px;
  background: var(--bg);
}
.insp-content { flex: 0 0 auto; }

.detail { position: relative; padding: 20px 16px 22px; }
.detail::before,
.detail::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  pointer-events: none;
}
.detail::before {
  top: 0; left: 0;
  border-top: 2px solid var(--muted);
  border-left: 2px solid var(--muted);
}
.detail::after {
  bottom: 0; right: 0;
  border-bottom: 2px solid var(--muted);
  border-right: 2px solid var(--muted);
}
.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.file-no {
  font: 400 11px/1.4 var(--mono);
  letter-spacing: 0.16em;
  color: var(--amber);
  overflow-wrap: anywhere;
}
.btn-close {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 12px 15px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 3px;
  font: 400 11px var(--mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  transition: color 170ms var(--ease), border-color 170ms var(--ease);
}
.detail-title {
  margin: 0 0 18px;
  font: 700 19px/1.35 var(--mono);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.status-ctl {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.st-border-todo { border-color: var(--st-todo); }
.st-border-in-progress { border-color: var(--st-in-progress); }
.st-border-blocked { border-color: var(--st-blocked); }
.st-border-done { border-color: var(--st-done); }

.detail-meta { margin: 0 0 22px; min-width: 0; }
.detail-meta > div {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dotted var(--line);
}
.detail-meta dt {
  font: 400 10.5px/1.5 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
}
.detail-meta dd {
  margin: 0;
  font: 400 13px/1.5 var(--mono);
  color: var(--ink);
  overflow-wrap: anywhere;
}
.dimtx { color: var(--dim); }
.detail-body {
  max-width: 62ch;
  font: 400 15.5px/1.68 var(--sans);
  color: var(--ink);
}
.detail-body p { margin: 0 0 14px; }
.detail-body p:last-child { margin-bottom: 2px; }

/* ---------- idle inspector ---------- */
.idle {
  padding: 34px 22px 30px;
  border: 1px dashed var(--line);
  background-image: radial-gradient(rgba(233, 239, 230, 0.055) 1px, transparent 1.2px);
  background-size: 22px 22px;
}
.idle-mark { margin: 0 0 20px; font: 400 42px/1 var(--mono); }
.idle-block { color: var(--dim); }
.idle-title { margin: 0 0 10px; font: 700 16px/1.3 var(--mono); }
.idle-copy {
  margin: 0;
  max-width: 42ch;
  font: 400 14px/1.65 var(--sans);
  color: var(--muted);
}

/* ---------- session tape ---------- */
.tape {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.tape-head {
  margin: 0 0 8px;
  font: 500 10.5px/1 var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}
.tape-lines {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
}
.tape-line {
  padding: 3px 0;
  font: 400 12px/1.7 var(--mono);
  color: var(--muted);
  overflow-wrap: anywhere;
}
.tape-line .t-time { color: var(--amber); margin-right: 7px; }
.tape-line .cursor { width: 0.5em; height: 0.85em; }
.tape-boot { color: var(--dim); }
.tape-idle { color: var(--dim); }
.tape-new {
  color: var(--ink);
  animation: tape-flash 800ms var(--ease) 1;
}
@keyframes tape-flash {
  from { background: rgba(255, 176, 0, 0.13); }
  to { background: transparent; }
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 120;
  max-width: min(460px, calc(100vw - 32px));
}
.toast[hidden] { display: none; }
.toast-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px 10px 16px;
  background: #131A14;
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: 3px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  animation: toast-in 220ms var(--ease) 1;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
}
.toast-msg { margin: 0; font: 400 12.5px/1.5 var(--mono); color: var(--ink); min-width: 0; }
.btn-undo {
  flex: none;
  min-height: 44px;
  padding: 12px 15px;
  background: transparent;
  border: 1px solid var(--amber);
  border-radius: 3px;
  font: 700 11px var(--mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--amber);
  cursor: pointer;
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}
.toast-x {
  flex: none;
  min-width: 44px;
  min-height: 44px;
  background: none;
  border: 0;
  border-radius: 3px;
  font: 400 15px/1 var(--mono);
  color: var(--muted);
  cursor: pointer;
  transition: color 160ms var(--ease);
}

/* ---------- press feedback (all pointers) ---------- */
.row-card:active { background: var(--surface-2); }
.chip:active,
.btn:active,
.btn-close:active,
.btn-undo:active { transform: scale(0.97); }

/* ---------- hover states (fine pointers only) ---------- */
@media (hover: hover) and (pointer: fine) {
  .row-card:hover { background: var(--surface); }
  .row-card:hover .glyph { transform: scale(1.25); }
  .chip:hover { color: var(--ink); border-color: var(--muted); }
  .chip:hover .chip-n { color: var(--ink); }
  .input:hover { border-color: var(--muted); }
  .btn:hover { filter: brightness(1.09); }
  .btn-close:hover { color: var(--ink); border-color: var(--muted); }
  .btn-undo:hover { background: var(--amber); color: var(--amber-ink); }
  .toast-x:hover { color: var(--ink); }
}

/* ---------- mobile ---------- */
@media (max-width: 879px) {
  .app-shell { height: auto; min-height: 100dvh; }
  .topbar { flex-wrap: wrap; padding: 10px 20px; gap: 10px 16px; }
  .topbar-sub { display: none; }
  .counts { display: none; }
  .clock { margin-left: auto; text-align: right; }
  .panels { grid-template-columns: 1fr; }
  .list-pane { border-right: 0; }
  .toolbar { flex-wrap: wrap; gap: 12px; padding: 12px 20px; }
  .ctl { width: 100%; }
  .input { font-size: 16px; } /* keep iOS from zooming on focus */
  .readout { width: 100%; }
  .row-card { min-height: 64px; padding: 12px 20px 12px 14px; }
  .row-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .keyhints { display: none; }
  .rows-scroll { overflow-y: visible; }
  .inspector {
    position: fixed;
    inset: 0;
    z-index: 60;
    padding: 20px 20px 24px;
    transform: translateY(103%);
    visibility: hidden;
    transition: transform 240ms var(--ease), visibility 0s linear 240ms;
  }
  .inspector.is-open {
    transform: none;
    visibility: visible;
    transition: transform 240ms var(--ease);
  }
  .detail-title { font-size: 17px; }
  .detail-body { font-size: 15px; }
  .toast { left: 20px; right: 20px; bottom: 20px; max-width: none; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .app-shell { animation: none; }
  .cursor { animation: none; }
  .tape-new { animation: none; }
  .toast-card { animation: none; }
  .row-card,
  .row-card .glyph,
  .chip,
  .input,
  .btn,
  .btn-close,
  .btn-undo,
  .toast-x,
  .inspector {
    transition: none;
  }
}
