:root {
  --bg: #090f1f;
  --bg-2: #121f3e;
  --panel: rgba(16, 24, 45, 0.72);
  --text: #eef4ff;
  --muted: #9db1d8;
  --border: rgba(160, 196, 255, 0.2);
  --accent: #52c7ff;
  --accent-2: #8f7dff;
  --danger: #ff4b81;
  --warn: #ffb238;
  --success: #30d7a1;
  --shadow: 0 14px 36px rgba(5, 10, 24, 0.45);
  --hot-pink: #ff3da8;
  --electric: #00d1ff;
  --lime: #9eff5a;
  --pastel-pink: #ff8ecb;
  --pastel-cyan: #8be9ff;
  --pastel-lilac: #b9a7ff;
}

body.light {
  --bg: #e3e9f5;
  --bg-2: #d6dfef;
  --panel: rgba(248, 251, 255, 0.86);
  --text: #1a2a4d;
  --muted: #506892;
  --border: rgba(40, 71, 123, 0.14);
  --accent: #007be8;
  --accent-2: #6952ff;
  --danger: #e63f67;
  --warn: #ff9d1d;
  --success: #00a976;
  --shadow: 0 14px 30px rgba(55, 83, 141, 0.16);
}

body.live-danger {
  background: radial-gradient(circle at 18% 8%, #a70f3a 0%, #3b071b 40%), linear-gradient(130deg, #3b071b, #5a0e2a);
  animation: dangerFlashDark .62s infinite ease-in-out;
}

body.light.live-danger {
  background: linear-gradient(180deg, #ffb7c7, #ff9fb4);
  animation: dangerFlashLight .62s infinite ease-in-out;
}

body.live-danger::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: repeating-linear-gradient(
    120deg,
    rgba(255, 40, 80, 0.08) 0,
    rgba(255, 40, 80, 0.08) 24px,
    rgba(255, 120, 80, 0.03) 24px,
    rgba(255, 120, 80, 0.03) 48px
  );
  animation: dangerStripeMove .9s linear infinite;
}

body.live-danger .app-shell,
body.live-danger .content {
  position: relative;
  z-index: 1;
}

body.live-danger .topbar {
  background-image: linear-gradient(110deg, rgba(255, 45, 97, 0.34), rgba(255, 85, 100, 0.3), rgba(255, 30, 70, 0.34));
  animation: dangerPulseGlow .62s infinite ease-in-out;
}

body.live-danger .glass {
  border-color: color-mix(in oklab, var(--danger) 78%, var(--border));
  box-shadow: 0 0 0 1px rgba(255, 65, 95, 0.25), 0 16px 36px rgba(115, 10, 35, 0.45);
}

body.light.live-danger .glass {
  border-color: rgba(220, 40, 80, 0.55);
  box-shadow: 0 0 0 2px rgba(230, 20, 70, 0.22), 0 16px 30px rgba(180, 30, 70, 0.22);
}

body.live-danger .status-chip.is-danger,
body.live-danger .badge.flying {
  animation: dangerPulseBadge .62s infinite ease-in-out;
}

body.live-danger .bg-glow {
  background:
    radial-gradient(ellipse at 76% 10%, rgba(255, 45, 97, 0.35), transparent 42%),
    radial-gradient(ellipse at 12% 80%, rgba(255, 90, 70, 0.26), transparent 38%);
}

@keyframes dangerFlashDark {
  0%, 100% {
    filter: saturate(1.05) brightness(1);
  }
  50% {
    filter: saturate(1.42) brightness(1.15);
  }
}

@keyframes dangerFlashLight {
  0%, 100% {
    filter: saturate(1.06) brightness(1);
  }
  50% {
    filter: saturate(1.48) brightness(0.88);
  }
}

@keyframes dangerPulseGlow {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(255, 70, 100, 0.2);
  }
  50% {
    box-shadow: 0 0 0 2px rgba(255, 70, 100, 0.35), 0 0 26px rgba(255, 60, 90, 0.45);
  }
}

@keyframes dangerPulseBadge {
  0%, 100% {
    transform: translateY(0);
    filter: saturate(1);
  }
  50% {
    transform: translateY(-1px);
    filter: saturate(1.3);
  }
}

@keyframes dangerStripeMove {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(48px);
  }
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 18% 8%, #284278 0%, var(--bg) 36%), linear-gradient(130deg, var(--bg), var(--bg-2));
  min-height: 100vh;
  isolation: isolate;
}

body.light {
  background: linear-gradient(180deg, #e9eff8, #dfe7f3);
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 76% 10%, rgba(90, 193, 255, 0.24), transparent 42%),
    radial-gradient(ellipse at 12% 80%, rgba(143, 125, 255, 0.2), transparent 38%);
  animation: glowDrift 14s ease-in-out infinite alternate;
}

.bg-symbols {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
  filter: saturate(1.18);
}

.bg-symbols::before,
.bg-symbols::after {
  content: '';
  position: absolute;
  width: 48vmax;
  height: 48vmax;
  border-radius: 50%;
  mix-blend-mode: screen;
  opacity: .24;
  filter: blur(14px);
  animation: auraOrbit 32s ease-in-out infinite;
}

.bg-symbols::before {
  top: -18vmax;
  right: -16vmax;
  background: radial-gradient(circle, rgba(255, 142, 203, .75) 0%, rgba(143, 125, 255, .12) 55%, transparent 72%);
}

.bg-symbols::after {
  bottom: -20vmax;
  left: -14vmax;
  background: radial-gradient(circle, rgba(139, 233, 255, .68) 0%, rgba(255, 61, 168, .1) 56%, transparent 74%);
  animation-delay: -9s;
}

.bg-symbols span {
  position: absolute;
  left: var(--x, 50%);
  top: var(--y, 50%);
  color: rgba(255, 255, 255, 0.2);
  font-size: var(--s, 1.7rem);
  text-shadow: 0 0 20px rgba(110, 130, 255, 0.42), 0 0 36px rgba(255, 112, 200, 0.24);
  animation: floatRune calc(var(--d, 14s) * 1.6) ease-in-out infinite;
  animation-delay: var(--dl, 0s);
}

.bg-symbols span:nth-child(3n) {
  color: color-mix(in oklab, var(--pastel-pink) 66%, #fff);
}

.bg-symbols span:nth-child(3n + 1) {
  color: color-mix(in oklab, var(--pastel-cyan) 68%, #fff);
}

.bg-symbols span:nth-child(5n) {
  color: color-mix(in oklab, var(--pastel-lilac) 72%, #fff);
}

.bg-doodles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.bg-doodles span {
  position: absolute;
  left: var(--x, 50%);
  top: var(--y, 50%);
  font-size: clamp(1rem, 2.4vw, 1.8rem);
  opacity: .22;
  filter: drop-shadow(0 0 10px rgba(175, 220, 255, .35));
  transform: rotate(var(--r, 0deg));
  animation: doodleDrift calc(var(--d, 18s) * 1.6) ease-in-out infinite;
}

.app-shell,
.content {
  position: relative;
  z-index: 1;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem;
  width: min(100%, 1800px);
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: 1rem;
  height: calc(100vh - 2rem);
  padding: 1rem;
  z-index: 25;
}

.brand-mini {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: .4px;
}

.menu {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: .55rem;
}

.menu a {
  color: var(--text);
  text-decoration: none;
  padding: .72rem .78rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(95deg, rgba(0, 209, 255, 0.2), rgba(255, 61, 168, 0.2));
  font-weight: 700;
  position: relative;
  overflow: hidden;
  transition: transform .24s ease, box-shadow .24s ease, filter .24s ease;
}

.menu a::before {
  content: '✦';
  margin-inline-end: .4rem;
  opacity: .88;
}

.menu a:hover {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 8px 22px rgba(0, 209, 255, 0.2);
  filter: saturate(1.2);
}

.content {
  min-width: 0;
}

.topbar {
  padding: 1rem 1.15rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  background-image: linear-gradient(110deg, rgba(0, 209, 255, 0.14), rgba(143, 125, 255, 0.12), rgba(255, 61, 168, 0.12));
  animation: topbarFlow 14s ease-in-out infinite;
}

.topbar h1 { margin: 0; font-size: clamp(1.2rem, 2.8vw, 2rem); }
.topbar p { margin: .3rem 0 0; color: var(--muted); }

.topbar h1 {
  background: linear-gradient(90deg, #9ff2ff 0%, #8bb8ff 33%, #d5a2ff 66%, #ff8ecb 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 8px rgba(140, 180, 255, 0.18));
  animation: titleShimmer 12s ease-in-out infinite;
}

body.light .topbar h1 {
  background: linear-gradient(90deg, #1b62d8 0%, #5a56df 45%, #c93b94 100%);
  -webkit-background-clip: text;
  background-clip: text;
}
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; }
.toolbar .btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.role-badge {
  border-radius: 999px;
  padding: .35rem .7rem;
  border: 1px solid var(--border);
  background: linear-gradient(90deg, rgba(0, 209, 255, 0.16), rgba(255, 61, 168, 0.16));
  font-size: .8rem;
  font-weight: 700;
}
.login-screen {
  width: min(560px, calc(100% - 2rem));
  margin: 2rem auto;
  padding: 1.5rem;
  text-align: center;
}
.login-screen h1 {
  margin: 0;
}
.login-screen p {
  color: var(--muted);
}
.app-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 8, 22, 0.56);
  display: grid;
  place-items: center;
  z-index: 1200;
  padding: 1rem;
}
.app-modal {
  width: min(520px, 100%);
  padding: 1rem;
}
.app-modal h3 {
  margin: 0 0 .8rem;
}
.app-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  margin-top: .8rem;
}
.toast-host {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1300;
  display: grid;
  gap: .5rem;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .55rem .7rem;
  box-shadow: var(--shadow);
  max-width: 320px;
}
.toast.is-error {
  border-color: color-mix(in oklab, var(--danger) 62%, var(--border));
}
.toast.is-success {
  border-color: color-mix(in oklab, var(--success) 62%, var(--border));
}
.btn-google {
  position: relative;
  border: 1px solid color-mix(in oklab, var(--accent) 45%, var(--border));
  background: linear-gradient(90deg, rgba(0, 209, 255, 0.3), rgba(143, 125, 255, 0.25), rgba(255, 61, 168, 0.28));
  color: var(--text);
  font-weight: 800;
  letter-spacing: .02em;
  border-radius: 999px;
  padding-inline: 1rem;
  box-shadow: 0 10px 26px rgba(40, 80, 160, 0.28);
  overflow: hidden;
}
.btn-google::before {
  content: '🦄';
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  margin-inline-end: .45rem;
  background: rgba(255, 255, 255, 0.9);
  color: #7a42ff;
  font-size: .85rem;
  font-weight: 900;
}
.btn-google::after {
  content: '✦';
  position: absolute;
  inset-inline-end: .65rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: .78;
  font-size: .8rem;
}

.vibe-badges {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.vibe-badges span {
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--accent-2) 45%, var(--border));
  background: linear-gradient(90deg, rgba(143, 125, 255, .2), rgba(255, 61, 168, .18));
  color: var(--text);
  padding: .18rem .52rem;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .08em;
  animation: badgeNeon 6s ease-in-out infinite;
}

.vibe-badges span:nth-child(2n) { animation-delay: -.7s; }
.vibe-badges span:nth-child(3n) { animation-delay: -1.2s; }

.glass {
  background: var(--panel);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  transition: box-shadow .28s ease, border-color .28s ease, transform .28s ease;
}

.glass:hover {
  box-shadow: 0 18px 34px rgba(20, 35, 70, 0.34);
  border-color: color-mix(in oklab, var(--accent) 38%, var(--border));
}

.layout {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.panel { padding: 1rem; }

.subsection-box {
  border: 1px solid color-mix(in oklab, var(--border) 85%, transparent);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.03), rgba(143, 125, 255, 0.02));
  padding: .8rem;
  margin-bottom: .8rem;
  transition: border-color .22s ease, box-shadow .22s ease, background .22s ease;
}

.subsection-box:hover {
  border-color: color-mix(in oklab, var(--accent) 50%, var(--border));
  box-shadow: 0 10px 26px rgba(35, 70, 140, 0.22);
  background: linear-gradient(135deg, rgba(0, 209, 255, 0.07), rgba(255, 61, 168, 0.06));
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .7rem;
  flex-wrap: wrap;
}

.mine-controls {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
}

.inline-control {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .86rem;
  color: var(--muted);
}

.switch-control input { accent-color: var(--accent); }

h2 { margin: 0; font-size: 1.1rem; }
.sub-title { margin: .95rem 0 .6rem; font-size: .98rem; color: var(--muted); }

.section-toggle {
  cursor: pointer;
  user-select: none;
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 46px;
  padding: .55rem .9rem;
  margin: .05rem 0 .55rem;
  padding-inline-end: 1.3rem;
  border-radius: 10px;
  transition: color .18s ease, background .18s ease, text-shadow .18s ease;
  -webkit-tap-highlight-color: transparent;
}

.section-toggle::after {
  content: '▾';
  position: absolute;
  inset-inline-end: .7rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: .75;
  font-size: .9em;
}

.section-toggle.is-collapsed::after {
  content: '▸';
}

.section-toggle:hover {
  color: color-mix(in oklab, var(--accent) 72%, #fff);
  background: linear-gradient(90deg, rgba(0, 209, 255, 0.14), rgba(143, 125, 255, 0.12));
  text-shadow: 0 0 12px rgba(0, 209, 255, 0.28);
}

.section-toggle:active {
  background: linear-gradient(90deg, rgba(0, 209, 255, 0.2), rgba(143, 125, 255, 0.18));
}

.section-inline-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin: -.15rem 0 .45rem;
}

.manage-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: .75rem 0 .55rem;
}

.manage-quick-actions .btn {
  min-height: 38px;
}
.form-grid {
  margin-top: .9rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
}

.form-grid label { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; }
.form-grid span { font-size: .9rem; color: var(--muted); }

input, select, button {
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: .6rem .7rem;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

body:not(.light) select,
body:not(.light) input {
  background: rgba(21, 34, 66, 0.95);
  color: #eef4ff;
}

select option {
  background: #132345;
  color: #eaf3ff;
}

body.light select option {
  background: #ffffff;
  color: #1a2a4d;
}

body.light input,
body.light select {
  background: #fff;
}

.btn {
  cursor: pointer;
  font-weight: 700;
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(60, 100, 180, 0.28);
  filter: saturate(1.1);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: .52;
  cursor: not-allowed;
  filter: grayscale(.2);
}

.btn-action-edit {
  background: linear-gradient(90deg, #6fd2ff, #5f8dff);
  border-color: rgba(130, 185, 255, 0.5);
  color: #fff;
}

.btn-action-fly {
  background: linear-gradient(90deg, #ff56a2, #ff7b65);
  border-color: rgba(255, 128, 160, 0.5);
  color: #fff;
}

.btn-action-idle {
  background: linear-gradient(90deg, #ffb94a, #ff8e48);
  border-color: rgba(255, 183, 95, 0.5);
  color: #fff;
}

.btn-action-online {
  background: linear-gradient(90deg, #3be9b1, #1fcfa8);
  border-color: rgba(79, 233, 182, 0.5);
  color: #073326;
}

.btn-action-offline {
  background: linear-gradient(90deg, #8f95aa, #6f7897);
  border-color: rgba(161, 171, 201, 0.45);
  color: #f4f7ff;
}

.btn-action-delete {
  background: linear-gradient(90deg, #ff6d7b, #ff4b81);
  border-color: rgba(255, 124, 156, 0.5);
  color: #fff;
}

.btn-action-edit:hover,
.btn-action-fly:hover,
.btn-action-idle:hover,
.btn-action-online:hover,
.btn-action-offline:hover,
.btn-action-delete:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 10px 24px rgba(40, 60, 120, .3);
  filter: saturate(1.15) brightness(1.04);
}

.btn-primary {
  background: linear-gradient(90deg, #00d1ff, #5c70ff 55%, #ff3da8);
  color: #fff;
  border: none;
}

.btn-secondary {
  background: linear-gradient(90deg, #00c38a, #00dea1);
  color: #fff;
  border: none;
}

.checkline { grid-column: span 2; flex-direction: row !important; align-items: center; gap: .45rem; }
.form-actions { grid-column: span 2; display: flex; gap: .5rem; }

.channel-warning {
  grid-column: span 2;
  border: 1px solid color-mix(in oklab, var(--danger) 65%, var(--border));
  background: color-mix(in oklab, var(--danger) 16%, transparent);
  border-radius: 10px;
  padding: .55rem .65rem;
  font-size: .86rem;
}

.dynamic-help {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .7rem;
}

.help-details {
  margin-top: .7rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .8rem;
  background: rgba(255, 255, 255, 0.04);
}

.help-details ol {
  margin: .3rem 0 .5rem;
  padding-inline-start: 1.15rem;
}

.help-details ul {
  margin: .3rem 0 0;
  padding-inline-start: 1.15rem;
}

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: .6rem .54rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { position: sticky; top: 0; background: rgba(9, 19, 39, .94); z-index: 2; }
body.light th { background: rgba(255, 255, 255, .95); }

.table-wrap tr:hover {
  background: linear-gradient(90deg, rgba(143, 125, 255, .08), rgba(255, 142, 203, .05));
}

.master-table {
  border-radius: 14px;
  overflow: hidden;
}

.master-row {
  transition: transform .14s ease, box-shadow .14s ease;
}

.master-row:hover {
  transform: translateX(2px);
  box-shadow: inset 4px 0 0 var(--electric);
}

.master-row.is-safe {
  background: linear-gradient(90deg, rgba(48, 215, 161, 0.13), transparent 55%);
}

.master-row.is-warn {
  background: linear-gradient(90deg, rgba(255, 178, 56, 0.18), transparent 55%);
}

.master-row.is-danger {
  background: linear-gradient(90deg, rgba(255, 75, 129, 0.2), transparent 55%);
}

.status-chip {
  border-radius: 999px;
  padding: .2rem .52rem;
  font-size: .75rem;
  border: 1px solid var(--border);
}

.status-chip.is-warn,
.status-chip.is-danger {
  animation: none;
}

.status-chip.is-safe { background: rgba(48, 215, 161, 0.2); }
.status-chip.is-warn { background: rgba(255, 178, 56, 0.24); }
.status-chip.is-danger { background: rgba(255, 75, 129, 0.24); }

.pilot-inactive {
  opacity: .7;
}

.table-empty {
  text-align: center;
  color: var(--muted);
  padding: 1rem !important;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: .95rem;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: .14rem .5rem;
  font-size: .76rem;
  margin: .12rem;
  border: 1px solid var(--border);
  color: var(--text);
}

.badge.selected { background: color-mix(in oklab, var(--warn) 30%, transparent); }
.badge.flying { background: color-mix(in oklab, var(--danger) 34%, transparent); }
.badge.ok { background: color-mix(in oklab, var(--success) 26%, transparent); }
.badge.online { background: color-mix(in oklab, var(--success) 36%, transparent); border-color: color-mix(in oklab, var(--success) 60%, var(--border)); }
.badge.offline { background: color-mix(in oklab, #8089a2 34%, transparent); border-color: color-mix(in oklab, #9aa4be 60%, var(--border)); }

.badge {
  animation: none;
}

.badge:nth-child(2n) { animation-duration: 5.4s; }
.badge:nth-child(3n) { animation-duration: 6.2s; }

.spectrum {
  min-height: 260px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: .6rem;
}

.spectrum {
  position: relative;
}

.spectrum::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(125deg, rgba(0, 209, 255, 0.03), rgba(255, 61, 168, 0.03));
  animation: spectrumSheen 10s ease-in-out infinite;
}

.spectrum-ruler {
  position: relative;
  height: 18px;
  margin: 0 0 .45rem 220px;
  border-bottom: 1px dashed var(--border);
}

.spectrum-ruler span {
  position: absolute;
  top: 1px;
  transform: translateX(-50%);
  font-size: .66rem;
  color: var(--muted);
}

.spectrum-row {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: start;
  column-gap: .35rem;
  min-height: 42px;
  margin-bottom: .35rem;
  border-radius: 10px;
  border: 1px solid color-mix(in oklab, var(--border) 70%, transparent);
  overflow: hidden;
}

.spectrum-label {
  position: static;
  padding: .42rem .58rem;
  z-index: 1;
  max-width: 100%;
  font-size: .9rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text);
}

.spectrum-label small {
  opacity: .82;
  font-size: .75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spectrum-track {
  position: relative;
  min-height: 34px;
}

.band {
  position: absolute;
  min-height: 22px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  overflow: hidden;
  box-shadow: inset 0 -2px 8px rgba(255,255,255,0.12);
  transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s ease, filter .18s ease;
  transform-origin: center;
  animation: none;
}

.band:hover {
  transform: translateY(-2px) scale(1.015);
  box-shadow: 0 10px 24px rgba(15, 25, 50, 0.4);
  filter: saturate(1.08);
  z-index: 2;
}

.band:nth-child(2n) { animation-duration: 3.3s; }
.band:nth-child(3n) { animation-duration: 4.1s; }

.band-title {
  display: block;
  font-size: .66rem;
  white-space: nowrap;
  line-height: 1.08;
  padding: 3px 6px 0;
  color: #0d2144;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.band-pilots {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: .58rem;
  line-height: 1.05;
  padding: 0 6px 3px;
  color: #0d2144;
  opacity: .88;
}

.band.analog { background: linear-gradient(90deg, #66ffc8, #5decb8); }
.band.walksnail { background: linear-gradient(90deg, #71d2ff, #63bbff, #53a6ff); }
.band.dji { background: linear-gradient(90deg, #ff87d8, #b7a5ff, #8f7dff); }
.band.hdzero { background: linear-gradient(90deg, #ffd56f, #ffb85f, #ff9c7a); }
.band.unknown { background: linear-gradient(90deg, #b5c7df, #9db3d7); }
.band.selected { outline: 2px solid var(--warn); }
.band.flying { outline: 2px solid var(--danger); }

.legend { margin-top: .65rem; display: flex; gap: .4rem; flex-wrap: wrap; }
.tag { border-radius: 999px; font-size: .74rem; padding: .16rem .5rem; border: 1px solid var(--border); }
.tag.analog { background: rgba(61, 220, 151, .28); }
.tag.walksnail { background: rgba(86, 196, 255, .28); }
.tag.dji { background: rgba(137, 124, 255, .28); }
.tag.selected { background: rgba(255, 167, 58, .35); }
.tag.flying { background: rgba(255, 70, 97, .35); }

.tag {
  animation: none;
}

.tag:nth-child(2n) { animation-duration: 4.4s; }

.sub-title::before,
h2[data-i18n]::before {
  content: '✧ ';
  opacity: .75;
}

.mobile-conflict-inline {
  display: none;
}

@keyframes glowDrift {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-10px) scale(1.02); }
}

@keyframes floatRune {
  0% { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); opacity: .2; }
  35% { transform: translate3d(4px, -10px, 0) rotate(6deg) scale(1.06); opacity: .36; }
  68% { transform: translate3d(-3px, -16px, 0) rotate(-4deg) scale(.98); opacity: .28; }
  100% { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); opacity: .2; }
}

@keyframes auraOrbit {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(6vmax, -3vmax) scale(1.08); }
}

@keyframes topbarFlow {
  0%, 100% { filter: saturate(1); }
  50% { filter: saturate(1.14); }
}

@keyframes doodleDrift {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(var(--r, 0deg)); opacity: .18; }
  45% { transform: translate3d(-6px, -12px, 0) rotate(calc(var(--r, 0deg) + 8deg)); opacity: .3; }
  75% { transform: translate3d(6px, -6px, 0) rotate(calc(var(--r, 0deg) - 6deg)); opacity: .24; }
}

@keyframes badgeNeon {
  0%, 100% {
    box-shadow: 0 0 0 rgba(255, 61, 168, 0);
    filter: saturate(1);
  }
  50% {
    box-shadow: 0 0 16px rgba(143, 125, 255, .28), 0 0 22px rgba(255, 61, 168, .2);
    filter: saturate(1.18);
  }
}

@keyframes titleShimmer {
  0%, 100% { letter-spacing: .1px; filter: drop-shadow(0 0 8px rgba(140, 180, 255, 0.18)); }
  50% { letter-spacing: .45px; filter: drop-shadow(0 0 12px rgba(255, 142, 203, 0.24)); }
}

@keyframes chipPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

@keyframes badgeFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1px); }
}

@keyframes bandIdle {
  0%, 100% { filter: saturate(1); }
  50% { filter: saturate(1.12); }
}

@keyframes spectrumSheen {
  0%, 100% { opacity: .25; }
  50% { opacity: .55; }
}

@keyframes legendBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1px); }
}

@keyframes guideSparkle {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: .32; }
  50% { transform: scale(1.18) rotate(14deg); opacity: .7; }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 980px), (hover: none) and (pointer: coarse) {
  .bg-symbols::before,
  .bg-symbols::after,
  .bg-symbols span,
  .bg-doodles span,
  .topbar,
  .topbar h1,
  .vibe-badges span,
  .spectrum::before {
    animation: none !important;
  }
}

.guides-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .7rem;
}

.guide-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .7rem;
  background: rgba(255, 255, 255, 0.03);
  position: relative;
  overflow: hidden;
}

.guide-card::after {
  content: '✧';
  position: absolute;
  right: 10px;
  top: 8px;
  opacity: .4;
  font-size: .95rem;
  animation: guideSparkle 3.2s ease-in-out infinite;
}

.guide-card h3 { margin: 0 0 .5rem; }
.guide-card ul { margin: 0; padding-inline-start: 1rem; color: var(--muted); }
.guide-card li { margin-bottom: .35rem; }

.status-dot {
  width: .7rem;
  height: .7rem;
  border-radius: 50%;
  display: inline-block;
  margin-inline-end: .4rem;
}

.status-flying { background: var(--danger); }
.status-idle { background: var(--warn); }

.status-stack {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  flex-wrap: wrap;
}

.flight-state {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: .14rem .48rem;
  font-size: .76rem;
  line-height: 1;
}

.flight-state.status-flying {
  background: color-mix(in oklab, var(--danger) 24%, transparent);
}

.flight-state.status-idle {
  background: color-mix(in oklab, var(--warn) 24%, transparent);
}

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: .35rem;
    height: auto;
  }

  .menu {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .menu a {
    flex: 1;
    text-align: center;
    min-width: 130px;
  }

  .spectrum-row {
    grid-template-columns: 165px minmax(0, 1fr);
  }

  .spectrum-ruler {
    margin-left: 165px;
  }

  .spectrum-label {
    max-width: 100%;
  }
}

@media (max-width: 980px) {
  .form-grid,
  .dynamic-help {
    grid-template-columns: 1fr;
  }

  .checkline,
  .form-actions {
    grid-column: span 1;
  }

  .channel-warning {
    grid-column: span 1;
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .section-inline-controls {
    justify-content: flex-start;
    margin-top: .2rem;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar {
    width: 100%;
  }

  .vibe-badges {
    justify-content: flex-start;
  }

  .toolbar > * {
    flex: 1;
    min-width: 120px;
  }

  .spectrum-row {
    grid-template-columns: 120px minmax(0, 1fr);
  }

  .spectrum-ruler {
    margin-left: 120px;
  }

  .spectrum-label {
    max-width: 108px;
    font-size: .8rem;
  }

  .spectrum-label small {
    font-size: .66rem;
  }

  .table-wrap {
    overflow-x: visible;
  }

  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap th,
  .table-wrap td,
  .table-wrap tr {
    display: block;
    width: 100%;
  }

  .table-wrap thead {
    display: none;
  }

  .table-wrap tr {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: .4rem .55rem;
    margin-bottom: .55rem;
    background: rgba(255, 255, 255, 0.03);
  }

  .table-wrap td {
    border-bottom: 1px dashed color-mix(in oklab, var(--border) 70%, transparent);
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    text-align: right;
    padding: .45rem .2rem;
  }

  .table-wrap td:last-child {
    border-bottom: none;
  }

  .table-wrap td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: .76rem;
    font-weight: 700;
    text-align: left;
    flex: 0 0 42%;
  }

  .table-wrap td button {
    margin: 0 .15rem .25rem 0;
  }

  .table-empty {
    justify-content: center !important;
    text-align: center !important;
  }

  .table-empty::before {
    display: none;
  }

}

@media (max-width: 640px) {
  .app-shell {
    padding: .55rem;
    gap: .55rem;
  }

  .panel {
    padding: .7rem;
  }

  .menu {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: .25rem;
  }

  .menu a {
    min-width: 150px;
    white-space: nowrap;
  }

  .spectrum-row {
    grid-template-columns: 1fr;
  }

  .spectrum-label {
    border-bottom: 1px dashed var(--border);
    padding-bottom: .35rem;
  }

  .spectrum-ruler {
    margin-left: 0;
  }

  .spectrum-track {
    min-height: 64px;
  }

  .legend {
    gap: .25rem;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: .45rem;
  }

  .toolbar > * {
    width: 100%;
    min-width: 0;
  }

  .mine-controls {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: .45rem;
  }

  .mine-controls .inline-control {
    width: 100%;
  }

  .mine-controls .inline-control select {
    flex: 1;
    min-width: 0;
  }

  .spectrum-ruler {
    height: 22px;
    overflow: hidden;
  }

  .spectrum-ruler span {
    font-size: .62rem;
  }

  .band-pilots {
    display: none;
  }

  .band-title {
    font-size: .66rem;
    padding: 6px 6px 2px;
  }

  .table-wrap td:last-child .btn {
    width: calc(50% - .32rem);
    justify-content: center;
  }
}

@media (hover: none) and (pointer: coarse) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: .55rem;
    gap: .55rem;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .menu {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: .2rem;
  }

  .menu a {
    flex: 0 0 auto;
    min-width: 145px;
    white-space: nowrap;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    padding: .75rem;
  }

  .toolbar {
    width: 100%;
  }

  .toolbar > * {
    flex: 1 1 calc(50% - .5rem);
    min-width: 120px;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: .45rem;
  }

  .toolbar > * {
    width: 100%;
    min-width: 0;
  }

  .vibe-badges {
    justify-content: flex-start;
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .mine-controls {
    width: 100%;
  }

  .mine-controls .inline-control {
    width: 100%;
    justify-content: space-between;
  }

  .mine-controls .inline-control select {
    flex: 1;
    min-width: 0;
  }

  .form-grid,
  .dynamic-help {
    grid-template-columns: 1fr;
  }

  .checkline,
  .form-actions,
  .channel-warning {
    grid-column: span 1;
  }

  .table-wrap {
    overflow-x: visible;
  }

  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap th,
  .table-wrap td,
  .table-wrap tr {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .table-wrap thead {
    display: none;
  }

  .table-wrap tr {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: .45rem .55rem;
    margin-bottom: .55rem;
    background: rgba(255, 255, 255, 0.03);
  }

  .table-wrap td {
    border-bottom: 1px dashed color-mix(in oklab, var(--border) 70%, transparent);
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    text-align: right;
    padding: .45rem .2rem;
  }

  .table-wrap td:last-child {
    border-bottom: none;
    display: block;
    text-align: left;
    padding-top: .6rem;
  }

  .table-wrap td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: .76rem;
    font-weight: 700;
    text-align: left;
    flex: 0 0 42%;
  }

  .table-wrap td:last-child::before {
    display: block;
    margin-bottom: .35rem;
  }

  .table-wrap td:last-child .btn {
    display: inline-flex;
    margin: 0 .25rem .28rem 0;
    width: calc(50% - .32rem);
    justify-content: center;
  }

  .spectrum-row {
    grid-template-columns: 1fr;
  }

  .spectrum-label {
    border-bottom: 1px dashed var(--border);
    padding-bottom: .35rem;
    max-width: none;
  }

  .spectrum-ruler {
    margin-left: 0;
    overflow: hidden;
  }

  .spectrum-ruler span {
    font-size: .62rem;
  }

  .band-pilots {
    display: none;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .sidebar {
    position: sticky;
    top: .35rem;
    height: auto;
  }

  .menu {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
  }
}

.switch-control {
  border: 1px solid var(--border);
  background: linear-gradient(110deg, rgba(139, 233, 255, .1), rgba(255, 142, 203, .08));
  border-radius: 999px;
  padding: .26rem .58rem;
  transition: transform .2s ease, box-shadow .2s ease;
}

.switch-control:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(118, 145, 255, 0.18);
}

.conflict-mobile-note {
  display: none;
  margin: .55rem 0 0;
  padding: .6rem .7rem;
  border-radius: 10px;
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: .86rem;
  background: rgba(255, 255, 255, 0.03);
}

/* Final mobile-first compact pass */
@media (max-width: 900px) {
  body {
    font-size: 15px;
  }

  .app-shell {
    padding: .45rem;
    gap: .45rem;
  }

  .sidebar,
  .panel,
  .topbar {
    border-radius: 14px;
  }

  .sidebar,
  .panel {
    padding: .7rem;
  }

  .brand-mini {
    font-size: 1rem;
  }

  .menu {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .45rem;
    overflow: visible;
    padding-bottom: 0;
  }

  .menu a {
    min-width: 0;
    width: 100%;
    text-align: center;
    padding: .62rem .55rem;
    white-space: nowrap;
  }

  .topbar h1 {
    font-size: clamp(1.05rem, 7vw, 1.85rem);
  }

  .topbar p {
    font-size: .95rem;
  }

  .vibe-badges {
    gap: .25rem;
  }

  .vibe-badges span {
    font-size: .62rem;
    padding: .12rem .44rem;
  }

  .spectrum {
    padding: .45rem;
  }

  .spectrum-row {
    margin-bottom: .35rem;
  }

  .spectrum-label {
    padding: .45rem .5rem;
    font-size: .8rem;
  }

  .spectrum-label small {
    font-size: .66rem;
  }

  .spectrum-track {
    min-height: 44px;
  }

  .band {
    min-height: 26px;
    border-radius: 7px;
  }

  .band-title {
    font-size: .62rem;
    padding: 4px 6px 1px;
  }

  .table-wrap td,
  .table-wrap td::before {
    font-size: .84rem;
  }

  .table-wrap td:last-child .btn {
    min-height: 38px;
    font-size: .9rem;
  }
}

@media (max-width: 520px) {
  .menu {
    grid-template-columns: 1fr;
  }

  .vibe-badges {
    display: none;
  }

  .legend .tag {
    font-size: .68rem;
  }

  .spectrum-ruler span:nth-child(2n) {
    display: none;
  }
}

@media (max-width: 420px) {
  .bg-symbols,
  .bg-doodles {
    display: none;
  }
}

@media (max-width: 760px) and (orientation: portrait) {
  body {
    font-size: 14px;
  }

  .app-shell {
    padding: .35rem;
    gap: .35rem;
  }

  .panel,
  .topbar,
  .sidebar {
    padding: .55rem;
    border-radius: 12px;
  }

  .menu a {
    padding: .55rem .45rem;
    font-size: .9rem;
  }

  .topbar h1 {
    font-size: clamp(1rem, 6.4vw, 1.45rem);
  }

  .topbar p {
    margin-top: .2rem;
    font-size: .9rem;
  }

  .sub-title {
    margin: .7rem 0 .45rem;
  }

  .inline-control {
    font-size: .82rem;
  }

  .legend {
    gap: .18rem;
  }

  .tag {
    font-size: .64rem;
    padding: .12rem .42rem;
  }

  .spectrum {
    padding: .35rem;
    min-height: 180px;
  }

  .spectrum-ruler {
    margin-bottom: .3rem;
  }

  .spectrum-ruler span {
    font-size: .56rem;
  }

  .spectrum-label {
    font-size: .75rem;
    padding: .38rem .45rem;
  }

  .spectrum-label small {
    font-size: .62rem;
  }

  .spectrum-track {
    min-height: 38px;
  }

  .band {
    min-height: 22px;
  }

  .band-title {
    font-size: .58rem;
    padding: 3px 5px 0;
  }

  #spectrumTitle,
  .spectrum,
  #spectrumLegend {
    display: none;
  }

  .conflict-mobile-note {
    display: block;
  }
}

/* JS-enforced compact mode (device/browser-proof) */
body.compact-mobile .app-shell {
  grid-template-columns: 1fr !important;
  padding: .35rem !important;
  gap: .35rem !important;
}

body.compact-mobile .sidebar,
body.compact-mobile .topbar,
body.compact-mobile .panel {
  padding: .55rem !important;
  border-radius: 12px !important;
}

body.compact-mobile .menu {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: .4rem !important;
  overflow: visible !important;
}

body.compact-mobile .menu a {
  min-width: 0 !important;
  width: 100% !important;
  padding: .52rem .42rem !important;
  font-size: .88rem !important;
}

body.compact-mobile .topbar {
  flex-direction: column !important;
  align-items: stretch !important;
}

body.compact-mobile .toolbar {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: .4rem !important;
}

body.compact-mobile .toolbar > * {
  width: 100% !important;
  min-width: 0 !important;
}

body.compact-mobile .mine-controls {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: .4rem !important;
  width: 100% !important;
}

body.compact-mobile .mine-controls .inline-control {
  width: 100% !important;
}

body.compact-mobile .mine-controls .inline-control select {
  flex: 1;
  min-width: 0;
}

body.compact-mobile .spectrum {
  padding: .3rem !important;
  min-height: 160px !important;
}

body.compact-mobile .spectrum-row {
  grid-template-columns: 1fr !important;
  margin-bottom: .28rem !important;
}

body.compact-mobile .spectrum-label {
  font-size: .72rem !important;
  padding: .34rem .38rem !important;
}

body.compact-mobile .spectrum-label small {
  font-size: .6rem !important;
}

body.compact-mobile .spectrum-ruler {
  margin-left: 0 !important;
  height: 18px !important;
  overflow: hidden !important;
}

body.compact-mobile .spectrum-ruler span {
  font-size: .52rem !important;
}

body.compact-mobile .band {
  min-height: 20px !important;
}

body.compact-mobile .band-title {
  font-size: .56rem !important;
  padding: 2px 4px 0 !important;
}

body.compact-mobile .band-pilots,
body.compact-mobile .vibe-badges,
body.compact-mobile .bg-symbols,
body.compact-mobile .bg-doodles {
  display: none !important;
}

body.compact-mobile .legend .tag {
  font-size: .62rem !important;
  padding: .1rem .36rem !important;
}

body.compact-mobile-portrait #spectrumTitle,
body.compact-mobile-portrait .spectrum,
body.compact-mobile-portrait #spectrumLegend {
  display: none !important;
}

body.compact-mobile-portrait .conflict-mobile-note {
  display: block !important;
}

@media (max-width: 520px) {
  body.compact-mobile .menu {
    grid-template-columns: 1fr !important;
  }

  body.compact-mobile .spectrum-ruler span:nth-child(2n) {
    display: none;
  }
}

/* Compact mobile tables: keep true table layout to reduce vertical scroll */
@media (max-width: 980px) {
  #conflictTableBlock .table-wrap,
  #manageSection .table-wrap {
    overflow-x: auto !important;
  }

  #conflictTableBlock .table-wrap table,
  #conflictTableBlock .table-wrap thead,
  #conflictTableBlock .table-wrap tbody,
  #conflictTableBlock .table-wrap tr,
  #conflictTableBlock .table-wrap th,
  #conflictTableBlock .table-wrap td,
  #manageSection .table-wrap table,
  #manageSection .table-wrap thead,
  #manageSection .table-wrap tbody,
  #manageSection .table-wrap tr,
  #manageSection .table-wrap th,
  #manageSection .table-wrap td {
    display: revert !important;
    width: auto !important;
  }

  #conflictTableBlock .table-wrap table,
  #manageSection .table-wrap table {
    table-layout: fixed;
    min-width: 640px;
    font-size: .82rem;
  }

  #conflictTableBlock th,
  #conflictTableBlock td,
  #manageSection th,
  #manageSection td {
    padding: .4rem .35rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left !important;
    vertical-align: middle;
  }

  #conflictTableBlock .table-empty,
  #manageSection .table-empty {
    text-align: center !important;
    white-space: normal !important;
  }

  /* Conflict table: keep only key columns on mobile */
  #conflictTableBlock .master-table th:nth-child(2),
  #conflictTableBlock .master-table td:nth-child(2),
  #conflictTableBlock .master-table th:nth-child(6),
  #conflictTableBlock .master-table td:nth-child(6),
  #conflictTableBlock .master-table th:nth-child(7),
  #conflictTableBlock .master-table td:nth-child(7),
  #conflictTableBlock .master-table th:nth-child(8),
  #conflictTableBlock .master-table td:nth-child(8) {
    display: none !important;
  }

  /* Pilots table: keep compact columns on mobile */
  #pilotsTable th:nth-child(4),
  #pilotsTable td:nth-child(4),
  #pilotsTable th:nth-child(6),
  #pilotsTable td:nth-child(6) {
    display: none !important;
  }

  #pilotsTable td:last-child {
    white-space: normal;
    min-width: 160px;
  }

  #pilotsTable td:last-child .btn {
    min-height: 34px;
    padding: .35rem .45rem;
    font-size: .8rem;
    margin: 0 .2rem .2rem 0;
    width: auto !important;
    display: inline-flex !important;
  }
}

/* Responsive polish: phones + tablets + larger floating backdrop */
.bg-symbols span {
  font-size: calc(var(--s, 1.7rem) * 1.35);
}

.bg-doodles span {
  font-size: clamp(1.25rem, 3vw, 2.5rem);
  opacity: .28;
}

@media (hover: none) and (pointer: coarse) {
  input,
  select,
  button,
  .btn {
    min-height: 44px;
  }
}

@media (min-width: 761px) and (max-width: 1180px) {
  .app-shell {
    padding: .7rem;
    gap: .7rem;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .55rem;
  }

  .toolbar > * {
    min-width: 0;
  }

  .mine-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .5rem;
    width: 100%;
  }

  .mine-controls .inline-control {
    min-width: 0;
  }
}

@media (max-width: 760px) {
  body {
    font-size: 15px;
  }

  .topbar h1 {
    font-size: clamp(1.05rem, 6.2vw, 1.55rem);
  }

  .topbar p {
    font-size: .92rem;
  }

  .spectrum-label {
    font-size: .78rem;
  }

  .spectrum-label small {
    font-size: .64rem;
  }

  .spectrum-ruler span {
    font-size: .58rem;
  }
}

body.compact-mobile .bg-symbols {
  display: block !important;
  opacity: .56;
}

body.compact-mobile .bg-doodles {
  display: block !important;
  opacity: .3;
}

@media (max-width: 420px) {
  .bg-symbols,
  .bg-doodles {
    display: block;
    opacity: .34;
  }

  .bg-symbols span {
    font-size: calc(var(--s, 1.7rem) * 1.15);
  }
}

/* Android/iPhone hardening: avoid clipped sections and keep spectrum landscape-only on phones */
@media (max-width: 820px) and (pointer: coarse) and (orientation: portrait) {
  #spectrumTitle,
  .spectrum,
  #spectrumLegend {
    display: none !important;
  }

  .conflict-mobile-note {
    display: block !important;
  }
}

@media (max-width: 820px) and (pointer: coarse) and (orientation: landscape) {
  #spectrumTitle,
  .spectrum,
  #spectrumLegend {
    display: block !important;
  }

  .conflict-mobile-note {
    display: none !important;
  }
}

@media (max-width: 820px) and (pointer: coarse) {
  html,
  body {
    overflow-x: hidden !important;
    width: 100%;
    max-width: 100%;
  }

  .content,
  .layout,
  .panel,
  .section-head,
  .mine-controls,
  .inline-control,
  .form-grid,
  .dynamic-help,
  .help-details,
  .table-wrap,
  .table-wrap tr,
  .table-wrap td,
  .spectrum,
  .spectrum-row,
  .spectrum-label,
  .spectrum-track {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .app-shell {
    width: 100%;
    max-width: 100vw;
    overflow-x: clip;
  }

  .table-wrap {
    overflow-x: hidden !important;
  }

  .table-wrap table {
    min-width: 0 !important;
    width: 100% !important;
  }

  .spectrum,
  .spectrum-track {
    overflow-x: hidden;
  }

  .inline-control {
    display: grid;
    grid-template-columns: 1fr;
    gap: .32rem;
  }

  .inline-control select,
  .inline-control input,
  .inline-control button {
    width: 100%;
    min-width: 0;
  }

  .table-wrap td {
    display: grid !important;
    grid-template-columns: 1fr;
    justify-items: start;
    text-align: left;
    gap: .24rem;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .table-wrap td::before {
    flex: none !important;
    width: 100%;
    margin-bottom: .08rem;
  }

  .table-wrap td:last-child .btn {
    width: 100% !important;
    margin-right: 0 !important;
  }

  .help-details,
  .help-details li,
  .help-details ul,
  .help-details ol,
  .guide-card,
  .guide-card li {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}

/* Small-screen hard rule: show live spectrum map only in landscape */
@media (max-width: 980px) {
  #spectrumTitle,
  .spectrum,
  #spectrumLegend {
    display: none !important;
  }

  .conflict-mobile-note {
    display: block !important;
  }
}

@media (max-width: 980px) and (orientation: landscape) {
  #spectrumTitle,
  .spectrum,
  #spectrumLegend {
    display: block !important;
  }

  .conflict-mobile-note {
    display: none !important;
  }
}

/* Final mobile table override: prevent card-style leakage and clipped actions */
@media (max-width: 980px) {
  #conflictTableBlock .table-wrap,
  #manageSection .table-wrap {
    overflow-x: auto !important;
  }

  #conflictTableBlock .table-wrap table,
  #manageSection .table-wrap table {
    display: table !important;
    width: 100% !important;
    min-width: 0 !important;
    table-layout: auto !important;
  }

  #conflictTableBlock .table-wrap thead,
  #manageSection .table-wrap thead {
    display: table-header-group !important;
  }

  #conflictTableBlock .table-wrap tbody,
  #manageSection .table-wrap tbody {
    display: table-row-group !important;
  }

  #conflictTableBlock .table-wrap tr,
  #manageSection .table-wrap tr {
    display: table-row !important;
  }

  #conflictTableBlock .table-wrap th,
  #conflictTableBlock .table-wrap td,
  #manageSection .table-wrap th,
  #manageSection .table-wrap td {
    display: table-cell !important;
    width: auto !important;
    padding: .34rem .28rem !important;
    font-size: .8rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    text-align: left !important;
    vertical-align: middle !important;
  }

  #conflictTableBlock .table-wrap td::before,
  #manageSection .table-wrap td::before {
    content: none !important;
    display: none !important;
  }

  /* Conflict table compact columns */
  #conflictTableBlock .master-table th:nth-child(2),
  #conflictTableBlock .master-table td:nth-child(2),
  #conflictTableBlock .master-table th:nth-child(5),
  #conflictTableBlock .master-table td:nth-child(5),
  #conflictTableBlock .master-table th:nth-child(6),
  #conflictTableBlock .master-table td:nth-child(6),
  #conflictTableBlock .master-table th:nth-child(9),
  #conflictTableBlock .master-table td:nth-child(9) {
    display: none !important;
  }

  /* Keep most important columns visible on mobile */
  #conflictTableBlock .master-table th:nth-child(7),
  #conflictTableBlock .master-table td:nth-child(7),
  #conflictTableBlock .master-table th:nth-child(8),
  #conflictTableBlock .master-table td:nth-child(8) {
    display: table-cell !important;
  }

  /* Prioritize full pilot names in Selected/Flying columns */
  #conflictTableBlock .master-table th:nth-child(1),
  #conflictTableBlock .master-table td:nth-child(1) { width: 16%; }
  #conflictTableBlock .master-table th:nth-child(3),
  #conflictTableBlock .master-table td:nth-child(3) { width: 24%; }
  #conflictTableBlock .master-table th:nth-child(4),
  #conflictTableBlock .master-table td:nth-child(4) { width: 14%; }
  #conflictTableBlock .master-table th:nth-child(7),
  #conflictTableBlock .master-table td:nth-child(7) { width: 23%; }
  #conflictTableBlock .master-table th:nth-child(8),
  #conflictTableBlock .master-table td:nth-child(8) { width: 23%; }

  #conflictTableBlock .master-table td:nth-child(7),
  #conflictTableBlock .master-table td:nth-child(8),
  #conflictTableBlock .master-table th:nth-child(7),
  #conflictTableBlock .master-table th:nth-child(8) {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    vertical-align: top !important;
  }

  #conflictTableBlock .master-table td:nth-child(7) .badge,
  #conflictTableBlock .master-table td:nth-child(8) .badge {
    display: inline-flex;
    margin: .08rem .12rem .08rem 0;
    max-width: 100%;
  }

  #conflictTableBlock .master-table td:nth-child(3) {
    white-space: normal !important;
  }

  #conflictTableBlock .mobile-conflict-inline {
    display: block;
    margin-top: .18rem;
    font-size: .66rem;
    line-height: 1.2;
    color: var(--muted);
    white-space: normal !important;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* Pilots table compact columns */
  #pilotsTable th:nth-child(4),
  #pilotsTable td:nth-child(4),
  #pilotsTable th:nth-child(6),
  #pilotsTable td:nth-child(6) {
    display: none !important;
  }

  #pilotsTable th:nth-child(1), #pilotsTable td:nth-child(1) { width: 19%; }
  #pilotsTable th:nth-child(2), #pilotsTable td:nth-child(2) { width: 18%; }
  #pilotsTable th:nth-child(3), #pilotsTable td:nth-child(3) { width: 16%; }
  #pilotsTable th:nth-child(5), #pilotsTable td:nth-child(5) { width: 14%; }
  #pilotsTable th:nth-child(7), #pilotsTable td:nth-child(7) { width: 14%; }
  #pilotsTable th:nth-child(8), #pilotsTable td:nth-child(8) { width: 19%; }

  #pilotsTable td:last-child {
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: normal !important;
  }

  #pilotsTable td:last-child .btn {
    display: block !important;
    width: 100% !important;
    min-height: 30px !important;
    margin: 0 0 .18rem 0 !important;
    padding: .24rem .3rem !important;
    font-size: .72rem !important;
    line-height: 1.1 !important;
    justify-content: center !important;
  }

  #pilotsTable td:last-child .btn:last-child {
    margin-bottom: 0 !important;
  }

  #manageFilterControls .switch-control {
    padding: .16rem .45rem !important;
  }

  #manageFilterControls .inline-control span {
    font-size: .8rem !important;
  }

  /* Auto assignment: show key info cleanly on mobile */
  .assignments-table th:nth-child(2),
  .assignments-table td:nth-child(2),
  .assignments-table th:nth-child(4),
  .assignments-table td:nth-child(4) {
    display: none !important;
  }

  .assignments-table th:nth-child(1), .assignments-table td:nth-child(1) { width: 28%; }
  .assignments-table th:nth-child(3), .assignments-table td:nth-child(3) { width: 50%; }
  .assignments-table th:nth-child(5), .assignments-table td:nth-child(5) { width: 22%; }

  .assignments-table td:nth-child(3) {
    white-space: normal !important;
    text-overflow: clip !important;
  }
}

@media (max-width: 640px) {
  /* Conflict table: keep most relevant columns on phones */
  #conflictTableBlock .master-table th:nth-child(1),
  #conflictTableBlock .master-table td:nth-child(1),
  #conflictTableBlock .master-table th:nth-child(4),
  #conflictTableBlock .master-table td:nth-child(4) {
    display: none !important;
  }

  #conflictTableBlock .master-table th:nth-child(3),
  #conflictTableBlock .master-table td:nth-child(3),
  #conflictTableBlock .master-table th:nth-child(7),
  #conflictTableBlock .master-table td:nth-child(7),
  #conflictTableBlock .master-table th:nth-child(8),
  #conflictTableBlock .master-table td:nth-child(8) {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }

  /* Pilots: keep Name, Channel, Status, Actions on very small screens */
  #pilotsTable th:nth-child(2),
  #pilotsTable td:nth-child(2),
  #pilotsTable th:nth-child(3),
  #pilotsTable td:nth-child(3) {
    display: none !important;
  }

  #pilotsTable th:nth-child(1), #pilotsTable td:nth-child(1) { width: 24%; }
  #pilotsTable th:nth-child(5), #pilotsTable td:nth-child(5) { width: 16%; }
  #pilotsTable th:nth-child(7), #pilotsTable td:nth-child(7) { width: 20%; }
  #pilotsTable th:nth-child(8), #pilotsTable td:nth-child(8) { width: 40%; }

  #pilotsTable td:nth-child(1),
  #pilotsTable td:nth-child(5) {
    text-overflow: clip !important;
  }
}
