/* Dispatch · dark instrument-panel theme
   Fonts self-hosted from public/assets (OFL licenses ship beside the files). */

@font-face {
  font-family: "Oswald";
  src: url("assets/oswald.ttf") format("truetype");
  font-weight: 200 700;
  font-display: swap;
}
@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: 100 1000;
  font-display: swap;
}

:root {
  --bg: #101216;
  --bg-raised: #16181d;
  --bg-panel: #14161a;
  --bg-hover: #1b1e24;
  --line: #262a31;
  --line-soft: #1f2329;
  --text: #e9eaee;
  --text-mid: #a7abb5;
  --text-dim: #7d828d;
  --accent: #f2b23e;
  --accent-ink: #171308;
  --todo: #9aa0ad;
  --todo-bg: #1d2027;
  --progress: #7fb2f0;
  --progress-bg: #16222f;
  --blocked: #f08a7a;
  --blocked-bg: #2b1d1b;
  --done: #74cf9d;
  --done-bg: #17251e;
  --radius: 4px;
  --row-radius: 4px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-panel);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.brand-mark {
  color: var(--accent);
  align-self: center;
  flex: none;
}

.brand-name {
  font-family: "Oswald", "DM Sans", sans-serif;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
}

.brand-tag {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.topbar-count { margin: 0; color: var(--text-mid); }

/* ---------- shell ---------- */

.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 0;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 28px;
  align-items: start;
}

/* ---------- rail ---------- */

.rail {
  position: sticky;
  top: 0;
  padding: 32px 28px 32px 0;
  border-right: 1px solid var(--line-soft);
  min-height: calc(100vh - 64px);
}

.rail-title {
  margin: 0 0 14px;
  font-family: "Oswald", sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mid);
}

.rail-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line-soft);
}

.rail-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 8px 11px 2px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text-mid);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  border-radius: 0;
}

.rail-row:hover { color: var(--text); background: var(--bg-hover); }
.rail-row[aria-pressed="true"] { color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }

.rail-count {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  color: var(--text-dim);
}

.rail-note {
  margin: 22px 0 0;
  font-size: 13px;
  color: var(--text-dim);
  max-width: 30ch;
}

/* ---------- toolbar ---------- */

.content { padding: 32px 0 64px 28px; min-width: 0; }

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 16px;
}

.field { display: grid; gap: 6px; }

.field-label {
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.input::placeholder { color: var(--text-dim); opacity: 1; }
.input:hover { border-color: #343a43; }

.select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23a7abb5' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

.list-meta {
  margin: 22px 2px 8px;
  color: var(--text-dim);
}

/* ---------- task list ---------- */

.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.task-row {
  border-bottom: 1px solid var(--line-soft);
}

.task-btn {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  width: 100%;
  padding: 18px 14px 18px 6px;
  background: none;
  border: 0;
  border-radius: var(--row-radius);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.task-btn:hover { background: var(--bg-hover); }
.task-btn:active { transform: translateY(1px); }

.task-idx {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  color: var(--text-dim);
}

.task-main { display: grid; gap: 5px; min-width: 0; }

.task-title {
  margin: 0;
  font-size: 16.5px;
  font-weight: 550;
  color: var(--text);
  line-height: 1.35;
}

.task-meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  color: var(--text-dim);
}

.task-meta strong { font-weight: 400; color: var(--text-mid); }

.task-side {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-self: end;
}

.chip {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 3px;
  white-space: nowrap;
}

.chip-todo      { color: var(--todo);     background: var(--todo-bg); }
.chip-progress  { color: var(--progress); background: var(--progress-bg); }
.chip-blocked   { color: var(--blocked);  background: var(--blocked-bg); }
.chip-done      { color: var(--done);     background: var(--done-bg); }

.chip-pri {
  background: none;
  border: 1px solid var(--line);
  color: var(--text-mid);
}

/* ---------- empty state ---------- */

.empty {
  margin-top: 28px;
  padding: 44px 32px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--bg-raised);
}

.empty-title {
  margin: 0 0 8px;
  font-family: "Oswald", sans-serif;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.empty-body {
  margin: 0 0 20px;
  color: var(--text-mid);
  max-width: 52ch;
}

.btn {
  padding: 10px 18px;
  background: var(--accent);
  border: 0;
  border-radius: var(--radius);
  color: var(--accent-ink);
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover { background: #f7c05c; }
.btn:active { transform: translateY(1px); }

/* ---------- detail panel ---------- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgb(6 7 9 / 0.62);
}

.detail {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  width: min(520px, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-left: 1px solid var(--line);
  box-shadow: -24px 0 60px rgb(4 5 7 / 0.5);
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}

.detail-kicker { margin: 0; color: var(--text-dim); text-transform: uppercase; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text-mid);
  cursor: pointer;
}

.icon-btn:hover { color: var(--text); border-color: #343a43; background: var(--bg-hover); }

.detail-scroll {
  overflow-y: auto;
  padding: 26px 24px 40px;
}

.detail-title {
  margin: 0 0 22px;
  font-family: "Oswald", sans-serif;
  font-size: 27px;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: 0.01em;
}

.status-row {
  display: grid;
  gap: 6px;
  margin-bottom: 24px;
}

.select-status { max-width: 240px; }

.detail-facts {
  margin: 0 0 26px;
  display: grid;
  grid-template-columns: auto 1fr;
  row-gap: 0;
  border-top: 1px solid var(--line-soft);
}

.detail-facts > dt {
  padding: 11px 24px 11px 2px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--line-soft);
  align-self: center;
}

.detail-facts > dd {
  margin: 0;
  padding: 11px 2px;
  font-size: 14.5px;
  color: var(--text);
  border-bottom: 1px solid var(--line-soft);
  align-self: center;
}

.detail-body {
  font-size: 15.5px;
  color: var(--text-mid);
  line-height: 1.65;
  white-space: pre-line;
  max-width: 62ch;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 60;
  transform: translateX(-50%);
  padding: 11px 18px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  color: var(--text);
  box-shadow: 0 12px 40px rgb(4 5 7 / 0.55);
}

/* ---------- motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  .scrim { animation: fade-in 180ms ease-out; }
  .detail { animation: slide-in 220ms cubic-bezier(0.16, 1, 0.3, 1); }
  .toast { animation: fade-in 160ms ease-out; }
  .task-btn, .rail-row, .btn, .icon-btn, .input { transition: background-color 140ms ease, border-color 140ms ease; }
}

@keyframes fade-in { from { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; padding: 0 18px; }
  .rail {
    position: static;
    min-height: 0;
    padding: 22px 0 0;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .rail-list { display: flex; border-top: 0; gap: 8px; flex-wrap: wrap; padding-bottom: 18px; }
  .rail-row {
    width: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 6px 13px;
    gap: 8px;
    font-size: 13px;
  }
  .rail-row[aria-pressed="true"] { box-shadow: none; border-color: var(--accent); color: var(--text); }
  .rail-note { display: none; }
  .content { padding: 22px 0 56px; }
  .toolbar { grid-template-columns: 1fr; }
  .topbar { padding: 0 18px; }
  .brand-tag { display: none; }
}

@media (max-width: 560px) {
  .task-btn { grid-template-columns: minmax(0, 1fr) auto; }
  .task-idx { display: none; }
  .task-side { flex-direction: column; align-items: flex-end; gap: 6px; }
  .topbar-count { display: none; }
}

@media (min-width: 901px) {
  body.detail-open { overflow: hidden; }
}
