:root {
  color-scheme: dark;
  --bg: #06111c;
  --bg-deep: #030a12;
  --panel: rgba(9, 26, 41, 0.9);
  --panel-solid: #0a1c2c;
  --panel-raised: #102a40;
  --line: #234c68;
  --line-soft: rgba(79, 143, 180, 0.28);
  --text: #f3f8fc;
  --muted: #96b3c6;
  --cyan: #59d8f2;
  --cyan-strong: #8cecff;
  --green: #4ce0a5;
  --orange: #ffad42;
  --red: #ff5964;
  --shadow: 0 24px 72px rgba(0, 0, 0, 0.34);
  --glow: 0 0 0 1px rgba(89, 216, 242, 0.6), 0 0 30px rgba(29, 166, 204, 0.24);
  --radius: 16px;
  --content-width: 1740px;
  --ui-scale: clamp(0.94rem, 0.73rem + 0.23vw, 1.16rem);
  font-family: "Bahnschrift", "Aptos Display", "Segoe UI Variable Display", sans-serif;
  font-size: var(--ui-scale);
  line-height: 1.35;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  min-width: 300px;
  overflow-x: hidden;
  color: var(--text);
  background:
    linear-gradient(rgba(64, 130, 164, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(64, 130, 164, 0.04) 1px, transparent 1px),
    radial-gradient(circle at 78% 3%, rgba(28, 107, 178, 0.24), transparent 42rem),
    radial-gradient(circle at 0% 60%, rgba(20, 116, 103, 0.12), transparent 34rem),
    linear-gradient(135deg, var(--bg-deep), var(--bg));
  background-size: 42px 42px, 42px 42px, auto, auto, auto;
}

button,
input,
a {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

.ambient {
  position: fixed;
  z-index: -1;
  width: 32vw;
  height: 32vw;
  min-width: 320px;
  min-height: 320px;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(90px);
  opacity: 0.12;
}

.ambient-a {
  top: -16vw;
  right: 8vw;
  background: #168cc7;
}

.ambient-b {
  bottom: -20vw;
  left: -8vw;
  background: #18a477;
}

.app-shell {
  width: min(calc(100% - clamp(1rem, 4vw, 5rem)), var(--content-width));
  margin: 0 auto;
  padding: clamp(0.7rem, 1.4vw, 1.35rem) 0 max(1rem, env(safe-area-inset-bottom));
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(360px, 1fr) auto;
  align-items: center;
  gap: clamp(0.65rem, 1.2vw, 1.25rem);
  min-height: 64px;
  padding: 0.55rem 0.65rem;
  margin-bottom: clamp(0.75rem, 1.3vw, 1.25rem);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: rgba(6, 18, 29, 0.86);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(18px);
}

.tabs,
.top-actions,
.quick-profiles,
.profile-launcher,
.debug-tabs,
.dialog-actions,
.maintenance-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tabs,
.top-actions,
.host-strip {
  min-width: 0;
}

.tab,
.debug-tab {
  min-height: 42px;
  padding: 0.55rem 0.9rem;
  border: 1px solid #28516d;
  border-radius: 10px;
  background: #0e263a;
  color: #c6d9e6;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.tab:hover,
.debug-tab:hover {
  border-color: #4c88aa;
  color: white;
}

.tab.is-current,
.debug-tab.is-current {
  border-color: var(--green);
  background: linear-gradient(145deg, #123849, #0c293d);
  color: white;
  box-shadow: 0 0 0 2px rgba(76, 224, 165, 0.12), 0 0 20px rgba(76, 224, 165, 0.13);
}

.host-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(90px, 1fr)) auto;
  align-items: center;
  gap: clamp(0.7rem, 2vw, 2.2rem);
  min-width: 0;
  padding: 0 0.5rem;
}

.host-item {
  display: grid;
  min-width: 0;
}

.host-item small,
.eyebrow {
  margin: 0;
  color: #79a9c4;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.host-item strong {
  overflow: hidden;
  font-size: 0.86rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.connection-pill i,
.status-dot {
  display: inline-block;
  width: 0.62rem;
  height: 0.62rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 10px currentColor;
}

.connection-pill.is-online {
  color: var(--green);
}

.connection-pill.is-online i {
  background: var(--green);
}

.connection-pill.is-offline {
  color: var(--red);
}

.connection-pill.is-offline i {
  background: var(--red);
}

.button {
  min-height: 43px;
  padding: 0.65rem 1rem;
  border: 1px solid #3a6683;
  border-radius: 10px;
  background: linear-gradient(180deg, #173a55, #102a41);
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 130ms ease, border-color 150ms ease, filter 150ms ease, box-shadow 150ms ease;
}

.button:hover:not(:disabled) {
  border-color: #6ca8c9;
  filter: brightness(1.12);
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

.button:disabled {
  cursor: not-allowed;
  filter: saturate(0.3);
  opacity: 0.45;
}

.button-quiet {
  background: linear-gradient(180deg, #102d43, #0a2032);
}

.button-primary {
  border-color: #33c58e;
  background: linear-gradient(180deg, #147d5b, #0e5a43);
  box-shadow: 0 0 18px rgba(76, 224, 165, 0.12);
}

.button-danger {
  border-color: #ef5962;
  background: linear-gradient(180deg, #9d2e37, #681d26);
  box-shadow: 0 0 18px rgba(255, 89, 100, 0.12);
}

.button-danger-quiet {
  border-color: #81434b;
  background: linear-gradient(180deg, #3b242d, #271a22);
  color: #ffb9bd;
}

.button-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.button-icon svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

:focus-visible {
  outline: 3px solid var(--cyan-strong);
  outline-offset: 3px;
}

main {
  min-height: 0;
}

.page {
  display: none;
  animation: page-enter 260ms ease both;
}

.page.is-visible {
  display: block;
}

@keyframes page-enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(29, 67, 95, 0.09), transparent 45%),
    var(--panel);
  box-shadow: var(--shadow);
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.05fr) minmax(310px, 0.95fr);
  gap: clamp(0.75rem, 1.2vw, 1.2rem);
  align-items: stretch;
}

.arrangement-panel,
.selected-panel,
.debug-output,
.maintenance-card {
  padding: clamp(0.8rem, 1.2vw, 1.25rem);
}

.panel-heading,
.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.panel-heading h1,
.panel-heading h2,
.page-heading h1,
.maintenance-card h2 {
  margin: 0.12rem 0 0;
  line-height: 1.05;
}

.panel-heading h1,
.page-heading h1 {
  font-size: clamp(1.45rem, 1.1rem + 0.8vw, 2.2rem);
}

.panel-heading h2,
.maintenance-card h2 {
  font-size: clamp(1.25rem, 1.06rem + 0.4vw, 1.7rem);
}

.count-label,
.selected-marker {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.selected-marker {
  padding: 0.25rem 0.5rem;
  border: 1px solid rgba(89, 216, 242, 0.42);
  border-radius: 999px;
  color: var(--cyan-strong);
}

.quick-profiles,
.profile-launcher {
  flex-wrap: wrap;
  margin: 1rem 0 0.8rem;
}

.quick-profiles .button,
.profile-launcher .button {
  min-width: clamp(125px, 12vw, 205px);
  min-height: clamp(48px, 3.4vw, 58px);
  padding-inline: 1.25rem;
  font-size: clamp(0.92rem, 0.78rem + 0.25vw, 1.08rem);
}

.arrangement-plane {
  position: relative;
  width: 100%;
  height: clamp(300px, 42vh, 590px);
  min-height: 300px;
  overflow: hidden;
  border: 1px solid #28506a;
  border-radius: 13px;
  background:
    radial-gradient(circle at 45% 42%, rgba(28, 91, 132, 0.15), transparent 47%),
    linear-gradient(rgba(68, 125, 160, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(68, 125, 160, 0.055) 1px, transparent 1px),
    #061522;
  background-size: auto, 32px 32px, 32px 32px, auto;
}

.arrangement-plane::after {
  position: absolute;
  inset: auto 0 0;
  height: 28%;
  pointer-events: none;
  content: "";
  background: linear-gradient(transparent, rgba(1, 7, 13, 0.22));
}

.monitor-tile {
  position: absolute;
  z-index: 1;
  display: grid;
  place-content: center;
  min-width: 78px;
  min-height: 58px;
  padding: 0.55rem;
  overflow: hidden;
  border: 1px solid #345d78;
  border-radius: 12px;
  background: linear-gradient(145deg, #122b41, #0b1d2d);
  color: #adc5d4;
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, filter 160ms ease, transform 160ms ease;
}

.monitor-tile:hover {
  filter: brightness(1.12);
}

.monitor-tile strong,
.monitor-tile small,
.monitor-tile span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.monitor-tile strong {
  color: var(--text);
  font-size: clamp(0.72rem, 0.62rem + 0.16vw, 0.92rem);
}

.monitor-tile small {
  margin-top: 0.25rem;
  color: #9ab5c8;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.65rem;
}

.monitor-tile span {
  margin-top: 0.22rem;
  color: #7fa4ba;
  font-size: 0.66rem;
}

.monitor-tile.is-active {
  border-color: #60d7ef;
  background:
    radial-gradient(circle at 50% 12%, rgba(157, 232, 255, 0.24), transparent 35%),
    linear-gradient(145deg, #274f77, #173451);
  color: white;
  box-shadow: inset 0 0 26px rgba(72, 183, 224, 0.18), 0 0 22px rgba(70, 190, 224, 0.2);
}

.monitor-tile.is-primary {
  border-color: var(--green);
  box-shadow: inset 0 0 30px rgba(76, 224, 165, 0.12), 0 0 22px rgba(76, 224, 165, 0.18);
}

.monitor-tile.is-inactive {
  border-style: dashed;
  background: linear-gradient(145deg, rgba(20, 43, 59, 0.86), rgba(7, 19, 29, 0.92));
  filter: saturate(0.62);
  opacity: 0.78;
}

.monitor-tile.is-missing {
  border-color: #713942;
  border-style: dashed;
  background: rgba(31, 17, 23, 0.78);
  opacity: 0.55;
}

.monitor-tile.is-selected {
  z-index: 3;
  border-color: white;
  box-shadow: 0 0 0 3px var(--cyan), 0 0 28px rgba(89, 216, 242, 0.42);
}

.monitor-tile.is-selected::after {
  position: absolute;
  top: 0.38rem;
  right: 0.38rem;
  width: 0.38rem;
  height: 0.38rem;
  border-radius: 50%;
  background: white;
  content: "";
  box-shadow: 0 0 8px white;
}

.display-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
  gap: 0.55rem;
  margin-top: 0.65rem;
}

.display-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-height: 92px;
  padding: 0.72rem 0.8rem;
  overflow: hidden;
  border: 1px solid #2e5874;
  border-radius: 11px;
  background: linear-gradient(145deg, #112c42, #0b2032);
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.display-card:hover {
  border-color: #5893b5;
}

.display-card.is-active {
  border-color: #36bd8c;
}

.display-card.is-selected {
  border-color: var(--cyan-strong);
  box-shadow: inset 0 0 0 1px var(--cyan), 0 0 16px rgba(89, 216, 242, 0.17);
}

.display-card strong {
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.display-card .device-name {
  overflow: hidden;
  color: #bdd1de;
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-status {
  display: flex;
  align-items: center;
  align-self: end;
  gap: 0.4rem;
  margin-top: 0.45rem;
  color: #9eb9ca;
  font-size: 0.7rem;
}

.status-active { background: var(--green); color: var(--green); }
.status-inactive { background: var(--orange); color: var(--orange); }
.status-error { background: var(--red); color: var(--red); }

.selected-panel {
  min-height: 100%;
  border-color: #315c78;
}

.selected-content {
  display: grid;
  gap: 0.85rem;
  margin-top: 1rem;
}

.empty-state {
  min-height: 220px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.selected-title {
  margin: 0;
  font-size: 1rem;
}

.selected-token {
  color: var(--cyan);
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.72rem;
}

.field-label {
  display: grid;
  gap: 0.38rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.field-label input,
.confirm-input-wrap input,
.debug-filter {
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 0.75rem;
  border: 1px solid #3a6682;
  border-radius: 9px;
  outline: none;
  background: #071927;
  color: var(--text);
}

.field-label input:focus,
.confirm-input-wrap input:focus,
.debug-filter:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(89, 216, 242, 0.13);
}

.alias-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem;
}

.meta-grid {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(110px, auto);
  gap: 0.42rem 1rem;
  padding: 0.8rem 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.77rem;
}

.meta-grid span:nth-child(odd) {
  color: var(--muted);
}

.meta-grid strong {
  overflow-wrap: anywhere;
  text-align: right;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.badge {
  padding: 0.24rem 0.48rem;
  border: 1px solid #345f7b;
  border-radius: 999px;
  background: rgba(19, 51, 74, 0.72);
  color: #b8d4e4;
  font-size: 0.67rem;
  font-weight: 700;
}

.badge-primary { border-color: #38bf8e; color: #8df0c9; }
.badge-warning { border-color: #ad7535; color: #ffc875; }
.badge-error { border-color: #a7434d; color: #ff9da4; }

.display-actions {
  display: grid;
  gap: 0.58rem;
}

.display-actions .button {
  min-height: clamp(52px, 4vw, 66px);
  font-size: clamp(0.9rem, 0.78rem + 0.23vw, 1.05rem);
}

.action-reason {
  margin: -0.25rem 0 0;
  color: var(--muted);
  font-size: 0.68rem;
  text-align: center;
}

.page-heading {
  align-items: end;
  margin: 0.2rem 0 1rem;
  padding: 0 0.2rem;
}

.page-heading > p {
  max-width: 550px;
  margin: 0;
  color: var(--muted);
  text-align: right;
}

.profile-launcher {
  margin-bottom: 1rem;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
  gap: 0.85rem;
}

.profile-card {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-height: 330px;
  padding: 1rem;
  border: 1px solid #315e7d;
  border-radius: 15px;
  background: linear-gradient(145deg, rgba(19, 48, 73, 0.95), rgba(7, 21, 34, 0.95));
  box-shadow: var(--shadow);
}

.profile-card h2 {
  margin: 0;
}

.profile-note {
  min-height: 2.7em;
  margin: 0.45rem 0 0.7rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.profile-targets {
  display: grid;
  align-content: start;
  gap: 0.55rem;
}

.profile-target {
  padding: 0.65rem;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(3, 14, 23, 0.46);
}

.profile-target-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.profile-target-mode {
  margin-top: 0.35rem;
  color: #b7ccda;
  font-size: 0.74rem;
}

.profile-ids {
  display: grid;
  gap: 0.16rem;
  margin-top: 0.45rem;
  color: #71b8d8;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.65rem;
  overflow-wrap: anywhere;
}

.profile-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.profile-actions .button {
  min-height: 50px;
}

.profile-warning {
  color: #ffc875;
}

.debug-heading {
  align-items: center;
}

.debug-tabs {
  margin-bottom: 0.7rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.debug-tabs::-webkit-scrollbar {
  display: none;
}

.debug-output {
  min-height: 440px;
}

.debug-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  margin-bottom: 0.8rem;
}

.debug-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}

.debug-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.73rem;
}

.debug-table th,
.debug-table td {
  padding: 0.58rem 0.65rem;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}

.debug-table th {
  position: sticky;
  top: 0;
  background: #0e2a3e;
  color: #a9c6d8;
  letter-spacing: 0.05em;
}

.debug-table td {
  overflow-wrap: anywhere;
}

.code,
.debug-json {
  font-family: "Cascadia Code", "Consolas", monospace;
}

.debug-json {
  max-height: min(66vh, 760px);
  margin: 0;
  padding: 0.85rem;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #030c14;
  color: #b9d4e3;
  font-size: 0.68rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

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

.maintenance-card {
  display: grid;
  align-content: start;
  min-height: 250px;
}

.maintenance-card > p:not(.eyebrow) {
  color: var(--muted);
}

.maintenance-actions {
  align-self: end;
  flex-wrap: wrap;
  margin-top: auto;
}

.danger-zone {
  border-color: #633943;
  background: linear-gradient(145deg, rgba(75, 30, 38, 0.35), rgba(16, 18, 28, 0.92));
}

.toast-region {
  position: fixed;
  z-index: 50;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  display: grid;
  width: min(420px, calc(100vw - 2rem));
  gap: 0.55rem;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 4px 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.8rem;
  border: 1px solid #39657f;
  border-radius: 12px;
  background: rgba(7, 24, 37, 0.97);
  box-shadow: var(--shadow);
  animation: toast-enter 220ms ease both;
  pointer-events: auto;
}

.toast::before {
  width: 4px;
  height: 100%;
  border-radius: 4px;
  background: var(--cyan);
  content: "";
}

.toast.is-success::before { background: var(--green); }
.toast.is-warning::before { background: var(--orange); }
.toast.is-error::before { background: var(--red); }

.toast p {
  margin: 0;
  font-size: 0.78rem;
}

.toast .button {
  min-height: 36px;
  padding: 0.4rem 0.65rem;
  font-size: 0.72rem;
}

@keyframes toast-enter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.confirm-dialog {
  width: min(500px, calc(100% - 2rem));
  padding: 0;
  border: 1px solid #49738d;
  border-radius: 17px;
  background: #0a1b2a;
  color: var(--text);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.62);
}

.confirm-dialog::backdrop {
  background: rgba(0, 5, 10, 0.76);
  backdrop-filter: blur(6px);
}

.confirm-dialog form {
  padding: 1.25rem;
}

.confirm-dialog h2 {
  margin: 0.2rem 0 0.7rem;
}

.confirm-dialog p:not(.eyebrow) {
  color: #b6cbd8;
}

.confirm-input-wrap {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.8rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 1rem;
}

.is-hidden {
  display: none !important;
}

.loading-shimmer {
  min-height: 96px;
  border-radius: 10px;
  background: linear-gradient(100deg, #0a2031 30%, #153b53 50%, #0a2031 70%);
  background-size: 220% 100%;
  animation: shimmer 1.4s infinite linear;
}

@keyframes shimmer {
  to { background-position-x: -220%; }
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: auto 1fr;
  }

  .host-strip {
    order: 3;
    grid-column: 1 / -1;
    padding: 0.45rem 0.35rem 0;
    border-top: 1px solid var(--line-soft);
  }

  .top-actions {
    justify-self: end;
  }

  .home-grid {
    grid-template-columns: minmax(0, 1.65fr) minmax(290px, 0.85fr);
  }
}

@media (max-width: 880px) {
  .app-shell {
    width: min(calc(100% - 1rem), var(--content-width));
  }

  .topbar {
    position: static;
  }

  .tabs {
    overflow-x: auto;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .top-actions .button span {
    display: none;
  }

  .top-actions .button {
    width: 43px;
    padding: 0;
  }

  .home-grid {
    grid-template-columns: 1fr;
  }

  .selected-panel {
    min-height: auto;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .maintenance-card {
    min-height: 210px;
  }
}

@media (max-width: 620px) {
  :root {
    --radius: 13px;
  }

  .app-shell {
    width: calc(100% - 0.75rem);
    padding-top: 0.4rem;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.45rem;
    padding: 0.45rem;
  }

  #restart-button {
    display: none;
  }

  .tab {
    min-height: 40px;
    padding-inline: 0.7rem;
    font-size: 0.8rem;
  }

  .host-strip {
    grid-template-columns: 1fr 0.75fr 0.9fr;
    gap: 0.6rem;
  }

  .connection-pill {
    grid-column: 1 / -1;
  }

  .arrangement-panel,
  .selected-panel,
  .debug-output,
  .maintenance-card {
    padding: 0.7rem;
  }

  .arrangement-heading .count-label {
    max-width: 47%;
    overflow: hidden;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .quick-profiles,
  .profile-launcher {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.38rem;
  }

  .quick-profiles .button,
  .profile-launcher .button {
    min-width: 0;
    min-height: 48px;
    padding-inline: 0.35rem;
    font-size: 0.78rem;
  }

  .arrangement-plane {
    height: 330px;
    min-height: 330px;
  }

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

  .display-card {
    min-height: 98px;
  }

  .alias-row,
  .profile-actions {
    grid-template-columns: 1fr;
  }

  .page-heading {
    align-items: flex-start;
  }

  .page-heading > p {
    display: none;
  }

  .debug-heading .button {
    padding-inline: 0.7rem;
    font-size: 0.75rem;
  }
}

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