/* Trayline: native CSS, system type, one teal accent, 8px radius throughout. */
:root {
  color-scheme: light dark;
  --bg: #eceff1;
  --surface: #f9fafb;
  --surface-2: #f1f3f5;
  --ink: #15191d;
  --muted: #56606b;
  --line: #d6dbe0;
  --accent: #0e6a63;
  --accent-ink: #ffffff;
  --accent-wash: #dcefec;
  --blocked-ink: #9a3412;
  --blocked-wash: #fbe8df;
  --done-ink: #46505a;
  --done-wash: #e3e7ea;
  --shadow: 0 10px 30px rgb(21 36 45 / .14);
  --radius: 8px;
  --font: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1214;
    --surface: #171b1e;
    --surface-2: #1d2226;
    --ink: #e8ebee;
    --muted: #9ba5af;
    --line: #2b3237;
    --accent: #5fc7ba;
    --accent-ink: #052320;
    --accent-wash: #173633;
    --blocked-ink: #f2a98e;
    --blocked-wash: #3a211a;
    --done-ink: #aab3bb;
    --done-wash: #252b30;
    --shadow: 0 10px 30px rgb(0 0 0 / .45);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
}
html.lock, html.lock body { overflow: hidden; }

h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }

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

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

.skip {
  position: absolute; left: 12px; top: -60px;
  background: var(--accent); color: var(--accent-ink);
  padding: 8px 12px; border-radius: var(--radius); z-index: 60;
}
.skip:focus { top: 12px; }

/* ---------- shell ---------- */
.app {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr) 456px;
  min-height: 100dvh;
}

.rail {
  position: sticky; top: 0; align-self: start;
  height: 100dvh;
  display: flex; flex-direction: column; gap: 28px;
  padding: 24px 16px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: 18px;
}
.brand-name { font-weight: 750; font-size: 19px; letter-spacing: -.01em; }

.views { display: grid; gap: 2px; }
.view {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 40px; padding: 6px 10px;
  border: 0; border-radius: var(--radius);
  background: transparent; cursor: pointer; text-align: left;
  color: var(--muted); font-weight: 560;
  transition: background-color .15s ease, color .15s ease;
}
.view:hover { background: var(--surface-2); color: var(--ink); }
.view[aria-pressed="true"] { background: var(--accent-wash); color: var(--ink); font-weight: 700; }
.view-count { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.rail-note { margin-top: auto; padding: 0 8px; font-size: 13px; color: var(--muted); line-height: 1.45; }

/* ---------- list pane ---------- */
.list-pane { padding: 32px 36px 72px; min-width: 0; }
.page-head { display: grid; gap: 4px; margin-bottom: 24px; }
.page-head h1 { font-size: 32px; line-height: 1.1; letter-spacing: -.025em; font-weight: 760; }
.page-sub { color: var(--muted); }

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px 170px;
  gap: 12px;
  align-items: end;
}
.field { display: grid; gap: 6px; min-width: 0; }
.field label { font-size: 13px; font-weight: 650; color: var(--muted); }
input[type="text"], select {
  width: 100%; min-height: 44px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid #8a949e;
  border-radius: var(--radius);
}
@media (prefers-color-scheme: dark) {
  input[type="text"], select { border-color: #66717b; }
}
input::placeholder { color: var(--muted); opacity: 1; }
select { cursor: pointer; }

.result-count { margin: 18px 0 8px; font-size: 14px; color: var(--muted); min-height: 21px; }

.items { display: grid; gap: 0; }
.item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 20px;
  padding: 16px 14px 16px 18px;
  border-top: 1px solid var(--line);
  border-radius: 0;
  transition: background-color .15s ease;
}
.item:last-child { border-bottom: 1px solid var(--line); }
.item:hover { background: var(--surface); }
.item.is-open { background: var(--surface); box-shadow: inset 4px 0 0 var(--accent); }
.item.flash { animation: flash 1.4s ease-out; }
@keyframes flash { from { background: var(--accent-wash); } to { background: transparent; } }

.item-main { min-width: 0; display: grid; gap: 4px; }
.open-item {
  all: unset;
  display: block;
  font-weight: 680; font-size: 17px; line-height: 1.3;
  letter-spacing: -.005em;
  cursor: pointer;
}
.open-item::after { content: ""; position: absolute; inset: 0; }
.open-item:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; border-radius: var(--radius); }
.item-sub { display: flex; flex-wrap: wrap; gap: 2px 16px; font-size: 14px; color: var(--muted); }
.item-sub .mono { font-family: var(--mono); font-size: 13px; }

.item-side { display: flex; align-items: center; gap: 16px; align-self: start; }
.prio { font-size: 13px; font-weight: 650; color: var(--muted); min-width: 52px; text-align: right; }
.prio[data-p="high"] { color: var(--ink); }
.cmt { font-family: var(--mono); font-size: 13px; color: var(--muted); min-width: 28px; text-align: right; }

.pill {
  display: inline-flex; align-items: center;
  min-height: 26px; padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 13px; font-weight: 680; white-space: nowrap;
  background: var(--surface-2); color: var(--ink);
}
.pill[data-s="in-progress"] { background: var(--accent-wash); color: var(--ink); border-color: transparent; }
.pill[data-s="blocked"] { background: var(--blocked-wash); color: var(--blocked-ink); border-color: transparent; }
.pill[data-s="done"] { background: var(--done-wash); color: var(--done-ink); border-color: transparent; }
.pill-fixed { min-width: 104px; justify-content: center; }

.skeleton {
  height: 72px; border-top: 1px solid var(--line);
  background: linear-gradient(90deg, transparent, var(--surface), transparent);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.empty {
  margin-top: 8px; padding: 40px 24px;
  border: 1px dashed #8a949e; border-radius: var(--radius);
  display: grid; justify-items: start; gap: 10px;
}
.empty h2 { font-size: 20px; letter-spacing: -.01em; }
.empty p { color: var(--muted); max-width: 52ch; }

/* ---------- buttons ---------- */
.btn {
  min-height: 40px; padding: 6px 14px;
  border-radius: var(--radius);
  border: 1px solid #8a949e;
  background: var(--surface);
  font-weight: 650; cursor: pointer; white-space: nowrap;
  transition: background-color .15s ease, transform .1s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-quiet { border-color: transparent; background: transparent; }
.btn-quiet:hover { background: var(--surface-2); }

/* ---------- detail ---------- */
.detail-pane {
  position: sticky; top: 0; align-self: start;
  height: 100dvh; overflow-y: auto;
  background: var(--surface);
  border-left: 1px solid var(--line);
}
.detail-idle { padding: 40px 32px; display: grid; gap: 8px; color: var(--muted); }
.detail-idle h2 { color: var(--ink); font-size: 20px; letter-spacing: -.01em; }

.detail { padding: 14px 28px 48px; display: grid; gap: 22px; }
.detail-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 -10px; }
.detail-nav { display: flex; gap: 2px; }
.detail-id { font-family: var(--mono); font-size: 13px; color: var(--muted); padding-left: 10px; }
.detail-title { font-size: 26px; line-height: 1.2; letter-spacing: -.02em; font-weight: 760; text-wrap: balance; }
.detail-title:focus { outline: none; }
.detail-title:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 4px; }

.status-box { display: grid; gap: 10px; padding: 16px; background: var(--surface-2); border-radius: var(--radius); }
.status-box select { background: var(--surface); }
.inline-feedback { font-size: 14px; font-weight: 600; color: var(--ink); }
.inline-feedback.pulse { animation: pulse .9s ease-out; }
@keyframes pulse { from { background: var(--accent-wash); } to { background: transparent; } }
.hidden-note { font-size: 14px; color: var(--muted); }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.facts div { display: grid; gap: 2px; min-width: 0; }
.facts dt { font-size: 13px; color: var(--muted); font-weight: 600; }
.facts dd { font-weight: 600; overflow-wrap: anywhere; }
.facts .mono { font-family: var(--mono); font-size: 15px; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 13px; font-weight: 600; padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }

.body { display: grid; gap: 14px; max-width: 62ch; }
.body p { line-height: 1.6; }
.body p + p { padding-top: 14px; border-top: 1px solid var(--line); }

.activity { display: grid; gap: 8px; }
.activity h3 { font-size: 14px; color: var(--muted); font-weight: 650; }
.activity ol { display: grid; gap: 6px; font-size: 14px; }
.activity li { display: flex; justify-content: space-between; gap: 12px; }
.activity .when { font-family: var(--mono); font-size: 13px; color: var(--muted); white-space: nowrap; }
.activity .none { color: var(--muted); }

.scrim { position: fixed; inset: 0; background: rgb(8 14 18 / .5); z-index: 20; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  z-index: 50;
  display: flex; align-items: center; gap: 8px;
  max-width: min(560px, calc(100% - 24px));
  padding: 8px 8px 8px 16px;
  background: var(--ink); color: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: toast-in .25s ease-out;
}
.toast .btn-quiet { color: var(--bg); text-decoration: underline; flex: none; }
.toast .btn-quiet:hover { background: rgb(255 255 255 / .12); }
.toast :focus-visible { outline-color: var(--bg); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- medium and small: detail becomes a sheet, rail becomes a top bar ---------- */
@media (max-width: 1099px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap;
    gap: 8px 20px; padding: 14px 20px 10px; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .rail nav { flex: 1 1 100%; order: 3; overflow-x: auto; margin: 0 -20px; padding: 0 20px 4px; }
  .rail-note { display: none; }
  .views { display: flex; gap: 6px; width: max-content; }
  .view { width: auto; min-height: 40px; gap: 10px; border: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
  .view[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
  .list-pane { padding: 24px 20px 96px; }

  .detail-pane { display: none; }
  .detail-pane.is-open {
    display: block; position: fixed; z-index: 30;
    top: 0; right: 0; bottom: 0; height: auto;
    width: min(560px, 100%);
    box-shadow: var(--shadow);
    animation: sheet-in .22s ease-out;
  }
  .detail { padding: 10px 20px 56px; }
  @keyframes sheet-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
}

@media (max-width: 720px) {
  .toolbar { grid-template-columns: 1fr 1fr; }
  .field-search { grid-column: 1 / -1; }
  .page-head h1 { font-size: 28px; }
  .item { grid-template-columns: minmax(0, 1fr); padding: 14px 8px 14px 14px; gap: 8px; }
  .item-side { justify-content: flex-start; gap: 12px; }
  .prio, .cmt { min-width: 0; text-align: left; }
  .pill-fixed { min-width: 0; }
  .facts { grid-template-columns: 1fr 1fr; }
  .toast { bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
