/* ============================================================
   RELAY — dark ops-console theme
   Sharp corners, hairline borders, monospace data type
   ============================================================ */

@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: "Literata";
  src: url("assets/literata.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0b0e11;
  --surface: #12161b;
  --surface-2: #171c22;
  --line: #242b33;
  --line-strong: #39424d;
  --text: #d7dee4;
  --muted: #8a95a1;
  --faint: #5c666f;
  --accent: #d9f24b;
  --accent-ink: #10130a;
  --todo: #9db2c7;
  --in-progress: #4cc2ff;
  --blocked: #ff6d5c;
  --done: #63e39c;
  --focus: #ffffff;
  --rail-w: 248px;
  --drawer-w: 480px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---- shared focus ---- */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

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

/* ============================================================
   SHELL: rail + main
   ============================================================ */
.shell {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  min-height: 100vh;
}

/* ---------------- LEFT RAIL ---------------- */
.rail {
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 34px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--accent);
}

.brand-mark { flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }

.brand-name {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.28em;
  color: var(--text);
}

.brand-sub {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.tally-title,
.rail-note-kicker {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--faint);
}

.tally { display: flex; flex-direction: column; gap: 4px; }

.tally-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
}
.tally-row:hover { border-color: var(--line-strong); background: var(--surface-2); }
.tally-row[aria-current="true"] { border-color: var(--accent); }

.tally-label {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.tally-row[aria-current="true"] .tally-label { color: var(--text); }

.tally-num {
  font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 0 8px;
  min-width: 30px;
  text-align: center;
}

.dot {
  width: 8px; height: 8px;
  flex: none;
  display: inline-block;
}
.dot-todo { background: var(--todo); }
.dot-in-progress { background: var(--in-progress); }
.dot-blocked { background: var(--blocked); }
.dot-done { background: var(--done); }

.rail-note {
  margin-top: auto;
  font-size: 12px;
  color: var(--faint);
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

/* ---------------- MAIN ---------------- */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  padding: 34px 40px 20px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

.page-title {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.1;
}

.page-title::before { content: "▮ "; color: var(--accent); }

.page-kicker {
  margin: 6px 0 20px;
  font-size: 13px;
  color: var(--muted);
}

/* ---- controls ---- */
.controls {
  display: grid;
  grid-template-columns: minmax(200px, 380px) 220px;
  gap: 14px;
  align-items: end;
}

.field { display: flex; flex-direction: column; gap: 6px; }

.field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

input[type="search"], select {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 0;
  appearance: none;
}

input[type="search"]:hover, select:hover { border-color: var(--muted); }

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
  cursor: pointer;
}

select option { background: var(--surface); color: var(--text); }

.result-line {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--faint);
  letter-spacing: 0.04em;
}

/* ---------------- LIST ---------------- */
.list-wrap { padding: 6px 40px 80px; }

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item {
  border-bottom: 1px solid var(--line);
}

.item-inner {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 16px 4px;
}

.item:hover { background: var(--surface); }
.item:focus-within { background: var(--surface); }

.item-id {
  font-size: 11px;
  color: var(--faint);
  letter-spacing: 0.04em;
}

.item-main { min-width: 0; }

.item-title {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}
.item-title:hover { color: var(--accent); }

.item-sub {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}
.item-sub .sep { color: var(--faint); }

.item-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border: 1px solid;
  padding: 3px 9px;
  white-space: nowrap;
}
.chip-todo { color: var(--todo); border-color: var(--todo); }
.chip-in-progress { color: var(--in-progress); border-color: var(--in-progress); }
.chip-blocked { color: var(--blocked); border-color: var(--blocked); }
.chip-done { color: var(--done); border-color: var(--done); }

.chip .dot { width: 6px; height: 6px; }

.item-due { font-size: 12px; color: var(--faint); }
.item-due[data-overdue="true"] { color: var(--blocked); }

.pri {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--faint);
  text-transform: uppercase;
}
.pri-high { color: var(--blocked); }
.pri-medium { color: var(--in-progress); }

/* ---------------- EMPTY ---------------- */
.empty {
  padding: 90px 40px;
  text-align: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.empty svg { color: var(--faint); margin-bottom: 10px; }
.empty h2 { margin: 0; font-size: 19px; color: var(--text); }
.empty p { margin: 0 0 14px; font-size: 14px; }

/* ---------------- BUTTONS ---------------- */
.btn {
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 16px;
  cursor: pointer;
  border-radius: 0;
  font-size: 13px;
  letter-spacing: 0.05em;
}
.btn:hover { border-color: var(--muted); }

.btn-accent {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 700;
}
.btn-accent:hover { filter: brightness(1.08); }

/* ============================================================
   DETAIL DRAWER
   ============================================================ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 5, 7, 0.62);
  z-index: 40;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(var(--drawer-w), 100vw);
  background: var(--surface);
  border-left: 1px solid var(--line-strong);
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: -18px 0 50px rgba(0, 0, 0, 0.5);
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.drawer-kicker {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
}

.btn-close { flex: none; }

.drawer-body {
  padding: 26px 26px 60px;
  overflow-y: auto;
  flex: 1;
}

.detail-title {
  margin: 0 0 18px;
  font-size: 22px;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}

.detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
  margin: 0 0 26px;
  border: 1px solid var(--line);
  padding: 14px 16px;
}

.meta-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.meta-k {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--faint);
}
.meta-v { font-size: 13px; color: var(--text); overflow-wrap: anywhere; }

.detail-section { margin-bottom: 26px; }

.detail-label {
  display: block;
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.status-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

#status-control { min-width: 200px; }

.status-flag {
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.03em;
  min-height: 1.2em;
}
.status-flag::before { content: "✓ "; }

.detail-body {
  margin: 0;
  font-family: "Literata", Georgia, "Times New Roman", serif;
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-line;
}

.tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.tag {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  padding: 3px 9px;
}

.comment-count { margin: 0; font-size: 12px; color: var(--faint); }

/* ---------------- TOAST ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  padding: 10px 18px;
  z-index: 80;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

/* ============================================================
   MOTION
   ============================================================ */
.drawer, .toast {
  transition: transform 0.22s ease, opacity 0.22s ease;
}
.drawer[data-open="false"] { transform: translateX(100%); opacity: 0; pointer-events: none; }
.toast[data-shown="false"] { opacity: 0; transform: translate(-50%, 12px); }

@media (prefers-reduced-motion: reduce) {
  .drawer, .toast { transition: none; }
  * { animation: none !important; }
}

/* ============================================================
   MOBILE (390 x 844)
   ============================================================ */
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }

  .rail {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 18px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand-sub { display: none; }
  .tally { flex-direction: row; flex-wrap: wrap; gap: 0; }
  .tally-title, .rail-note { display: none; }
  .tally-row { padding: 6px 8px; }
  .tally-label { font-size: 0; gap: 0; }
  .tally-label .dot { width: 10px; height: 10px; }
  .tally-num { margin-left: 6px; font-size: 11px; min-width: 24px; }

  .topbar { padding: 20px 18px 14px; position: static; }
  .page-title { font-size: 24px; }
  .page-kicker { margin-bottom: 14px; }

  .controls { grid-template-columns: 1fr; gap: 10px; }

  .list-wrap { padding: 4px 18px 70px; }

  .item-inner {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px 0;
  }
  .item-id { display: none; }
  .item-side { flex-direction: row; align-items: center; justify-content: space-between; width: 100%; flex-wrap: wrap; gap: 8px; }

  .drawer { width: 100vw; border-left: 0; }
  .drawer-body { padding: 20px 18px 50px; }
  .detail-meta { grid-template-columns: 1fr; }

  .toast { left: 18px; right: 18px; transform: none; text-align: center; }
  .toast[data-shown="false"] { transform: translateY(12px); }
}
