/* components.css: the base kit. Uses only tokens.css. Anatomy and reasons: references/components.md */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--text);
  font: var(--weight-body) var(--step-body)/var(--lh-body) var(--font-sans);
  -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01";
  overflow-wrap: break-word;
}
h1, h2, h3 { margin: 0; font-weight: var(--weight-title); text-wrap: balance; }
h1 { font-size: var(--step-title); line-height: var(--lh-title); letter-spacing: var(--tr-title); }
.display { font-size: var(--step-display); line-height: var(--lh-display); letter-spacing: var(--tr-display); font-weight: var(--weight-title); }
p { margin: 0; text-wrap: pretty; max-width: var(--measure); }
.num, time, td, .count, .meter-value { font-variant-numeric: tabular-nums; }
.small { font-size: var(--step-small); line-height: var(--lh-small); color: var(--muted); }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--state); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Button: three, and no fourth */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-md); padding: 0 14px; border-radius: var(--radius);
  font: var(--weight-strong) 14px/1 var(--font-sans); white-space: nowrap; cursor: pointer;
  border: 1px solid transparent; background: transparent; color: var(--text-2);
  transition: background-color var(--motion), border-color var(--motion), color var(--motion),
              box-shadow var(--motion), transform var(--motion-press);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; transform: none; }
.btn.primary { background: var(--solid); color: var(--on-solid); box-shadow: var(--shadow-sm); }
.btn.primary:hover { background: var(--solid-hover); }
.btn.secondary { background: var(--ground); color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover { background: var(--hover); }
.btn.bare:hover { background: var(--hover); color: var(--text); }
.btn.lg { height: var(--control-lg); padding: 0 20px; font-size: 15px; }
.btn.sm { height: var(--control-sm); padding: 0 12px; font-size: 13px; border-radius: var(--radius-sm); }

/* Key cap: the only mono in the UI */
kbd, .kbd {
  display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 4px;
  border-radius: var(--radius-sm); background: var(--ground); color: var(--text-2);
  box-shadow: inset 0 0 0 1px var(--border-strong), var(--shadow-sm);
  font: 500 12px/1 var(--font-mono); text-transform: uppercase;
}
.btn kbd { order: -1; margin-left: -6px; }
.btn.primary kbd { background: rgb(255 255 255 / 14%); color: var(--on-solid); box-shadow: inset 0 0 0 1px rgb(255 255 255 / 22%); }
@media (pointer: coarse) { .btn kbd { display: none; } }

/* Field */
.label { display: block; margin-bottom: 6px; font-size: var(--step-row); font-weight: var(--weight-strong); }
.field {
  width: 100%; height: var(--tap); padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--ground); color: var(--text);
  font: 15px/1.4 var(--font-sans);
  transition: border-color var(--motion), box-shadow var(--motion);
}
textarea.field { height: auto; padding: 12px 14px; font-size: var(--step-body); line-height: var(--lh-body); resize: none; field-sizing: content; min-height: 96px; }
.field::placeholder { color: var(--muted); }
.field:focus { outline: none; border-color: var(--state); box-shadow: 0 0 0 3px var(--state-soft); }
.field[aria-invalid="true"] { border-color: var(--danger); }
.help { margin-top: 6px; font-size: var(--step-small); line-height: var(--lh-small); color: var(--muted); }
.help.error { color: var(--danger); }
@media (pointer: coarse) { .field { font-size: max(16px, 1em); } }

/* Segmented */
.seg { display: inline-flex; flex-wrap: wrap; max-width: 100%; gap: 2px; padding: 3px; border-radius: var(--radius); background: var(--hover); box-shadow: inset 0 0 0 1px var(--border); }
.seg button { height: 30px; padding: 0 12px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); font: var(--weight-strong) 14px/1 var(--font-sans); cursor: pointer; transition: background-color var(--motion), color var(--motion), box-shadow var(--motion); }
.seg button[aria-pressed="true"] { background: var(--ground); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }

/* List: a list is a list. No box, no card per row. */
.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--text); }
.row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-3);
  min-height: var(--row-list); padding: 8px 10px; border-bottom: 1px solid var(--border);
  font-size: var(--step-row); line-height: var(--lh-row); cursor: pointer;
  transition: background-color var(--motion);
}
.row:hover { background: var(--hover); }
.row[aria-selected="true"] { background: var(--selected); }
.row-title { font-weight: var(--weight-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--muted); font-size: var(--step-small); line-height: var(--lh-small); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { display: flex; flex-wrap: wrap; color: var(--muted); font-size: var(--step-small); }
.meta > * + *::before { content: "\00b7"; margin: 0 6px; color: var(--faint); } /* the one dot is drawn, never typed */

/* Count chip: "this needs you", never "this exists" */
.count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: var(--radius-pill); box-shadow: inset 0 0 0 1px var(--border-strong); font: var(--weight-strong) 12px/1 var(--font-sans); color: var(--text-2); }

/* Status: a glyph, and a word only when the person must act */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--step-small); color: var(--muted); }
/* deslop-ignore-next-line 19: a dot, a ring or an avatar is round; cards and controls never are */
.status::before { content: ""; width: 7px; height: 7px; border-radius: var(--radius-round); box-shadow: inset 0 0 0 1.5px var(--faint); }
.status[data-tone="state"]::before { background: var(--state); box-shadow: none; }
.status[data-tone="danger"] { color: var(--danger); }
.status[data-tone="danger"]::before { background: var(--danger); box-shadow: none; border-radius: 1px; transform: rotate(45deg); }

/* Meter: label, track, value on one line. Neutral until trouble. */
.meter { display: grid; grid-template-columns: auto minmax(60px, 1fr) auto; align-items: center; gap: var(--space-3); font-size: var(--step-row); }
.meter-track { height: 4px; border-radius: var(--radius-pill); background: var(--selected); overflow: hidden; }
.meter-track > i { display: block; height: 100%; border-radius: inherit; background: var(--text); transform: translateX(calc((var(--p, 0) - 1) * 100%)); transition: transform var(--motion-bar); }
.meter[data-spent] .meter-track > i { background: var(--danger); }
.meter-value { color: var(--muted); }

/* Empty: one line, one sentence, at most one action */
.empty { display: grid; justify-items: center; gap: var(--space-3); max-width: 520px; margin: 0 auto; padding: 40px 32px; text-align: center; }
.empty h2 { font-size: var(--step-title); line-height: var(--lh-title); letter-spacing: var(--tr-title); }
.empty p { color: var(--muted); max-width: 44ch; }
.empty .btn { margin-top: var(--space-2); }

/* Stages: the honest wait */
.stages { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.stage { position: relative; display: grid; grid-template-columns: 20px 1fr; gap: var(--space-3); padding-bottom: var(--space-4); font-size: var(--step-row); color: var(--muted); animation: settle var(--motion-settle) both; }
/* deslop-ignore-next-line 19: a dot, a ring or an avatar is round; cards and controls never are */
.stage::before { content: ""; width: 14px; height: 14px; margin: 3px; border-radius: var(--radius-round); box-shadow: inset 0 0 0 1.5px var(--faint); }
.stage:not(:last-child)::after { content: ""; position: absolute; left: 9.5px; top: 22px; bottom: 2px; width: 1px; background: var(--border-strong); }
.stage[data-done] { color: var(--text-2); }
.stage[data-done]::before { background: var(--text); box-shadow: none; }
.stage[data-done]:not(:last-child)::after { background: var(--text); }
.stage[data-now] { color: var(--text); font-weight: var(--weight-strong); }
/* deslop-ignore-next-line 06: a conic quarter ring masked to a 1.5px stroke, the stage arc; not a surface */
.stage[data-now]::before { box-shadow: inset 0 0 0 1.5px var(--border-strong); background: conic-gradient(var(--text) 0 25%, transparent 0) border-box; -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 0); mask: radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 0); animation: turn 1200ms linear infinite; }
@keyframes turn { to { transform: rotate(1turn); } }
@keyframes settle { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { .stage[data-now]::before { animation: none; } }

/* Toast: one sentence and a way back. At most two, six seconds each. */
.toasts { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: var(--space-2); z-index: 50; }
.toast { display: flex; align-items: center; gap: var(--space-3); width: max-content; max-width: calc(100vw - 32px); padding: 10px 10px 10px 16px; border-radius: var(--radius-lg); background: var(--solid); color: var(--on-solid); box-shadow: var(--shadow-lg); font-size: 14px; animation: settle var(--motion-settle) both; }
.toast .btn { height: 28px; padding: 0 10px; color: var(--on-solid); }
.toast .btn:hover { background: rgb(255 255 255 / 12%); }

/* Sheet, dialog, menu: the things that float, and the only things with big shadows */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; }
.panel-float { background: var(--ground); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.menu { padding: 6px; min-width: 200px; }
.menu button { display: flex; width: 100%; align-items: center; gap: var(--space-2); height: 34px; padding: 0 10px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); font: 14px/1 var(--font-sans); cursor: pointer; text-align: left; }
.menu button:hover, .menu button[aria-selected="true"] { background: var(--hover); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px -6px; }

/* Command bar */
.cmd { position: fixed; top: 12vh; left: 50%; transform: translateX(-50%); width: min(620px, calc(100vw - 32px)); z-index: 41; overflow: hidden; }
.cmd input { width: 100%; height: 52px; padding: 0 18px; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); font: 16px/1 var(--font-sans); outline: none; }
.cmd ul { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow: auto; }
.cmd li { display: grid; grid-template-columns: 18px max-content 1fr; align-items: center; gap: var(--space-3); height: 40px; padding: 0 10px; border-radius: var(--radius-sm); font-size: 14px; }
.cmd li[aria-selected="true"] { background: var(--selected); }
.cmd li .small { justify-self: end; }

/* Avatar */
/* deslop-ignore-next-line 19: a dot, a ring or an avatar is round; cards and controls never are */
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-round); background: var(--selected); color: var(--text-2); font: var(--weight-title) 12px/1 var(--font-sans); object-fit: cover; }
img.avatar { filter: saturate(.85); box-shadow: 0 0 0 1px var(--border); }

/* App shell: sidebar + window bar + view. The shell never scrolls; views do. */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); height: 100dvh; overflow: hidden; }
.side { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 16px 12px 12px; background: var(--panel); border-right: 1px solid var(--border); overflow: auto; }
.side h3 { margin: var(--space-5) 10px 6px; font: 400 12px/1 var(--font-sans); color: var(--muted); }
.nav { display: flex; align-items: center; gap: var(--space-3); min-width: 0; height: var(--row-nav); padding: 0 10px; border-radius: var(--radius-sm); color: var(--text-2); font-size: var(--step-row); text-decoration: none; transition: background-color var(--motion); }
.nav:hover { background: var(--hover); }
.nav[aria-current="page"] { background: var(--selected); color: var(--text); font-weight: var(--weight-strong); }
.nav span:first-of-type { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { display: grid; grid-template-rows: 44px minmax(0, 1fr); min-width: 0; min-height: 0; }
.top { display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-4); background: var(--panel); border-bottom: 1px solid var(--border); font: var(--weight-strong) 13px/1 var(--font-sans); }
/* deslop-ignore-next-line 19: a dot, a ring or an avatar is round; cards and controls never are */
.top .notice { width: 6px; height: 6px; border-radius: var(--radius-round); background: var(--state); }
.top .find { margin-left: auto; }
.view { display: grid; grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); min-height: 0; container-type: inline-size; }
.view > * { min-height: 0; overflow: auto; }
.pane-list { border-right: 1px solid var(--border); padding: var(--space-4) var(--space-3); }
.pane-detail { padding: clamp(20px, 3.5cqi, 40px); }
.pane-detail > * { max-width: 720px; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .side { order: 2; flex-direction: row; justify-content: space-around; min-height: 56px; padding: 4px 4px env(safe-area-inset-bottom); border-right: 0; border-top: 1px solid var(--border); overflow: visible; }
  .side h3, .side .desk { display: none; }
  .nav { flex-direction: column; justify-content: center; gap: 2px; height: auto; padding: 6px 8px; font-size: 12px; }
  .view { grid-template-columns: 1fr; }
  .view[data-open] .pane-list, .view:not([data-open]) .pane-detail { display: none; }
  .pane-list { border-right: 0; }
}
