/* RetroTracker — restrained CRT-inspired inventory UI (light + dark) */

:root {
  /* Shared structural tokens */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  --font-sans: "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --text-xs: 0.8125rem;
  --text-sm: 0.9375rem;
  --text-base: 1.0625rem;
  --text-lg: 1.25rem;
  --text-xl: clamp(1.5rem, 1.2rem + 1vw, 2rem);
  --text-2xl: clamp(1.85rem, 1.4rem + 1.5vw, 2.5rem);

  --motion-quick: 150ms;
  --motion-fast: 250ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Default = dark (CRT phosphor look) until theme.js resolves preference */
  --bg: #0a0b0c;
  --bg-elevated: #16191c;
  --bg-subtle: #1a1d20;
  --fg: #e8eaed;
  --fg-muted: #9aa0a6;
  --fg-subtle: #6b7280;
  --border: rgba(232, 234, 237, 0.1);
  --border-strong: rgba(232, 234, 237, 0.18);
  --accent: #8fd6a8;
  --accent-dim: rgba(143, 214, 168, 0.14);
  --accent-fg: #0a0b0c;
  --danger: #e8a0a0;
  --danger-bg: rgba(232, 160, 160, 0.12);
  --warn: #d4c48a;
  --ok: #8fd6a8;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 12px 40px rgba(0, 0, 0, 0.35);
  --glow-a: rgba(143, 214, 168, 0.06);
  --glow-b: rgba(140, 160, 180, 0.05);
  --map-surface: #101214;
  --map-panel: #16191c;
  --map-panel-deep: #0c0e10;
  --map-ink: #f2f4f3;
  --map-gutter: #0b0d0f;
  --map-grid: rgba(255, 255, 255, 0.09);
  --map-grid-fine: rgba(255, 255, 255, 0.04);
  --map-chrome: #121416;
  --map-chrome-border: rgba(255, 255, 255, 0.12);
  --map-overlay: rgba(12, 14, 16, 0.72);
  --map-world-edge: rgba(255, 255, 255, 0.1);
  --map-hover: rgba(255, 255, 255, 0.1);
  --bin-label: #f4f6f5;
  --table-hover: rgba(143, 214, 168, 0.06);
  --theme-color: #0a0b0c;
  --chip-bin-bg: rgba(140, 170, 200, 0.12);
  --chip-bin-fg: #d2e0ec;
  --chip-bin-border: rgba(140, 170, 200, 0.3);
  --chip-ok-bg: rgba(143, 214, 168, 0.14);
  --chip-ok-fg: #c5f0d4;
  --chip-ok-border: rgba(143, 214, 168, 0.32);
}

html[data-theme="dark"],
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0b0c;
  --bg-elevated: #16191c;
  --bg-subtle: #1a1d20;
  --fg: #e8eaed;
  --fg-muted: #9aa0a6;
  --fg-subtle: #6b7280;
  --border: rgba(232, 234, 237, 0.1);
  --border-strong: rgba(232, 234, 237, 0.18);
  --accent: #8fd6a8;
  --accent-dim: rgba(143, 214, 168, 0.14);
  --accent-fg: #0a0b0c;
  --danger: #c45c5c;
  --danger-bg: rgba(196, 92, 92, 0.12);
  --warn: #d4c48a;
  --ok: #8fd6a8;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 12px 40px rgba(0, 0, 0, 0.35);
  --glow-a: rgba(143, 214, 168, 0.06);
  --glow-b: rgba(140, 160, 180, 0.05);
  --map-surface: #101214;
  --map-panel: #16191c;
  --map-panel-deep: #0c0e10;
  --map-ink: #f2f4f3;
  --map-gutter: #0b0d0f;
  --map-grid: rgba(255, 255, 255, 0.09);
  --map-grid-fine: rgba(255, 255, 255, 0.04);
  --map-chrome: #121416;
  --map-chrome-border: rgba(255, 255, 255, 0.12);
  --map-overlay: rgba(12, 14, 16, 0.72);
  --map-world-edge: rgba(255, 255, 255, 0.1);
  --map-hover: rgba(255, 255, 255, 0.1);
  --bin-label: #f4f6f5;
  --table-hover: rgba(143, 214, 168, 0.06);
  --theme-color: #0a0b0c;
  --chip-bin-bg: rgba(140, 170, 200, 0.12);
  --chip-bin-fg: #d2e0ec;
  --chip-bin-border: rgba(140, 170, 200, 0.3);
  --chip-ok-bg: rgba(143, 214, 168, 0.14);
  --chip-ok-fg: #c5f0d4;
  --chip-ok-border: rgba(143, 214, 168, 0.32);
}

html[data-theme="light"],
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6f4;
  --bg-elevated: #ffffff;
  --bg-subtle: #e8ece8;
  --fg: #1a1f1c;
  --fg-muted: #5c6560;
  --fg-subtle: #7a847e;
  --border: rgba(26, 31, 28, 0.1);
  --border-strong: rgba(26, 31, 28, 0.18);
  --accent: #2f7a4a;
  --accent-dim: rgba(47, 122, 74, 0.12);
  --accent-fg: #ffffff;
  --danger: #b33b3b;
  --danger-bg: rgba(179, 59, 59, 0.1);
  --warn: #9a7b20;
  --ok: #2f7a4a;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 10px 28px rgba(26, 31, 28, 0.08);
  --glow-a: rgba(47, 122, 74, 0.08);
  --glow-b: rgba(80, 110, 140, 0.05);
  --map-surface: #e7ebe6;
  --map-panel: #fbfcfb;
  --map-panel-deep: #eef2ee;
  --map-ink: #1a1f1c;
  --map-gutter: #dfe4de;
  --map-grid: rgba(26, 31, 28, 0.12);
  --map-grid-fine: rgba(26, 31, 28, 0.06);
  --map-chrome: #e8ece8;
  --map-chrome-border: rgba(26, 31, 28, 0.14);
  --map-overlay: rgba(255, 255, 255, 0.86);
  --map-world-edge: rgba(26, 31, 28, 0.12);
  --map-hover: rgba(26, 31, 28, 0.08);
  --bin-label: #f7faf7;
  --table-hover: rgba(47, 122, 74, 0.06);
  --theme-color: #f4f6f4;
  --chip-bin-bg: #d9e4ee;
  --chip-bin-fg: #1a3348;
  --chip-bin-border: #8aa4bb;
  --chip-ok-bg: #d4eadc;
  --chip-ok-fg: #164a2c;
  --chip-ok-border: #5d9a72;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark light;
}

body.rt-body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--fg);
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--glow-a), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, var(--glow-b), transparent 50%),
    var(--bg);
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-bottom);
  transition: background-color var(--motion-fast) var(--ease-out), color var(--motion-fast) var(--ease-out);
}

body.rt-body main {
  flex: 1;
}

.skip-link:focus {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 2000;
  background: var(--accent);
  color: var(--accent-fg);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

/* PWA update / offline banners */
.rt-pwa-banner {
  background: var(--accent-dim);
  border-bottom: 1px solid color-mix(in oklab, var(--accent) 35%, var(--border));
  color: var(--fg);
  font-size: var(--text-sm);
  position: sticky;
  top: 0;
  z-index: 1080;
  transform: translate3d(0, 0, 0);
  touch-action: manipulation;
}

.rt-pwa-banner[hidden] {
  display: none !important;
}
.rt-pwa-banner-offline {
  background: var(--warn-bg, color-mix(in oklab, var(--warn) 16%, var(--bg)));
  border-bottom-color: color-mix(in oklab, var(--warn) 40%, var(--border));
}
.rt-pwa-banner [data-rt-refresh],
.rt-pwa-banner [data-rt-reload] {
  touch-action: manipulation;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Nav */
.rt-nav {
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding-top: max(0.35rem, var(--safe-top));
  padding-bottom: 0.35rem;
}

.rt-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--fg) !important;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.rt-brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  display: block;
  background: #000;
  object-fit: cover;
  flex-shrink: 0;
}

.rt-brand-text {
  font-size: 1.05rem;
}

.rt-nav .nav-link {
  color: var(--fg-muted) !important;
  font-weight: 500;
  padding: 0.55rem 0.85rem !important;
  border-radius: var(--radius-sm);
  transition: color var(--motion-quick) var(--ease-out), background var(--motion-quick) var(--ease-out);
}

.rt-nav .nav-link:hover,
.rt-nav .nav-link:focus-visible {
  color: var(--fg) !important;
  background: var(--bg-subtle);
}

.rt-nav .nav-link.active {
  color: var(--fg) !important;
  background: var(--accent-dim);
}

.rt-nav .navbar-toggler {
  border-color: var(--border-strong);
  padding: 0.4rem 0.55rem;
}

.rt-nav-meta {
  margin-left: auto;
}

.rt-nav-drawer {
  --rt-nav-drawer-width: 16.5rem;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1045;
  width: min(20rem, 92vw);
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  color: var(--fg);
  border-left: 1px solid var(--border);
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  transform: translateX(100%);
  visibility: hidden;
  pointer-events: none;
  transition: transform var(--motion-fast) var(--ease-out), visibility var(--motion-fast) var(--ease-out);
}

.rt-nav-drawer.is-open {
  transform: none;
  visibility: visible;
  pointer-events: auto;
}

.rt-nav-scrim {
  position: fixed;
  inset: 0;
  z-index: 1040;
  background: color-mix(in oklab, #000 45%, transparent);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--motion-fast) var(--ease-out), visibility var(--motion-fast) var(--ease-out);
}

.rt-nav-scrim.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

body.rt-nav-open {
  overflow: hidden;
}

.rt-nav-drawer-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0.65rem 0 0;
}

.rt-nav-drawer-links {
  flex: 1 1 auto;
  padding: 0.35rem 0.65rem 1rem;
  gap: 0.15rem;
  overflow: auto;
}

.rt-nav-drawer .nav-link {
  color: var(--fg-muted) !important;
  font-weight: 500;
  padding: 0.7rem 0.9rem !important;
  border-radius: var(--radius-sm);
}

.rt-nav-drawer .nav-link:hover,
.rt-nav-drawer .nav-link:focus-visible {
  color: var(--fg) !important;
  background: var(--bg-subtle);
}

.rt-nav-drawer .nav-link.active {
  color: var(--fg) !important;
  background: var(--accent-dim);
}

.rt-nav-drawer-foot {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: color-mix(in oklab, var(--bg) 70%, var(--bg-elevated));
}

.rt-nav-drawer-horde {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 0.85rem 0.35rem;
}

.rt-nav-drawer-horde .rt-horde-switch {
  flex: 1;
  min-width: 0;
}

.rt-nav-drawer-horde .rt-horde-select {
  width: 100%;
  max-width: none;
}

.rt-nav-drawer-horde .rt-horde-chip {
  flex: 1;
  min-width: 0;
  max-width: none;
}

.rt-horde-gear {
  flex: 0 0 auto;
}

.rt-nav-drawer-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem 0.9rem;
  padding-bottom: max(0.9rem, env(safe-area-inset-bottom, 0px));
  color: var(--fg) !important;
  text-decoration: none !important;
}

.rt-nav-drawer-profile:hover,
.rt-nav-drawer-profile:focus-visible,
.rt-nav-drawer-profile.is-active {
  background: var(--accent-dim);
}

.rt-nav-drawer-profile .rt-user-avatar {
  width: 2.5rem;
  height: 2.5rem;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.rt-nav-drawer-profile .rt-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.rt-nav-drawer-profile-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.1rem;
}

.rt-nav-drawer-profile-text strong {
  font-size: 0.95rem;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rt-nav-drawer-profile-text .rt-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0;
}

@media (min-width: 1200px) {
  body:has(aside.rt-nav-drawer) {
    padding-right: calc(var(--rt-nav-drawer-width, 16.5rem) + var(--space-5));
  }
  body:has(aside.rt-nav-drawer) .rt-nav-drawer {
    width: var(--rt-nav-drawer-width, 16.5rem);
    transform: none;
    visibility: visible;
    pointer-events: auto;
  }
  body:has(aside.rt-nav-drawer) .rt-nav .navbar-toggler,
  body:has(aside.rt-nav-drawer) .rt-nav-scrim {
    display: none !important;
  }
}

.rt-nav .navbar-toggler-icon {
  /* Bootstrap's data-bs-theme already swaps the SVG; extra invert made dark-theme black. */
  filter: none;
  opacity: 0.92;
}

.rt-pill {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  letter-spacing: 0.02em;
}

/* Typography */
.rt-kicker {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0;
}

.rt-display {
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--fg);
  margin: 0;
}

.rt-lead {
  color: var(--fg-muted);
  max-width: 52ch;
  font-size: var(--text-sm);
}

.rt-section-title {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.rt-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.95em;
}

.rt-strong {
  font-weight: 600;
  color: var(--fg);
}

.rt-sub {
  color: var(--fg-muted);
  font-size: var(--text-xs);
}

.rt-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  font-size: var(--text-sm);
}

.rt-link:hover {
  text-decoration: underline;
}

/* Panels & stats */
.rt-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow);
}

.rt-panel-head {
  margin-bottom: var(--space-4);
}

.rt-panel-title {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin: 0;
}

.rt-stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow);
}

a.rt-stat-card {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: border-color var(--motion-quick) var(--ease-out);
}

a.rt-stat-card:hover,
a.rt-stat-card:focus-visible {
  border-color: var(--border-strong);
  color: inherit;
}

.rt-stat-accent {
  border-color: color-mix(in oklab, var(--accent) 35%, var(--border));
  background: linear-gradient(180deg, var(--accent-dim), var(--bg-elevated) 70%);
}

.rt-stat-label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 0.35rem;
}

.rt-stat-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.35rem, 1.1rem + 1vw, 1.85rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--fg);
}

.rt-stat-hint {
  margin-top: 0.35rem;
  font-size: var(--text-xs);
  color: var(--fg-subtle);
}

/* Bars */
.rt-bar-list > li + li {
  margin-top: var(--space-3);
}

.rt-bar {
  height: 6px;
  background: var(--bg-subtle);
  border-radius: 999px;
  overflow: hidden;
}

.rt-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  min-width: 2px;
  transition: width var(--motion-fast) var(--ease-out);
}

.rt-bar-fill.is-empty {
  min-width: 0;
  background: transparent;
}

.rt-bar-fill.is-over {
  background: var(--danger);
}

.rt-bar-quota {
  height: 10px;
}

.rt-bar-fill.is-pole {
  min-width: 0;
  background-color: var(--accent);
  background-image: repeating-linear-gradient(
    -45deg,
    color-mix(in oklab, var(--accent) 100%, #fff 18%) 0 8px,
    color-mix(in oklab, var(--accent) 62%, var(--bg-elevated)) 8px 16px
  );
  background-size: 22px 22px;
  animation: rt-barberpole 0.65s linear infinite;
}

.rt-bar-fill.is-pole.is-indet {
  width: 100%;
  min-width: 100%;
}

@keyframes rt-barberpole {
  to { background-position: 22px 0; }
}

.rt-plan-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.rt-plan {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.85rem;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.rt-plan.is-current {
  border-color: color-mix(in oklab, var(--accent) 45%, var(--border));
  background: var(--accent-dim);
}

.rt-plan-name {
  font-weight: 650;
}

.rt-plan-quota {
  font-size: var(--text-sm);
}

.rt-plan-note {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  line-height: 1.35;
}

.rt-plan-action {
  margin-top: 0.65rem;
}

@media (max-width: 575.98px) {
  .rt-plan-list {
    grid-template-columns: 1fr;
  }
}

.rt-status-list > li + li {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

/* Table */
.rt-table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--fg);
  --bs-table-border-color: var(--border);
  --bs-table-hover-bg: rgba(255, 255, 255, 0.02);
  margin: 0;
  font-size: var(--text-sm);
}

.rt-table thead th {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-muted);
  border-bottom-color: var(--border-strong) !important;
  padding: 0.9rem 1.1rem;
  white-space: nowrap;
}

.rt-table tbody td {
  padding: 0.95rem 1.1rem;
  vertical-align: middle;
  border-color: var(--border);
}

.rt-row-link {
  color: var(--fg);
  font-weight: 600;
  text-decoration: none;
}

.rt-row-link:hover {
  color: var(--accent);
}

.rt-empty,
.rt-empty-inline {
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.rt-empty {
  padding: 2rem 1.1rem !important;
  text-align: center;
}

.rt-empty a,
.rt-empty-inline a {
  color: var(--accent);
}

.rt-result-count {
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

/* Badges */
.badge {
  font-weight: 500;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  padding: 0.4em 0.65em;
  border-radius: 999px;
  border: 1px solid transparent;
}

.badge-status-working {
  background: rgba(143, 214, 168, 0.14);
  color: #b6ebc7;
  border-color: rgba(143, 214, 168, 0.28);
}

.badge-status-partial {
  background: rgba(212, 196, 138, 0.14);
  color: #e6d7a4;
  border-color: rgba(212, 196, 138, 0.28);
}

.badge-status-dead {
  background: rgba(232, 160, 160, 0.12);
  color: #f0b8b8;
  border-color: rgba(232, 160, 160, 0.28);
}

.badge-status-untested {
  background: rgba(154, 160, 166, 0.12);
  color: #c4c8cc;
  border-color: rgba(154, 160, 166, 0.25);
}

.badge-condition-good {
  background: rgba(143, 214, 168, 0.1);
  color: #b6ebc7;
  border-color: rgba(143, 214, 168, 0.22);
}

.badge-condition-ok {
  background: rgba(140, 170, 200, 0.12);
  color: #c5d5e5;
  border-color: rgba(140, 170, 200, 0.25);
}

.badge-condition-warn {
  background: rgba(212, 196, 138, 0.12);
  color: #e6d7a4;
  border-color: rgba(212, 196, 138, 0.25);
}

.badge-condition-bad {
  background: rgba(232, 160, 160, 0.1);
  color: #f0b8b8;
  border-color: rgba(232, 160, 160, 0.22);
}

.badge-condition-muted {
  background: rgba(154, 160, 166, 0.1);
  color: #c4c8cc;
  border-color: rgba(154, 160, 166, 0.22);
}

/* Forms */
.rt-filters {
  padding: var(--space-4) var(--space-5);
}

.rt-form-wrap {
  max-width: 860px;
}

.form-label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 0.4rem;
}

.rt-req {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--fg-subtle);
  margin-left: 0.35rem;
}

.rt-input,
.form-control.rt-input,
.form-select.rt-input {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--fg);
  border-radius: var(--radius-sm);
  min-height: 44px;
  padding: 0.55rem 0.85rem;
  box-shadow: none;
  transition: border-color var(--motion-quick) var(--ease-out), box-shadow var(--motion-quick) var(--ease-out);
}

.form-select.rt-input {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%9aa0a6' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

.rt-input:focus,
.form-control.rt-input:focus,
.form-select.rt-input:focus {
  background: var(--bg);
  border-color: color-mix(in oklab, var(--accent) 55%, var(--border-strong));
  color: var(--fg);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.rt-input::placeholder {
  color: var(--fg-subtle);
}

textarea.rt-input {
  min-height: 120px;
  resize: vertical;
}

.rt-file {
  padding: 0.45rem 0.65rem;
}

.rt-file::file-selector-button {
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  color: var(--fg);
  border-radius: var(--radius-xs);
  margin-right: 0.75rem;
  padding: 0.35rem 0.75rem;
  font-weight: 500;
}

.rt-form-actions {
  border-top: 1px solid var(--border);
}

.rt-alert {
  background: var(--danger-bg);
  border: 1px solid rgba(232, 160, 160, 0.3);
  color: #f0b8b8;
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
}

.rt-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  border-bottom: 1px solid var(--border);
  margin: 0 0 1.5rem;
}

.rt-tab {
  display: inline-flex;
  align-items: center;
  padding: 0.7rem 1rem;
  margin-bottom: -1px;
  color: var(--fg-muted);
  font-weight: 650;
  font-size: var(--text-sm);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  background: transparent;
}

.rt-tab:hover,
.rt-tab:focus-visible {
  color: var(--fg);
  outline: none;
}

.rt-tab.is-active {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

.rt-settings-grid {
  --rt-settings-save: 6.5rem;
  --rt-settings-count: minmax(5.75rem, 8rem);
  --rt-settings-icon: 44px;
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: var(--rt-settings-icon) minmax(10rem, 1fr) var(--rt-settings-count) var(--rt-settings-icon);
  column-gap: 0.5rem;
  row-gap: 0.5rem;
  align-items: center;
}

.rt-settings-row,
.rt-settings-add {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: center;
  min-width: 0;
}

.rt-settings-add {
  margin-top: 0.75rem;
  align-items: end;
  row-gap: 0.35rem;
}

.rt-settings-add-label {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.rt-settings-field {
  min-width: 0;
}

.rt-settings-field .rt-input,
.rt-settings-row .rt-input,
.rt-settings-add .rt-input {
  min-width: 0;
  width: 100%;
}

.rt-settings-save {
  width: 100%;
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.rt-settings-count {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  white-space: nowrap;
  justify-self: start;
}

.rt-settings-row > form {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rt-settings-handle {
  cursor: grab;
  touch-action: none;
}

.rt-settings-handle:active,
.rt-settings-row.is-dragging .rt-settings-handle {
  cursor: grabbing;
  transform: none;
}

.rt-settings-row.is-dragging {
  opacity: 0.7;
}

.rt-settings-row.is-saving .rt-input {
  border-color: color-mix(in oklab, var(--accent) 45%, var(--border-strong));
}

.rt-settings-row .rt-icon-btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}

.rt-settings-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.rt-settings-tag-list .rt-tag-chip {
  padding-right: 0.25rem;
}

.rt-settings-tag-list .rt-tag-chip:not(:has(.rt-tag-chip-x)) {
  padding-right: 0.45rem;
}

.rt-settings-tag-add {
  margin-top: 1rem;
  max-width: 24rem;
}

.rt-settings-tag-add-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.rt-settings-tag-add-row .rt-input {
  flex: 1;
  min-width: 0;
}

@supports not (grid-template-columns: subgrid) {
  .rt-settings-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  .rt-settings-row,
  .rt-settings-add {
    display: grid;
    grid-template-columns: var(--rt-settings-icon) minmax(10rem, 1fr) var(--rt-settings-count) var(--rt-settings-icon);
    column-gap: 0.5rem;
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .rt-settings-grid {
    overflow-x: auto;
  }
}

.rt-category-row {
  align-items: flex-start;
  gap: 0.75rem;
}

.rt-category-edit {
  display: flex;
  flex: 1 1 16rem;
  gap: 0.5rem;
  min-width: 0;
  align-items: center;
}

.rt-category-edit .rt-input {
  flex: 1 1 auto;
  min-width: 0;
}

.rt-category-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-left: auto;
}

.rt-category-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.rt-category-actions .rt-icon-btn {
  width: 2.25rem;
  height: 2.25rem;
  min-height: 2.25rem;
}

.rt-category-actions .rt-icon-btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* Buttons */
.btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 0.55rem 1.1rem;
  transition: transform var(--motion-quick) var(--ease-out), background var(--motion-quick) var(--ease-out), border-color var(--motion-quick) var(--ease-out), opacity var(--motion-quick) var(--ease-out);
}

.btn-sm {
  min-height: 36px;
  padding: 0.35rem 0.85rem;
  font-size: var(--text-xs);
}

.btn:active {
  transform: scale(0.98);
}

.btn-rt-primary {
  background: var(--accent);
  border: 1px solid color-mix(in oklab, var(--accent) 80%, white);
  color: var(--accent-fg);
}

.btn-rt-primary:hover,
.btn-rt-primary:focus-visible {
  background: color-mix(in oklab, var(--accent) 88%, white);
  border-color: color-mix(in oklab, var(--accent) 70%, white);
  color: var(--accent-fg);
}

.btn-rt-ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--fg);
}

.btn-rt-ghost:hover,
.btn-rt-ghost:focus-visible {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
  color: var(--fg);
}

.rt-part-action {
  min-width: 7.75rem;
  text-align: center;
  justify-content: center;
}

.btn-rt-danger {
  background: transparent;
  border: 1px solid rgba(232, 160, 160, 0.35);
  color: #f0b8b8;
}

.btn-rt-danger:hover,
.btn-rt-danger:focus-visible {
  background: var(--danger-bg);
  border-color: rgba(232, 160, 160, 0.5);
  color: #f5c8c8;
}

.btn-rt-success {
  background: transparent;
  border: 1px solid color-mix(in oklab, var(--ok) 42%, var(--border));
  color: var(--ok);
}

.btn-rt-success:hover,
.btn-rt-success:focus-visible {
  background: color-mix(in oklab, var(--ok) 14%, transparent);
  border-color: color-mix(in oklab, var(--ok) 58%, var(--border));
  color: var(--ok);
}

/* Detail */
.rt-breadcrumb {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.rt-breadcrumb a {
  color: var(--fg-muted);
  text-decoration: none;
}

.rt-breadcrumb a:hover {
  color: var(--accent);
}

.rt-dl dt {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-subtle);
  margin-bottom: 0.25rem;
}

.rt-dl dd {
  margin: 0 0 1rem;
  color: var(--fg);
}

.rt-dl .col-sm-6:last-child dd,
.rt-dl dd:last-child {
  margin-bottom: 0;
}

.rt-notes {
  white-space: pre-wrap;
  color: var(--fg);
  line-height: 1.6;
}

.rt-value-block .rt-stat-value {
  color: var(--accent);
}

/* Worklogs */
.rt-worklog-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.rt-worklog-card {
  scroll-margin-top: 5rem;
}

.rt-worklog-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.rt-worklog-author {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem;
}

.rt-worklog-meta {
  color: var(--fg-muted);
  font-size: var(--text-xs);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  align-items: center;
}

.rt-meta-sep {
  color: var(--fg-subtle);
}

.rt-worklog-notes {
  margin: 0 0 var(--space-4);
}

.rt-empty-worklogs {
  text-align: center;
  padding: var(--space-6) var(--space-5);
}

.rt-empty-worklogs .rt-empty {
  padding: 0 !important;
}

/* Photo grid */
.rt-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: var(--space-3);
}

.rt-photo-thumb {
  display: block;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
  transition: border-color var(--motion-quick) var(--ease-out), transform var(--motion-quick) var(--ease-out);
}

.rt-photo-thumb:hover {
  border-color: var(--border-strong);
  transform: scale(1.02);
}

.rt-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rt-photo-grid-edit {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

.rt-photo-edit {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.rt-photo-edit .rt-photo-thumb {
  aspect-ratio: 1;
}

.rt-photo-name {
  font-size: var(--text-xs);
  color: var(--fg-subtle);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rt-photo-remove {
  margin: 0;
}

.rt-photo-useas {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin: 0;
}

.rt-photo-useas .form-label {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--fg-muted);
}

.rt-photo-useas .form-select {
  font-size: var(--text-sm);
  padding: 0.28rem 0.5rem;
}

/* Mobile cards */
.rt-machine-card {
  display: block;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-decoration: none;
  color: inherit;
  margin-bottom: var(--space-2);
  transition: border-color var(--motion-quick) var(--ease-out);
}

.rt-machine-card:hover {
  border-color: var(--border-strong);
  color: inherit;
}

/* Footer */
.rt-footer {
  border-top: 1px solid var(--border);
  padding: var(--space-5) 0 max(var(--space-5), var(--safe-bottom));
  margin-top: var(--space-6);
  font-size: var(--text-xs);
  color: var(--fg-muted);
}

.rt-footer-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
}

.rt-footer-slogan {
  margin: 0;
  color: var(--fg-muted);
}

.rt-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
}

.rt-footer-muted {
  margin: 0;
  color: var(--fg-subtle);
}

.rt-feedback-link {
  color: var(--fg-muted);
  text-decoration: none;
}
.rt-feedback-link:hover,
.rt-feedback-link:focus-visible {
  color: var(--fg);
  text-decoration: underline;
}

/* HTMX busy */
.htmx-request .rt-table tbody {
  opacity: 0.55;
  transition: opacity var(--motion-quick) var(--ease-out);
}

/* Standalone display mode (installed PWA) */
@media (display-mode: standalone) {
  .rt-nav {
    padding-top: max(0.5rem, var(--safe-top));
  }
}

@media (max-width: 767.98px) {
  .rt-table thead {
    display: none;
  }

  .rt-panel.p-0 .table-responsive {
    display: none;
  }

  .rt-worklog-head {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* Photo picker — camera + library (iOS-friendly) */
.rt-visually-hidden-file {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.rt-photo-picker {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.rt-photo-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
}

@media (min-width: 576px) {
  .rt-photo-actions {
    grid-template-columns: 1fr 1fr;
  }
  .rt-photo-action-secondary {
    grid-column: 1 / -1;
  }
}

@media (min-width: 768px) {
  .rt-photo-actions {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .rt-photo-action-secondary {
    grid-column: auto;
  }
}

.rt-photo-action {
  justify-content: flex-start !important;
  gap: 0.75rem;
  min-height: 56px;
  text-align: left;
  padding: 0.75rem 1rem;
}

.rt-photo-action .bi {
  font-size: 1.35rem;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0.95;
}

.rt-photo-action-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  line-height: 1.25;
}

.rt-photo-action-label strong {
  font-weight: 600;
  font-size: var(--text-sm);
}

.rt-photo-action-label small {
  font-weight: 400;
  font-size: var(--text-xs);
  color: var(--fg-muted);
  opacity: 0.95;
}

.btn-rt-primary.rt-photo-action .rt-photo-action-label small {
  color: color-mix(in oklab, var(--accent-fg) 70%, transparent);
}

.rt-photo-ios-hint {
  margin: 0;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in oklab, var(--accent) 30%, var(--border));
  background: var(--accent-dim);
  color: var(--fg);
  font-size: var(--text-sm);
  line-height: 1.45;
}

.rt-photo-status {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--fg-muted);
}

.rt-photo-status-error {
  color: #f0b8b8;
}

.rt-photo-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
}

.rt-pending-photo {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
}

.rt-pending-photo-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  display: block;
  background: var(--bg-subtle);
}

.rt-pending-photo-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.rt-pending-photo-name {
  font-size: var(--text-xs);
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rt-pending-photo-size {
  font-size: 0.7rem;
  color: var(--fg-subtle);
}

.rt-pending-photo-remove {
  width: 100%;
}

/* Larger touch targets on iOS photo picker */
.rt-photo-picker-ios .rt-photo-action {
  min-height: 64px;
}

@supports (-webkit-touch-callout: none) {
  .rt-photo-action {
    -webkit-tap-highlight-color: transparent;
  }
}

/* Machine gallery */
.rt-machine-gallery {
  scroll-margin-top: 5rem;
}

.rt-gallery-hero {
  display: grid;
  gap: var(--space-3);
}

@media (min-width: 768px) {
  .rt-gallery-hero {
    grid-template-columns: 1fr minmax(100px, 160px);
    align-items: stretch;
  }
}

.rt-gallery-main {
  display: block;
  width: 100%;
  padding: 0;
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  aspect-ratio: 16 / 10;
  cursor: pointer;
  position: relative;
}

.rt-gallery-main.is-empty {
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rt-gallery-main img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rt-gallery-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: var(--space-2);
}

@media (min-width: 768px) {
  .rt-gallery-thumbs {
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(72px, 1fr);
    max-height: 100%;
    overflow-y: auto;
  }
}

.rt-gallery-thumb {
  display: block;
  width: 100%;
  padding: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 1;
  background: var(--bg-elevated);
  cursor: pointer;
}

.rt-gallery-thumb.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.rt-gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rt-gallery-add {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg);
  background: color-mix(in oklab, var(--accent-dim) 70%, var(--bg-elevated));
  border-style: dashed;
  border-width: 2px;
}

.rt-gallery-add .bi {
  font-size: 2rem;
  line-height: 1;
}

.rt-gallery-box {
  cursor: default;
  display: flex;
  flex-direction: column;
  padding: 0;
  position: relative;
}

.rt-gallery-main.is-photo {
  cursor: pointer;
}

.rt-gallery-hero-photo {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--bg-elevated);
}

.rt-gallery-hero-photo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.rt-gallery-box .rt-soft-viewer {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  border-radius: 0;
}

.rt-gallery-box-mini {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, var(--bg-subtle), var(--bg));
}

.rt-gallery-box-mini-cube {
  position: relative;
  width: 34px;
  height: 40px;
}

.rt-gallery-box-mini-cube span {
  position: absolute;
  display: block;
  overflow: hidden;
  background: hsl(var(--spine-h), 26%, 22%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.28);
}

.rt-gallery-box-mini-cube span img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rt-gallery-box-mini-cube .is-front {
  left: 6px;
  top: 8px;
  width: 22px;
  height: 30px;
  z-index: 2;
}

.rt-gallery-box-mini-cube .is-side {
  left: 28px;
  top: 5px;
  width: 8px;
  height: 30px;
  background: hsl(var(--spine-h), 22%, 16%);
  transform: skewY(-28deg);
  z-index: 1;
}

.rt-gallery-box-mini-cube .is-lid {
  left: 10px;
  top: 2px;
  width: 22px;
  height: 8px;
  background: hsl(var(--spine-h), 24%, 28%);
  transform: skewX(-52deg);
  z-index: 3;
}

.rt-gallery-empty {
  color: var(--fg-muted);
  font-size: 0.95rem;
}

.rt-empty-photos {
  text-align: center;
  padding: var(--space-6) var(--space-5);
}

.rt-empty-photos .rt-empty {
  padding: 0 !important;
}

/* List thumbnails */
.rt-col-thumb {
  width: 56px;
  padding-right: 0 !important;
}

.rt-list-thumb {
  display: block;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  flex-shrink: 0;
}

.rt-list-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rt-list-thumb-empty {
  display: block;
  width: 100%;
  height: 100%;
  background:
    linear-gradient(135deg, var(--bg-subtle) 0%, var(--bg-elevated) 100%);
}

.rt-list-thumb-card {
  width: 56px;
  height: 56px;
}

.min-w-0 {
  min-width: 0;
}

/* Parts */
.rt-location-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-decoration: none;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rt-location-bin {
  background: var(--chip-bin-bg);
  color: var(--chip-bin-fg);
  border-color: var(--chip-bin-border);
}

.rt-location-installed {
  background: var(--chip-ok-bg);
  color: var(--chip-ok-fg);
  border-color: var(--chip-ok-border);
}

a.rt-location-installed:hover,
a.rt-location-installed:focus-visible {
  color: var(--chip-ok-fg);
  box-shadow: inset 0 0 0 1px var(--chip-ok-border);
}

a.rt-location-bin:hover,
a.rt-location-bin:focus-visible {
  color: var(--chip-bin-fg);
  box-shadow: inset 0 0 0 1px var(--chip-bin-border);
}

.rt-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.rt-tags {
  position: relative;
}

.rt-tags-box {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  min-height: 44px;
  padding: 0.35rem 0.55rem;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.rt-tags-box:focus-within {
  border-color: color-mix(in oklab, var(--accent) 55%, var(--border-strong));
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.rt-tags-chips {
  display: contents;
}

.rt-tags-input {
  flex: 1 1 8rem;
  min-width: 7rem;
  border: 0;
  background: transparent;
  color: var(--fg);
  outline: none;
  padding: 0.2rem 0.15rem;
  font: inherit;
}

.rt-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  max-width: 100%;
  padding: 0.15rem 0.2rem 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-dim);
  border: 1px solid color-mix(in oklab, var(--accent) 32%, var(--border));
  color: var(--fg);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.2;
}

.rt-tag-chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  line-height: 1;
}

.rt-tag-chip-x:hover,
.rt-tag-chip-x:focus-visible {
  background: color-mix(in oklab, var(--fg) 12%, transparent);
}

.rt-tag-chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.2rem;
  height: 1.2rem;
  padding: 0 0.35rem;
  margin-left: 0.1rem;
  border-radius: 999px;
  background: color-mix(in oklab, var(--fg) 14%, transparent);
  font-variant-numeric: tabular-nums;
  font-size: 0.85em;
  font-weight: 700;
  line-height: 1;
}

.rt-tags-suggest {
  position: absolute;
  z-index: 8;
  left: 0;
  right: 0;
  top: calc(100% + 0.25rem);
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  max-height: 12rem;
  overflow: auto;
}

.rt-tags-suggest-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--fg);
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  font: inherit;
}

.rt-tags-suggest-item:hover,
.rt-tags-suggest-item.is-active {
  background: var(--accent-dim);
}

.rt-label-pick-list {
  max-height: 24rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.rt-label-pick {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.45rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
}
.rt-label-pick:hover {
  background: var(--bg-subtle);
}
.rt-label-pick:has(input:checked) {
  background: var(--accent-dim);
  border-color: color-mix(in oklab, var(--accent) 35%, var(--border));
}
.rt-label-pick strong {
  display: block;
}
.rt-label-pick small {
  display: block;
  color: var(--fg-subtle);
  font-size: var(--text-xs);
}
.rt-label-pick input {
  margin-top: 0.2rem;
  flex: 0 0 auto;
}

.rt-compat-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rt-compat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
}

.rt-compat-remove,
.rt-compat-search,
.rt-compat-add {
  min-width: 44px;
  padding-left: 0.65rem;
  padding-right: 0.65rem;
}

.rt-compat-pick .rt-compat-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto auto;
}

.rt-compat-pick .rt-compat-add {
  visibility: hidden;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.rt-compat-pick .rt-compat-row:last-child .rt-compat-add {
  visibility: visible;
  pointer-events: auto;
}

#fill-make-model {
  max-width: 18rem;
}

.rt-placement {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
}

@media (min-width: 576px) {
  .rt-placement {
    grid-template-columns: 1fr 1fr;
  }
}

.rt-placement-option {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg);
  cursor: pointer;
  min-height: 64px;
}

.rt-placement-option:has(input:checked) {
  border-color: color-mix(in oklab, var(--accent) 50%, var(--border-strong));
  background: var(--accent-dim);
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--accent) 30%, transparent);
}

.rt-placement-option input {
  margin-top: 0.25rem;
  accent-color: var(--accent);
}

.rt-placement-option strong {
  display: block;
  font-size: var(--text-sm);
  color: var(--fg);
}

.rt-placement-option small {
  display: block;
  color: var(--fg-muted);
  font-size: var(--text-xs);
  margin-top: 0.15rem;
}

.rt-part-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.rt-part-list-item {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.rt-part-list-item:last-child {
  border-bottom: 0;
}

.rt-install-from-bin {
  padding: var(--space-4) var(--space-5);
}

.rt-install-summary {
  cursor: pointer;
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--fg-muted);
  list-style: none;
}

.rt-install-summary::-webkit-details-marker {
  display: none;
}

.rt-install-summary::before {
  content: "▸ ";
  color: var(--accent);
}

details[open] > .rt-install-summary::before {
  content: "▾ ";
}

#parts {
  scroll-margin-top: 5rem;
}

/* Storage locations — list tiles (v3) */
.rt-loc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.rt-loc-list-item {
  margin: 0;
  padding: 0;
  position: relative;
}
.rt-loc-tile {
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
  max-width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-decoration: none !important;
  color: var(--fg) !important;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.rt-loc-tile:hover,
.rt-loc-tile:focus-visible {
  border-color: color-mix(in oklab, var(--accent) 45%, var(--border));
  color: var(--fg) !important;
  text-decoration: none !important;
}
.rt-loc-tile:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
}
.rt-loc-tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Fixed-size thumbnail — never expands the page */
.rt-loc-tile-thumb {
  flex: 0 0 7.5rem;
  width: 7.5rem;
  max-width: 7.5rem;
  min-height: 5.75rem;
  position: relative;
  background: var(--map-surface);
  overflow: hidden;
  border-right: 1px solid var(--border);
}
.rt-loc-tile-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  border: 0;
  max-width: none;
}
.rt-loc-tile-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  font-size: 1.35rem;
  background:
    radial-gradient(ellipse at 40% 30%, rgba(143, 214, 168, 0.1), transparent 60%),
    var(--map-panel);
}

.rt-loc-tile-body {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.25rem;
}
.rt-loc-tile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.rt-loc-tile-name {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--fg);
  text-transform: none;
  text-decoration: none !important;
}
.rt-loc-tile-photos {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-mono, ui-monospace, monospace);
  color: var(--fg-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.rt-loc-tile-address {
  margin: 0;
  font-size: 0.9rem;
  color: var(--fg-muted);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none !important;
}
.rt-loc-tile-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--fg-muted);
}
.rt-loc-tile-stats strong {
  color: var(--fg);
  font-weight: 650;
}
.rt-loc-tile-dot {
  opacity: 0.5;
}
.rt-loc-tile-go {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 0 0.9rem 0 0.25rem;
  color: var(--fg-subtle);
  font-size: 1rem;
}
.rt-tile-edit {
  position: absolute;
  z-index: 2;
  background: color-mix(in oklab, var(--bg-elevated) 92%, transparent);
  box-shadow: var(--shadow);
}
.rt-loc-list-item > .rt-tile-edit {
  top: 50%;
  right: 0.45rem;
  transform: translateY(-50%);
}
.rt-loc-list-item:has(.rt-tile-edit) .rt-loc-tile-go {
  visibility: hidden;
}

@media (min-width: 576px) {
  .rt-loc-tile-thumb {
    flex-basis: 9.5rem;
    width: 9.5rem;
    max-width: 9.5rem;
    min-height: 6.5rem;
  }
}
@media (min-width: 768px) {
  .rt-loc-tile-thumb {
    flex-basis: 11rem;
    width: 11rem;
    max-width: 11rem;
    min-height: 7rem;
  }
  .rt-loc-tile-body {
    padding: 1rem 1.15rem;
  }
  .rt-loc-tile-name {
    font-size: 1.2rem;
  }
}

/* keep legacy class harmless if referenced */
.rt-location-card { display: block; }

.rt-room-card {
  transition: border-color var(--motion-quick) var(--ease-out), transform var(--motion-quick) var(--ease-out);
  color: inherit;
}
.rt-room-card:hover {
  border-color: color-mix(in oklab, var(--accent) 40%, var(--border));
  transform: translateY(-1px);
  color: inherit;
}

.rt-unit-badge {
  font-size: var(--text-xs);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  white-space: nowrap;
}

.rt-mini-map {
  position: relative;
  height: 72px;
  border-radius: var(--radius-md);
  background:
    linear-gradient(to right, var(--map-grid-fine) 1px, transparent 1px) 0 0 / 12px 12px,
    linear-gradient(to bottom, var(--map-grid-fine) 1px, transparent 1px) 0 0 / 12px 12px,
    var(--map-panel);
  border: 1px solid var(--border);
  overflow: hidden;
}
.rt-mini-bin {
  position: absolute;
  border-radius: 2px;
  opacity: 0.85;
  min-width: 4px;
  min-height: 4px;
}

/* Room map canvas */
.rt-map-shell {
  position: relative;
  display: grid;
  grid-template-columns: 1.75rem minmax(0, 1fr);
  grid-template-rows: 1.35rem auto;
  gap: 0;
  width: 100%;
  max-width: 100%;
}

.rt-map-ruler-x,
.rt-map-ruler-y {
  position: relative;
  color: var(--fg-muted);
  font-size: 0.62rem;
  font-family: var(--font-mono, ui-monospace, monospace);
  pointer-events: none;
  background: var(--map-chrome);
}
.rt-map-ruler-x { grid-column: 2; grid-row: 1; }
.rt-map-ruler-y { grid-column: 1; grid-row: 2; }
.rt-map-shell > .rt-room-map {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  border-radius: 0;
  border: 0;
}

.rt-map-world {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
  background:
    radial-gradient(ellipse at 30% 20%, var(--glow-a), transparent 50%),
    linear-gradient(180deg, var(--map-panel) 0%, var(--map-panel-deep) 100%);
  box-shadow: 0 0 0 1px var(--map-world-edge);
}

.rt-room-map.rt-map-zoomed-out {
  background: var(--map-gutter);
}

.rt-map-zoom-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.rt-map-marquee {
  position: absolute;
  z-index: 8;
  border: 1px solid var(--accent);
  background: color-mix(in oklab, var(--accent) 22%, transparent);
  pointer-events: none;
  box-sizing: border-box;
}

.rt-inspector-multi .insp-single,
.rt-inspector-multi .rt-inspector-open,
.rt-inspector-multi button[type="submit"] {
  display: none !important;
}

.rt-room-map {
  cursor: grab;
}
.rt-room-map.rt-map-panning,
.rt-room-map.rt-map-space {
  cursor: grabbing;
}

.rt-map-zoom {
  position: absolute;
  right: 0.45rem;
  bottom: 0.45rem;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--map-overlay);
  border: 1px solid var(--map-chrome-border);
  box-shadow: var(--shadow);
}
.rt-map-zoom-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--fg);
  min-width: 2rem;
  height: 1.85rem;
  padding: 0 0.35rem;
  border-radius: 7px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  font-family: var(--font-mono, ui-monospace, monospace);
}
.rt-map-zoom-btn:hover,
.rt-map-zoom-btn:focus-visible {
  background: var(--map-hover);
  outline: none;
}
.rt-map-zoom-pct {
  min-width: 3.15rem;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--fg-muted);
}

.rt-map-add {
  position: absolute;
  left: 0.45rem;
  bottom: 0.45rem;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.rt-map-add[hidden] {
  display: none !important;
}
.rt-map-add-toggle {
  display: flex;
  align-items: center;
  padding: 3px;
  border-radius: 10px;
  background: var(--map-overlay);
  border: 1px solid var(--map-chrome-border);
  box-shadow: var(--shadow);
}
.rt-map-add-toggle .rt-map-zoom-btn {
  font-size: 1.25rem;
  font-weight: 600;
}
.rt-map-add-menu {
  display: flex;
  flex-direction: column;
  min-width: 8.75rem;
  padding: 4px;
  border-radius: 10px;
  background: var(--map-overlay);
  border: 1px solid var(--map-chrome-border);
  box-shadow: var(--shadow);
}
.rt-map-add-menu[hidden] {
  display: none !important;
}
.rt-map-add-menu button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--fg);
  text-align: left;
  padding: 0.42rem 0.7rem;
  border-radius: 7px;
  font-size: 0.82rem;
  line-height: 1.2;
  cursor: pointer;
  font-family: var(--font-sans);
}
.rt-map-add-menu button:hover,
.rt-map-add-menu button:focus-visible {
  background: var(--map-hover);
  outline: none;
}
.rt-map-ruler-x .rt-map-tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
}
.rt-map-ruler-y .rt-map-tick {
  position: absolute;
  right: 0.15rem;
  transform: translateY(-50%);
}

.rt-room-map {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-strong);
  background:
    radial-gradient(ellipse at 30% 20%, var(--glow-a), transparent 50%),
    var(--map-gutter);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  grid-column: 2;
  grid-row: 2;
}

.rt-map-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--map-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--map-grid) 1px, transparent 1px);
  background-size: calc(100% / var(--room-w-ft, 20)) calc(100% / var(--room-h-ft, 14));
  pointer-events: none;
}
.rt-map-grid-quarter {
  opacity: 0;
  background-image:
    linear-gradient(to right, var(--map-grid-fine) 1px, transparent 1px),
    linear-gradient(to bottom, var(--map-grid-fine) 1px, transparent 1px);
  background-size: calc(25% / var(--room-w-ft, 20)) calc(25% / var(--room-h-ft, 14));
  transition: opacity 0.15s ease;
}
.rt-map-design .rt-map-grid-quarter { opacity: 1; }

.rt-map-size {
  font-size: 0.58rem;
  opacity: 0.85;
  white-space: nowrap;
}

.rt-map-bin {
  position: absolute;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  color: var(--map-ink);
  padding: 0.35rem 0.4rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  cursor: pointer;
  min-width: 28px;
  min-height: 24px;
  transition: box-shadow var(--motion-quick) var(--ease-out), outline-color var(--motion-quick);
}

.rt-map-design .rt-map-bin {
  cursor: grab;
}

.rt-map-design .rt-map-bin.rt-bin-dragging {
  cursor: grabbing;
  z-index: 5;
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
  outline: 2px solid var(--accent);
}

.rt-map-bin.rt-bin-selected {
  outline: 2px solid var(--accent);
  z-index: 4;
}

.rt-map-bin-label {
  font-size: 0.7rem;
  line-height: 1.2;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  overflow: hidden;
}

.rt-map-bin-label strong {
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.rt-map-bin-label span {
  opacity: 0.9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rt-map-bin-counts {
  display: flex;
  gap: 0.25rem;
  font-size: 0.65rem;
  font-family: var(--font-mono, ui-monospace, monospace);
  opacity: 0.9;
}

.rt-map-bin-handle {
  display: none;
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(0,0,0,0.25);
  cursor: nwse-resize;
}

.rt-map-design .rt-map-bin-handle {
  display: block;
}

.rt-map-bin-tools {
  display: none;
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 4;
  gap: 2px;
  flex-direction: row;
}
.rt-map-design .rt-map-bin-tools {
  display: flex;
}
.rt-map-bin-tool {
  appearance: none;
  width: 1.2rem;
  height: 1.2rem;
  border: 0;
  border-radius: 4px;
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--map-overlay);
  color: var(--fg);
  cursor: pointer;
  font-size: 0.62rem;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
  pointer-events: auto;
}
.rt-map-bin-tool:hover,
.rt-map-bin-tool:focus-visible {
  background: var(--bg-elevated);
  outline: none;
}
.rt-map-bin-del:hover,
.rt-map-bin-del:focus-visible {
  color: var(--danger);
}
.rt-map-bin-tool .bi {
  font-size: 0.7rem;
}

.rt-map-status {
  margin: 0 0 var(--space-3);
  font-size: var(--text-sm);
  color: var(--fg-muted);
}
.rt-map-status-error { color: var(--danger); }

.rt-bin-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.form-control-color {
  min-height: 44px;
  max-width: 5rem;
  padding: 0.25rem;
}



/* ── Storage polish (v2) ─────────────────────────────────────────── */
.rt-storage-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.rt-storage-header-main {
  min-width: 0;
  width: 100%;
}
.rt-storage-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
}
.rt-storage-header-row > .rt-lead,
.rt-storage-header-row > .rt-sub,
.rt-storage-header-row > .rt-location-card-meta {
  min-width: 0;
  flex: 1 1 12rem;
  margin-bottom: 0;
}
.rt-storage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  width: auto;
  flex: 0 1 auto;
  margin-left: auto;
  justify-content: flex-end;
}
.rt-storage-actions form {
  display: inline;
  margin: 0;
}

.rt-location-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.rt-meta-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  white-space: nowrap;
  font-size: 0.8rem;
  line-height: 1.2;
  color: var(--fg-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.22rem 0.65rem;
}
.rt-meta-chip .rt-mono {
  color: var(--fg);
  font-weight: 600;
}

.rt-map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
}
.rt-map-toolbar .btn:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Location photo strip (not giant 16:10 hero) */
.rt-loc-photos-strip {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: var(--space-2);
}
@media (max-width: 575.98px) {
  .rt-loc-photos-strip {
    grid-template-columns: 1fr 1fr;
  }
  .rt-loc-photo-primary {
    grid-column: 1 / -1;
  }
}
.rt-loc-photo {
  display: block;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
  aspect-ratio: 4 / 3;
}
.rt-loc-photo-primary {
  aspect-ratio: 16 / 10;
}
.rt-loc-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Room cards */
.rt-room-card-wrap {
  position: relative;
  height: 100%;
}
.rt-room-card-wrap > .rt-tile-edit {
  top: 0.55rem;
  right: 0.55rem;
}
.rt-room-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow);
  text-decoration: none !important;
  color: var(--fg) !important;
  transition: border-color var(--motion-quick) var(--ease-out),
              transform var(--motion-quick) var(--ease-out);
}
.rt-room-card:hover {
  border-color: color-mix(in oklab, var(--accent) 45%, var(--border));
  transform: translateY(-2px);
  color: var(--fg) !important;
}
.rt-room-card-map {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.rt-room-card-body {
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}
.rt-room-card-name {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-transform: none;
  line-height: 1.25;
}
.rt-mini-map-lg {
  height: 120px;
  border: 0;
  border-radius: 0;
}
.rt-mini-bin {
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.25);
}

.rt-unit-badge {
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-mono, ui-monospace, monospace);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg-muted);
  white-space: nowrap;
  letter-spacing: 0.02em;
  text-transform: none;
}

/* Map layout */
.rt-map-layout {
  display: grid;
  gap: var(--space-4);
}
@media (min-width: 992px) {
  .rt-map-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
    align-items: start;
  }
}
.rt-map-main {
  min-width: 0;
}
.rt-map-shell {
  width: 100%;
  max-width: 100%;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-strong);
  overflow: hidden;
  background: var(--map-surface);
  box-shadow: var(--shadow);
}
.rt-room-map {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--map-gutter);
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
.rt-map-floor {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.rt-map-compass {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  z-index: 11;
  width: 1.5rem;
  height: 1.5rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--map-chrome-border);
  background: var(--map-overlay);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--fg-muted);
  letter-spacing: 0.04em;
}
.rt-map-hint {
  margin: 0.65rem 0 0;
  font-size: var(--text-sm);
  color: var(--fg-muted);
}
.rt-map-status {
  margin: 0 0 var(--space-3);
  font-size: var(--text-sm);
  color: var(--fg-muted);
  min-height: 1.25em;
}
.rt-map-status-error { color: var(--danger); }

.rt-map-bin {
  position: absolute;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.22);
  background: var(--bin-color, #3d5a4c);
  box-shadow: 0 4px 14px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.12);
  color: var(--bin-label);
  padding: 0.35rem 0.45rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  cursor: pointer;
  min-width: 36px;
  min-height: 28px;
  z-index: 1;
}
.rt-map-design .rt-map-bin { cursor: grab; }
.rt-map-design .rt-map-bin.rt-bin-dragging {
  cursor: grabbing;
  z-index: 10;
  box-shadow: 0 10px 28px rgba(0,0,0,0.55);
  outline: 2px solid var(--accent);
}
.rt-map-bin.rt-bin-selected {
  outline: 2px solid var(--accent);
  z-index: 8;
}
.rt-map-bin-label {
  font-size: 0.68rem;
  line-height: 1.15;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  overflow: hidden;
  text-shadow: 0 1px 2px rgba(0,0,0,0.45);
}
.rt-map-bin-label strong {
  font-size: 0.82rem;
  letter-spacing: 0.03em;
}
.rt-map-bin-label span {
  opacity: 0.92;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rt-map-bin-counts {
  display: flex;
  gap: 0.3rem;
  font-size: 0.62rem;
  font-family: var(--font-mono, ui-monospace, monospace);
  opacity: 0.9;
}
.rt-map-bin-handle {
  display: none;
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(0,0,0,0.3);
  cursor: nwse-resize;
}
.rt-map-design .rt-map-bin-handle { display: block; }

.rt-map-bin[data-kind="table"] {
  border-radius: 2px 2px 10px 10px;
  box-shadow: 0 8px 16px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.18);
}
.rt-map-bin[data-kind="rack"] {
  border-radius: 3px;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.08) 0,
    rgba(255,255,255,0.08) 2px,
    transparent 2px,
    transparent calc(100% / var(--shelf-count, 4))
  );
  background-color: var(--bin-color, #4c5d6e);
}

.rt-mini-table { border-radius: 1px 1px 3px 3px; }
.rt-mini-rack {
  border-radius: 1px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25);
}

.rt-rack-stack {
  display: flex;
  flex-direction: column-reverse;
  gap: 0.85rem;
}
.rt-shelf-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  padding: 1rem 1.1rem 1.15rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  position: relative;
}
.rt-shelf-card::before {
  content: "";
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0;
  height: 6px;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(0,0,0,0.25));
}
.rt-shelf-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.rt-shelf-bins {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.5rem;
  margin-top: 0.65rem;
}
.rt-shelf-bin {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated, rgba(255,255,255,0.03));
  color: inherit;
  text-decoration: none;
}
.rt-shelf-bin:hover { border-color: var(--accent); }
.rt-shelf-bin-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

/* Sidebar bin list */
.rt-bin-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.rt-bin-list > li + li {
  border-top: 1px solid var(--border);
}
.rt-bin-list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  text-decoration: none !important;
  color: inherit !important;
}
.rt-bin-list-item:first-child { padding-top: 0; }
.rt-bin-list > li:last-child .rt-bin-list-item { padding-bottom: 0; }
.rt-bin-list-item:hover .rt-bin-list-name { color: var(--accent); }
.rt-bin-list-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  flex: 1;
}
.rt-bin-list-name {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--fg);
  text-transform: none;
}
.rt-bin-list-chevron {
  color: var(--fg-subtle);
  font-size: 0.85rem;
}
.rt-bin-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.15);
  flex-shrink: 0;
}
.rt-bin-swatch-lg {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 5px;
}

/* Content lists on bin page */
.rt-content-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.rt-content-list-item {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.rt-content-list-item:last-child { border-bottom: 0; }

.rt-content-list-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.rt-unstore {
  margin: 0;
}
.rt-unstore-icon {
  display: block;
  flex: 0 0 auto;
  width: 27px;
  height: 27px;
}
.rt-unstore .rt-icon-btn {
  width: 2.625rem;
  height: 2.625rem;
}

.form-control-color {
  min-height: 44px;
  max-width: 100%;
  padding: 0.35rem;
  width: 5rem;
}


/* ── Auth ─────────────────────────────────────────────────────────── */
.rt-auth-wrap {
  max-width: 28rem;
  margin: 0 auto;
}
.rt-auth-wrap-wide {
  max-width: 36rem;
}
.rt-auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--fg-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.rt-auth-divider::before,
.rt-auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.rt-oauth-stack {
  display: grid;
  gap: 0.55rem;
}
.btn-rt-oauth {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg) !important;
  font-weight: 600;
  text-decoration: none !important;
}
.btn-rt-oauth:hover {
  border-color: color-mix(in oklab, var(--accent) 40%, var(--border));
  background: var(--bg-elevated);
  color: var(--fg) !important;
}
.btn-rt-oauth.disabled,
.rt-oauth-disabled .btn-rt-oauth {
  opacity: 0.45;
  pointer-events: none;
}
.rt-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.2rem 0.55rem 0.2rem 0.2rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--fg) !important;
  text-decoration: none !important;
  font-size: 0.85rem;
  font-weight: 600;
}
.rt-user-avatar {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: color-mix(in oklab, var(--accent) 25%, var(--bg));
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.rt-user-name {
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ── QR shortlinks ──────────────────────────────────────────────── */
.rt-shortlink-card {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-4);
  margin: var(--space-4) 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}
.rt-shortlink-qr {
  flex: 0 0 auto;
  padding: 0.5rem;
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  line-height: 0;
}
.rt-shortlink-qr img {
  display: block;
  width: 140px;
  height: 140px;
  image-rendering: pixelated;
}
.rt-shortlink-body {
  flex: 1 1 14rem;
  min-width: 0;
}
.rt-shortlink-url {
  margin: 0 0 0.35rem;
  word-break: break-all;
}
.rt-shortlink-href {
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--accent) !important;
  text-decoration: none !important;
}
.rt-shortlink-href:hover {
  text-decoration: underline !important;
}
.rt-shortlink-copied {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
}
@media (max-width: 575.98px) {
  .rt-shortlink-card {
    flex-direction: column;
    align-items: flex-start;
  }
}

.rt-forgot {
  font-size: 0.85rem;
  white-space: nowrap;
}


/* ── Public landing hero ─────────────────────────────────────────── */
body.rt-body-landing main {
  padding: 0;
}

.rt-landing-hero {
  padding: clamp(2.5rem, 6vw, 5rem) 0 clamp(2rem, 4vw, 3.5rem);
}

.rt-landing-title {
  font-size: clamp(2.25rem, 1.6rem + 2.8vw, 3.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0;
  color: var(--fg);
}

.rt-landing-title-accent {
  color: var(--accent);
}

.rt-landing-lead {
  font-size: clamp(1.05rem, 1rem + 0.35vw, 1.2rem);
  color: var(--fg-muted);
  max-width: 36rem;
  line-height: 1.55;
  margin: 0;
}

.rt-landing-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.rt-landing-panel-chrome {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}

.rt-landing-panel-chrome span {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--border-strong);
}

.rt-landing-panel-chrome span:nth-child(1) { background: #e8a0a0; }
.rt-landing-panel-chrome span:nth-child(2) { background: #d4c48a; }
.rt-landing-panel-chrome span:nth-child(3) { background: var(--accent); }

.rt-landing-panel-chrome em {
  margin-left: auto;
  font-style: normal;
  font-size: 0.75rem;
  color: var(--fg-subtle);
  letter-spacing: 0.06em;
}

.rt-landing-panel-body {
  padding: 1.25rem 1.25rem 1.35rem;
}

.rt-landing-stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.rt-landing-stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-subtle);
  margin-bottom: 0.2rem;
}

.rt-landing-stat-value {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 650;
  color: var(--fg);
  letter-spacing: -0.02em;
}

.rt-landing-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.rt-landing-list li {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  font-size: 0.9rem;
  min-width: 0;
}

.rt-landing-list li .rt-mono {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rt-landing-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  flex: 0 0 auto;
}
.rt-dot-ok { background: var(--ok); }
.rt-dot-warn { background: var(--warn); }
.rt-dot-muted { background: var(--fg-subtle); }

.rt-landing-tag {
  flex: 0 0 auto;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius-xs);
  font-weight: 600;
}

.rt-landing-qr-hint {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-strong);
  color: var(--fg-muted);
  font-size: 0.9rem;
}

.rt-landing-features {
  padding: 0 0 clamp(2.5rem, 5vw, 4rem);
  scroll-margin-top: 5rem;
}

.rt-landing-card {
  padding: 1.25rem 1.3rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color var(--motion-fast) var(--ease-out), transform var(--motion-fast) var(--ease-out);
}

@media (hover: hover) {
  .rt-landing-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
  }
}

.rt-landing-icon {
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 1.2rem;
  margin-bottom: 0.85rem;
}

.rt-landing-card-title {
  font-size: 1.05rem;
  font-weight: 650;
  margin: 0 0 0.4rem;
  letter-spacing: -0.01em;
}

.rt-landing-cta {
  padding: 0 0 clamp(3rem, 6vw, 5rem);
}

.rt-landing-cta-panel {
  padding: clamp(1.5rem, 3vw, 2.25rem);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background:
    linear-gradient(135deg, rgba(143, 214, 168, 0.08), transparent 55%),
    var(--bg-elevated);
  box-shadow: var(--shadow);
}

.rt-landing-cta-title {
  font-size: clamp(1.35rem, 1.15rem + 0.8vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

@media (max-width: 575.98px) {
  .rt-landing-stat-value {
    font-size: 1.1rem;
  }
  .rt-landing-list li {
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rt-landing-card {
    transition: none;
  }
  .rt-landing-card:hover {
    transform: none;
  }
}


/* ── MFA / passkeys ──────────────────────────────────────────────── */
.rt-totp-setup {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
  align-items: flex-start;
}
.rt-totp-qr {
  flex: 0 0 auto;
  padding: 0.75rem;
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  line-height: 0;
}
.rt-totp-qr img {
  display: block;
  width: 200px;
  height: 200px;
}
.rt-totp-secret {
  font-size: 1rem;
  letter-spacing: 0.08em;
  word-break: break-all;
  color: var(--accent);
  margin: 0;
}
.rt-recovery-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: 0.5rem 1rem;
}
.rt-recovery-list li {
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  letter-spacing: 0.04em;
}
.rt-flash-ok {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(143, 214, 168, 0.25);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
}


/* ── Profile avatars ─────────────────────────────────────────────── */
.rt-user-avatar {
  overflow: hidden;
  position: relative;
}
.rt-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 999px;
}
.rt-profile-head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: center;
}
.rt-profile-avatar-lg {
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 999px;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 0;
  background: color-mix(in oklab, var(--accent) 22%, var(--bg));
  color: var(--accent);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  flex: 0 0 auto;
  cursor: pointer;
  appearance: none;
  font-family: inherit;
}
.rt-profile-avatar-lg:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.rt-profile-avatar-title {
  width: 4.5rem;
  height: 4.5rem;
  font-size: 1.15rem;
}
.rt-profile-avatar-lg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.rt-profile-head-meta {
  flex: 1 1 12rem;
  min-width: 0;
}
.rt-divider {
  border: 0;
  border-top: 1px solid var(--border);
  opacity: 1;
}
.rt-avatar-picker .rt-photo-actions {
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 575.98px) {
  .rt-avatar-picker .rt-photo-actions {
    grid-template-columns: 1fr;
  }
}


/* ── Theme toggle ────────────────────────────────────────────────── */
.rt-theme-toggle,
.rt-find-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 999px;
  flex: 0 0 auto;
}
.rt-theme-toggle .rt-theme-icon,
.rt-find-toggle i {
  font-size: 1.05rem;
  line-height: 1;
}
.rt-theme-toggle .rt-theme-icon-sun { display: none; }
.rt-theme-toggle .rt-theme-icon-moon { display: none; }
.rt-theme-toggle .rt-theme-icon-auto { display: none; }
html[data-theme-pref="light"] .rt-theme-toggle .rt-theme-icon-sun { display: inline; }
html[data-theme-pref="dark"] .rt-theme-toggle .rt-theme-icon-moon { display: inline; }
html[data-theme-pref="system"] .rt-theme-toggle .rt-theme-icon-auto { display: inline; }

html[data-theme="light"] .rt-nav .navbar-toggler-icon {
  filter: none;
}
html[data-theme="dark"] .rt-nav .navbar-toggler-icon {
  filter: none;
}

html[data-theme="light"] .rt-landing-title-accent {
  color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  body.rt-body {
    transition: none;
  }
}

/* ── Admin / users ───────────────────────────────────────────────── */
.rt-crumb {
  color: inherit;
  text-decoration: none;
}
.rt-crumb:hover,
.rt-crumb:focus-visible {
  color: var(--accent);
  text-decoration: underline;
}

.rt-badge-admin {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: color-mix(in oklab, var(--accent) 38%, transparent);
}
.rt-badge-member {
  background: var(--bg-subtle);
  color: var(--fg-muted);
  border-color: var(--border-strong);
}

.rt-user-list-thumb {
  border-radius: 999px;
}
.rt-user-initials {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: color-mix(in oklab, var(--accent) 18%, var(--bg-subtle));
}

.rt-stat-list {
  display: grid;
  gap: 0;
  margin: 0;
}
.rt-stat-list > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}
.rt-stat-list > div:first-child {
  padding-top: 0;
}
.rt-stat-list > div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.rt-stat-list dt {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--fg-muted);
  font-weight: 500;
}
.rt-stat-list dd {
  margin: 0;
  color: var(--fg);
  font-weight: 600;
}

.rt-meta-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.rt-meta-list li {
  padding: 0.4rem 0;
  color: var(--fg);
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border);
}
.rt-meta-list li:first-child {
  padding-top: 0;
}
.rt-meta-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.rt-panel-danger {
  border-color: color-mix(in oklab, var(--danger) 42%, var(--border));
  background: color-mix(in oklab, var(--danger-bg) 80%, var(--bg-elevated));
}

.rt-admin-form {
  max-width: 32rem;
}

html[data-theme="light"] .btn-rt-danger {
  color: var(--danger);
  border-color: color-mix(in oklab, var(--danger) 38%, var(--border));
}
html[data-theme="light"] .btn-rt-danger:hover,
html[data-theme="light"] .btn-rt-danger:focus-visible {
  color: var(--danger);
}

html[data-theme="light"] .btn-rt-success {
  color: var(--ok);
  border-color: color-mix(in oklab, var(--ok) 40%, var(--border));
}

/* ── Invites / admin tabs ────────────────────────────────────────── */
.rt-admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0 0 1.35rem;
  padding: 0.25rem;
  width: fit-content;
  max-width: 100%;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.rt-admin-tab {
  display: inline-flex;
  align-items: center;
  min-height: 2.4rem;
  padding: 0.35rem 1rem;
  border-radius: 999px;
  color: var(--fg-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
}
.rt-admin-tab:hover,
.rt-admin-tab:focus-visible {
  color: var(--fg);
  background: color-mix(in oklab, var(--bg-elevated) 70%, transparent);
}
.rt-admin-tab.is-active {
  color: var(--fg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

.rt-invite-chip {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.85rem;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.rt-invite-url {
  word-break: break-all;
  margin: 0;
}

.rt-expiry-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.rt-choice {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.4rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-subtle);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--fg);
}
.rt-choice input {
  margin: 0;
  accent-color: var(--accent);
}
.rt-choice:has(input:checked) {
  border-color: color-mix(in oklab, var(--accent) 50%, var(--border));
  background: var(--accent-dim);
  color: var(--accent);
}

.rt-empty-title {
  color: var(--fg);
  font-weight: 600;
  font-size: var(--text-base);
}

.rt-feedback-body {
  white-space: pre-wrap;
  line-height: var(--leading-normal);
  color: var(--fg);
}

.rt-thread {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
}
.rt-thread-item {
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
}
.rt-thread-item.is-admin {
  border-color: color-mix(in oklab, var(--accent) 40%, var(--border));
  background: var(--accent-dim);
}
.rt-thread-item.is-report {
  background: var(--bg-elevated);
}
.rt-thread-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.7rem;
  margin-bottom: 0.55rem;
}
.rt-thread-author {
  font-weight: 600;
  color: var(--fg);
}

.rt-updates-wrap {
  width: 100%;
}
.rt-update-post,
.rt-legal {
  max-width: 48rem;
}
.rt-update-roll {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-4);
}
@media (min-width: 992px) {
  .rt-update-roll {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5);
  }
}
.rt-update-card {
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}
.rt-update-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  color: var(--fg-muted);
  font-size: var(--text-sm);
  margin-bottom: 0.35rem;
}
.rt-update-card-title {
  font-size: var(--text-lg);
  font-weight: 650;
  margin: 0 0 0.35rem;
  letter-spacing: -0.02em;
}
.rt-update-card-title a {
  color: var(--fg);
  text-decoration: none;
}
.rt-update-card-title a:hover {
  color: var(--accent);
}

.rt-prose {
  color: var(--fg);
  line-height: 1.65;
  font-size: var(--text-base);
}
.rt-prose > *:first-child {
  margin-top: 0;
}
.rt-prose > *:last-child {
  margin-bottom: 0;
}
.rt-prose h1,
.rt-prose h2,
.rt-prose h3 {
  color: var(--fg);
  letter-spacing: -0.02em;
  margin: 1.6rem 0 0.6rem;
}
.rt-prose h2 {
  font-size: var(--text-lg);
}
.rt-prose h3 {
  font-size: var(--text-base);
}
.rt-prose p,
.rt-prose ul,
.rt-prose ol,
.rt-prose blockquote {
  margin: 0 0 1rem;
}
.rt-prose ul,
.rt-prose ol {
  padding-left: 1.25rem;
}
.rt-prose a {
  color: var(--accent);
}
.rt-prose code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-subtle);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-xs);
}
.rt-prose-pre {
  margin: 0 0 1rem;
  padding: var(--space-3);
  overflow-x: auto;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.rt-prose-pre code {
  background: none;
  padding: 0;
}
.rt-prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}
.rt-prose blockquote {
  margin-left: 0;
  padding: 0.15rem 0 0.15rem 0.9rem;
  border-left: 3px solid var(--accent);
  color: var(--fg-muted);
}

.btn-rt-ghost.is-active {
  background: var(--accent-dim);
  color: var(--fg);
}

a, button, .btn, .nav-link, .navbar-toggler, summary, [role="button"] {
  touch-action: manipulation;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.rt-offline {
  max-width: 32rem;
  padding: var(--space-5) var(--space-4);
}
.rt-offline-mark {
  display: block;
  width: 160px;
  height: 160px;
  margin: 0 auto var(--space-4);
  border-radius: 24px;
  background: #000;
}

.rt-error {
  max-width: 34rem;
  padding: var(--space-5) var(--space-4);
}
.rt-error-code {
  font-size: clamp(4.5rem, 3rem + 8vw, 7.5rem);
  font-weight: 650;
  letter-spacing: -0.06em;
  line-height: 0.9;
  color: var(--accent);
  margin: 0 0 var(--space-3);
  text-shadow: 0 0 32px var(--glow-a);
}
.rt-error-ref {
  text-align: left;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin: 0 auto var(--space-4);
}
.rt-error-hash {
  font-size: 0.85rem;
  word-break: break-all;
  color: var(--fg);
  margin: 0 0 var(--space-2);
  user-select: all;
}

.rt-horde-switch {
  min-width: 10rem;
}
.rt-horde-select {
  background: var(--bg-elevated);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  max-width: 14rem;
}
.rt-horde-chip {
  color: var(--fg-muted);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rt-horde-chip:hover {
  color: var(--fg);
}
.rt-machine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.rt-machine-card {
  display: block;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  color: inherit;
  text-decoration: none;
}
.rt-machine-card:hover {
  border-color: var(--border-strong);
}
.rt-machine-card-photo {
  aspect-ratio: 4/3;
  background: var(--bg-subtle);
}
.rt-machine-card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.rt-machine-card-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--fg-muted);
  font-size: 2.4rem;
  opacity: 0.4;
}
.rt-machine-card-body {
  padding: 0.85rem 1rem 1rem;
}
.rt-machine-card-title {
  font-size: 1.05rem;
  margin: 0 0 0.2rem;
}

/* Software library shelf — boxes standing on end */
.rt-soft-shelf-wrap {
  margin-top: 0.25rem;
}

.rt-soft-shelf {
  --shelf-h: 210;
  --shelf-head: 3.25rem;
  background: linear-gradient(180deg, var(--bg-subtle) 0%, var(--bg-elevated) 72%, var(--bg) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 1rem 0;
  overflow-x: auto;
  overflow-y: clip;
}

.rt-soft-shelf-row {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  box-sizing: border-box;
  height: calc(var(--shelf-h) * 1px + var(--shelf-head));
  padding: var(--shelf-head) 0.5rem 0;
  perspective: 900px;
  perspective-origin: 50% 100%;
  isolation: isolate;
}

.rt-soft-shelf-plank {
  height: 10px;
  margin: 0 -1rem;
  background: linear-gradient(180deg, var(--border-strong), var(--bg-subtle));
  border-top: 1px solid var(--border);
}

.rt-soft-box {
  --box-h: 200;
  --box-d: 28;
  --box-w: 140;
  --spine-h: 140;
  --fit: min(1, calc(var(--shelf-h) / var(--box-h)));
  --h: calc(var(--box-h) * var(--fit) * 1px);
  --d: calc(var(--box-d) * var(--fit) * 1px);
  --w: calc(var(--box-w) * var(--fit) * 1px);
  position: relative;
  flex: 0 0 var(--d);
  align-self: flex-end;
  margin-top: auto;
  margin-bottom: -4px;
  width: var(--d);
  height: var(--h);
  max-height: calc(var(--shelf-h) * 1px);
  text-decoration: none;
  color: inherit;
  transform: scale(1);
  transform-origin: center bottom;
  transition:
    transform var(--motion-fast) var(--ease-out),
    flex-basis 0.45s var(--ease-out),
    width 0.45s var(--ease-out);
  z-index: 0;
}

.rt-soft-box.is-open {
  flex-basis: var(--w);
  width: var(--w);
  z-index: 4;
  transform: none;
}

.rt-soft-box:hover:not(.is-open),
.rt-soft-box:focus-visible:not(.is-open) {
  transform: scale(1.12);
  z-index: 2;
  outline: none;
}

.rt-soft-box.is-open:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.rt-soft-box-stage {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: var(--h);
  perspective: 700px;
  perspective-origin: 50% 100%;
  transform-style: preserve-3d;
}

.rt-soft-box-cube {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: var(--w);
  height: var(--h);
  transform-origin: center bottom;
  transform-style: preserve-3d;
  transform: translateX(-50%) rotateY(90deg);
  transition: transform 0.45s var(--ease-out);
}

.rt-soft-box.is-open .rt-soft-box-cube {
  transform: translateX(-50%) translateY(-4px) rotateY(-12deg);
}

.rt-soft-box-face {
  position: absolute;
  left: 50%;
  top: 50%;
  overflow: hidden;
  backface-visibility: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.28);
  background: hsl(var(--spine-h), 26%, 22%);
  color: #f3efe6;
}

.rt-soft-box-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rt-soft-box-face.is-front {
  width: var(--w);
  height: var(--h);
  transform: translate(-50%, -50%) translateZ(calc(var(--d) / 2));
  background: hsl(var(--spine-h), 28%, 24%);
}

.rt-soft-box-face.is-spine {
  width: var(--d);
  height: var(--h);
  transform: translate(-50%, -50%) rotateY(-90deg) translateZ(calc(var(--w) / 2));
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.28), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.22)),
    hsl(var(--spine-h), 32%, 28%);
}

.rt-soft-box-face.is-right {
  width: var(--d);
  height: var(--h);
  transform: translate(-50%, -50%) rotateY(90deg) translateZ(calc(var(--w) / 2));
  background: hsl(var(--spine-h), 24%, 18%);
}

.rt-soft-box-face.is-top {
  width: var(--w);
  height: var(--d);
  transform: translate(-50%, -50%) rotateX(90deg) translateZ(calc(var(--h) / 2));
  background: hsl(var(--spine-h), 18%, 34%);
}

.rt-soft-box-spine {
  display: block;
}

.rt-soft-box-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 0.4rem 0;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-size: clamp(0.4rem, calc(var(--d) * 0.4), 0.78rem);
  font-weight: 650;
  letter-spacing: clamp(0.01em, calc(var(--d) * 0.002), 0.08em);
  line-height: 1;
  text-align: center;
  overflow: hidden;
}

.rt-soft-box-cover-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 0.45rem 0.4rem;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.rt-soft-viewer {
  position: relative;
  height: min(420px, 62vw);
  min-height: 280px;
  touch-action: none;
  overflow: hidden;
  background: linear-gradient(180deg, var(--bg-subtle), var(--bg));
  border-radius: var(--radius-sm);
  cursor: grab;
  perspective: 1100px;
  user-select: none;
}

.rt-soft-viewer.is-grabbing {
  cursor: grabbing;
}

.rt-soft-viewer:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.rt-soft-viewer-world {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-style: preserve-3d;
}

.rt-soft-viewer-cube {
  position: relative;
  width: var(--box-w);
  height: var(--box-h);
  transform-style: preserve-3d;
  transform: rotateX(-12deg) rotateY(-28deg);
}

.rt-soft-viewer-face {
  position: absolute;
  left: 50%;
  top: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  backface-visibility: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3);
  background: hsl(var(--spine-h), 26%, 22%);
  color: #f3efe6;
}

.rt-soft-viewer-face.is-picked {
  box-shadow: inset 0 0 0 2px var(--accent), 0 0 12px color-mix(in oklab, var(--accent) 45%, transparent);
}

.rt-soft-viewer-face.is-front {
  width: var(--box-w);
  height: var(--box-h);
  transform: translate(-50%, -50%) translateZ(calc(var(--box-d) / 2));
}

.rt-soft-viewer-face.is-back {
  width: var(--box-w);
  height: var(--box-h);
  transform: translate(-50%, -50%) rotateY(180deg) translateZ(calc(var(--box-d) / 2));
  background: hsl(var(--spine-h), 22%, 16%);
}

.rt-soft-viewer-face.is-left,
.rt-soft-viewer-face.is-right {
  width: var(--box-d);
  height: var(--box-h);
}

.rt-soft-viewer-face.is-left {
  transform: translate(-50%, -50%) rotateY(-90deg) translateZ(calc(var(--box-w) / 2));
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.28), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.22)),
    hsl(var(--spine-h), 32%, 28%);
}

.rt-soft-viewer-face.is-right {
  transform: translate(-50%, -50%) rotateY(90deg) translateZ(calc(var(--box-w) / 2));
  background: hsl(var(--spine-h), 24%, 20%);
}

.rt-soft-viewer-face.is-top,
.rt-soft-viewer-face.is-bottom {
  width: var(--box-w);
  height: var(--box-d);
}

.rt-soft-viewer-face.is-top {
  transform: translate(-50%, -50%) rotateX(90deg) translateZ(calc(var(--box-h) / 2));
  background: hsl(var(--spine-h), 18%, 34%);
}

.rt-soft-viewer-face.is-bottom {
  transform: translate(-50%, -50%) rotateX(-90deg) translateZ(calc(var(--box-h) / 2));
  background: hsl(var(--spine-h), 16%, 12%);
}

.rt-soft-viewer-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.75rem;
  text-align: center;
  font-weight: 700;
  line-height: 1.15;
}

.rt-soft-viewer-title small {
  font-weight: 500;
  font-size: 0.75rem;
  opacity: 0.8;
}

.rt-soft-viewer-spine-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 0.45rem 0.05rem;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.08em;
}

.rt-soft-viewer-ui {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  pointer-events: none;
}

.rt-soft-viewer-hint {
  font-size: var(--text-xs);
  color: var(--fg-muted);
}

.rt-soft-viewer-ui .btn {
  pointer-events: auto;
  min-height: 36px;
}

.rt-soft-faces {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.rt-soft-photo-strip {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.15rem;
}

.rt-soft-photo-strip .rt-soft-face {
  flex: 0 0 132px;
}

.rt-soft-face-label,
.rt-soft-face .form-label {
  margin-bottom: 0.4rem;
}

.rt-soft-face-empty {
  aspect-ratio: 3 / 4;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--fg-subtle);
  font-size: var(--text-xs);
  background: var(--bg);
}

@media (max-width: 575.98px) {
  .rt-soft-faces {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rt-soft-box,
  .rt-soft-box:hover,
  .rt-soft-box:focus-visible,
  .rt-soft-box-cube {
    transition: none;
  }
}

html[data-theme="light"] .rt-soft-box-face.is-spine {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.16), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.12)),
    hsl(var(--spine-h), 28%, 42%);
  color: #fffaf0;
}

html[data-theme="light"] .rt-soft-box-face.is-front,
html[data-theme="light"] .rt-soft-box-cover-label {
  color: #fffaf0;
}

html[data-theme="light"] .rt-soft-viewer-face.is-left {
  color: #fffaf0;
}

.rt-form-modal {
  position: fixed;
  inset: 0;
  z-index: 1070;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 4vh 1rem 1.25rem;
}
.rt-form-modal.is-open {
  display: flex;
}
.rt-form-modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.rt-form-modal-card {
  position: relative;
  width: min(52rem, 100%);
  max-height: 92vh;
  overflow: auto;
  padding: 1.15rem 1.2rem 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
}
.rt-form-modal .rt-machine-gallery {
  margin: 0;
}
body.rt-form-modal-open {
  overflow: hidden;
}

.rt-store-modal {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 1rem 1rem;
}

.rt-store-modal.is-open {
  display: flex;
}

.rt-store-modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.rt-store-modal-card {
  position: relative;
  width: min(32rem, 100%);
  max-height: 72vh;
  overflow: auto;
  padding: 1.15rem 1.2rem 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
}

.rt-store-picks {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.rt-store-pick {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: inherit;
}

.rt-store-pick:hover,
.rt-store-pick.is-active {
  border-color: var(--accent);
  background: var(--bg-subtle);
}

.rt-store-pick:disabled,
.rt-store-pick.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.rt-store-pick:disabled:hover,
.rt-store-pick.is-disabled:hover,
.rt-store-pick.is-disabled.is-active {
  border-color: var(--border);
  background: var(--bg);
}

.rt-store-pick-name {
  font-weight: 650;
}

.rt-choose {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
  min-width: 0;
  max-width: 100%;
}
.rt-choose-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 44px;
  padding: 0.55rem 0.85rem;
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--fg);
  border-radius: var(--radius-sm);
}
.rt-choose-btn:hover,
.rt-choose-btn:focus-visible {
  border-color: color-mix(in oklab, var(--accent) 55%, var(--border-strong));
}
.rt-choose-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.rt-choose-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rt-choose-placeholder {
  color: var(--fg-subtle);
}
.rt-choose-btn-inline {
  flex: 1 1 14rem;
  max-width: 22rem;
}
.rt-choose-clear {
  min-width: 44px;
  min-height: 44px;
  flex-shrink: 0;
}

body.rt-store-open,
body.rt-install-open,
body.rt-cat-delete-open,
body.rt-tag-delete-open,
body.rt-perm-open {
  overflow: hidden;
}

.rt-store-results {
  min-height: 8rem;
}

.rt-store-pick-check {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.7rem;
  cursor: pointer;
}

.rt-store-pick-cb {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0.22rem 0 0;
  padding: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.rt-store-pick-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  min-width: 0;
}

.rt-store-pick-check.is-checked {
  border-color: var(--accent);
  background: var(--bg-subtle);
}

.rt-search-ops code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--fg);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 0.05em 0.35em;
}

.rt-store-multi {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.rt-store-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 8rem;
  padding: 1.5rem 1rem;
}

.rt-spinner {
  width: 1.85rem;
  height: 1.85rem;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: rt-spin 0.7s linear infinite;
}

.rt-spinner-sm {
  width: 1.1rem;
  height: 1.1rem;
  border-width: 2px;
  flex-shrink: 0;
}

.rt-export-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.rt-export-form {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.htmx-indicator {
  opacity: 0;
  transition: opacity 0.12s ease;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

.rt-store-loading-label {
  font-size: var(--text-sm);
  color: var(--fg-subtle);
}

@keyframes rt-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .rt-spinner {
    animation: none;
  }
  .rt-bar-fill.is-pole {
    animation: none;
  }
}

.rt-store-scan-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.rt-store-scan {
  margin-top: 0.85rem;
}

.rt-store-scan-frame {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #111;
}

.rt-store-scan-frame::after {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 12px;
  border: 2px solid rgba(143, 214, 168, 0.55);
  border-radius: 4px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.18);
}

.rt-store-scan video {
  display: block;
  width: 100%;
  max-height: 16rem;
  object-fit: cover;
  background: #111;
}

.rt-store-add {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
}
.rt-store-add-btns {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.rt-store-add-icon {
  display: block;
  flex: 0 0 auto;
  width: 27px;
  height: 27px;
}
.rt-store-add .rt-icon-btn {
  width: 2.625rem;
  height: 2.625rem;
}
.rt-store-create-toggle .bi {
  font-size: 1.45rem;
}
.rt-store-add-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  min-width: 9.5rem;
  padding: 4px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.rt-store-add-menu[hidden] {
  display: none !important;
}
.rt-store-add-menu button,
.rt-store-add-menu a {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--fg);
  text-align: left;
  padding: 0.42rem 0.7rem;
  border-radius: 7px;
  font-size: 0.82rem;
  line-height: 1.2;
  cursor: pointer;
  font-family: var(--font-sans);
  text-decoration: none;
  display: block;
}
.rt-store-add-menu button:hover,
.rt-store-add-menu button:focus-visible,
.rt-store-add-menu a:hover,
.rt-store-add-menu a:focus-visible {
  background: var(--bg-subtle);
  outline: none;
  color: var(--fg);
}

body.rt-crop-open {
  overflow: hidden;
}

.rt-crop-modal {
  position: fixed;
  inset: 0;
  z-index: 1090;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 4vh 1rem 1rem;
}

.rt-crop-modal.is-open {
  display: flex;
}

.rt-crop-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
}

.rt-crop-card {
  position: relative;
  width: min(40rem, 100%);
  max-height: 92vh;
  overflow: auto;
  padding: 1rem 1.1rem 1.15rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.4);
}

.rt-crop-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.rt-crop-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 650;
}

.rt-crop-hint {
  margin: 0 0 0.75rem;
  font-size: var(--text-sm);
  color: var(--fg-muted);
}

.rt-crop-stage {
  position: relative;
  width: 100%;
  height: min(58vh, 28rem);
  background: color-mix(in oklab, var(--bg) 70%, #000);
  border-radius: var(--radius-sm);
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.rt-crop-img {
  position: absolute;
  display: block;
  max-width: none;
  pointer-events: none;
}

.rt-crop-rect {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
  cursor: move;
  touch-action: none;
}

.rt-crop-rect.is-circle {
  border-radius: 50%;
}

.rt-crop-rect.is-circle [data-rt-crop-handle="n"],
.rt-crop-rect.is-circle [data-rt-crop-handle="s"],
.rt-crop-rect.is-circle [data-rt-crop-handle="e"],
.rt-crop-rect.is-circle [data-rt-crop-handle="w"] {
  display: none;
}

.rt-crop-rect span {
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border: 2px solid var(--bg-elevated);
  border-radius: 2px;
  box-sizing: border-box;
}

.rt-crop-rect [data-rt-crop-handle="nw"] { left: -7px; top: -7px; cursor: nwse-resize; }
.rt-crop-rect [data-rt-crop-handle="n"]  { left: 50%; top: -7px; margin-left: -7px; cursor: ns-resize; }
.rt-crop-rect [data-rt-crop-handle="ne"] { right: -7px; top: -7px; cursor: nesw-resize; }
.rt-crop-rect [data-rt-crop-handle="w"]  { left: -7px; top: 50%; margin-top: -7px; cursor: ew-resize; }
.rt-crop-rect [data-rt-crop-handle="e"]  { right: -7px; top: 50%; margin-top: -7px; cursor: ew-resize; }
.rt-crop-rect [data-rt-crop-handle="sw"] { left: -7px; bottom: -7px; cursor: nesw-resize; }
.rt-crop-rect [data-rt-crop-handle="s"]  { left: 50%; bottom: -7px; margin-left: -7px; cursor: ns-resize; }
.rt-crop-rect [data-rt-crop-handle="se"] { right: -7px; bottom: -7px; cursor: nwse-resize; }

.rt-crop-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.rt-icon-btn {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.rt-section-add {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.rt-section-add > :first-child {
  min-width: 0;
  flex: 1 1 auto;
}

.rt-section-add .rt-icon-btn {
  flex: 0 0 auto;
  margin-left: auto;
  align-self: flex-start;
}

.rt-icon-btn .bi {
  font-size: 1.2rem;
  line-height: 1;
}

.rt-crop-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.65rem;
}

.rt-pending-photo-crop {
  width: 100%;
}

body.rt-photo-view-open {
  overflow: hidden;
}

.rt-photo-view {
  position: fixed;
  inset: 0;
  z-index: 1085;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 3vh 0.75rem 1rem;
}

.rt-photo-view.is-open {
  display: flex;
}

.rt-photo-view-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.rt-photo-view-card {
  position: relative;
  width: min(44rem, 100%);
  max-height: 94vh;
  overflow: auto;
  padding: 0.9rem 1rem 1.1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

.rt-photo-view-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.rt-photo-view-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rt-photo-view-stage {
  position: relative;
  width: 100%;
  height: min(58vh, 28rem);
  background: color-mix(in oklab, var(--bg) 55%, #000);
  border-radius: var(--radius-sm);
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  user-select: none;
}

.rt-photo-view-img {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  transform-origin: 0 0;
  pointer-events: none;
}

.rt-photo-view-hint {
  margin: 0.45rem 0 0.7rem;
  font-size: var(--text-xs);
  color: var(--fg-muted);
}

.rt-photo-view-face {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.rt-photo-view-face .form-label {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--fg-muted);
}

.rt-photo-view-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.rt-photo-view-tools [data-rt-pv-save] {
  margin-left: auto;
}

.rt-upload-progress {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.rt-upload-progress.is-open {
  display: flex;
}

.rt-upload-progress-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.rt-upload-progress-card {
  position: relative;
  width: min(22rem, 100%);
  padding: 1.15rem 1.25rem 1.2rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

.rt-upload-progress-title {
  margin: 0 0 0.85rem;
  font-size: var(--text-lg);
  font-weight: 650;
}

.rt-upload-progress-track {
  height: 0.7rem;
  border-radius: 999px;
  background: var(--bg-subtle);
  overflow: hidden;
}

.rt-upload-progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.12s linear;
}

.rt-upload-progress-label {
  margin: 0.55rem 0 0;
  font-size: var(--text-sm);
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

.rt-crop-modal.is-busy .rt-crop-actions .btn,
.rt-crop-modal.is-busy .rt-crop-tools .btn,
.rt-crop-modal.is-busy [data-rt-crop-cancel] {
  pointer-events: none;
  opacity: 0.6;
}

.rt-perm-label {
  margin-top: 0.2rem;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent);
}

.rt-perm-modal-card {
  width: min(42rem, 100%);
  max-height: 82vh;
}

.rt-perm-groups {
  display: grid;
  gap: 0.75rem;
}

.rt-perm-group {
  margin: 0;
  padding: 0.85rem 0.95rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: color-mix(in oklab, var(--bg) 70%, var(--bg-elevated));
  min-width: 0;
}

.rt-perm-group-legend {
  float: left;
  width: 100%;
  padding: 0;
  margin: 0 0 0.2rem;
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1.35;
}

.rt-perm-group-legend + * {
  clear: both;
}

.rt-perm-group > .rt-sub {
  margin: 0 0 0.55rem;
  padding-left: calc(1.1rem + 0.55rem);
}

.rt-perm-grant-all,
.rt-perm-item {
  display: grid;
  grid-template-columns: 1.1rem minmax(0, 1fr);
  column-gap: 0.55rem;
  align-items: start;
  margin: 0;
  font-weight: 600;
  cursor: pointer;
}

.rt-perm-item {
  font-weight: 500;
}

.rt-perm-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.4rem;
}

.rt-perm-list li {
  margin: 0;
  padding: 0;
}

.rt-perm-grant-all input,
.rt-perm-item input {
  grid-column: 1;
  width: 1.1rem;
  height: 1.1rem;
  margin: 0.18rem 0 0;
  padding: 0;
  flex: none;
  justify-self: center;
  accent-color: var(--accent);
}

@media (min-width: 720px) {
  .rt-perm-groups {
    grid-template-columns: 1fr 1fr;
  }
  .rt-perm-group[data-rt-perm-group="storage"] {
    grid-column: 1 / -1;
  }
}

.rt-file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.rt-file-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.15rem;
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
}

.rt-file-item:last-child {
  border-bottom: 0;
}

.rt-file-icon {
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--accent);
  font-size: 1rem;
}

.rt-file-form-row {
  display: grid;
  gap: 0.5rem;
}

@media (min-width: 720px) {
  .rt-file-form-row {
    grid-template-columns: minmax(8rem, 0.7fr) minmax(12rem, 1.4fr) auto;
    align-items: center;
  }
}












