/* Material 3 Expressive components. */

/* ---- State layer helper -------------------------------------------------------- */
.btn, .icon-btn, .fab, .chip, .btn-group-item, .nav-item, .tab, .pick-tile, .watch-player, .standing-row, .format-tile, .format-option, .menu button, .banner, .expander > summary {
  position: relative;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}
.btn::after, .icon-btn::after, .fab::after, .chip::after, .btn-group-item::after, .nav-indicator::after, .tab::after, .pick-tile::after, .watch-player::after, .standing-row::after, .format-tile::after, .format-option::after, .menu button::after, .banner::after, .expander > summary::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  border-radius: inherit; background: currentColor; opacity: 0;
  transition: opacity var(--dur-fast) var(--effect-fast);
  pointer-events: none;
}
@media (hover: hover) {
  .btn:hover:not(:disabled)::after, .icon-btn:hover:not(:disabled)::after, .fab:hover::after, .chip:hover::after, .btn-group-item:hover:not(:disabled)::after,
  .nav-item:hover .nav-indicator::after, .tab:hover::after, .pick-tile:hover::after, .watch-player:hover::after, .standing-row:hover::after,
  .format-tile:hover::after, .format-option:hover::after, .menu button:hover::after, .banner:hover::after, .expander > summary:hover::after { opacity: var(--state-hover); }
}
.btn:focus-visible::after, .icon-btn:focus-visible::after, .chip:focus-visible::after { opacity: var(--state-focus); }
.btn:active:not(:disabled)::after, .icon-btn:active:not(:disabled)::after, .fab:active::after, .chip:active::after, .btn-group-item:active::after,
.nav-item:active .nav-indicator::after, .tab:active::after, .pick-tile:active::after, .watch-player:active::after, .standing-row:active::after,
.format-tile:active::after, .format-option:active::after, .menu button:active::after { opacity: var(--state-press); }

/* ---- Buttons (shape morphs on press) --------------------------------------------- */
.btn {
  --h: 40px; --pad: 16px; --radius: var(--shape-full); --radius-pressed: var(--shape-s);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--h); padding: 0 var(--pad);
  border: 0; border-radius: var(--radius);
  font-size: 0.875rem; font-weight: 600; letter-spacing: 0.01em; line-height: 1.2;
  text-decoration: none; white-space: nowrap;
  transition: border-radius var(--dur) var(--spring-fast), background-color var(--dur-fast) var(--effect), color var(--dur-fast) var(--effect), box-shadow var(--dur-fast) var(--effect), transform var(--dur) var(--spring-fast);
}
.btn:active:not(:disabled) { border-radius: var(--radius-pressed); }
.btn .icon { width: 20px; height: 20px; }
.btn-xs { --h: 32px; --pad: 12px; font-size: 0.8125rem; gap: 4px; }
.btn-xs .icon { width: 18px; height: 18px; }
.btn-s { --h: 40px; --pad: 16px; }
.btn-m { --h: 56px; --pad: 24px; --radius-pressed: var(--shape-m); font-size: 1rem; }
.btn-m .icon { width: 24px; height: 24px; }
.btn-l { --h: 72px; --pad: 32px; --radius-pressed: var(--shape-l); font-size: 1.125rem; font-stretch: 108%; }
.btn-l .icon { width: 28px; height: 28px; }
.btn-xl { --h: 96px; --pad: 48px; --radius-pressed: var(--shape-xl); font-size: 1.5rem; }
.btn-full { width: 100%; }

.btn-filled { background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); }
.btn-filled:hover:not(:disabled) { box-shadow: var(--shadow-1); }
.btn-tonal { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.btn-outlined { background: transparent; color: var(--md-sys-color-on-surface-variant); box-shadow: inset 0 0 0 1px var(--md-sys-color-outline-variant); }
.btn-text { background: transparent; color: var(--md-sys-color-primary); --pad: 12px; }
.btn-elevated { background: var(--md-sys-color-surface-container-low); color: var(--md-sys-color-primary); box-shadow: var(--shadow-1); }
.btn-danger { background: var(--md-sys-color-error); color: var(--md-sys-color-on-error); }
.btn.is-danger { color: var(--md-sys-color-error); }
.btn:disabled, .icon-btn:disabled, .btn-group-item:disabled {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 10%, transparent);
  color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent);
  box-shadow: none;
}
.btn-text:disabled, .btn-outlined:disabled { background: transparent; }
.btn-outlined:disabled { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.btn-grid .btn { width: 100%; }

/* ---- Icon buttons ------------------------------------------------------------------- */
.icon-btn {
  --size: 40px;
  display: inline-grid; place-items: center; flex: none;
  width: var(--size); height: var(--size); padding: 0;
  border: 0; border-radius: var(--shape-full);
  background: transparent; color: var(--md-sys-color-on-surface-variant);
  transition: border-radius var(--dur) var(--spring-fast), background-color var(--dur-fast) var(--effect), color var(--dur-fast) var(--effect);
}
.icon-btn:active:not(:disabled), .icon-btn.is-selected { border-radius: var(--shape-m); }
.icon-btn-xs { --size: 32px; }
.icon-btn-xs .icon { width: 20px; height: 20px; }
.icon-btn-m { --size: 56px; }
.icon-btn-l { --size: 96px; }
.icon-btn-l .icon { width: 32px; height: 32px; }
.icon-btn-filled { background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); }
.icon-btn-tonal { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.icon-btn-outlined { box-shadow: inset 0 0 0 1px var(--md-sys-color-outline-variant); }
.icon-btn.is-danger { color: var(--md-sys-color-error); }
.icon-btn.is-selected { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }

/* ---- FAB ------------------------------------------------------------------------------ */
.fab {
  --size: 56px;
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  min-width: var(--size); height: var(--size); padding: 0;
  border: 0; border-radius: var(--shape-l);
  box-shadow: var(--shadow-3);
  font-size: 1rem; font-weight: 650;
  transition: border-radius var(--dur) var(--spring-fast), transform var(--dur) var(--spring-fast), box-shadow var(--dur-fast) var(--effect);
}
.fab:active { border-radius: var(--shape-m); transform: scale(0.97); }
.fab-extended { padding: 0 20px 0 16px; }
.fab-l { --size: 96px; border-radius: var(--shape-xl); }
.fab-l .icon { width: 36px; height: 36px; }
.fab-primary { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-primary); }
.fab-secondary { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.fab-tertiary { background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); }

/* ---- Connected button group -------------------------------------------------------------- */
.btn-group { display: inline-flex; gap: 2px; flex-wrap: nowrap; max-width: 100%; }
.btn-group-item {
  --h: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--h); min-width: 48px; padding: 0 14px;
  border: 0; border-radius: var(--shape-s);
  background: var(--md-sys-color-surface-container-highest); color: var(--md-sys-color-on-surface-variant);
  font-size: 0.875rem; font-weight: 600;
  transition: border-radius var(--dur) var(--spring-fast), background-color var(--dur-fast) var(--effect), color var(--dur-fast) var(--effect);
}
.btn-group-item .icon { width: 18px; height: 18px; }
.btn-group-item:first-child { border-radius: var(--shape-full) var(--shape-s) var(--shape-s) var(--shape-full); }
.btn-group-item:last-child { border-radius: var(--shape-s) var(--shape-full) var(--shape-full) var(--shape-s); }
.btn-group-item:only-child { border-radius: var(--shape-full); }
.btn-group-item.is-selected { background: var(--md-sys-color-secondary); color: var(--md-sys-color-on-secondary); border-radius: var(--shape-full); }
.btn-group-item:active:not(:disabled) { border-radius: var(--shape-xs); }
.btn-group-m .btn-group-item { --h: 56px; padding: 0 20px; font-size: 1rem; }

/* ---- Chips, badges, indicators ------------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 16px;
  border: 0; border-radius: var(--shape-s);
  background: transparent; color: var(--md-sys-color-on-surface-variant);
  box-shadow: inset 0 0 0 1px var(--md-sys-color-outline-variant);
  font-size: 0.875rem; font-weight: 600; white-space: nowrap;
  transition: background-color var(--dur-fast) var(--effect), border-radius var(--dur) var(--spring-fast);
}
.chip .icon { width: 18px; height: 18px; margin-left: -4px; }
.chip.is-selected { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); box-shadow: none; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:focus-visible) { outline: 3px solid var(--md-sys-color-secondary); outline-offset: 2px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 24px; padding: 0 10px;
  border-radius: var(--shape-full);
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap;
  background: var(--md-sys-color-surface-container-highest); color: var(--md-sys-color-on-surface-variant);
}
.badge .icon { width: 16px; height: 16px; margin-left: -2px; }
.badge-primary { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-primary); }
.badge-secondary { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.badge-tertiary { background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); }
.badge-error { background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); }
.badge-success { background: var(--success-container); color: var(--on-success-container); }
.count-badge {
  display: inline-grid; place-items: center;
  min-width: 24px; height: 24px; padding: 0 8px;
  border-radius: var(--shape-full);
  background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container);
  font-size: 0.75rem; font-weight: 700; font-variant-numeric: tabular-nums;
}

.live-indicator { display: inline-flex; align-items: center; gap: 8px; font-size: 0.8125rem; font-weight: 700; white-space: nowrap; color: var(--md-sys-color-on-surface-variant); }
.live-indicator i { width: 10px; height: 10px; border-radius: 50%; background: var(--md-sys-color-outline); }
.live-indicator.is-live i { background: var(--md-sys-color-primary); color: var(--md-sys-color-primary); animation: pulse 1.8s var(--effect) infinite; }
.live-indicator.is-reconnecting i, .live-indicator.is-connecting i { background: var(--md-sys-color-tertiary); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

/* ---- Cards ------------------------------------------------------------------------------------- */
.card { border-radius: var(--shape-xl); padding: 20px; display: grid; gap: 16px; align-content: start; min-width: 0; }
.card-elevated { background: var(--md-sys-color-surface-container-low); box-shadow: var(--shadow-1); }
.card-filled { background: var(--md-sys-color-surface-container-highest); }
.card-outlined { background: var(--md-sys-color-surface); box-shadow: inset 0 0 0 1px var(--md-sys-color-outline-variant); }
.card-primary { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.card-primary .eyebrow { color: inherit; opacity: 0.85; }
@media (min-width: 840px) { .card { padding: 24px; } }

.section-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; }
.section-header > div:first-child { display: grid; gap: 2px; min-width: 0; }
.section-title { font-size: 1.5rem; line-height: 1.3; font-weight: 700; font-stretch: 106%; }
h3.section-title { font-size: 1.25rem; }
.section-supporting { font-size: 0.875rem; color: var(--md-sys-color-on-surface-variant); }
.section-trailing { display: flex; align-items: center; gap: 8px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat {
  display: flex; gap: 12px; align-items: center;
  padding: 16px; border-radius: var(--shape-l);
  background: var(--md-sys-color-surface-container);
  min-width: 0;
}
.stat > div { display: grid; min-width: 0; }
.stat-icon { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: var(--shape-m); background: var(--md-sys-color-surface-container-highest); color: var(--md-sys-color-primary); }
.stat-label { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; color: var(--md-sys-color-on-surface-variant); }
.stat-value { font-size: 1.75rem; line-height: 1.1; font-weight: 800; font-stretch: 112%; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-detail { font-size: 0.75rem; color: var(--md-sys-color-on-surface-variant); }
.stat-primary { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.stat-primary .stat-icon { background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); }
.stat-primary .stat-label, .stat-primary .stat-detail { color: inherit; opacity: 0.85; }

.empty-state { display: grid; justify-items: center; gap: 6px; padding: 28px 16px; text-align: center; color: var(--md-sys-color-on-surface-variant); }
.empty-state .icon { width: 36px; height: 36px; color: var(--md-sys-color-outline); }
.empty-state strong { color: var(--md-sys-color-on-surface); font-size: 1rem; }
.empty-state p { font-size: 0.875rem; max-width: 36ch; }

/* ---- Progress ----------------------------------------------------------------------------------- */
.progress { position: relative; height: 12px; display: flex; align-items: center; gap: 4px; }
.progress-active {
  height: 4px; width: var(--value); flex: none;
  border-radius: var(--shape-full);
  background: var(--md-sys-color-primary);
  transition: width var(--dur-slow) var(--spring);
}
.progress-wavy .progress-active {
  height: 12px;
  background: none;
  -webkit-mask: none;
}
.progress-wavy .progress-active::before {
  content: ""; display: block; height: 100%;
  background: var(--md-sys-color-primary);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='12'%3E%3Cpath d='M0 6 Q10 0 20 6 T40 6' fill='none' stroke='black' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E") repeat-x left center / 40px 12px;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='12'%3E%3Cpath d='M0 6 Q10 0 20 6 T40 6' fill='none' stroke='black' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E") repeat-x left center / 40px 12px;
  animation: wave 1.6s linear infinite;
}
@keyframes wave { to { -webkit-mask-position: 40px center; mask-position: 40px center; } }
.progress-track { height: 4px; flex: 1; border-radius: var(--shape-full); background: var(--md-sys-color-secondary-container); }
.progress-stop { position: absolute; right: 0; width: 4px; height: 4px; border-radius: 50%; background: var(--md-sys-color-primary); }
.progress[aria-valuenow="0"] .progress-active { display: none; }
.progress[aria-valuenow="100"] .progress-track, .progress[aria-valuenow="100"] .progress-stop { display: none; }
.progress[aria-valuenow="100"] .progress-active { flex: 1; }

.ring { position: relative; width: 132px; aspect-ratio: 1; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring circle { fill: none; stroke-width: 9; stroke-linecap: round; transition: stroke-dasharray var(--dur-slow) var(--spring), stroke-dashoffset var(--dur-slow) var(--spring); }
.ring-track { stroke: var(--md-sys-color-secondary-container); }
.ring-active { stroke: var(--md-sys-color-primary); }
.ring-content { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.1; }
.ring-number { font-size: 2.25rem; font-weight: 850; font-stretch: 120%; font-variant-numeric: tabular-nums; }

/* ---- Text fields ------------------------------------------------------------------------------------ */
.text-field { position: relative; display: grid; min-width: 0; }
.text-field input, .text-field textarea {
  width: 100%; min-height: 56px;
  padding: 16px 16px 14px;
  border: 0; border-radius: var(--shape-xs);
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--md-sys-color-outline);
  color: var(--md-sys-color-on-surface);
  font-size: 1rem;
  transition: box-shadow var(--dur-fast) var(--effect);
  outline: none;
}
.text-field textarea { resize: vertical; padding-top: 18px; line-height: 1.5; }
.text-field input:hover, .text-field textarea:hover { box-shadow: inset 0 0 0 1px var(--md-sys-color-on-surface); }
.text-field input:focus, .text-field textarea:focus { box-shadow: inset 0 0 0 2px var(--md-sys-color-primary); }
.text-field-label {
  position: absolute; left: 12px; top: 16px;
  padding: 0 4px;
  background: var(--field-bg, var(--md-sys-color-surface));
  color: var(--md-sys-color-on-surface-variant);
  font-size: 1rem; line-height: 24px;
  pointer-events: none;
  transform-origin: left top;
  transition: transform var(--dur-fast) var(--effect), color var(--dur-fast) var(--effect);
}
.text-field input:focus ~ .text-field-label, .text-field textarea:focus ~ .text-field-label { color: var(--md-sys-color-primary); }
.text-field input:not(:placeholder-shown) ~ .text-field-label,
.text-field input:focus ~ .text-field-label,
.text-field input[type="date"] ~ .text-field-label,
.text-field textarea:not(:placeholder-shown) ~ .text-field-label,
.text-field textarea:focus ~ .text-field-label { transform: translateY(-27px) scale(0.75); }
.text-field-supporting { padding: 4px 16px 0; font-size: 0.75rem; color: var(--md-sys-color-on-surface-variant); }
.text-field.has-leading input { padding-left: 48px; }
.text-field.has-leading .text-field-label { left: 44px; }
.text-field.has-leading input:not(:placeholder-shown) ~ .text-field-label, .text-field.has-leading input:focus ~ .text-field-label { transform: translate(-32px, -27px) scale(0.75); }
.text-field-leading { position: absolute; left: 12px; top: 16px; color: var(--md-sys-color-on-surface-variant); }
.pin-field input { font-size: 1.75rem; font-weight: 800; font-stretch: 118%; letter-spacing: 0.3em; text-transform: uppercase; text-align: center; min-height: 64px; padding-top: 18px; }
.pin-field .text-field-label { top: 20px; }
.card-filled, .dialog, .expander-body { --field-bg: var(--md-sys-color-surface-container-highest); }
.card-elevated { --field-bg: var(--md-sys-color-surface-container-low); }
.dialog { --field-bg: var(--md-sys-color-surface-container-high); }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 12px; padding-top: 6px; }
.field-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 479px) { .field-grid { grid-template-columns: 1fr; } }

.search-field {
  display: flex; align-items: center; gap: 8px;
  height: 48px; padding: 0 16px;
  border-radius: var(--shape-full);
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
  min-width: 0;
}
.search-field input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; color: var(--md-sys-color-on-surface); font-size: 1rem; }
.search-field:focus-within { outline: 2px solid var(--md-sys-color-primary); }

.select-field { display: grid; gap: 2px; min-width: 0; }
.select-field span { font-size: 0.75rem; font-weight: 600; color: var(--md-sys-color-on-surface-variant); }
.select-field select, .select-field input {
  width: 100%; height: 44px; padding: 0 12px;
  border: 0; border-radius: var(--shape-s);
  background: var(--md-sys-color-surface-container-highest);
  box-shadow: inset 0 -1px 0 var(--md-sys-color-on-surface-variant);
  color: var(--md-sys-color-on-surface);
}
.select-field select:focus, .select-field input:focus { outline: none; box-shadow: inset 0 -2px 0 var(--md-sys-color-primary); }

/* ---- Switch ------------------------------------------------------------------------------------------ */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; }
.switch-copy { display: grid; min-width: 0; }
.switch-copy strong { font-size: 1rem; font-weight: 600; }
.switch-copy small { font-size: 0.8125rem; color: var(--md-sys-color-on-surface-variant); }
.switch-inline { gap: 10px; }
.switch-inline .switch-copy strong { font-size: 0.875rem; }
.switch {
  appearance: none; flex: none; margin: 0;
  position: relative; width: 52px; height: 32px;
  border-radius: var(--shape-full);
  background: var(--md-sys-color-surface-container-highest);
  box-shadow: inset 0 0 0 2px var(--md-sys-color-outline);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--effect), box-shadow var(--dur-fast) var(--effect);
}
.switch::before {
  content: ""; position: absolute; top: 8px; left: 8px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--md-sys-color-outline);
  transition: transform var(--dur) var(--spring-fast), width var(--dur) var(--spring-fast), height var(--dur) var(--spring-fast), top var(--dur) var(--spring-fast), left var(--dur) var(--spring-fast), background-color var(--dur-fast) var(--effect);
}
.switch:checked { background: var(--md-sys-color-primary); box-shadow: none; }
.switch:checked::before { top: 4px; left: 4px; width: 24px; height: 24px; transform: translateX(20px); background: var(--md-sys-color-on-primary); }
.switch:active::before { width: 28px; height: 28px; top: 2px; left: 2px; }
.switch:checked:active::before { transform: translateX(18px); }

/* ---- Radio list (dialogs) ------------------------------------------------------------------------------ */
.radio-list { display: grid; gap: 8px; }
.radio-list.is-inline { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.radio-list legend { margin-bottom: 8px; }
.radio-list label {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--shape-l);
  background: var(--md-sys-color-surface-container-highest);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--effect), border-radius var(--dur) var(--spring-fast);
}
.radio-list label span { display: grid; }
.radio-list label small { color: var(--md-sys-color-on-surface-variant); font-size: 0.8125rem; }
.radio-list input { accent-color: var(--md-sys-color-primary); width: 20px; height: 20px; margin: 0; flex: none; }
.radio-list label:has(input:checked) { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); border-radius: var(--shape-xl); }

/* ---- Stepper ---------------------------------------------------------------------------------------- */
.stepper-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.stepper-row > div:first-child { display: grid; }
.stepper-row small { font-size: 0.8125rem; color: var(--md-sys-color-on-surface-variant); }
.stepper { display: inline-flex; align-items: center; gap: 8px; }
.stepper output { min-width: 2.5ch; text-align: center; font-size: 1.75rem; font-weight: 800; font-stretch: 115%; font-variant-numeric: tabular-nums; }

/* ---- Avatar & pips -------------------------------------------------------------------------------------- */
.avatar {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container);
  font-weight: 800; font-size: 1rem;
}
.pips { display: inline-flex; gap: 3px; flex-wrap: wrap; }
.pips i { width: 10px; height: 10px; border-radius: 3px; background: var(--md-sys-color-surface-container-highest); box-shadow: inset 0 0 0 1px var(--md-sys-color-outline-variant); }
.pips i.is-hit { background: var(--md-sys-color-primary); box-shadow: none; }
.pips i.is-out { border-radius: 50%; }
.pips i.is-out.is-hit { background: var(--md-sys-color-error); }

/* ---- Expressive shapes -------------------------------------------------------------------------------------- */
.shape { --size: 48px; position: relative; display: inline-grid; place-items: center; width: var(--size); height: var(--size); flex: none; color: var(--on, var(--md-sys-color-on-secondary-container)); }
.shape > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.shape > svg path { fill: var(--fill, var(--md-sys-color-secondary-container)); transition: fill var(--dur) var(--effect); }
.shape-content { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 850; font-stretch: 118%; font-variant-numeric: tabular-nums; line-height: 1; }
.shape-xs { --size: 32px; font-size: 0.875rem; }
.shape-xs .icon { width: 18px; height: 18px; }
.shape-sm { --size: 48px; font-size: 1.05rem; }
.shape-md { --size: 64px; font-size: 1.4rem; }
.shape-md .icon { width: 30px; height: 30px; }
.shape-lg { --size: 96px; font-size: 2rem; }
.shape-lg .icon { width: 44px; height: 44px; }
.shape-primary { --fill: var(--md-sys-color-primary); --on: var(--md-sys-color-on-primary); }
.shape-secondary { --fill: var(--md-sys-color-secondary-container); --on: var(--md-sys-color-on-secondary-container); }
.shape-tertiary { --fill: var(--md-sys-color-tertiary-container); --on: var(--md-sys-color-on-tertiary-container); }
.shape-neutral { --fill: var(--md-sys-color-surface-container-highest); --on: var(--md-sys-color-on-surface-variant); }
.shape-error { --fill: var(--md-sys-color-error); --on: var(--md-sys-color-on-error); }

.loading-indicator { display: inline-grid; width: 64px; height: 64px; animation: spin 4.8s linear infinite; }
.loading-indicator svg { width: 100%; height: 100%; overflow: visible; }
.loading-indicator path, .morphing { fill: var(--md-sys-color-primary); animation: shape-morph 4.8s var(--spring) infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Expander (details) ---------------------------------------------------------------------------------------- */
.expander { border-radius: var(--shape-l); background: var(--md-sys-color-surface-container); overflow: hidden; }
.expander > summary {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 0 16px;
  list-style: none; cursor: pointer; font-weight: 600;
  border-radius: inherit;
}
.expander > summary::-webkit-details-marker { display: none; }
.expander > summary > span { flex: 1; min-width: 0; }
.expander-chevron { transition: transform var(--dur) var(--spring); }
.expander[open] > summary .expander-chevron { transform: rotate(180deg); }
.expander-body { display: grid; gap: 16px; padding: 4px 16px 16px; }
.expander-compact > summary { min-height: 48px; font-size: 0.9375rem; }
.expander.has-entries > summary { color: var(--md-sys-color-primary); }

/* ---- Banner (announcement) ---------------------------------------------------------------------------------------- */
.banner {
  display: flex; align-items: center; gap: 16px;
  width: 100%; padding: 16px 20px;
  border: 0; border-radius: var(--shape-xl);
  text-align: left;
  background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container);
}
.banner > span { display: grid; flex: 1; min-width: 0; }
.banner small { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; opacity: 0.85; }
.banner strong { font-size: 1.125rem; font-weight: 700; overflow-wrap: anywhere; }
.banner > .icon:first-child { width: 28px; height: 28px; }
.banner-pause { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.banner-important { background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); }
.banner.is-live-note { animation: pop-in var(--dur-slow) var(--spring) both; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-8px) scale(0.97); } }

/* ---- Menu --------------------------------------------------------------------------------------------------- */
.menu {
  position: absolute; right: var(--gutter); top: calc(100% - 4px); z-index: 60;
  display: grid; min-width: 260px; padding: 8px 0;
  border-radius: var(--shape-l);
  background: var(--md-sys-color-surface-container);
  box-shadow: var(--shadow-2);
  transform-origin: top right;
  animation: menu-in var(--dur) var(--spring) both;
}
@keyframes menu-in { from { opacity: 0; transform: scale(0.9) translateY(-6px); } }
.menu button {
  display: flex; align-items: center; gap: 12px;
  height: 48px; padding: 0 16px;
  border: 0; background: transparent; text-align: left;
  font-size: 0.9375rem;
}
.menu button .icon { color: var(--md-sys-color-on-surface-variant); }
.menu button.is-danger, .menu button.is-danger .icon { color: var(--md-sys-color-error); }
.menu hr { border: 0; border-top: 1px solid var(--md-sys-color-outline-variant); margin: 8px 0; }

/* ---- Snackbar ------------------------------------------------------------------------------------------------- */
.snackbar {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 90;
  width: max-content; max-width: min(560px, calc(100vw - 32px));
  padding: 14px 20px;
  border-radius: var(--shape-s);
  background: var(--md-sys-color-inverse-surface); color: var(--md-sys-color-inverse-on-surface);
  box-shadow: var(--shadow-3);
  font-size: 0.9375rem;
  transform: translateX(-50%);
  animation: snackbar-in var(--dur) var(--spring) both;
}
.snackbar[data-tone="error"] { background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); }
.snackbar.is-leaving { animation: snackbar-out var(--dur-fast) var(--effect) both; }
@keyframes snackbar-in { from { opacity: 0; transform: translate(-50%, 16px) scale(0.96); } }
@keyframes snackbar-out { to { opacity: 0; transform: translate(-50%, 8px); } }
body[data-view="running"] .snackbar { bottom: calc(96px + env(safe-area-inset-bottom)); }
@media (min-width: 840px) { body[data-view="running"] .snackbar { bottom: 24px; } }

/* ---- Connectivity banner ------------------------------------------------------------------------------------- */
.connectivity-banner {
  position: sticky; top: var(--app-bar-height); z-index: 35;
  display: flex; align-items: center; gap: 16px;
  margin: 8px var(--gutter) 0; padding: 12px 16px;
  border-radius: var(--shape-l);
  background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container);
  animation: pop-in var(--dur) var(--spring) both;
}
.connectivity-banner > div { flex: 1; display: grid; }
.connectivity-banner p { font-size: 0.875rem; }
.connectivity-banner b { font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase; }
.connectivity-banner.is-restored { background: var(--success-container); color: var(--on-success-container); }
body[data-view="watch"] .connectivity-banner, body[data-view="tv"] .connectivity-banner { top: 8px; }

/* ---- Dialogs (bottom sheet on phones) ---------------------------------------------------------------------------- */
.dialog {
  width: min(560px, calc(100vw - 32px)); max-height: min(88dvh, 900px);
  padding: 0; border: 0;
  border-radius: var(--shape-xl);
  background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface);
  box-shadow: var(--shadow-3);
  overflow: auto;
}
.dialog-wide { width: min(760px, calc(100vw - 32px)); }
.dialog::backdrop { background: color-mix(in srgb, var(--md-sys-color-scrim) 42%, transparent); }
.dialog[open] { animation: dialog-in var(--dur-slow) var(--spring) both; }
.dialog[open]::backdrop { animation: fade-in var(--dur) var(--effect) both; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(24px) scale(0.94); } }
@keyframes fade-in { from { opacity: 0; } }
.dialog > form { display: grid; gap: 16px; padding: 24px; }
.dialog-icon { display: grid; justify-self: center; color: var(--md-sys-color-secondary); }
.dialog-icon .icon { width: 28px; height: 28px; }
.dialog-headline { font-size: 1.5rem; line-height: 1.33; font-weight: 700; font-stretch: 106%; text-align: center; }
.dialog-supporting { font-size: 0.875rem; color: var(--md-sys-color-on-surface-variant); }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; padding-top: 8px; }
.dialog-actions-spacer { flex: 1; }
.dialog-scroll .bulk-list { max-height: 56dvh; overflow: auto; padding: 2px; }
.kv-list { display: grid; gap: 8px; }
.kv-list div { display: grid; padding: 12px 16px; border-radius: var(--shape-l); background: var(--md-sys-color-surface-container-highest); }
.kv-list dt { font-size: 0.75rem; font-weight: 700; color: var(--md-sys-color-on-surface-variant); }
.help-steps { display: grid; gap: 10px; counter-reset: step; }
.help-steps li { position: relative; padding-left: 44px; font-size: 0.9375rem; counter-increment: step; }
.help-steps li::before {
  content: counter(step); position: absolute; left: 0; top: -2px;
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: var(--shape-m);
  background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container);
  font-weight: 800; font-size: 0.875rem;
}
@media (max-width: 599px) {
  .dialog, .dialog-wide {
    width: 100vw; max-width: 100vw; max-height: 92dvh;
    margin: auto 0 0; border-radius: var(--shape-xl) var(--shape-xl) 0 0;
  }
  .dialog > form { padding: 12px 20px calc(20px + env(safe-area-inset-bottom)); }
  .dialog > form::before { content: ""; justify-self: center; width: 32px; height: 4px; border-radius: 2px; background: var(--md-sys-color-on-surface-variant); opacity: 0.4; margin-bottom: 4px; }
  .dialog[open] { animation: sheet-in var(--dur-slow) var(--spring) both; }
  .dialog-actions { justify-content: stretch; }
  .dialog-actions > .btn { flex: 1; }
  .dialog-actions-spacer { display: none; }
  .radio-list.is-inline { grid-template-columns: 1fr; }
}
@keyframes sheet-in { from { transform: translateY(100%); } }

/* ---- Tabs ------------------------------------------------------------------------------------------------------ */
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--md-sys-color-outline-variant); }
.tab {
  flex: 1; min-width: max-content;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 56px; padding: 0 16px;
  border: 0; background: transparent;
  color: var(--md-sys-color-on-surface-variant); font-weight: 600; font-size: 0.9375rem;
  border-radius: var(--shape-m) var(--shape-m) 0 0;
}
.tab::before { content: ""; position: absolute; left: 16px; right: 16px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--md-sys-color-primary); transform: scaleX(0); transition: transform var(--dur) var(--spring); }
.tab.is-active { color: var(--md-sys-color-primary); }
.tab.is-active::before { transform: scaleX(1); }
.tab .count-badge { background: var(--md-sys-color-surface-container-highest); color: var(--md-sys-color-on-surface-variant); }
.tab.is-active .count-badge { background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); }

/* ---- Navigation rail / bar ------------------------------------------------------------------------------------- */
.nav-rail, .nav-bar { display: none; }
.nav-item {
  display: grid; justify-items: center; gap: 4px;
  border: 0; background: transparent; padding: 0;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.75rem; font-weight: 600;
}
.nav-indicator {
  position: relative; isolation: isolate;
  display: grid; place-items: center;
  width: 56px; height: 32px; border-radius: var(--shape-full);
  transition: background-color var(--dur) var(--effect), width var(--dur) var(--spring);
}
.nav-item.is-active { color: var(--md-sys-color-on-surface); }
.nav-item.is-active .nav-indicator { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.nav-badge {
  position: absolute; top: -4px; right: 6px;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: grid; place-items: center;
  border-radius: var(--shape-full);
  background: var(--md-sys-color-error); color: var(--md-sys-color-on-error);
  font-size: 0.6875rem; font-weight: 700;
}
@media (min-width: 840px) {
  .nav-rail {
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    position: sticky; top: calc(var(--app-bar-height) + 8px); align-self: start;
    width: 96px; padding: 8px 0 24px;
  }
  .nav-rail-fab { margin-bottom: 28px; }
  .nav-rail .nav-item { width: 80px; padding: 4px 0; }
}
@media (max-width: 839px) {
  .nav-bar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    height: calc(80px + env(safe-area-inset-bottom)); padding: 12px 8px env(safe-area-inset-bottom);
    background: var(--md-sys-color-surface-container);
  }
  .nav-bar-fab {
    position: fixed; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 46;
    animation: pop-in var(--dur-slow) var(--spring) both;
  }
}
@media (min-width: 840px) { .nav-bar-fab { display: none; } }

/* ---- Share dialog ------------------------------------------------------------------------------------------ */
.share-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.share-code { display: grid; justify-items: start; gap: 6px; padding: 16px; border-radius: var(--shape-xl); background: var(--md-sys-color-surface-container-highest); }
.share-code small { font-size: 0.75rem; font-weight: 700; color: var(--md-sys-color-on-surface-variant); }
.share-code strong { font-size: 2rem; line-height: 1.1; font-weight: 850; font-stretch: 118%; letter-spacing: 0.14em; font-variant-numeric: tabular-nums; }
.share-code.is-public { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.share-code.is-public small { color: inherit; opacity: 0.85; }
.share-code.is-private strong { font-size: 1.25rem; letter-spacing: 0.08em; }
.is-concealed { filter: blur(7px); transition: filter var(--dur) var(--effect); cursor: pointer; border-radius: var(--shape-xs); }
.is-concealed:hover, .is-concealed:focus { filter: none; }
.share-targets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.share-target { display: grid; align-content: start; gap: 10px; padding: 16px; border-radius: var(--shape-xl); background: var(--md-sys-color-surface-container); min-width: 0; }
.share-target > div:not(.btn-row) { display: grid; gap: 4px; min-width: 0; }
.share-target code { font-size: 0.75rem; color: var(--md-sys-color-on-surface-variant); }
.qr-frame { position: relative; justify-self: center; width: min(200px, 100%); aspect-ratio: 1; padding: 10px; border-radius: var(--shape-l); background: #fff; }
.qr-frame img { width: 100%; height: 100%; image-rendering: pixelated; }
.qr-frame[data-qr-state="loading"] img, .qr-frame[data-qr-state="error"] img { visibility: hidden; }
.qr-frame[data-qr-state="error"]::after { content: "QR nicht verfügbar"; position: absolute; inset: 0; display: grid; place-items: center; color: #444; font-size: 0.8125rem; }
.share-tv-icon { display: grid; place-items: center; justify-self: center; width: min(200px, 100%); aspect-ratio: 1; border-radius: var(--shape-xxl); background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); }
.share-tv-icon .icon { width: 72px; height: 72px; }
@media (max-width: 599px) { .share-codes, .share-targets { grid-template-columns: 1fr; } .share-tv-icon { display: none; } }
@media (max-width: 599px) {
  .tabs { gap: 0; }
  .tab { min-width: 0; flex-direction: column; gap: 2px; height: 64px; padding: 6px 4px; font-size: 0.8125rem; }
  .tab .count-badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; font-size: 0.6875rem; }
  .tab::before { left: 20%; right: 20%; }
}

/* ---- Segmented toggle with sliding indicator ------------------------------------------------------ */
.segmented {
  position: relative; isolation: isolate;
  display: grid; grid-template-columns: repeat(var(--count), minmax(0, 1fr));
  padding: 4px; border-radius: var(--shape-full);
  background: var(--md-sys-color-surface-container-highest);
}
.segmented::before {
  content: ""; position: absolute; z-index: -1; top: 4px; bottom: 4px; left: 4px;
  width: calc((100% - 8px) / var(--count));
  border-radius: var(--shape-full);
  background: var(--md-sys-color-secondary);
  transform: translateX(calc(var(--index) * 100%));
  transition: transform var(--dur-slow) var(--spring);
}
.segmented-item {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px;
  border: 0; border-radius: var(--shape-full); background: transparent;
  color: var(--md-sys-color-on-surface-variant); font-size: 0.9375rem; font-weight: 650; white-space: nowrap;
  transition: color var(--dur) var(--effect);
}
.segmented-item .icon { width: 20px; height: 20px; }
.segmented-item.is-selected { color: var(--md-sys-color-on-secondary); }
.segmented-item:focus-visible { outline: 3px solid var(--md-sys-color-secondary); outline-offset: 2px; }
