/* Component library — spec §4 and Appendix B. Every colour and size comes from tokens.css. */

/* ---------- buttons (§4.1) ---------- */
.btn {
  height: var(--control-h); padding: 0 16px; border-radius: var(--r-md); font: var(--t-body-strong); display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; border: 1px solid transparent; white-space: nowrap; color: var(--text); background: var(--surface);
  transition: background-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); text-decoration: none; position: relative; min-width: 0;
}
.btn-primary { background: var(--brand-600); color: #fff; } .btn-primary:hover { background: var(--brand-700); } .btn-primary:active { background: var(--brand-800); }
.btn-done { background: var(--success-700); color: #fff; } .btn-done:hover { background: var(--success-800); } .btn-done:active { background: var(--success-900); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); } .btn-secondary:hover { background: var(--n50); } .btn-secondary:active { background: var(--n100); }
.btn-ghost { background: transparent; color: var(--text-2); } .btn-ghost:hover { background: var(--n100); } .btn-ghost:active { background: var(--n200); }
.btn-danger { background: var(--surface); border-color: var(--border-strong); color: var(--danger-600); } .btn-danger:hover { background: var(--danger-50); }
.btn-danger-solid { background: var(--danger-600); color: #fff; } .btn-danger-solid:hover { background: var(--danger-700); }
.btn-link { background: none; border: 0; padding: 0; height: auto; color: var(--link); font: var(--t-sm); font-weight: 700; text-decoration: underline; min-height: 44px; }
.btn-link:hover { color: var(--text); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; } .btn.lg { height: 48px; padding: 0 20px; font-size: 16px; }
.btn.block { width: 100%; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: var(--r-md); justify-content: center; }
.btn-icon .i { width: 20px; height: 20px; }
.btn-icon.round { border-radius: 50%; }
.btn[aria-busy="true"] { pointer-events: none; }
.btn[aria-busy="true"] > .i:first-child { display: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn[hidden] { display: none; }
.btn:focus-visible, .chip:focus-visible, .seg-opt:focus-visible, .tile:focus-visible, .row:focus-visible, .switch:focus-visible, .tabbar-item:focus-visible, .nav-link:focus-visible { outline: none; box-shadow: var(--focus); }
.btn .i { flex: 0 0 auto; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; flex: 0 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }
@media (pointer: coarse) { .btn { min-height: var(--target-min); } .btn.sm { min-height: 40px; } .btn-icon { width: 44px; height: 44px; } .btn-icon.sq { width: 48px; height: 48px; } }
@media (max-width: 559px) { .btn.lg.block, .btn.block { width: 100%; } }
.btn-group, .actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.actions-end { justify-content: flex-end; }

/* ---------- fields (§4.2) ---------- */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .field > legend.label, .label { font: var(--t-label); color: var(--text); }
.field .optional { font-weight: 400; color: var(--text-3); }
.field .hint { font: var(--t-sm); color: var(--text-3); }
.field .hint.above { order: -1; }
.field-error { display: flex; align-items: center; gap: 6px; font: var(--t-sm); color: var(--danger-600); }
.field-error[hidden] { display: none; }
.field-error .i { flex: 0 0 auto; }
.control, .field input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]), .field select, .field textarea {
  height: var(--control-h); width: 100%; font: var(--t-input); padding: 0 var(--pad-r, 12px) 0 var(--pad-l, 12px); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.field textarea, textarea.control { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 24px; }
.field textarea.autogrow { resize: none; overflow: hidden; }
.field input:hover, .field select:hover, .field textarea:hover, .control:hover { border-color: var(--n500); }
.field input:focus, .field select:focus, .field textarea:focus, .control:focus { border-color: var(--brand-600); box-shadow: var(--focus); outline: none; }
.field input[aria-invalid="true"], .field select[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: var(--danger-600); }
.field input:disabled, .field select:disabled, .field textarea:disabled { background: var(--n50); color: var(--text-3); }
.field select { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236D6E71' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; }
.field input[type="color"] { width: 56px; height: var(--control-h); padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); }
.field input[type="file"] { font: var(--t-sm); }
.field .with-toggle { position: relative; }
.field .with-toggle { --pad-r: 72px; }
.field .with-toggle .toggle-pw { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); height: calc(var(--control-h) - 8px); padding: 0 10px; font: var(--t-label); color: var(--text-2); border-radius: var(--r-sm); min-width: 44px; }
.field .with-toggle .toggle-pw:hover { background: var(--n100); }
.field .with-icon { position: relative; }
.field .with-icon > .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.field .with-icon { --pad-l: 36px; --pad-r: 44px; }
.field .with-icon .clear-search { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); }
.field .counter { font: var(--t-caption); color: var(--text-3); text-align: right; }
.field .counter[hidden] { display: none; }
.field-row { display: grid; gap: var(--s4); grid-template-columns: 1fr; }
@media (min-width: 560px) { .field-row { grid-template-columns: 1fr 1fr; } .field-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; } }
.form { display: flex; flex-direction: column; gap: var(--s4); }
.form .actions { margin-top: var(--s2); }
.error-summary { background: var(--danger-50); color: var(--danger-text); border-left: 4px solid var(--danger-600); border-radius: var(--r-md); padding: 10px 12px; font: var(--t-sm); }
.error-summary ul { padding-left: 16px; list-style: disc; margin-top: 4px; }
.error-summary a { color: inherit; text-decoration: underline; }
.notice { background: var(--info-100); color: var(--info-700); border-radius: var(--r-md); padding: 10px 12px; font: var(--t-sm); display: flex; gap: 8px; align-items: flex-start; }
.notice .i { flex: 0 0 auto; margin-top: 1px; }
.notice.warning { background: var(--warning-100); color: var(--warning-700); }
.notice.success { background: var(--success-100); color: var(--success-800); }
.notice.neutral { background: var(--n100); color: var(--text-2); }
.notice.danger { background: var(--danger-50); color: var(--danger-text); }

/* switch, checkbox, radio cards (§4.18) */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 44px; padding: 6px 0; cursor: pointer; }
.switch-row .switch-text { flex: 1; min-width: 0; }
.switch-row .switch-label { font: var(--t-body); color: var(--text); }
.switch-row .switch-sub { display: block; font: var(--t-sm); color: var(--text-3); }
.switch-row .switch-label { display: block; }
.switch { position: relative; width: 44px; height: 24px; flex: 0 0 44px; border-radius: var(--r-full); background: var(--n300); transition: background var(--dur) var(--ease); border: 0; padding: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--sh-sm); transition: transform var(--dur) var(--ease); }
.switch[aria-checked="true"] { background: var(--brand-600); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.switch:disabled { opacity: .5; }
.check-row { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font: var(--t-body); }
.check-row input[type="checkbox"], .checkbox { width: 20px; height: 20px; flex: 0 0 20px; accent-color: var(--brand-600); border-radius: 2px; margin: 0; }
.radio-cards { display: flex; flex-direction: column; gap: var(--s2); }
.radio-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: var(--r-md); cursor: pointer; background: var(--surface); }
.radio-card input { width: 20px; height: 20px; accent-color: var(--brand-600); margin: 2px 0 0; flex: 0 0 20px; }
.radio-card .rc-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.radio-card .rc-title { font: var(--t-body-strong); }
.radio-card .rc-desc { font: var(--t-sm); color: var(--text-3); }
.radio-card.selected { border-color: var(--brand-600); background: var(--brand-50); }
.radio-card.disabled { opacity: .6; cursor: not-allowed; }
.radio-card .rc-reason { font: var(--t-sm); color: var(--text-3); }

/* ---------- chips (§4.6), status chips, tags (§4.8) ---------- */
.chip-row { display: flex; gap: var(--s2); flex-wrap: wrap; }
.chip-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); }
.chip-scroll::-webkit-scrollbar { display: none; }
.chip-scroll .chip-row { flex-wrap: nowrap; scroll-snap-type: x proximity; width: max-content; }
.chip-scroll .chip { scroll-snap-align: start; }
.chip { height: 36px; padding: 0 14px; border-radius: var(--r-full); border: 1px solid var(--border-strong); font: var(--t-label); background: var(--surface); color: var(--text); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.chip:hover { background: var(--n50); }
.chip[aria-pressed="true"], .chip.active { background: var(--n800); color: #fff; border-color: var(--n800); }
.chip .count { font-weight: 400; opacity: .85; }
.chip.ctx { padding-right: 4px; }
.chip.ctx .chip-x { width: 36px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-full); color: inherit; }
.chip.ctx .chip-x:hover { background: rgba(0, 0, 0, .06); }
.status { height: 24px; padding: 0 10px; border-radius: var(--r-full); font: 700 12px/24px var(--font); display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.status.open { background: var(--n100); color: var(--n800); }
.status.in_progress { background: var(--info-100); color: var(--info-700); }
.status.awaiting { background: var(--review-100); color: var(--review-700); }
.status.done { background: var(--success-100); color: var(--success-700); }
.status.verified { background: var(--verified-100); color: var(--verified-700); }
.status.invite { background: var(--warning-100); color: var(--warning-700); }
.status.inactive { background: var(--n100); color: var(--text-3); }
.tag { height: 20px; padding: 0 6px; border-radius: var(--r-sm); font: 700 12px/20px var(--font); display: inline-flex; gap: 4px; align-items: center; white-space: nowrap; }
.tag.urgent { background: var(--danger-50); color: var(--danger-600); }
.tag.high { background: var(--warning-100); color: var(--warning-700); }
.tag.low { background: var(--n100); color: var(--n600); }
.tag.role { background: transparent; border: 1px solid var(--border-strong); color: var(--text-2); }
.tag.you { background: var(--brand-50); color: var(--brand-700); }
.meta { display: inline-flex; align-items: center; gap: 4px; font: var(--t-sm); color: var(--text-3); white-space: nowrap; }
.meta .i { color: var(--text-3); }
.meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font: var(--t-sm); color: var(--text-3); }
.due { display: inline-flex; align-items: center; gap: 4px; font: var(--t-sm); color: var(--text-3); white-space: nowrap; }
.due.overdue { color: var(--danger-600); font-weight: 700; }
.due.today, .due.soon { color: var(--warning-700); font-weight: 700; }
.due-banner { padding: 8px 12px; border-radius: var(--r-md); font: var(--t-body); }
.due-banner.overdue { background: var(--danger-50); color: var(--danger-text); border-left: 4px solid var(--danger-600); font-weight: 700; }
.due-banner.today, .due-banner.soon { background: var(--warning-100); color: var(--warning-700); font-weight: 700; }
.part { display: inline-flex; align-items: center; gap: 6px; font: var(--t-sm); color: var(--text-2); white-space: nowrap; }
.part.done .i { color: var(--success-700); } .part.pending .i { color: var(--n400); } .part.overdue { color: var(--danger-600); } .part.overdue .i { color: var(--danger-600); }

/* ---------- avatar (§4.15), badge (§4.16) ---------- */
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--av-0); color: var(--n800); font: 700 12px/1 var(--font); flex: 0 0 auto; text-transform: uppercase; letter-spacing: .02em; width: 32px; height: 32px; }
.avatar.av-24 { width: 24px; height: 24px; font-size: 11px; } .avatar.av-28 { width: 28px; height: 28px; } .avatar.av-32 { width: 32px; height: 32px; font-size: 14px; }
.avatar.av-36 { width: 36px; height: 36px; font-size: 14px; } .avatar.av-40 { width: 40px; height: 40px; font-size: 14px; } .avatar.av-48 { width: 48px; height: 48px; font-size: 16px; }
.avatar.c0 { background: var(--av-0); } .avatar.c1 { background: var(--av-1); } .avatar.c2 { background: var(--av-2); } .avatar.c3 { background: var(--av-3); } .avatar.c4 { background: var(--av-4); } .avatar.c5 { background: var(--av-5); }
.avatar.owner { background: var(--brand-100); }
.avatar-stack { display: inline-flex; align-items: center; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar + .avatar, .avatar-stack .avatar + .avatar-more { margin-left: -8px; }
.avatar-more { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--n200); color: var(--n800); font: 700 11px/1 var(--font); width: 24px; height: 24px; box-shadow: 0 0 0 2px var(--surface); }
.person-chip { display: inline-flex; align-items: center; gap: 6px; font: var(--t-sm); color: var(--text-2); }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-full); background: var(--danger-600); color: #fff; font: 700 11px/18px var(--font); }
.badge[hidden] { display: none; }
.nav-link .badge { margin-left: 6px; }
.role-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; background: var(--n500); }
.role-dot.owner { background: var(--brand-600); }

/* ---------- cards, lists, rows, tables, key-value (§4.7, §4.20) ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--card-pad); display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.card.tight { padding: 0; gap: 0; overflow: hidden; }
.card.tight > .card-head { padding: var(--card-pad) var(--card-pad) 0; }
.card.tight > .card-foot { padding: 0 var(--card-pad) var(--card-pad); }
.card.flat { border: 0; background: transparent; padding: 0; }
.card.muted { background: var(--surface-muted); }
.card.highlight { border-left: 4px solid var(--success-700); }
.card.callout { border-left: 4px solid var(--danger-600); background: var(--danger-50); color: var(--danger-text); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.card-head h2 { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; }
.card-head .card-count { font: var(--t-sm); color: var(--text-3); font-weight: 400; }
.card-sub { font: var(--t-sm); color: var(--text-3); }
@media (min-width: 720px) { .card { box-shadow: var(--sh-sm); } }
.list { display: flex; flex-direction: column; }
.list.boxed { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.list > .row-item + .row-item, .list > .task-row + .task-row, .list > .alert-row + .alert-row { border-top: 1px solid var(--border); }
.row-item { display: flex; align-items: center; gap: var(--s3); min-height: 56px; padding: 12px var(--s4); color: var(--text); text-decoration: none; }
.row-item.link:hover { background: var(--n50); text-decoration: none; }
.row-item .row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-item .row-title { font: var(--t-body-strong); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-item .row-sub { font: var(--t-sm); color: var(--text-3); overflow-wrap: anywhere; }
.row-item .row-end { display: flex; align-items: center; gap: var(--s2); flex: 0 0 auto; }
.row-item .chev { color: var(--n400); }
.row-item.you { background: var(--brand-50); }
.kv { display: grid; grid-template-columns: 112px 1fr; gap: 8px 12px; font: var(--t-body); }
.kv dt { font: var(--t-label); color: var(--text-3); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 559px) { .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd + dt { margin-top: 10px; } }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 0 10px; height: 44px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font: 700 12px/16px var(--font); text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tbody tr:hover { background: var(--n50); }
.table tbody tr:last-child td { border-bottom: 0; }
@media (max-width: 719px) {
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack thead { display: none; }
  .table.stack tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
  .table.stack tr:last-child { border-bottom: 0; }
  .table.stack td { height: auto; padding: 2px 0; border: 0; display: flex; justify-content: space-between; gap: 12px; text-align: left; }
  .table.stack td.num { text-align: left; }
  .table.stack td::before { content: attr(data-th); font: var(--t-label); color: var(--text-3); flex: 0 0 40%; }
  .table.stack td:not([data-th])::before { display: none; }
}

/* task row (§4.7) */
.task-row { display: flex; gap: var(--s3); align-items: flex-start; padding: 12px var(--s4) 12px 13px; min-height: 64px; color: var(--text); background: var(--surface); border-left: 3px solid transparent; position: relative; text-decoration: none; }
.task-row:hover { background: var(--n50); text-decoration: none; }
.task-row.rail-urgent { border-left-color: var(--danger-600); } .task-row.rail-high { border-left-color: var(--warning-700); }
.task-row.finished { background: var(--surface-muted); } .task-row.finished .task-title { color: var(--text-2); }
.task-row .task-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.task-row .task-title { font: var(--t-body-strong); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.task-row .task-title .tag { vertical-align: middle; margin-left: 6px; position: relative; top: -1px; }
.task-row .task-end { flex: 0 0 auto; display: flex; align-items: center; gap: var(--s2); }
@media (min-width: 720px) {
  .list.spaced { gap: var(--s2); }
  .list.spaced .task-row { border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--r-md); }
  .list.spaced .task-row.rail-urgent, .list.spaced .task-row.rail-high { border-left-width: 3px; }
  .list.spaced .task-row:not(.rail-urgent):not(.rail-high) { border-left-color: var(--border); }
  .list.spaced > .task-row + .task-row { border-top: 1px solid var(--border); }
  .task-row:hover { box-shadow: var(--sh-md); }
}
@media (max-width: 719px) {
  .task-row { flex-direction: column; gap: 6px; }
  .task-row .task-end { position: absolute; top: 10px; right: 12px; }
  .task-row.has-status .task-title { padding-right: 130px; }
}
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 36px; }
.section-head h3, .section-head .h3 { color: var(--text-3); }
.section-head.danger h3 { color: var(--danger-600); } .section-head.warning h3 { color: var(--warning-700); }
.section-head .sec-action { font: var(--t-sm); color: var(--text-2); font-weight: 700; }
@media (max-width: 719px) { .section-head.sticky { position: sticky; top: calc(var(--header-h-phone) + var(--safe-top) + 3px); background: var(--bg); z-index: 5; } }

/* ---------- tiles (§4.9) ---------- */
.tiles { display: grid; gap: var(--s3); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); } }
.tile { display: flex; flex-direction: column; gap: 4px; padding: var(--s4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); color: var(--text); text-decoration: none; min-height: 72px; transition: box-shadow var(--dur) var(--ease); }
.tile:hover { box-shadow: var(--sh-md); text-decoration: none; }
.tile .tile-label { font: var(--t-label); color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; font-size: 12px; }
.tile .tile-value { font: var(--t-display); font-variant-numeric: tabular-nums; color: var(--text); }
.tile .tile-hint { font: var(--t-caption); color: var(--text-3); }
.tile.zero .tile-value { color: var(--text-3); }
.tile.danger:not(.zero) .tile-value { color: var(--danger-600); } .tile.warning:not(.zero) .tile-value { color: var(--warning-700); } .tile.review:not(.zero) .tile-value { color: var(--review-700); }
@media (max-width: 719px) { .tile { flex-direction: row; align-items: center; justify-content: space-between; min-height: 72px; } .tile .tile-value { font-size: 28px; line-height: 32px; } .tile .tile-hint { display: none; } }

/* ---------- segmented (§4.5) ---------- */
/* Fills its container by default (also as a flex item: width 100% + min-width 0 so it shares the row instead of collapsing). */
.segmented { display: flex; width: 100%; min-width: 0; gap: 2px; padding: 4px; background: var(--n100); border-radius: var(--r-md); }
.seg-opt { flex: 1 1 0; height: 40px; min-width: 0; border-radius: calc(var(--r-md) - 4px); font: var(--t-label); color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg-opt[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--sh-sm); }
.seg-opt[aria-checked="true"].tone-warning .i { color: var(--warning-700); } .seg-opt[aria-checked="true"].tone-danger .i { color: var(--danger-600); }
/* Phones: 44px targets (§9.1.4); four-option segments wrap 2x2 (§4.5). */
@media (max-width: 719px) { .seg-opt { height: 44px; } .segmented.wrap-phone { flex-wrap: wrap; } .segmented.wrap-phone .seg-opt { flex: 1 1 45%; } }
/* Desktop variant that hugs its labels (scope controls, filters): segmented({ cls: 'inline' }). */
@media (min-width: 720px) { .segmented.inline { width: auto; flex: 0 0 auto; align-self: flex-start; } .segmented.inline .seg-opt { flex: 0 0 auto; padding: 0 20px; } }

/* ---------- progress (§4.17) ---------- */
.progress { height: 6px; background: var(--n200); border-radius: var(--r-full); overflow: hidden; width: 100%; }
.progress > i { display: block; height: 100%; background: var(--success-700); border-radius: var(--r-full); transition: width var(--dur) var(--ease); }
.progress-label { font: var(--t-sm); color: var(--text-3); white-space: nowrap; }
.workload { display: flex; align-items: center; gap: 8px; }
.workload .wl-bar { flex: 1; height: 8px; display: flex; background: var(--n100); border-radius: var(--r-full); overflow: hidden; }
.workload .wl-bar i { display: block; height: 100%; }
.workload .wl-bar .wl-over { background: var(--danger-600); } .workload .wl-bar .wl-week { background: var(--warning-700); } .workload .wl-bar .wl-later { background: var(--n300); }
.workload .wl-total { font: var(--t-sm); color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 1.5em; text-align: right; }
.ring { display: inline-flex; align-items: center; gap: 6px; font: var(--t-sm); color: var(--text-2); }
.ring svg { width: 20px; height: 20px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3; } .ring .ring-track { stroke: var(--n200); } .ring .ring-fill { stroke: var(--success-700); stroke-linecap: round; }

/* ---------- skeleton (§4.14) ---------- */
.sk { background: var(--n100); border-radius: var(--r-sm); position: relative; overflow: hidden; min-height: 12px; }
.sk-text { height: 14px; } .sk-title { height: 20px; width: 60%; } .sk-meta { height: 12px; width: 40%; } .sk-row { height: 64px; border-radius: var(--r-md); } .sk-tile { height: 96px; border-radius: var(--r-lg); } .sk-card { height: 160px; border-radius: var(--r-lg); } .sk-avatar { width: 36px; height: 36px; border-radius: 50%; } .sk-chip { height: 36px; width: 96px; border-radius: var(--r-full); }
.sk-w40 { width: 40%; } .sk-input { height: 48px; border-radius: var(--r-sm); } .sk-w60 { width: 60%; } .sk-w80 { width: 80%; } .sk-w100 { width: 100%; }
@media (prefers-reduced-motion: no-preference) {
  .sk::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, var(--n100) 0%, var(--n50) 50%, var(--n100) 100%); animation: shimmer var(--dur-shimmer) infinite; }
  @keyframes shimmer { to { transform: translateX(100%); } }
}
.sk-rows { display: flex; flex-direction: column; gap: var(--s2); }
.sk-rowline { display: flex; flex-direction: column; gap: 8px; padding: 14px var(--s4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); min-height: 64px; }
.sk-person { display: flex; gap: var(--s3); align-items: center; padding: 10px var(--s4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); min-height: 56px; }
.sk-person .sk-lines { flex: 1; display: flex; flex-direction: column; gap: 6px; }

/* ---------- toast (§4.12) ---------- */
.toasts { position: fixed; z-index: 60; display: flex; flex-direction: column; gap: var(--s2); pointer-events: none; right: var(--s6); bottom: var(--s6); left: auto; width: min(420px, calc(100vw - 48px)); }
@media (max-width: 719px) { .toasts { left: var(--s4); right: var(--s4); bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--s4)); width: auto; } body.modal-route .toasts { bottom: calc(var(--actionbar-h) + var(--safe-bottom) + var(--s4)); } }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 8px 8px 14px; border-radius: var(--r-md); background: var(--n800); color: #fff; font: 400 14px/20px var(--font); box-shadow: var(--sh-lg); }
.toast .i { width: 20px; height: 20px; flex: 0 0 auto; }
.toast.success .i.lead { color: var(--success-100); } .toast.info .i.lead { color: #fff; } .toast.error .i.lead { color: var(--brand-100); }
.toast .toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast .toast-text .second { display: block; font: var(--t-caption); opacity: .85; margin-top: 2px; }
.toast .toast-action { color: #fff; font: var(--t-label); text-decoration: underline; min-height: 44px; padding: 0 8px; white-space: nowrap; }
.toast .toast-close { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; color: #fff; border-radius: var(--r-md); }
.toast .toast-close:hover { background: rgba(255, 255, 255, .12); }
.toast .toast-progress { height: 3px; width: 100%; background: rgba(255, 255, 255, .2); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.toast .toast-progress i { display: block; height: 100%; background: #fff; transition: width var(--dur) var(--ease); }
@media (prefers-reduced-motion: no-preference) { .toast { animation: toast-in var(--dur) var(--ease); } @keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } } }

/* ---------- dialog and bottom sheet (§4.11) ---------- */
dialog.dlg { border: 0; padding: 0; background: var(--surface); color: var(--text); border-radius: var(--r-lg); box-shadow: var(--sh-lg); width: 440px; max-width: min(90vw, 520px); max-height: 90vh; overflow: hidden; }
dialog.dlg.form { width: 520px; }
dialog.dlg.wide { width: 720px; max-width: 92vw; }
dialog.dlg::backdrop { background: var(--backdrop); }
.dlg-inner { display: flex; flex-direction: column; max-height: 90vh; }
.dlg-handle { display: none; }
.dlg-head { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s6) var(--s6) 0; }
.dlg-head h2 { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.dlg-head h2 .i { color: var(--danger-600); flex: 0 0 auto; }
.dlg-head .dlg-close { margin: -8px -8px 0 0; }
.dlg-body { padding: var(--s3) var(--s6) 0; overflow: auto; display: flex; flex-direction: column; gap: var(--s4); color: var(--text-2); font: var(--t-body); }
.dlg-body .form, .dlg-body .field { color: var(--text); }
.dlg-body:empty { display: none; }
.dlg-foot { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s5) var(--s6) var(--s6); flex-wrap: wrap; }
.dlg-foot .dlg-left { margin-right: auto; }
.dlg-error { color: var(--danger-600); font: var(--t-sm); display: flex; gap: 6px; align-items: center; }
.dlg-error[hidden] { display: none; }
.sheet-list { display: flex; flex-direction: column; padding: var(--s2) 0; }
.sheet-item { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 var(--s6); font: var(--t-body); color: var(--text); width: 100%; text-align: left; }
.sheet-item:hover, .sheet-item:focus-visible { background: var(--n100); box-shadow: none; }
.sheet-item .i { color: var(--text-3); }
.sheet-item.danger { color: var(--danger-600); } .sheet-item.danger .i { color: var(--danger-600); }
.sheet-item.disabled { opacity: .5; pointer-events: none; }
.sheet-sep { border-top: 1px solid var(--border); margin: 6px 0; }
.popover-menu { position: absolute; z-index: 30; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-md); min-width: 220px; padding: 6px; }
.popover-menu .sheet-item { padding: 0 12px; border-radius: var(--r-md); min-height: 44px; }
@media (max-width: 719px) {
  dialog.dlg, dialog.dlg.form, dialog.dlg.wide { width: 100%; max-width: 100%; margin: 0; inset: auto 0 0 0; border-radius: var(--r-sheet) var(--r-sheet) 0 0; max-height: 90vh; max-height: 90dvh; }
  .dlg-inner { max-height: 90vh; max-height: 90dvh; padding-bottom: var(--safe-bottom); }
  .dlg-handle { display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--n300); margin: 8px auto 0; }
  .dlg-head { padding: var(--s3) var(--s4) 0; }
  .dlg-body { padding: var(--s3) var(--s4) 0; }
  .dlg-foot { flex-direction: column-reverse; padding: var(--s4); gap: var(--s2); }
  .dlg-foot .btn { width: 100%; height: 48px; font-size: 16px; }
  .dlg-foot .dlg-left { margin-right: 0; order: -1; }
  .dlg-foot.keep-row { flex-direction: row; } .dlg-foot.keep-row .btn { flex: 1; width: auto; }
  .sheet-item { padding: 0 var(--s4); }
  @media (prefers-reduced-motion: no-preference) { dialog.dlg[open] { animation: sheet-up var(--dur) var(--ease); } @keyframes sheet-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } } }
}
dialog.lightbox { border: 0; padding: 0; background: var(--n900); color: #fff; width: 100vw; height: 100vh; height: 100dvh; max-width: 100vw; max-height: 100vh; max-height: 100dvh; margin: 0; inset: 0; }
dialog.lightbox::backdrop { background: rgba(0, 0, 0, .85); }
.lb-inner { display: flex; flex-direction: column; height: 100%; }
.lb-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: calc(var(--s2) + var(--safe-top)) var(--s3) var(--s2); }
.lb-top .lb-caption { flex: 1; min-width: 0; font: var(--t-sm); color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-top .btn-icon, .lb-foot .btn { color: #fff; } .lb-top .btn-icon:hover { background: rgba(255, 255, 255, .12); }
.lb-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; padding: 0 var(--s3); }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-stage iframe, .lb-stage object { width: 100%; height: 100%; border: 0; background: #fff; }
.lb-stage .lb-doc { display: flex; flex-direction: column; align-items: center; gap: var(--s3); color: #fff; text-align: center; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 255, 255, .12); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.lb-nav.prev { left: var(--s3); } .lb-nav.next { right: var(--s3); }
.lb-foot { display: flex; justify-content: center; gap: var(--s2); padding: var(--s3) var(--s3) calc(var(--s3) + var(--safe-bottom)); flex-wrap: wrap; }
.lb-foot .btn-secondary { background: transparent; border-color: rgba(255, 255, 255, .4); color: #fff; } .lb-foot .btn-secondary:hover { background: rgba(255, 255, 255, .12); }
.lb-foot .btn-danger { background: transparent; border-color: rgba(255, 255, 255, .4); color: #fff; }

/* ---------- empty state (§4.13) ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s3); padding: var(--s10) var(--s4) var(--s6); }
.empty .empty-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--n100); display: flex; align-items: center; justify-content: center; color: var(--text-3); }
.empty .empty-icon .i { width: 32px; height: 32px; }
.empty .empty-title { font: 700 16px/22px var(--font); color: var(--text); }
.empty .empty-body { font: 400 14px/20px var(--font); color: var(--text-3); max-width: 32ch; }
.empty .empty-actions { display: flex; flex-direction: column; align-items: center; gap: var(--s2); }
.empty.inline { padding: var(--s4); flex-direction: row; text-align: left; gap: var(--s3); }
.empty.inline .empty-icon { width: 40px; height: 40px; } .empty.inline .empty-icon .i { width: 24px; height: 24px; }
.empty.inline .empty-title { font-size: 15px; }
.empty.inline .empty-body { max-width: none; }

/* ---------- people picker (§4.4) ---------- */
.people { display: flex; flex-direction: column; gap: var(--s3); }
.people-search { position: sticky; top: 0; z-index: 1; }
.people-group { display: flex; flex-direction: column; gap: 6px; }
.people-chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.pchip { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px 0 6px; border-radius: var(--r-full); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: var(--t-body); max-width: 100%; }
.pchip:hover { background: var(--n50); }
.pchip .pchip-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pchip .pchip-dept { font: var(--t-caption); color: var(--text-3); display: block; }
.pchip .pchip-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; min-width: 0; }
.pchip .pchip-check { display: none; }
.pchip[aria-pressed="true"], .pchip[aria-checked="true"] { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.pchip[aria-pressed="true"] .pchip-dept, .pchip[aria-checked="true"] .pchip-dept { color: rgba(255, 255, 255, .85); }
.pchip[aria-pressed="true"] .pchip-check, .pchip[aria-checked="true"] .pchip-check { display: inline-flex; }
.pchip[aria-pressed="true"] .avatar, .pchip[aria-checked="true"] .avatar { box-shadow: 0 0 0 2px rgba(255, 255, 255, .6); }
.pchip .role-dot { margin-left: -2px; }
@media (max-width: 719px) { .pchip .pchip-dept { display: none; } }
.people-hint { font: var(--t-sm); color: var(--text-3); }
.people-collapsed { display: flex; align-items: center; gap: var(--s3); min-height: 48px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); width: 100%; background: var(--surface); font: var(--t-body); color: var(--text); }
.people-collapsed .grow { text-align: left; }
.people-sheet-list { display: flex; flex-direction: column; }
.people-sheet-row { display: flex; align-items: center; gap: var(--s3); min-height: 48px; padding: 0 var(--s4); cursor: pointer; }
.people-sheet-row + .people-sheet-row { border-top: 1px solid var(--border); }
.people-sheet-row input { margin-left: auto; }

/* ---------- due picker (§4.3) ---------- */
.due-picker { display: flex; flex-direction: column; gap: var(--s2); }
.due-custom { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
@media (max-width: 399px) { .due-custom { grid-template-columns: 1fr; } }
.due-resolved { font: var(--t-sm); color: var(--text-2); }
.due-resolved.past { color: var(--danger-600); }

/* ---------- checklist, timeline, proof (task detail body, §5.10) ---------- */
.check-list { display: flex; flex-direction: column; }
.check-item { display: flex; align-items: center; gap: 10px; min-height: 44px; border-bottom: 1px solid var(--border); }
.check-item:last-child { border-bottom: 0; }
.check-item label { flex: 1; min-width: 0; cursor: pointer; font: var(--t-body); overflow-wrap: anywhere; padding: 10px 0; }
.check-item.done label { text-decoration: line-through; color: var(--text-3); }
.check-item .btn-icon { color: var(--text-3); }
@media (hover: hover) and (pointer: fine) { .check-item .btn-icon { opacity: 0; } .check-item:hover .btn-icon, .check-item .btn-icon:focus-visible, .check-item:focus-within .btn-icon { opacity: 1; } }
.add-row { display: flex; gap: var(--s2); align-items: center; }
.add-row .field { flex: 1; }
.timeline { display: flex; flex-direction: column; gap: var(--s3); }
.tl-item { display: flex; gap: 10px; align-items: flex-start; }
.tl-item .tl-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.tl-item .tl-line { font: var(--t-sm); color: var(--text-2); overflow-wrap: anywhere; }
.tl-item .tl-line b { color: var(--text); }
.tl-item .tl-time { font: var(--t-caption); color: var(--text-3); }
.tl-item.comment .tl-bubble { background: var(--n50); border-radius: var(--r-md); padding: 10px 12px; font: var(--t-body); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.tl-item .tl-thumb { width: 56px; height: 56px; border-radius: var(--r-sm); object-fit: cover; background: var(--n100); }
.composer { display: flex; flex-direction: column; gap: var(--s2); border-top: 1px solid var(--border); padding-top: var(--s3); }
.composer .composer-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--s2); }
.proof-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
@media (min-width: 720px) { .proof-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.proof-thumb { position: relative; aspect-ratio: 1 / 1; border-radius: var(--r-md); overflow: hidden; background: var(--n100); display: block; width: 100%; padding: 0; }
.proof-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.proof-thumb .sk { position: absolute; inset: 0; border-radius: 0; }
.proof-thumb img[data-loaded="false"] { visibility: hidden; }
.proof-thumb:focus-visible { box-shadow: var(--focus); }
.file-row { display: flex; align-items: center; gap: var(--s3); min-height: 48px; }
.file-row + .file-row { border-top: 1px solid var(--border); }
.file-row .file-icon { width: 36px; height: 36px; border-radius: var(--r-sm); background: var(--n100); display: flex; align-items: center; justify-content: center; color: var(--text-3); flex: 0 0 36px; }
.file-row .file-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-row .file-name { font: var(--t-body); color: var(--text); text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .file-name:hover { text-decoration: underline; }
.file-row .file-sub { font: var(--t-caption); color: var(--text-3); }
.dropzone { border: 1px dashed var(--border-strong); border-radius: var(--r-md); min-height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s2); padding: var(--s4); text-align: center; color: var(--text-3); font: var(--t-sm); }
.dropzone .dz-icons { display: flex; gap: 8px; color: var(--n400); }
.dropzone .dz-title { font: var(--t-body-strong); color: var(--text); }
.upload-row { display: flex; align-items: center; gap: var(--s2); font: var(--t-sm); color: var(--text-2); }
.upload-row .progress { flex: 1; }
.thumbs { display: flex; flex-wrap: wrap; gap: var(--s2); }
.thumb { position: relative; width: 64px; height: 64px; border-radius: var(--r-sm); overflow: hidden; background: var(--n100); display: flex; align-items: center; justify-content: center; color: var(--text-3); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.sm { width: 56px; height: 56px; }
.thumb-wrap { display: flex; flex-direction: column; gap: 2px; width: 88px; font: var(--t-caption); color: var(--text-3); }
.thumb-wrap .thumb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* alerts rows (§5.12) */
.alert-row { display: flex; gap: var(--s3); align-items: flex-start; min-height: 64px; padding: 12px var(--s4); color: var(--text); text-decoration: none; background: var(--surface); }
.alert-row:hover { background: var(--n50); text-decoration: none; }
.alert-row.unread { background: var(--surface-muted); }
/* kind tile: 36px icon square used by alert rows, Me/Manage rows, settings list rows and the pinned To verify row */
.kind-tile { width: 36px; height: 36px; border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; flex: 0 0 36px; background: var(--n100); color: var(--text-2); }
.kind-tile.brand { background: var(--brand-50); color: var(--brand-700); } .kind-tile.warning { background: var(--warning-100); color: var(--warning-700); }
.kind-tile.danger { background: var(--danger-50); color: var(--danger-600); } .kind-tile.success { background: var(--success-100); color: var(--success-700); }
.kind-tile.verified { background: var(--verified-100); color: var(--verified-700); } .kind-tile.review { background: var(--review-100); color: var(--review-700); }
.alert-row .alert-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.alert-row .alert-title { font: var(--t-body); } .alert-row.unread .alert-title { font-weight: 700; }
.alert-row .alert-task { font: 400 14px/20px var(--font); color: var(--text-2); overflow-wrap: anywhere; }
.alert-row .alert-excerpt { font: var(--t-sm); color: var(--text-3); overflow-wrap: anywhere; }
.alert-row .alert-side { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font: var(--t-caption); color: var(--text-3); }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-600); display: inline-block; }

/* misc */
.pill-code { font-family: var(--font-mono); font-size: 20px; padding: 10px 12px; background: var(--n100); border-radius: var(--r-md); display: flex; align-items: center; justify-content: space-between; gap: var(--s2); overflow-wrap: anywhere; color: var(--text); }
.pill-code.sm { font-size: 15px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--n400); flex: 0 0 8px; }
.dot.ok { background: var(--success-700); } .dot.warn { background: var(--warning-700); } .dot.bad { background: var(--danger-600); }
.disclosure { display: flex; align-items: center; gap: 10px; min-height: 48px; width: 100%; font: var(--t-body-strong); color: var(--text); padding: 0; }
.disclosure .disc-sub { font: var(--t-sm); color: var(--text-3); font-weight: 400; }
.disclosure .i { transition: transform var(--dur) var(--ease); color: var(--text-3); margin-left: auto; }
.disclosure[aria-expanded="true"] .i.chev { transform: rotate(180deg); }
.datalist-hidden { display: none; }
