@font-face { font-family: 'Space Grotesk'; src: url('./assets/space-grotesk.ttf') format('truetype'); font-weight: 300 700; font-display: swap; }
@font-face { font-family: 'Work Sans'; src: url('./assets/work-sans.ttf') format('truetype'); font-weight: 300 700; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('./assets/ibm-plex-mono.ttf') format('truetype'); font-weight: 400 600; font-display: swap; }

:root {
  --bg: #f6f5f2;
  --bg-elev: #ffffff;
  --bg-soft: #eceae4;
  --text: #1c1b18;
  --text-muted: #5a574f;
  --border: #d9d6ce;
  --accent: #0f766e;
  --accent-soft: #d8efe9;
  --accent-text: #ffffff;
  --danger: #b42318;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(28,27,24,.06), 0 8px 24px rgba(28,27,24,.08);
  --focus: 0 0 0 3px rgba(15,118,110,.35);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151412;
    --bg-elev: #1f1e1b;
    --bg-soft: #2a2925;
    --text: #f2f1ed;
    --text-muted: #a9a69c;
    --border: #3a3833;
    --accent: #3fb8a8;
    --accent-soft: #1a3a36;
    --accent-text: #0b1f1d;
    --danger: #f08a82;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.5);
    --focus: 0 0 0 3px rgba(63,184,168,.35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Work Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--accent-text);
  padding: 8px 12px; border-radius: var(--radius-sm); z-index: 100;
}
.skip-link:focus { left: 12px; top: 12px; }

.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  background: var(--bg-elev); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text);
  font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 18px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.brand-tag { font-size: 12px; color: var(--text-muted); }
.count-pill {
  font-family: 'IBM Plex Mono', monospace; font-size: 12px;
  padding: 6px 10px; border-radius: 999px;
  background: var(--bg-soft); color: var(--text-muted);
  border: 1px solid var(--border);
}

.workspace { max-width: 1180px; margin: 0 auto; padding: 24px; display: grid; gap: 24px; }
.toolbar {
  display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: end;
}
@media (max-width: 640px) { .toolbar { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
input[type="search"], select {
  font: inherit; color: var(--text); background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; min-height: 42px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input[type="search"]:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--focus);
}
select { cursor: pointer; }

.task-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.task-item {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: grid; gap: 10px;
  transition: transform .12s ease, box-shadow .12s ease;
}
.task-item:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.task-item:focus-within { box-shadow: var(--focus); }
.item-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.item-title { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 17px; letter-spacing: -0.01em; margin: 0; }
.item-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 13px; color: var(--text-muted); }
.item-meta span { display: inline-flex; align-items: center; gap: 4px; }
.status-badge {
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--border);
  white-space: nowrap;
}
.status-todo { background: var(--bg-soft); }
.status-in-progress { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.status-blocked { background: #fdecea; color: var(--danger); border-color: var(--danger); }
.status-done { background: #e6f2ea; color: #1e7a3a; border-color: #1e7a3a; }
@media (prefers-color-scheme: dark) {
  .status-blocked { background: #3a1f1c; color: #f08a82; }
  .status-done { background: #1a3324; color: #7fd49a; border-color: #7fd49a; }
}

.item-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--bg-soft); color: var(--text-muted); border: 1px solid var(--border); }
.open-item {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--accent-text); border: none;
  padding: 8px 14px; border-radius: var(--radius-sm); white-space: nowrap;
  transition: transform .1s;
}
.open-item:hover { transform: translateY(-1px); }
.open-item:active { transform: translateY(0) scale(.98); }
.open-item:focus-visible { outline: none; box-shadow: var(--focus); }

.empty-state {
  text-align: center; padding: 48px 24px;
  background: var(--bg-elev); border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty-state h2 { font-family: 'Space Grotesk', sans-serif; margin: 0 0 8px; }
.empty-state p { color: var(--text-muted); margin: 0 0 16px; }

.btn { font: inherit; cursor: pointer; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 14px; }
.btn-secondary { background: var(--bg-elev); color: var(--text); }
.btn-secondary:hover { background: var(--bg-soft); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }

.detail-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: grid; place-items: center; padding: 24px; z-index: 50;
}
.detail-overlay[hidden] { display: none; }
.detail-panel {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 16px; width: min(640px, 100%); max-height: 88vh; overflow: auto;
  padding: 24px; position: relative; box-shadow: var(--shadow);
}
@media (max-width: 640px) {
  .detail-overlay { padding: 0; align-items: stretch; }
  .detail-panel { width: 100%; max-height: 100vh; border-radius: 0; }
}
.close-detail {
  position: absolute; top: 16px; right: 16px;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 12px; cursor: pointer; font: inherit;
}
.close-detail:focus-visible { outline: none; box-shadow: var(--focus); }

.detail-body-wrap { display: grid; gap: 16px; padding-top: 8px; }
.detail-title { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 22px; letter-spacing: -0.02em; margin: 0 0 4px; padding-right: 80px; }
.detail-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 16px; font-size: 13px; }
.detail-meta dt { color: var(--text-muted); font-weight: 600; }
.detail-meta dd { margin: 0; }
.detail-body { white-space: pre-wrap; color: var(--text); font-size: 15px; line-height: 1.6; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.status-control-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 8px; border-top: 1px solid var(--border); }
.status-control-wrap label { font-weight: 600; font-size: 13px; color: var(--text-muted); }
.status-control { flex: 1; min-width: 160px; }
.feedback { font-size: 13px; color: var(--accent); font-weight: 600; min-height: 18px; }

.toast-region { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; }
.toast {
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--radius-sm);
  font-size: 13px; box-shadow: var(--shadow); animation: fadein .2s ease;
}
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

:focus-visible { outline: none; }
button:focus-visible, a:focus-visible { box-shadow: var(--focus); }
@media (prefers-reduced-motion: reduce) {
  .task-item, .open-item { transition: none; }
  .task-item:hover { transform: none; }
}
