@font-face {
  font-family: "Literata";
  src: url("assets/literata.ttf") format("truetype");
  font-weight: 200 900;
  font-display: swap;
}
@font-face {
  font-family: "DM Sans";
  src: url("assets/dm-sans.ttf") format("truetype");
  font-weight: 100 1000;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

:root {
  --paper: #f3eee4;
  --panel: #fbf9f4;
  --panel-hover: #f6f2e9;
  --ink: #1c2230;
  --ink-2: #444d5f;
  --ink-3: #596373;
  --line: #ddd5c5;
  --line-strong: #c4baa6;
  --accent: #b93a14;
  --accent-bright: #e8643a;
  --accent-tint: #f9e3d8;

  --s-todo: #444d5f;
  --s-todo-bg: #e7e3da;
  --s-progress: #1b52a0;
  --s-progress-bg: #dce7f5;
  --s-blocked: #a22c10;
  --s-blocked-bg: #f7dcd1;
  --s-done: #24603d;
  --s-done-bg: #dbeadc;

  --serif: "Literata", Georgia, "Times New Roman", serif;
  --sans: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}

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

html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--line-strong) transparent; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.5 var(--sans);
  caret-color: var(--accent);
  min-height: 100vh;
}
::selection { background: var(--ink); color: var(--paper); }

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

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

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--ink); color: var(--paper);
  padding: 10px 14px; border-radius: 6px; text-decoration: none;
}
.skip:focus { top: 12px; }

.vh {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ---------- Shell ---------- */
.app {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar / views ---------- */
.sidebar { padding: 18px 16px 0; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand-mark { flex: none; }
.brand-name { font: 600 1.25rem/1.1 var(--serif); letter-spacing: -0.01em; }
.brand-sub { font-size: 0.8125rem; color: var(--ink-3); margin-top: 2px; }

.views ul {
  display: flex; gap: 8px; overflow-x: auto;
  margin: 16px -16px 0; padding: 2px 16px 4px;
  scrollbar-width: none;
}
.views ul::-webkit-scrollbar { display: none; }
.view-btn {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: transparent; font-size: 0.875rem; font-weight: 500;
  transition: background-color 0.15s, border-color 0.15s;
}
.view-btn:hover { background: var(--panel); }
.view-btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.view-btn .n { font-family: var(--mono); font-size: 0.8125rem; opacity: 0.8; }
.view-btn svg { flex: none; }

/* ---------- List pane ---------- */
.list-pane { padding: 20px 16px 96px; min-width: 0; }
.list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.list-head h1 {
  font: 600 2rem/1.1 var(--serif);
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.list-head h1:focus { outline: none; }
.count { font-size: 0.875rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.toolbar {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin: 18px 0 16px;
}
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-search { grid-column: 1 / -1; }
.field label { font-size: 0.8125rem; font-weight: 600; color: var(--ink-2); }

.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 12px; top: 50%; translate: 0 -50%; color: var(--ink-3); pointer-events: none; }
input[type="search"] {
  appearance: none; -webkit-appearance: none;
  width: 100%; height: 44px; padding: 0 12px 0 38px;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px;
}
input[type="search"]::placeholder { color: var(--ink-3); opacity: 1; }
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }

.select {
  appearance: none; -webkit-appearance: none;
  width: 100%; height: 44px; padding: 0 38px 0 12px;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m3.5 6 4.5 4.5L12.5 6' fill='none' stroke='%231c2230' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--line-strong); border-radius: 8px;
  text-overflow: ellipsis;
}
input[type="search"]:hover, .select:hover { border-color: var(--ink-3); }
input[type="search"]:focus-visible, .select:focus-visible { outline-offset: 1px; border-color: var(--ink); }

/* ---------- Task rows ---------- */
.tasks {
  background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden;
}
.task {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--line);
  transition: background-color 0.15s;
}
.task:first-child { border-top: 0; }
.task:hover { background: var(--panel-hover); }
.task:has(.row-open:focus-visible) { outline: 3px solid var(--accent); outline-offset: -3px; }
.task[aria-current="true"] { background: var(--accent-tint); }
.task.flash { animation: flash 1.4s var(--ease); }
@keyframes flash { from { background: #f6e3a4; } }

.task-id { font: 400 0.75rem/1.2 var(--mono); color: var(--ink-3); display: flex; gap: 8px; flex-wrap: wrap; }
.task-title { margin-top: 4px; font: 560 1.125rem/1.3 var(--serif); letter-spacing: -0.005em; text-wrap: pretty; }
.row-open {
  all: unset; box-sizing: border-box; cursor: pointer; display: inline;
}
.row-open::after { content: ""; position: absolute; inset: 0; }
.row-open:hover { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.task-sum {
  margin-top: 6px; color: var(--ink-2); font-size: 0.9375rem; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  max-width: 68ch;
}
.task-foot { margin-top: 10px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 0.8125rem; color: var(--ink-2); }
.who { display: inline-flex; align-items: center; gap: 8px; }
.avatar {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  display: inline-grid; place-items: center;
  background: var(--ink); color: var(--paper);
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.02em;
}
.cmt { display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }

.task-side { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 0.8125rem; color: var(--ink-2); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 28px; padding: 0 11px 0 8px; border-radius: 999px;
  font-size: 0.8125rem; font-weight: 600; white-space: nowrap;
  background: var(--pill-bg); color: var(--pill-fg);
}
[data-status="todo"] { --pill-bg: var(--s-todo-bg); --pill-fg: var(--s-todo); }
[data-status="in-progress"] { --pill-bg: var(--s-progress-bg); --pill-fg: var(--s-progress); }
[data-status="blocked"] { --pill-bg: var(--s-blocked-bg); --pill-fg: var(--s-blocked); }
[data-status="done"] { --pill-bg: var(--s-done-bg); --pill-fg: var(--s-done); }

.due { font-variant-numeric: tabular-nums; white-space: nowrap; }
.prio { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.prio-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.prio-bars i { width: 3px; border-radius: 1px; background: var(--line-strong); }
.prio-bars i:nth-child(1) { height: 5px; }
.prio-bars i:nth-child(2) { height: 8px; }
.prio-bars i:nth-child(3) { height: 12px; }
.prio-bars i.on { background: var(--ink); }
.prio-high .prio-bars i.on { background: var(--accent); }

/* ---------- Empty / loading ---------- */
.loading { color: var(--ink-3); padding: 32px 0; }
.empty {
  display: grid; justify-items: start; gap: 10px;
  padding: 36px 20px; color: var(--ink-2);
  border: 1.5px dashed var(--line-strong); border-radius: 12px;
}
.empty-art { color: var(--line-strong); margin-bottom: 4px; }
.empty h2 { font: 600 1.375rem/1.2 var(--serif); color: var(--ink); }
.empty p { max-width: 46ch; }

.btn {
  min-height: 44px; padding: 0 18px; margin-top: 6px;
  background: var(--ink); color: var(--paper);
  border: 0; border-radius: 8px; font-weight: 600;
  transition: background-color 0.15s, translate 0.15s var(--ease);
}
.btn:hover { background: #2d3750; }
.btn:active { translate: 0 1px; }

/* ---------- Detail ---------- */
.detail-pane { display: none; }
.detail-pane.open {
  display: block; position: fixed; inset: 0; z-index: 40;
  background: var(--panel); overflow-y: auto; overscroll-behavior: contain;
}
.pane-empty { display: none; }

.detail { min-height: 100%; display: flex; flex-direction: column; animation: rise 0.32s var(--ease); }
@keyframes rise { from { opacity: 0; translate: 0 14px; } }

.detail-bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.detail-bar .task-id { font-size: 0.8125rem; }
.close {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 14px 0 10px;
  background: transparent; border: 1px solid var(--line-strong); border-radius: 8px;
  font-weight: 600; font-size: 0.9375rem;
  transition: background-color 0.15s;
}
.close:hover { background: var(--paper); }

.detail-main { padding: 22px 20px 48px; display: grid; gap: 26px; max-width: 640px; width: 100%; }
.detail h2 { font: 600 1.75rem/1.2 var(--serif); letter-spacing: -0.02em; text-wrap: balance; }
.detail h2:focus { outline: none; }

.status-box {
  display: grid; gap: 8px; padding: 16px;
  background: var(--paper); border-radius: 10px;
}
.status-box label { font-weight: 600; font-size: 0.875rem; }
.status-row { display: flex; align-items: center; gap: 12px; }
.status-row .select { flex: 1; max-width: 280px; font-weight: 500; }
.status-row .pill { transition: background-color 0.3s, color 0.3s; }
.feedback { font-size: 0.875rem; color: var(--ink-2); min-height: 1.5em; }
.feedback b { color: var(--ink); font-weight: 600; }
.feedback.pulse { animation: pulse 0.9s var(--ease); }
@keyframes pulse { from { color: var(--accent); translate: 0 3px; opacity: 0.2; } }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 16px; }
.facts dt { font-size: 0.8125rem; font-weight: 600; color: var(--ink-3); margin-bottom: 4px; }
.facts dd { font-size: 0.9375rem; }
.facts .wide { grid-column: 1 / -1; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 3px 10px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 0.8125rem; }

.body-wrap h3 { font: 600 0.875rem/1.2 var(--sans); color: var(--ink-3); margin-bottom: 8px; }
.body {
  white-space: pre-line;
  font: 400 1.0625rem/1.65 var(--serif);
  max-width: 62ch; color: var(--ink);
}
.body .outcome { font-weight: 600; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 60;
  display: flex; justify-content: center; pointer-events: none;
}
.toast-card {
  pointer-events: auto;
  display: flex; align-items: center; gap: 14px;
  max-width: 480px; padding: 12px 12px 12px 16px;
  background: var(--ink); color: var(--paper);
  border-radius: 10px;
  box-shadow: 0 10px 28px -8px rgba(28, 34, 48, 0.5), 0 2px 6px rgba(28, 34, 48, 0.25);
  font-size: 0.9375rem;
  animation: toast-in 0.4s var(--ease);
}
.toast-card.out { opacity: 0; translate: 0 8px; transition: opacity 0.25s, translate 0.25s; }
@keyframes toast-in { from { opacity: 0; translate: 0 16px; } }
.toast-card b { font-weight: 600; }
.toast-btn {
  flex: none; min-height: 40px; padding: 0 14px;
  background: transparent; color: #ffd9c8;
  border: 1px solid rgba(243, 238, 228, 0.35); border-radius: 8px; font-weight: 600;
}
.toast-btn:hover { background: rgba(243, 238, 228, 0.12); }
.toast-btn:focus-visible { outline-color: #ffb08f; }

/* ---------- Wider screens ---------- */
@media (min-width: 640px) {
  .toolbar { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr); }
  .field-search { grid-column: auto; }
  .list-pane { padding: 28px 28px 80px; }
  .sidebar { padding: 22px 28px 0; }
  .views ul { margin: 18px -28px 0; padding: 2px 28px 4px; }
  .toast { left: auto; right: 20px; bottom: 20px; justify-content: flex-end; }
}

@media (min-width: 1000px) {
  .app { grid-template-columns: minmax(0, 1fr) minmax(380px, 460px); }
  .sidebar { grid-column: 1; grid-row: 1; }
  .list-pane { grid-column: 1; grid-row: 2; }

  .detail-pane, .detail-pane.open {
    display: block; position: sticky; top: 0; z-index: auto;
    grid-column: 2; grid-row: 1 / span 2; align-self: start;
    height: 100vh; overflow-y: auto;
    background: var(--panel); border-left: 1px solid var(--line);
  }
  .pane-empty {
    display: grid; justify-items: center; align-content: center; gap: 8px;
    height: 100%; padding: 32px; text-align: center; color: var(--ink-3);
  }
  .pane-empty svg { color: var(--line-strong); margin-bottom: 8px; }
  .pane-empty p { max-width: 30ch; font-size: 0.9375rem; }
  .pane-empty-title { font: 600 1.25rem/1.2 var(--serif); color: var(--ink); }
  .detail-bar { padding: 14px 24px; }
  .detail-main { padding: 28px 28px 56px; }
  .toast { right: 24px; bottom: 24px; }
}

@media (min-width: 1180px) {
  .app { grid-template-columns: 232px minmax(0, 1fr) minmax(400px, 480px); }
  .sidebar {
    grid-column: 1; grid-row: 1 / span 2;
    position: sticky; top: 0; height: 100vh; align-self: start;
    padding: 28px 18px; border-right: 1px solid var(--line);
  }
  .list-pane { grid-column: 2; grid-row: 1 / span 2; }
  .detail-pane, .detail-pane.open { grid-column: 3; grid-row: 1 / span 2; }
  .views ul { flex-direction: column; overflow: visible; margin: 28px 0 0; padding: 0; gap: 2px; }
  .view-btn {
    width: 100%; justify-content: flex-start; border: 0; border-radius: 8px; padding: 0 12px; min-height: 42px;
  }
  .view-btn .n { margin-left: auto; }
  .view-btn[aria-pressed="true"] { background: var(--ink); }
  .view-btn:not([aria-pressed="true"]):hover { background: rgba(28, 34, 48, 0.07); }
  .list-pane { padding: 32px 36px 80px; }
  .task {
    grid-template-columns: minmax(0, 1fr) 156px; gap: 8px 24px; padding: 18px 20px;
  }
  .task-side { flex-direction: column; align-items: flex-start; gap: 8px; padding-top: 2px; }
  .toast { right: 28px; }
}

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