/* ==========================================================================
   Features added after 1.0 — backups, tokens, live state, labels, board …
   Same language as components.css: inset lists, system colours, soft motion.
   ========================================================================== */

/* --- Busy rows ------------------------------------------------------------ */
.row.is-busy { pointer-events: none; }
.row.is-busy .row__chevron { animation: busy-spin 0.9s linear infinite; }
@keyframes busy-spin { to { transform: rotate(360deg); } }

.row--flash { animation: row-flash 1.6s var(--ease-out); }
@keyframes row-flash {
  0% { background: var(--accent-soft); }
  100% { background: transparent; }
}

/* --- Backup status -------------------------------------------------------- */
.backup-status {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--sys-green) 16%, transparent), transparent 60%),
    var(--bg-content);
}
.backup-status.is-off {
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--sys-orange) 16%, transparent), transparent 60%),
    var(--bg-content);
}
.backup-status__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(160deg, color-mix(in srgb, var(--sys-green) 80%, #fff), var(--sys-green));
  box-shadow: 0 6px 16px color-mix(in srgb, var(--sys-green) 35%, transparent);
}
.backup-status.is-off .backup-status__icon {
  background: linear-gradient(160deg, color-mix(in srgb, var(--sys-orange) 80%, #fff), var(--sys-orange));
  box-shadow: 0 6px 16px color-mix(in srgb, var(--sys-orange) 35%, transparent);
}
.backup-status__icon svg { width: 22px; height: 22px; stroke-width: 2.4; }
.backup-status__text { flex: 1; min-width: 0; }
.backup-status__title { font: var(--t-headline); letter-spacing: -0.01em; }
.backup-status__sub { font: var(--t-footnote); color: var(--label-secondary); margin-top: 2px; }
.backup-status .btn { flex: none; gap: 4px; }

@media (max-width: 480px) {
  .backup-status { flex-wrap: wrap; }
  .backup-status .btn { width: 100%; margin-top: var(--sp-1); }
}

/* --- API token reveal ----------------------------------------------------- */
.token-reveal { display: flex; flex-direction: column; align-items: stretch; gap: var(--sp-3); }
.token-reveal__badge {
  align-self: center;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-top: var(--sp-2);
  border-radius: 20px;
  color: #fff;
  background: linear-gradient(150deg, var(--sys-indigo), var(--sys-purple));
  box-shadow: 0 10px 28px color-mix(in srgb, var(--sys-indigo) 40%, transparent);
  animation: badge-pop 520ms var(--ease-out) both;
}
@keyframes badge-pop {
  0% { transform: scale(0.4) rotate(-12deg); opacity: 0; }
  60% { transform: scale(1.08) rotate(3deg); opacity: 1; }
  100% { transform: none; }
}
.token-reveal__title { font: var(--t-title3); text-align: center; }
.token-reveal__text { font: var(--t-callout); color: var(--label-secondary); text-align: center; }
.token-reveal__secret,
.token-reveal__code {
  display: block;
  font: 500 14px/1.45 var(--font-mono);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-sm);
  background: var(--bg-inset);
  overflow-wrap: anywhere;
  user-select: all;
  -webkit-user-select: all;
}
.token-reveal__secret {
  font-size: 15px;
  text-align: center;
  background: color-mix(in srgb, var(--sys-indigo) 12%, var(--bg-content));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--sys-indigo) 30%, transparent);
}
.token-reveal .btn-row { justify-content: center; }
.token-reveal .field--stack { gap: 6px; }
.btn.is-done { color: var(--sys-green); }

/* --- Live indicator (sidebar footer) -------------------------------------- */
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  color: var(--label-tertiary);
  transition: color var(--dur-base) var(--ease-ios);
}
.live-indicator__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sys-gray3);
  transition: background var(--dur-base) var(--ease-ios);
}
:root[data-live="on"] .live-indicator { color: var(--sys-green); }
:root[data-live="on"] .live-indicator__dot {
  background: var(--sys-green);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sys-green) 22%, transparent);
}
/* No endless animation here: iOS Safari treats constantly changing content as
   a hover effect and then needs a second tap for every click. */
:root[data-live="connecting"] .live-indicator__dot { background: var(--sys-orange); }
@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--sys-green) 55%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* --- Labels (real millimetres) -------------------------------------------- */
.label-controls { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.label-controls__title { font: var(--t-footnote); text-transform: uppercase; letter-spacing: 0.06em; color: var(--label-secondary); margin-top: var(--sp-2); }
.label-controls__title:first-child { margin-top: 0; }
.label-controls__label { font: var(--t-footnote); color: var(--label-secondary); margin-bottom: 6px; }
.label-controls__row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--sp-3); margin-top: var(--sp-2); }
.label-controls__skip { display: flex; align-items: center; gap: var(--sp-2); font: var(--t-subhead); color: var(--label-secondary); }
.label-controls__skip input, .label-custom input {
  width: 64px; padding: 6px 8px; border-radius: var(--r-xs); background: var(--bg-inset); font: var(--t-callout); text-align: right;
}
.label-custom { gap: var(--sp-4); font: var(--t-subhead); color: var(--label-secondary); }
.label-custom label { display: flex; align-items: center; gap: 6px; }
.label-controls__toggle { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); width: 100%; text-align: left; padding: var(--sp-2) 0; }
.label-controls__hint { font: var(--t-caption); color: var(--label-tertiary); }
.label-controls__actions { align-items: center; margin-top: var(--sp-1); flex-wrap: wrap; }
.label-controls__actions .btn { gap: 5px; }
.label-controls__actions .btn.is-busy { opacity: 0.6; pointer-events: none; }

.format-chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: var(--sp-2);
}
.format-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--sp-3) var(--sp-2) var(--sp-2);
  border-radius: var(--r-sm);
  background: var(--bg-inset);
  transition: background var(--dur-fast) var(--ease-ios), transform var(--dur-fast) var(--ease-ios), box-shadow var(--dur-base);
}
.format-chip:active { transform: scale(0.96); }
.format-chip.is-active {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
.format-chip__shape {
  display: grid;
  place-items: center;
  border-radius: 4px;
  margin: 2px 0;
  background: var(--bg-content);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15), inset 0 0 0 0.5px var(--separator);
  color: var(--label-secondary);
}
.format-chip.is-active .format-chip__shape { background: var(--accent); color: #fff; }
.format-chip__name { font: 600 13px/1.2 var(--font-ui); font-variant-numeric: tabular-nums; }
.format-chip__hint { font: var(--t-caption); color: var(--label-secondary); text-align: center; line-height: 1.2; }

.label-preview {
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background:
    radial-gradient(circle at 1px 1px, var(--label-quaternary) 1px, transparent 0) 0 0 / 14px 14px,
    var(--bg-content-alt);
  box-shadow: inset 0 0 0 0.5px var(--separator);
  overflow-x: auto;
}
.label-sheet { display: flex; flex-wrap: wrap; gap: 3mm; justify-content: flex-start; }
.mm-label {
  position: relative;
  flex: none;
  overflow: hidden;
  background: #fff;
  color: #000;
  border-radius: 1.2mm;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18), 0 6px 18px rgba(0, 0, 0, 0.08);
  animation: label-in 360ms var(--ease-out) both;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}
.mm-label--blank { background: transparent; box-shadow: inset 0 0 0 0.3mm dashed var(--separator-opaque); outline: 0.3mm dashed var(--separator-opaque); outline-offset: -0.3mm; }
@keyframes label-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
.mm-label__qr { position: absolute; }
.mm-label__qr svg { display: block; }
.mm-label__line {
  position: absolute;
  line-height: 1.12;
  white-space: nowrap;
  /* label-layout.js fits every line; never cut anything off with "…" */
  overflow: visible;
  color: #000;
}
.mm-label__line.is-mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.04em; }
.mm-label__swatch { position: absolute; border-radius: 0.6mm; box-shadow: inset 0 0 0 0.15mm rgba(0, 0, 0, 0.35); }

.pick-check {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  background: var(--bg-inset);
  color: transparent;
  transition: background var(--dur-fast) var(--ease-ios), transform var(--dur-base) var(--ease-out);
}
.row.is-selected .pick-check { background: var(--accent); color: #fff; transform: scale(1.06); }

@media print {
  .label-preview { padding: 0; background: none; box-shadow: none; overflow: visible; }
  .mm-label { animation: none; break-inside: avoid; }
  .page, .large-title { margin: 0 !important; }
  .large-title { display: none !important; }
}

/* --- Camera picker (scanner) ---------------------------------------------- */
.camera-picker { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-3); }
.camera-picker__label { display: inline-flex; align-items: center; gap: 5px; font: var(--t-footnote); color: var(--label-secondary); flex: none; }
.camera-picker .chips { padding: 0; }

.btn.is-spinning svg { animation: busy-spin 0.9s linear infinite; }
.btn { gap: 5px; }

/* --- Multi-colour ----------------------------------------------------------- */
.color-tile {
  width: 84px;
  height: 84px;
  flex: none;
  border-radius: var(--r-lg);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12), 0 8px 24px color-mix(in srgb, var(--spool-color) 35%, transparent);
}
.dot--multi { box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.25); }
.color-extra { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.color-extra__item {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15), var(--shadow-sm);
  animation: label-in 260ms var(--ease-out) both;
}
.color-extra__item input[type="color"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.color-extra__remove {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--label-secondary);
  color: var(--bg-content);
  z-index: 1;
}
.color-extra__remove svg { width: 10px; height: 10px; stroke-width: 3; }
.color-extra__add {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-inset);
  color: var(--accent);
}
.color-extra__preview { width: 100%; height: 14px; border-radius: 7px; box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.2); }

/* --- Colour filter chip ------------------------------------------------------ */
.color-chip { position: relative; overflow: hidden; }
.color-chip__input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.color-chip__clear {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin: -2px -6px -2px 2px;
  border-radius: 50%;
  background: color-mix(in srgb, currentColor 22%, transparent);
  color: inherit;
}

/* --- Storage board ------------------------------------------------------------ */
.board {
  display: flex;
  gap: var(--sp-4);
  align-items: flex-start;
  overflow-x: auto;
  padding: 2px 2px var(--sp-6);
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}
.board-column {
  flex: 0 0 280px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border-radius: var(--r-lg);
  background: var(--glass-panel);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-sm), inset 0 0 0 0.5px var(--border-glass);
  transition: box-shadow var(--dur-base) var(--ease-ios), transform var(--dur-base) var(--ease-out), background var(--dur-base);
}
.board-column.is-target {
  transform: translateY(-2px);
  background: color-mix(in srgb, var(--accent) 10%, var(--glass-panel));
  box-shadow: var(--shadow-md), inset 0 0 0 2px var(--accent);
}
.board-column__head { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; padding: 2px 2px var(--sp-1); }
.board-column__icon {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 10px; color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
.board-column__icon svg { width: 18px; height: 18px; }
.board-column__title { flex: 1; min-width: 0; }
.board-column__name { font: var(--t-headline); letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-column__sub { font: var(--t-caption); color: var(--label-secondary); margin-top: 1px; }
.board-column__capacity { flex-basis: 100%; height: 4px; border-radius: 2px; background: var(--bg-inset); overflow: hidden; }
.board-column__capacity > div { height: 100%; border-radius: 2px; transition: width var(--dur-slow) var(--ease-ios); }
.board-column__cards { display: flex; flex-direction: column; gap: var(--sp-2); min-height: 8px; }
.board-column__empty {
  padding: var(--sp-5) var(--sp-3);
  text-align: center;
  font: var(--t-footnote);
  color: var(--label-tertiary);
  border: 1.5px dashed var(--separator);
  border-radius: var(--r-md);
}
.board-column.is-target .board-column__empty { border-color: var(--accent); color: var(--accent); }

.board-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-2);
  border-radius: var(--r-md);
  background: var(--bg-content);
  box-shadow: var(--shadow-sm);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: pan-x pan-y;
  transition: transform var(--dur-fast) var(--ease-ios), box-shadow var(--dur-fast), opacity var(--dur-fast);
  animation: label-in 300ms var(--ease-out) both;
}
.board-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--spool-color);
}
@media (hover: hover) { .board-card:hover { box-shadow: var(--shadow-md); } }
.board-card:active { transform: scale(0.985); }
.board-card.is-lifted { opacity: 0.3; transform: scale(0.97); }
.board-card.is-dropped { animation: card-drop 420ms var(--ease-out); }
@keyframes card-drop { 0% { transform: scale(1.06); box-shadow: var(--shadow-lg); } 100% { transform: none; } }
.board-card__body { flex: 1; min-width: 0; }
.board-card__name { font: 600 14px/1.25 var(--font-ui); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-card__meta { font: var(--t-caption); color: var(--label-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-card__grams { font: 600 13px var(--font-ui); font-variant-numeric: tabular-nums; color: var(--label-secondary); flex: none; }
.board-card__check {
  display: none;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  background: var(--bg-inset);
  color: transparent;
  transition: background var(--dur-fast), transform var(--dur-base) var(--ease-out);
}
.board.is-selecting .board-card { cursor: pointer; }
.board.is-selecting .board-card__check { display: grid; }
.board-card.is-selected { box-shadow: var(--shadow-sm), inset 0 0 0 2px var(--accent); }
.board-card.is-selected .board-card__check { background: var(--accent); color: #fff; transform: scale(1.08); }

.board-card--ghost {
  position: fixed;
  z-index: 1000;
  margin: 0;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
  cursor: grabbing;
  animation: none;
  will-change: transform;
}
/* Higher rank than the desktop hover rule further down, which gives every
   card a transform transition — on the ghost that made it lag behind the
   mouse and feel sticky. */
.board-card.board-card--ghost { transition: none; }
.board-card.board-card--ghost.is-returning { transition: transform 200ms var(--ease-ios), opacity 200ms; opacity: 0.4; }
body.is-dragging-card, body.is-dragging-card * { cursor: grabbing !important; }

.board-actionbar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 18px);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4);
  border-radius: var(--r-full);
  background: var(--glass-bar-solid);
  -webkit-backdrop-filter: var(--glass-blur-strong);
  backdrop-filter: var(--glass-blur-strong);
  box-shadow: var(--shadow-tabbar), inset 0 0 0 0.5px var(--border-glass);
  transform: translate(-50%, 140%);
  opacity: 0;
  transition: transform var(--dur-slow) var(--ease-ios), opacity var(--dur-base);
  pointer-events: none;
}
.board-actionbar.is-visible { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.board-actionbar__count { font: var(--t-subhead); font-weight: 600; white-space: nowrap; }
@media (min-width: 820px) { .board-actionbar { bottom: 28px; left: calc(50% + var(--sidebar-w) / 2); } }

/* iPhone: columns stack and fill the width. */
@media (max-width: 699px) {
  .board { flex-direction: column; align-items: stretch; overflow: visible; scroll-snap-type: none; }
  .board-column { flex: none; }
}

/* --- NFC ---------------------------------------------------------------------- */
.nfc-empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  padding: var(--sp-5) 0 var(--sp-2); color: var(--label-secondary); font: var(--t-callout);
}
.nfc-empty svg { color: var(--sys-indigo); animation: nfc-wave 2.4s var(--ease-in-out) infinite; }
@keyframes nfc-wave { 0%, 100% { transform: scale(1); opacity: 0.7; } 50% { transform: scale(1.12); opacity: 1; } }
.row.is-pulsing .row__icon { animation: nfc-wave 1s infinite; }

.chips.chips--wrap { flex-wrap: wrap; overflow: visible; }
@media (max-width: 480px) {
  .format-chip { padding: var(--sp-2) 4px; }
  .format-chip__hint { font-size: 11px; }
}

/* --- Layout fixes ----------------------------------------------------------- */
.list-group--plain { margin-top: var(--sp-4); }
.list-group--plain:first-child { margin-top: 0; }
@media (min-width: 820px) { .navbar__back { display: none; } }
.sheet--tall { height: 92dvh; }
@media (min-width: 700px) { .sheet--tall { height: min(780px, 86dvh); } }
.dot { box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.22), 0 0 0 0.5px var(--separator); }
.title-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.title-actions .btn { gap: 5px; }

.locations-switch { display: flex; justify-content: center; margin: 0 0 var(--sp-4); }
.locations-switch .segmented { min-width: min(320px, 100%); }

/* --- Sheets: pull up to full screen (phones) ---------------------------------- */
@media (max-width: 699px) {
  .sheet { transition: transform var(--dur-slow) var(--ease-ios), height var(--dur-slow) var(--ease-ios), border-radius var(--dur-base); }
  .sheet.is-expanded { height: calc(100dvh - var(--safe-top) - 4px); max-height: none; }
  .sheet__grabber { padding: 6px 0; box-sizing: content-box; background-clip: content-box; cursor: grab; }
}
.field { cursor: default; }
.field__control input:not([type="color"]):not([type="checkbox"]) { min-width: 0; }

/* --- Wide layout: no double title, collapsible sidebar ----------------------- */
@media (min-width: 820px) {
  .navbar:not(.is-scrolled):not(.is-compact) .navbar__title { opacity: 0; transform: translateY(6px); }
  .shell { transition: grid-template-columns var(--dur-slow) var(--ease-ios); }
  .shell.is-sidebar-collapsed { grid-template-columns: var(--rail-w) 1fr; }
  .sidebar { transition: width var(--dur-slow) var(--ease-ios), padding var(--dur-slow) var(--ease-ios); overflow-x: hidden; }
  .shell.is-sidebar-collapsed .sidebar-resizer { display: none; }
  .title-actions.hide-mobile { display: flex; }
}
.title-actions.hide-mobile { display: none; }
@media (min-width: 820px) { .title-actions.hide-mobile { display: flex; } }

/* --- Sidebar: own collapse button, icon rail when collapsed -------------------- */
:root { --rail-w: 60px; }
.sidebar__name { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sidebar__toggle {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  margin-right: calc(var(--sp-2) * -1);
  border-radius: var(--r-sm);
  color: var(--label-secondary);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.sidebar__toggle svg { width: 20px; height: 20px; }
@media (hover: hover) { .sidebar__toggle:hover { background: var(--bg-hover); color: var(--label); } }

.shell.is-sidebar-collapsed .sidebar { width: var(--rail-w); padding-left: 8px; padding-right: 8px; }
.shell.is-sidebar-collapsed .sidebar__brand { flex-direction: column; padding-left: 0; padding-right: 0; gap: var(--sp-3); }
.shell.is-sidebar-collapsed .sidebar__toggle { margin: 0; order: -1; }
.shell.is-sidebar-collapsed .sidebar__name,
.shell.is-sidebar-collapsed .sidebar__item span,
.shell.is-sidebar-collapsed .live-indicator__text,
.shell.is-sidebar-collapsed .sidebar__footer > span:not(.live-indicator) { display: none; }
/* Section titles become a thin line between the groups */
.shell.is-sidebar-collapsed .sidebar__label { font-size: 0; padding: 0; height: 0.5px; margin: 0 8px var(--sp-2); background: var(--separator); }
.shell.is-sidebar-collapsed .sidebar__item { justify-content: center; padding: 9px 0; }
.shell.is-sidebar-collapsed .sidebar__item svg { width: 20px; height: 20px; }
.shell.is-sidebar-collapsed .sidebar__footer { justify-content: center; padding-left: 0; padding-right: 0; }
:root:has(.shell.is-sidebar-collapsed) .board-actionbar { left: calc(50% + var(--rail-w) / 2); }

.rail-tip {
  position: fixed;
  z-index: 130;
  transform: translate(-4px, -50%);
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--glass-bar-solid);
  -webkit-backdrop-filter: var(--glass-blur-strong);
  backdrop-filter: var(--glass-blur-strong);
  box-shadow: var(--shadow-md), 0 0 0 0.5px var(--separator);
  color: var(--label);
  font: var(--t-footnote);
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms var(--ease-out), transform 160ms var(--ease-out);
}
.rail-tip.is-visible { opacity: 1; transform: translate(0, -50%); }

/* Icons need a size of their own: with only max-width:100% Safari shrinks
   them to nothing inside auto-sized buttons (the navbar looked empty on iOS). */
.navbar__button svg { width: 22px; height: 22px; flex: none; }
.navbar__button span + svg, .navbar__button svg + span { flex: none; }
.navbar__back svg { width: 20px; height: 20px; }

/* --- Phones: buttons in the large-title row ----------------------------------- */
@media (max-width: 819px) {
  .navbar--overlay {
    position: sticky;
    top: 0;
    /* Sticky but taking no room: the page starts underneath the buttons. */
    margin-bottom: calc(-1 * (var(--nav-h) + var(--safe-top)));
    background: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    pointer-events: none;
  }
  .navbar--overlay .navbar__lead,
  .navbar--overlay .navbar__trail { pointer-events: auto; }
  .navbar--overlay.is-scrolled {
    background: var(--glass-bar);
    -webkit-backdrop-filter: var(--glass-blur-strong);
    backdrop-filter: var(--glass-blur-strong);
  }
  .navbar--overlay + .scroller { padding-top: var(--safe-top); }
  .navbar--overlay + .scroller .large-title { padding-top: 7px; }
  .navbar--overlay + .scroller .large-title h1 { padding-right: calc(var(--nav-trail-w, 0px) + 4px); }
}

/* No one-sided colour stripes on cards — the spool ring carries the colour. */
.spool-card::before,
.board-card::before { content: none; display: none; }

/* --- Title hand-over while scrolling ------------------------------------------ */
:root { --tp: 0; }
/* Title centred over the whole bar, not just the gap between the buttons:
   the side columns share the rest equally (each at least as wide as needed). */
.navbar__row { display: grid; grid-template-columns: minmax(max-content, 1fr) minmax(0, auto) minmax(max-content, 1fr); }
.navbar__trail { justify-content: flex-end; }
.navbar__title { text-align: center; }
.navbar:not(.is-compact) .navbar__title {
  opacity: var(--tp);
  transform: translateY(calc((1 - var(--tp)) * 10px));
  transition: none;
}
.large-title h1 {
  transform-origin: 0 100%;
  transform: scale(calc(1 - var(--tp) * 0.18));
  opacity: calc(1 - var(--tp) * 0.85);
  will-change: transform;
}
.large-title__sub { opacity: calc(1 - var(--tp)); }
@media (min-width: 820px) {
  .navbar:not(.is-scrolled):not(.is-compact) .navbar__title { opacity: var(--tp); transform: translateY(calc((1 - var(--tp)) * 10px)); }
}
@media (prefers-reduced-motion: reduce) {
  .large-title h1 { transform: none; }
}

/* ==========================================================================
   Motion — short, one-off, nothing endless (see ui/motion.js)
   ========================================================================== */

/* Items arrive one after another */
.stagger-in {
  animation: stagger-in 460ms var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 32ms);
}
@keyframes stagger-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

/* Spool rings fill up, meters grow, bars rise */
@property --pct {
  syntax: '<number>';
  inherits: true;
  initial-value: 0;
}
.view-enter .spool-visual:not(.spool-visual--multi) { animation: ring-fill 900ms var(--ease-out) both; animation-delay: 120ms; }
@keyframes ring-fill { from { --pct: 0; } }
.view-enter .spool-visual--multi { animation: ring-spin-in 800ms var(--ease-out) both; }
@keyframes ring-spin-in { from { transform: rotate(-120deg) scale(0.9); opacity: 0.4; } }

.view-enter .meter__fill { animation: meter-grow 900ms var(--ease-out) both; animation-delay: 180ms; }
@keyframes meter-grow { from { clip-path: inset(0 100% 0 0 round 99px); } to { clip-path: inset(0 0 0 0 round 99px); } }

.bars__bar { animation: bar-rise 700ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 35ms); transform-origin: 50% 100%; }
@keyframes bar-rise { from { transform: scaleY(0); opacity: 0.3; } }

.donut { animation: donut-in 900ms var(--ease-out) both; }
@keyframes donut-in { from { transform: rotate(-110deg) scale(0.86); opacity: 0; } }

/* Floating add button and empty states pop in */
.fab--enter { animation: fab-in 520ms var(--ease-out) both; animation-delay: 160ms; }
@keyframes fab-in { from { transform: scale(0.4) rotate(-90deg); opacity: 0; } }
.empty__icon { animation: empty-bob 900ms var(--ease-out) both; }
@keyframes empty-bob { 0% { transform: translateY(10px) scale(0.8); opacity: 0; } 60% { transform: translateY(-4px) scale(1.04); opacity: 1; } 100% { transform: none; } }

/* Changing section: tab icon and sidebar item give a small pop */
.tab.just-activated svg { animation: tab-pop 420ms var(--ease-out); }
@keyframes tab-pop { 0% { transform: scale(0.82); } 55% { transform: scale(1.14); } 100% { transform: none; } }
.sidebar__item.just-activated { animation: side-pop 380ms var(--ease-out); }
@keyframes side-pop { from { background: color-mix(in srgb, var(--accent) 40%, transparent); transform: scale(0.97); } }

/* A spool changed elsewhere (printer display, other device) */
.is-updated { animation: updated-glow 1600ms var(--ease-out); }
@keyframes updated-glow {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent), var(--shadow-sm); }
  25% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 28%, transparent), var(--shadow-md); }
  100% { box-shadow: 0 0 0 0 transparent, var(--shadow-sm); }
}

/* Toggles, chips, segmented controls respond to presses */
.chip, .segmented__item, .format-chip, .swatch, .color-cell { transition: transform 160ms var(--ease-ios), background var(--dur-fast) var(--ease-ios), box-shadow var(--dur-base); }
.chip:active, .format-chip:active, .swatch:active, .color-cell:active { transform: scale(0.93); }
.switch { transition: background var(--dur-base) var(--ease-ios); }
.btn { transition: transform 140ms var(--ease-ios), filter var(--dur-fast), background var(--dur-fast) var(--ease-ios); }
.btn:active { transform: scale(0.96); }
.action-tile { transition: transform 160ms var(--ease-ios), box-shadow var(--dur-base) var(--ease-ios), background var(--dur-fast); }
.action-tile:active { transform: scale(0.95); }
.search { transition: box-shadow var(--dur-base) var(--ease-ios), background var(--dur-base); }
.search:focus-within { box-shadow: 0 0 0 3px var(--accent-soft); }

/* Desktop with a mouse: hover feedback. Kept out of touch devices on purpose —
   on iOS hover effects can turn a tap into "hover first, click second". */
@media (hover: hover) and (pointer: fine) {
  button.row .row__chevron, a.row .row__chevron { transition: transform var(--dur-base) var(--ease-ios); }
  button.row:hover .row__chevron, a.row:hover .row__chevron { transform: translateX(3px); }
  .stat-tile, .action-tile, .board-card, .format-chip {
    transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out), background var(--dur-fast);
  }
  .stat-tile:hover, .action-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
  .board-card:hover { transform: translateY(-1px); }
  .sidebar__item svg { transition: transform var(--dur-base) var(--ease-out); }
  .sidebar__item:hover svg { transform: scale(1.12); }
  .sidebar__item { transition: background var(--dur-fast) var(--ease-ios); }
  .spool-card .spool-visual { transition: transform var(--dur-slow) var(--ease-out); }
  .spool-card:hover .spool-visual { transform: rotate(-12deg) scale(1.04); }
  .btn--filled:hover { box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 30%, transparent); }
  .navbar__button svg { transition: transform var(--dur-base) var(--ease-out); }
  .navbar__button:hover svg { transform: scale(1.1); }
  .legend__item { transition: transform var(--dur-fast); }
  .legend__item:hover { transform: translateX(2px); }
}

@media (prefers-reduced-motion: reduce) {
  .stagger-in, .view-enter .spool-visual, .view-enter .meter__fill, .bars__bar, .donut,
  .fab--enter, .empty__icon, .tab.just-activated svg, .sidebar__item.just-activated, .is-updated { animation: none !important; }
}

/* --- Touch: overlays and inputs ---------------------------------------------- */
.scrim { cursor: pointer; touch-action: none; }
.sheet__body, .actionsheet { overscroll-behavior: contain; }
/* iOS zooms into any input whose text is drawn smaller than 16px — and the
   layout stays zoomed afterwards. --input-font accounts for page zoom
   (ui/touch.js). */
@media (pointer: coarse) {
  input:not([type="color"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select,
  textarea { font-size: var(--input-font, 16px) !important; }
}

/* --- Desktop menus (instead of action sheets, like macOS pop-up menus) ------- */
.menu-scrim { position: fixed; inset: 0; z-index: 110; }
.menu {
  position: fixed;
  z-index: 111;
  min-width: 220px;
  max-width: 340px;
  padding: 5px;
  overflow-y: auto;
  border-radius: 12px;
  background: var(--glass-bar-solid);
  -webkit-backdrop-filter: var(--glass-blur-strong);
  backdrop-filter: var(--glass-blur-strong);
  box-shadow: var(--shadow-lg), 0 0 0 0.5px var(--separator);
  opacity: 0;
  transform: scale(0.94);
  transition: opacity 140ms var(--ease-out), transform 160ms var(--ease-out);
  outline: none;
}
.menu.is-open { opacity: 1; transform: none; }
.menu__title {
  padding: 6px 10px 6px;
  margin-bottom: 4px;
  border-bottom: 0.5px solid var(--separator);
  font: var(--t-caption);
  font-weight: 600;
  color: var(--label-secondary);
}
.menu__message { font-weight: 400; margin-top: 2px; }
.menu__item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 30px;
  padding: 4px 10px 4px 6px;
  border-radius: 7px;
  font: var(--t-subhead);
  color: var(--label);
  text-align: left;
  outline: none;
}
.menu__check { width: 16px; flex: none; display: grid; place-items: center; color: inherit; }
.menu__check svg { width: 14px; height: 14px; }
.menu__label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu__item:hover, .menu__item:focus-visible { background: var(--accent); color: #fff; }
.menu__item--destructive { color: var(--sys-red); }
.menu__item--destructive:hover, .menu__item--destructive:focus-visible { background: var(--sys-red); color: #fff; }
@media (prefers-reduced-motion: reduce) { .menu { transition: none; } }

/* --- Selects show that they open a list ----------------------------------------- */
.select { position: relative; display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; }
.field__control .select { justify-content: flex-end; flex: 1; }
.field--stack .select { width: 100%; }
.select select { cursor: pointer; }
.select svg { width: 14px; height: 14px; flex: none; color: var(--label-tertiary); pointer-events: none; }
.field:hover .select svg { color: var(--label-secondary); }

/* --- Collapsible sections (spool and filament pages) ----------------------------- */
.collapsible__head {
  width: 100%;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  color: var(--label);
  cursor: pointer;
  border-radius: var(--r-sm);
}
.collapsible__extra { font: var(--t-footnote); margin-left: auto; }
.collapsible__chevron { display: grid; place-items: center; width: 22px; height: 22px; color: var(--label-tertiary); transition: transform var(--dur-base) var(--ease-ios), color var(--dur-fast); }
.collapsible__extra + .collapsible__chevron { margin-left: 0; }
.collapsible__head > .section__title + .collapsible__chevron { margin-left: auto; }
.collapsible__chevron svg { width: 16px; height: 16px; }
@media (hover: hover) { .collapsible__head:hover .collapsible__chevron { color: var(--label-secondary); } }
.collapsible.is-collapsed .collapsible__chevron { transform: rotate(-90deg); }
/* Height animation without measuring: a grid row from 1fr to 0fr. */
.collapsible__body { display: grid; grid-template-rows: 1fr; transition: grid-template-rows var(--dur-slow) var(--ease-ios), opacity var(--dur-base); }
.collapsible.is-collapsed .collapsible__body { grid-template-rows: 0fr; opacity: 0; }
/* Room for the cards' shadows, which the clipping would cut off otherwise */
.collapsible__inner { min-height: 0; overflow: hidden; padding: 4px; margin: -4px; }
.collapsible.is-collapsed .collapsible__inner { visibility: hidden; transition: visibility 0s var(--dur-slow); }
@media (prefers-reduced-motion: reduce) { .collapsible__body, .collapsible__chevron { transition: none; } }
