@font-face {
  font-family: "Oswald";
  src: url("assets/oswald.ttf") format("truetype");
  font-weight: 200 700;
  font-display: swap;
}
@font-face {
  font-family: "Work Sans";
  src: url("assets/work-sans.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --paper: #E6ECF1;
  --sheet: #FBFCFD;
  --ink: #182640;
  --ink-2: #47556F;
  --line: #CCD5E0;
  --cab: #182640;
  --cab-cell: #22345A;
  --brass: #F2C230;
  --brass-deep: #D9A916;
  --hover: #F1F5F9;
  --picked: #FFF5D1;

  --todo-fill: #DCE3ED;   --todo-mark: #5A6A88;
  --prog-fill: #FCE8A8;   --prog-mark: #A67800;
  --block-fill: #F7D0CC;  --block-mark: #B3261E;
  --done-fill: #CFE8D9;   --done-mark: #1F6B4A;

  --display: "Oswald", "Arial Narrow", "Roboto Condensed", sans-serif;
  --text: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --detail-w: 448px;
  --focus: 0 0 0 3px var(--sheet), 0 0 0 5px var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-size: 16px;
  line-height: 1.5;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 12px; top: -60px; z-index: 50;
  background: var(--brass); color: var(--ink); padding: 8px 14px; border-radius: 4px;
  font-weight: 600; text-decoration: none;
}
.skip:focus { top: 12px; outline: none; box-shadow: var(--focus); }

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

/* ---------- Page frame ---------- */
.browse {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 32px 40px;
  transition: padding-right .2s ease;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 0 22px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 36px; height: 36px; flex: none; }
.brand-name {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 30px;
  line-height: 1;
  letter-spacing: .005em;
  display: flex; align-items: baseline; gap: 12px;
}
.brand-sub {
  font-family: var(--text);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-2);
  letter-spacing: 0;
}

.toolbar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field--search { position: relative; justify-content: flex-end; }
.field-icon {
  position: absolute; left: 12px; bottom: 12px;
  width: 18px; height: 18px; color: var(--ink-2); pointer-events: none;
}
input[type="search"], select {
  height: 42px;
  border: 1.5px solid #A9B5C6;
  border-radius: 6px;
  background-color: var(--sheet);
}
input[type="search"] {
  width: 340px;
  padding: 0 12px 0 38px;
}
input[type="search"]::placeholder { color: #66748C; }
select {
  appearance: none;
  -webkit-appearance: none;
  padding: 0 36px 0 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23182640' stroke-width='1.8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
  min-width: 150px;
}
input[type="search"]:hover, select:hover { border-color: var(--ink-2); }
input[type="search"]:focus-visible, select:focus-visible {
  outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(242, 194, 48, .85);
}

/* ---------- Sorting cabinet (the memorable piece) ---------- */
.cabinet {
  background: var(--cab);
  color: var(--sheet);
  border-radius: 10px;
  padding: 14px 16px 16px;
  box-shadow: inset 0 -6px 0 #0F1A2E;
}
.cabinet-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.cabinet-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 500;
  font-size: 18px;
  letter-spacing: .02em;
  color: #C9D3E3;
}
.cabinet-all {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 36px; padding: 4px 6px 4px 14px;
  border: 1.5px solid #3B5182; border-radius: 999px;
  background: transparent; color: var(--sheet);
  font-weight: 500; font-size: 15px;
}
.cabinet-all-count {
  min-width: 28px; padding: 2px 8px; border-radius: 999px;
  background: #2B4170; font-variant-numeric: tabular-nums; text-align: center;
}
.cabinet-all:hover { border-color: #6F86B6; }
.cabinet-all[aria-pressed="true"] { border-color: var(--brass); }
.cabinet-all[aria-pressed="true"] .cabinet-all-count { background: var(--brass); color: var(--ink); }
.cabinet-all:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }

.cubbies {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.cubby {
  position: relative;
  display: flex; flex-direction: column; justify-content: flex-end;
  min-height: 156px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: var(--cab-cell);
  box-shadow: inset 0 10px 14px -6px rgba(5, 10, 22, .65), inset 0 0 0 1px #2E4270;
  color: var(--sheet);
  text-align: left;
  overflow: hidden;
}
.cubby:hover { background: #283C66; }
.cubby:focus-visible { outline: 3px solid var(--brass); outline-offset: 3px; }
.cubby[aria-pressed="true"] {
  box-shadow: inset 0 10px 14px -6px rgba(5, 10, 22, .65), inset 0 0 0 3px var(--brass);
}

.slot {
  position: relative;
  flex: 1;
  margin: 0 14px;
}
.slip {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(4px + var(--i, 0) * var(--slip-step, 9px));
  height: 9px;
  border-radius: 1px;
  background: var(--sheet);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .25);
}
.slip::after {
  content: "";
  position: absolute; right: 8px; top: 2px;
  width: 14px; height: 5px; border-radius: 1px;
  background: var(--slip-mark, var(--todo-mark));
}
.slip:nth-child(even) { background: #EDF1F6; transform: rotate(-.8deg); }
.slip:nth-child(3n) { transform: rotate(.9deg); left: 6px; right: -2px; }
.slip.is-new { animation: drop .45s cubic-bezier(.2, .8, .3, 1.2); }
@keyframes drop {
  from { transform: translateY(-46px) rotate(-4deg); opacity: 0; }
  to { opacity: 1; }
}
.cubby.is-bumped .plate { animation: plate .5s ease; }
@keyframes plate {
  40% { transform: translateY(-3px); }
}

.cubby[data-status="todo"] { --slip-mark: var(--todo-mark); }
.cubby[data-status="in-progress"] { --slip-mark: #D9A916; }
.cubby[data-status="blocked"] { --slip-mark: #D9473E; }
.cubby[data-status="done"] { --slip-mark: #2E8C61; }

.plate {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin: 8px 10px 10px;
  padding: 4px 10px 5px;
  border-radius: 3px;
  background: linear-gradient(#F6D25A, var(--brass) 55%, var(--brass-deep));
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .35);
}
.plate-label {
  font-family: var(--display);
  font-weight: 500;
  font-size: 19px;
  line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.plate-count {
  font-family: var(--display);
  font-weight: 600;
  font-size: 30px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* ---------- Workspace / list ---------- */
.workspace { margin-top: 28px; }
.list-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  margin-bottom: 10px;
}
.list-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 500;
  font-size: 26px;
  line-height: 1.2;
}
.list-count { margin: 0; color: var(--ink-2); font-size: 15px; }

.list-wrap { container-type: inline-size; }
.sheet {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.rows { list-style: none; margin: 0; padding: 0; }
.rows:focus { outline: none; }

.columns, .row {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr) 176px 112px 96px 52px;
  grid-template-areas: "stamp main who due prio com";
  column-gap: 20px;
  align-items: center;
  padding: 0 20px;
}
.columns {
  min-height: 40px;
  border-bottom: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  background: #F3F6F9;
}
.columns .col-c { text-align: right; }

.row {
  position: relative;
  min-height: 74px;
  padding-top: 12px; padding-bottom: 12px;
  border-bottom: 1px solid #E1E7EE;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--hover); }
.row.is-open { background: var(--picked); box-shadow: inset 4px 0 0 var(--brass-deep); }

.row > .stamp { grid-area: stamp; justify-self: start; }
.row-main { grid-area: main; min-width: 0; }
.row-title { margin: 0; font-size: 16px; font-weight: 500; line-height: 1.35; }
.open {
  padding: 0; border: 0; background: none;
  text-align: left; font-weight: 500;
}
.open::after { content: ""; position: absolute; inset: 0; }
.open:focus-visible { outline: none; }
.open:focus-visible::after { outline: 3px solid var(--ink); outline-offset: -3px; border-radius: 2px; }
.row:hover .open { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

.row-sub {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  margin: 4px 0 0; font-size: 14px; color: var(--ink-2);
}
.tag {
  display: inline-block;
  padding: 0 7px; border: 1px solid var(--line); border-radius: 3px;
  font-size: 13px; line-height: 20px; color: var(--ink-2);
}

.row-facts { display: contents; }
.who { grid-area: who; display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 15px; }
.who-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  flex: none;
  display: inline-grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--ink); color: var(--sheet);
  font-size: 11px; font-weight: 600; letter-spacing: .03em;
}
.due { grid-area: due; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.prio { grid-area: prio; display: inline-flex; align-items: center; gap: 6px; font-size: 15px; }
.prio-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.prio-bars i { width: 3px; background: #B8C3D2; border-radius: 1px; }
.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--low .prio-bars i:nth-child(1),
.prio--medium .prio-bars i:nth-child(-n+2),
.prio--high .prio-bars i { background: var(--ink); }
.com {
  grid-area: com; justify-self: end;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums;
}
.com svg { width: 15px; height: 15px; }
.com--none { color: #8A96AA; }

/* Status stamp, shared by rows and detail */
.stamp {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 7px;
  border-radius: 4px;
  font-size: 14px; font-weight: 500; line-height: 20px;
  white-space: nowrap;
  color: var(--ink);
}
.stamp svg { width: 14px; height: 14px; flex: none; }
.stamp--todo { background: var(--todo-fill); --mark: var(--todo-mark); }
.stamp--in-progress { background: var(--prog-fill); --mark: var(--prog-mark); }
.stamp--blocked { background: var(--block-fill); --mark: var(--block-mark); }
.stamp--done { background: var(--done-fill); --mark: var(--done-mark); }
.stamp svg { color: var(--mark); }

/* Narrow list: rows reflow into two lines */
@container (max-width: 860px) {
  .columns { display: none; }
  .row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "main main"
      "facts stamp";
    row-gap: 10px;
    padding-left: 16px; padding-right: 16px;
  }
  .row-facts {
    grid-area: facts;
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px;
    min-width: 0;
  }
  .who, .due, .prio, .com { font-size: 14px; }
  .avatar { width: 24px; height: 24px; font-size: 10px; }
  .row > .stamp { justify-self: end; }
}

/* Empty state */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 48px 24px 56px;
}
.empty-art { width: 96px; height: 64px; margin-bottom: 16px; }
.empty-title {
  margin: 0;
  font-family: var(--display); font-weight: 500; font-size: 24px; line-height: 1.2;
}
.empty-text { margin: 6px 0 18px; max-width: 44ch; color: var(--ink-2); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 42px; padding: 0 18px;
  border: 1.5px solid var(--ink); border-radius: 6px;
  background: var(--ink); color: var(--sheet);
  font-weight: 600;
}
.btn:hover { background: #24375E; }
.btn--quiet {
  background: transparent; color: var(--ink); border-color: #A9B5C6;
  min-height: 40px; padding: 0 14px 0 10px;
}
.btn--quiet:hover { background: var(--hover); border-color: var(--ink-2); }
.btn svg { width: 18px; height: 18px; }

.foot { margin-top: 28px; font-size: 14px; color: var(--ink-2); }
.foot p { margin: 0; }

/* ---------- Detail panel ---------- */
.detail {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 20;
  width: var(--detail-w);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 32px 40px;
  background: var(--sheet);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 32px -18px rgba(24, 38, 64, .45);
  animation: panel-in .22s ease-out;
}
@keyframes panel-in {
  from { transform: translateX(24px); opacity: 0; }
}
body.has-detail .browse { padding-right: calc(var(--detail-w) + 32px); }

.detail-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 26px;
}
.detail-project { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.detail-title {
  margin: 0 0 22px;
  font-family: var(--display);
  font-weight: 500;
  font-size: 34px;
  line-height: 1.12;
  letter-spacing: .003em;
  text-wrap: balance;
}
.detail-title:focus { outline: none; }
.detail-title:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }

.status-field {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px 14px;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--paper);
}
.status-field label { font-weight: 600; font-size: 15px; }
.status-select { position: relative; }
.status-swatch {
  position: absolute; left: 12px; top: 50%;
  width: 14px; height: 14px; margin-top: -7px;
  border-radius: 50%; pointer-events: none;
  background: var(--mark, var(--todo-mark));
}
.status-select select { width: 100%; padding-left: 34px; font-weight: 500; }
.status-saved {
  grid-column: 2;
  margin: 0; min-height: 21px;
  font-size: 14px; color: var(--ink-2);
}
.status-saved.is-shown { color: var(--done-mark); font-weight: 500; }

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 20px;
  margin: 24px 0 0;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.detail-body { margin-top: 22px; max-width: 62ch; }
.detail-body p { margin: 0 0 14px; font-size: 16px; line-height: 1.6; }
.detail-body .outcome {
  padding: 12px 14px;
  border-left: 3px solid var(--brass-deep);
  background: #FBF4DA;
  border-radius: 0 6px 6px 0;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  z-index: 40;
  transform: translateX(-50%);
  width: max-content; max-width: calc(100vw - 32px);
  pointer-events: none;
}
.toast-inner {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 10px 10px 18px;
  border-radius: 8px;
  background: var(--ink); color: var(--sheet);
  box-shadow: 0 10px 30px -10px rgba(24, 38, 64, .6);
  pointer-events: auto;
  animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }
.toast-text { margin: 0; font-size: 15px; max-width: 52ch; }
.toast-undo {
  flex: none;
  min-height: 36px; padding: 0 14px;
  border: 0; border-radius: 5px;
  background: var(--brass); color: var(--ink); font-weight: 600;
}
.toast-undo:hover { background: #F6D25A; }
.toast-undo:focus-visible { outline: 3px solid var(--sheet); outline-offset: 2px; }

/* ---------- Medium widths, or desktop with the panel open ---------- */
@media (max-width: 1180px) {
  .masthead { flex-direction: column; align-items: stretch; }
  input[type="search"] { width: 100%; }
  .field--search { flex: 1 1 260px; }
}
body.has-detail .masthead { flex-direction: column; align-items: stretch; }
body.has-detail input[type="search"] { width: 100%; }
body.has-detail .field--search { flex: 1 1 260px; }

/* ---------- Mobile: detail becomes a full sheet ---------- */
@media (max-width: 900px) {
  .browse { padding: 0 16px 32px; }
  body.has-detail .browse { padding-right: 16px; }
  body.has-detail { overflow: hidden; }
  .detail {
    left: 0; width: auto;
    padding: 0 20px 48px;
    border-left: 0;
    animation-name: sheet-in;
  }
  @keyframes sheet-in { from { transform: translateY(28px); opacity: 0; } }
  .detail-bar {
    position: sticky; top: 0; z-index: 1;
    margin: 0 -20px 18px; padding: 12px 20px;
    background: var(--sheet);
    border-bottom: 1px solid var(--line);
  }
  .detail-title { font-size: 28px; }
  .status-field { grid-template-columns: 1fr; }
  .status-saved { grid-column: 1; }
}

@media (max-width: 640px) {
  .masthead { padding: 14px 0 16px; gap: 14px; }
  .brand-name { font-size: 26px; }
  .brand-mark { width: 30px; height: 30px; }
  .toolbar { gap: 10px; }
  .field--search { flex-basis: 100%; }
  .field--select { flex: 1 1 0; }
  select { min-width: 0; width: 100%; }

  .cabinet { padding: 10px 10px 12px; border-radius: 8px; }
  .cabinet-head { margin-bottom: 8px; }
  .cabinet-title { font-size: 16px; }
  .cabinet-all { min-height: 34px; font-size: 14px; }
  .cubbies { gap: 6px; }
  .cubby { min-height: 104px; }
  .slot { margin: 0 8px; }
  .cubby { --slip-step: 6px; }
  .slip { height: 5px; }
  .slip::after { width: 9px; height: 3px; right: 5px; }
  .plate {
    flex-direction: column; align-items: flex-start; gap: 0;
    margin: 4px; padding: 3px 6px 4px;
  }
  .plate-label { font-size: 13px; line-height: 1.1; white-space: normal; max-width: 100%; }
  .plate-count { font-size: 24px; }

  .workspace { margin-top: 22px; }
  .list-title { font-size: 22px; }
  .list-count { font-size: 14px; }
  .toast { bottom: 16px; }
  .toast-inner { gap: 12px; padding-left: 14px; }
  .toast-text { font-size: 14px; }
}

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