:root {
  color-scheme: light;
  --canvas: #f1f5f7;
  --surface: #ffffff;
  --surface-soft: #f6f8fa;
  --ink: #1f2d38;
  --muted: #657581;
  --line: #d8e0e6;
  --line-strong: #bdc9d2;
  --graphite: #344958;
  --graphite-soft: #435b6b;
  --accent: #dc6438;
  --accent-dark: #b94d28;
  --success: #287a59;
  --success-soft: #e8f3ed;
  --danger: #b94b47;
  --danger-soft: #f7eae9;
  --warning: #96691f;
  --focus: #3b7198;
  font-family:
    "Segoe UI Variable", "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei",
    system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--canvas);
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
}

body.is-auth-pending > .shell,
body.is-auth-pending > .mobile-nav {
  visibility: hidden;
}

body.is-auth-invalid > .shell,
body.is-auth-invalid > .mobile-nav {
  display: none !important;
}

.invalid-link-page {
  min-height: 100vh;
  min-height: 100svh;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--canvas);
}

body.is-auth-invalid > .invalid-link-page {
  display: flex;
}

.invalid-link-content {
  width: min(560px, 100%);
  text-align: center;
}

.invalid-link-content h1 {
  color: var(--ink);
  font-size: 38px;
  font-weight: 760;
  line-height: 1.18;
  letter-spacing: 0;
}

.invalid-link-content p {
  margin-top: 14px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(36, 109, 163, 0.28);
  outline-offset: 2px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.shell {
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 42px 48px;
}

.brandbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  min-height: 72px;
  padding-bottom: 18px;
}

.brand-kicker {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  font-size: 34px;
  font-weight: 720;
  line-height: 1.1;
  letter-spacing: 0;
}

h1 span {
  color: var(--accent);
}

.device-meta {
  max-width: 360px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: right;
}

.connection-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) auto;
  align-items: stretch;
  min-height: 130px;
  overflow: hidden;
  color: var(--ink);
  background: #f8fafb;
  border: 1px solid #ccd7df;
  border-radius: 4px;
  box-shadow: 0 12px 32px rgba(48, 72, 88, 0.09);
}

.connection-panel.is-online {
  box-shadow: 0 12px 32px rgba(48, 72, 88, 0.09);
}

.connection-panel.is-offline {
  box-shadow: 0 12px 32px rgba(48, 72, 88, 0.09);
}

.connection-primary {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 30px 36px 30px 52px;
  background: linear-gradient(
    90deg,
    rgba(40, 122, 89, 0.56) 0%,
    rgba(40, 122, 89, 0.28) 22%,
    rgba(248, 250, 251, 0) 52%
  );
}

.connection-panel.is-offline .connection-primary {
  background: linear-gradient(
    90deg,
    rgba(185, 75, 71, 0.52) 0%,
    rgba(185, 75, 71, 0.26) 22%,
    rgba(248, 250, 251, 0) 52%
  );
}

.connection-dot {
  display: none;
}

.connection-dot {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  border: 3px solid #d5dde3;
  border-radius: 50%;
  background: #9aa8b2;
  box-shadow: 0 0 0 7px rgba(105, 127, 143, 0.09);
}

.connection-panel.is-online .connection-dot {
  border-color: #acd6bf;
  background: var(--success);
  box-shadow: 0 0 0 7px rgba(40, 122, 89, 0.13);
}

.connection-panel.is-offline .connection-dot {
  border-color: #e1b5b2;
  background: var(--danger);
  box-shadow: 0 0 0 7px rgba(185, 75, 71, 0.13);
}

.status-label {
  color: #71818d;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0;
}

.connection-primary h2 {
  margin-top: 5px;
  font-size: 32px;
  font-weight: 720;
  line-height: 1.15;
  letter-spacing: 0;
}

.connection-detail {
  margin-top: 7px;
  color: #5d6d79;
  font-size: 13px;
}

.sync-meta {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  align-self: end;
  gap: 8px;
  min-width: 132px;
  min-height: 0;
  padding: 0 30px 24px;
  background: transparent;
  text-align: right;
}

.sync-meta time {
  margin-top: 0;
  color: var(--ink);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.summary-section {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  min-height: 112px;
  margin-top: 22px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.summary-heading {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 16px 28px;
  border-right: 1px solid var(--line);
}

.summary-heading h2,
.section-title h2,
.activity-heading h2 {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0;
}

.summary-heading h2 {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.summary-heading p {
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.summary-state {
  margin-top: 8px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.15;
}

.summary-state.is-running {
  color: var(--success);
}

.summary-state.is-paused {
  color: var(--warning);
}

.summary-state.is-unknown {
  color: var(--muted);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
}

.metric {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  padding: 16px 22px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  margin-top: 7px;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 28px;
  font-weight: 690;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.metric-meta {
  min-height: 18px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.summary-alert {
  grid-column: 2;
  padding: 10px 26px;
  color: #79511a;
  background: #fff5df;
  border-top: 1px solid #ead2a8;
  font-size: 12px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  gap: 44px;
  align-items: start;
  padding-top: 42px;
}

.controls-panel {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.section-title,
.activity-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.section-title {
  min-height: 72px;
  padding: 20px 24px;
  border-top: 4px solid var(--accent);
}

.section-title > span {
  color: var(--muted);
  font-size: 11px;
}

.control-row {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 24px;
  align-items: center;
  min-height: 92px;
  padding: 22px 24px;
  border-top: 1px solid var(--line);
}

.control-row h3 {
  font-size: 14px;
  font-weight: 680;
  letter-spacing: 0;
}

.action-group,
.mode-list,
.plan-list {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.action-group,
.mode-list {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.plan-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.action,
.mode {
  min-width: 0;
  min-height: 46px;
  padding: 0 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  font-size: 13px;
  font-weight: 650;
  transition:
    color 150ms ease,
    background 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

.action:hover:not(:disabled),
.mode:hover:not(:disabled) {
  color: #fff;
  background: var(--graphite-soft);
  border-color: var(--graphite-soft);
  transform: translateY(-1px);
}

.action-primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.action-primary:hover:not(:disabled) {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.action-danger {
  color: var(--danger);
  border-color: rgba(200, 77, 72, 0.48);
}

.action-danger:hover:not(:disabled) {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.mode.active {
  color: #fff;
  background: var(--graphite);
  border-color: var(--graphite);
}

.plan-list .mode.active {
  background: var(--accent);
  border-color: var(--accent);
}

.action:disabled,
.mode:disabled,
.profile-picker select:disabled {
  cursor: not-allowed;
  color: #9ba1a6;
  background: #f0f2f3;
  border-color: #dde1e4;
  transform: none;
}

.mode.active:disabled {
  color: #fff;
  background: #596168;
  border-color: #596168;
}

.plan-list .mode.active:disabled {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.hero-settings {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(240px, 1.2fr);
  gap: 16px;
  align-items: end;
}

.profile-picker {
  display: grid;
  min-width: 0;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.profile-picker select {
  width: 100%;
  min-height: 46px;
  padding: 0 38px 0 12px;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
}

.activity-panel {
  min-width: 0;
  padding-left: 30px;
  border-left: 1px solid var(--line-strong);
}

.activity-section {
  min-width: 0;
}

.activity-heading {
  min-height: 32px;
}

.command-list {
  display: grid;
  gap: 0;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.command-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-width: 0;
  min-height: 46px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.command-item time {
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.command-message {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-status {
  justify-self: end;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.command-item.pending .command-status {
  color: var(--warning);
}

.command-item.success .command-status {
  color: var(--success);
}

.command-item.failed .command-status {
  color: var(--danger);
}

.command-empty {
  padding: 20px 0;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.mobile-nav {
  display: none;
}

@media (max-width: 1050px) {
  .shell {
    padding-right: 28px;
    padding-left: 28px;
  }

  .connection-panel {
    grid-template-columns: 1fr;
  }

  .sync-meta {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: flex-end;
    gap: 8px;
    min-height: 40px;
    padding: 10px 24px;
    background: transparent;
  }

  .sync-meta time {
    margin-top: 0;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 30px;
  }

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

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

@media (max-width: 820px) {
  .shell {
    padding: 22px 18px 36px;
  }

  .brandbar {
    align-items: flex-start;
  }

  .connection-panel,
  .summary-section,
  .workspace {
    grid-template-columns: 1fr;
  }

  .connection-panel {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .sync-meta {
    grid-column: auto;
    align-self: end;
    min-width: 0;
    min-height: 0;
    padding: 0 18px 18px 8px;
    background: transparent;
  }

  .summary-heading {
    padding-left: 22px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .summary-alert {
    grid-column: 1;
  }

  .activity-panel {
    padding: 32px 0 0;
    border-top: 1px solid var(--line-strong);
    border-left: 0;
  }

  .mobile-nav {
    position: fixed;
    z-index: 20;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    min-height: 72px;
    padding: 7px 12px calc(7px + env(safe-area-inset-bottom));
    overflow: hidden;
    isolation: isolate;
    background: rgba(244, 248, 250, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow:
      0 -1px 0 rgba(126, 148, 163, 0.14),
      0 -16px 38px rgba(48, 72, 88, 0.13),
      inset 0 1px 0 rgba(255, 255, 255, 0.82),
      inset 0 -1px 0 rgba(78, 102, 119, 0.06);
    backdrop-filter: blur(42px) saturate(1.7) brightness(1.06);
    -webkit-backdrop-filter: blur(42px) saturate(1.7) brightness(1.06);
  }

  .mobile-nav::before {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.96);
    content: "";
    pointer-events: none;
  }

  .mobile-nav::after {
    position: absolute;
    z-index: -1;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.72' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.22'/%3E%3C/svg%3E");
    content: "";
    opacity: 0.045;
    pointer-events: none;
  }

  .mobile-nav-button {
    position: relative;
    z-index: 1;
    display: flex;
    min-height: 56px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 0;
    font-size: 11px;
    font-weight: 650;
    line-height: 1.2;
    transition:
      color 150ms ease,
      transform 150ms ease;
  }

  .mobile-nav-button.is-active {
    color: var(--accent);
  }

  .mobile-nav-button:active {
    transform: translateY(1px);
  }

  .mobile-nav-icon {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
  }

  body {
    padding-bottom: 0;
  }

  .shell {
    padding-bottom: 18px;
  }

  body[data-mobile-view="dashboard"] .mode-control,
  body[data-mobile-view="dashboard"] .hero-settings-row,
  body[data-mobile-view="dashboard"] .command-item:nth-child(n + 2) {
    display: none;
  }

  body[data-mobile-view="dashboard"] .device-meta,
  body[data-mobile-view="dashboard"] .controls-panel .section-title {
    display: none;
  }

  body[data-mobile-view="dashboard"] .control-row:first-of-type {
    grid-template-columns: 1fr;
    min-height: 0;
    padding: 16px 24px;
  }

  body[data-mobile-view="dashboard"] .control-row:first-of-type h3 {
    display: none;
  }

  body[data-mobile-view="dashboard"] .action-group {
    gap: 8px;
  }

  body[data-mobile-view="dashboard"] .activity-panel {
    padding-top: 22px;
  }

  body[data-mobile-view="dashboard"] .command-list {
    margin-top: 10px;
  }

  body[data-mobile-view="details"] .connection-panel,
  body[data-mobile-view="details"] .summary-section,
  body[data-mobile-view="details"] .control-row:first-of-type {
    display: none;
  }

  body[data-mobile-view="details"] .activity-panel {
    padding-top: 0;
    border-top: 0;
  }

  body[data-mobile-view="details"] .controls-panel {
    border-top: 0;
  }
}

@media (min-width: 821px) {
  .connection-panel {
    background: linear-gradient(
      90deg,
      rgba(40, 122, 89, 0.5) 0%,
      rgba(40, 122, 89, 0.34) 18%,
      rgba(40, 122, 89, 0.19) 38%,
      rgba(40, 122, 89, 0.08) 50%,
      rgba(248, 250, 251, 0) 58%
    );
  }

  .connection-primary {
    background: transparent;
  }

  .connection-panel.is-offline {
    background: linear-gradient(
      90deg,
      rgba(185, 75, 71, 0.46) 0%,
      rgba(185, 75, 71, 0.31) 18%,
      rgba(185, 75, 71, 0.17) 38%,
      rgba(185, 75, 71, 0.07) 50%,
      rgba(248, 250, 251, 0) 58%
    );
  }
}

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

/* Compact mobile status cards. */
@media (max-width: 820px) {
  .connection-panel {
    min-height: 0;
  }

  .connection-primary {
    padding: 20px 22px 18px 34px;
  }

  .connection-primary h2 {
    font-size: 26px;
  }

  .connection-detail {
    margin-top: 5px;
    font-size: 12px;
  }

  .sync-meta {
    padding: 0 16px 14px 6px;
  }

  .summary-heading {
    padding-top: 13px;
    padding-bottom: 13px;
  }

  .summary-state {
    margin-top: 6px;
    font-size: 20px;
  }

  .summary-heading p {
    margin-top: 6px;
    font-size: 11px;
  }

  .metric {
    min-height: 112px;
    padding: 13px 16px;
  }

  .metric-value {
    margin-top: 5px;
    font-size: 24px;
  }

  .metric-meta {
    min-height: 15px;
    margin-top: 4px;
    font-size: 10px;
  }
}

/* Mobile touch feedback and a restrained custom select treatment. */
@media (max-width: 820px) {
  button,
  select {
    -webkit-tap-highlight-color: transparent;
  }

  button:focus-visible,
  select:focus-visible {
    outline: 2px solid rgba(225, 100, 56, 0.5) !important;
    outline-offset: 2px;
  }

  button:focus:not(:focus-visible),
  select:focus:not(:focus-visible) {
    outline: none;
  }

  .profile-picker {
    position: relative;
  }

  .profile-picker select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 34px;
    background-image: none;
  }

  .profile-picker::after {
    position: absolute;
    right: 15px;
    bottom: 17px;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid var(--graphite);
    border-bottom: 1.5px solid var(--graphite);
    content: "";
    pointer-events: none;
    transform: rotate(45deg);
  }
}

/* Replace the browser popup with a compact, touch-friendly mobile listbox. */
@media (max-width: 820px) {
  .profile-picker::after {
    display: none;
  }

  .profile-select-shell {
    position: relative;
  }

  .controls-panel {
    overflow: visible !important;
  }

  .hero-settings-row {
    position: relative;
    z-index: 5;
  }

  .profile-picker select {
    display: none;
  }

  .profile-picker-button {
    position: relative;
    display: flex;
    width: 100%;
    min-height: 46px;
    align-items: center;
    justify-content: space-between;
    gap: 26px;
    padding: 0 34px 0 12px;
    overflow: hidden;
    color: var(--ink);
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 3px;
  }

  .profile-picker-button::after {
    position: absolute;
    top: 50%;
    right: 14px;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid var(--graphite);
    border-bottom: 1.5px solid var(--graphite);
    content: "";
    transform: translateY(-65%) rotate(45deg);
    transition: transform 150ms ease;
  }

  .profile-picker-button.is-open::after {
    transform: translateY(-25%) rotate(225deg);
  }

  .profile-picker-button:disabled {
    color: #9ba1a6;
    background: #f0f2f3;
    border-color: #dde1e4;
  }

  .profile-picker-menu {
    position: absolute;
    z-index: 30;
    top: calc(100% + 5px);
    right: 0;
    left: 0;
    display: grid;
    gap: 2px;
    max-height: 210px;
    padding: 5px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    box-shadow: 0 9px 22px rgba(38, 56, 67, 0.16);
  }

  .profile-picker-option {
    min-height: 38px;
    padding: 0 10px;
    overflow: hidden;
    color: var(--ink);
    background: transparent;
    border: 0;
    border-radius: 2px;
    font-size: 11px;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .profile-picker-option:hover,
  .profile-picker-option:focus-visible {
    color: var(--ink);
    background: var(--surface-soft);
    outline: none;
  }

  .profile-picker-option[aria-selected="true"] {
    color: var(--accent-dark);
    background: rgba(225, 100, 56, 0.12);
    box-shadow: inset 3px 0 0 var(--accent);
    font-weight: 700;
  }
}

/* Use the same custom listbox on desktop, with a roomier control density. */
@media (min-width: 821px) {
  .profile-picker::after {
    display: none;
  }

  .profile-select-shell {
    position: relative;
  }

  .controls-panel {
    overflow: visible !important;
  }

  .hero-settings-row {
    position: relative;
    z-index: 5;
  }

  .profile-picker select {
    display: none;
  }

  .profile-picker-button {
    position: relative;
    display: flex;
    width: 100%;
    min-height: 46px;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    padding: 0 38px 0 12px;
    overflow: hidden;
    color: var(--ink);
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 3px;
  }

  .profile-picker-button::after {
    position: absolute;
    top: 50%;
    right: 15px;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid var(--graphite);
    border-bottom: 1.5px solid var(--graphite);
    content: "";
    transform: translateY(-65%) rotate(45deg);
    transition: transform 150ms ease;
  }

  .profile-picker-button.is-open::after {
    transform: translateY(-25%) rotate(225deg);
  }

  .profile-picker-button:disabled {
    color: #9ba1a6;
    background: #f0f2f3;
    border-color: #dde1e4;
  }

  .profile-picker-menu {
    position: absolute;
    z-index: 30;
    top: calc(100% + 5px);
    right: 0;
    left: 0;
    display: grid;
    gap: 2px;
    max-height: 260px;
    padding: 5px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    box-shadow: 0 9px 22px rgba(38, 56, 67, 0.16);
  }

  .profile-picker-option {
    min-height: 40px;
    padding: 0 11px;
    overflow: hidden;
    color: var(--ink);
    background: transparent;
    border: 0;
    border-radius: 2px;
    font-size: 12px;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .profile-picker-option:hover,
  .profile-picker-option:focus-visible {
    color: var(--ink);
    background: var(--surface-soft);
    outline: none;
  }

  .profile-picker-option[aria-selected="true"] {
    color: var(--accent-dark);
    background: rgba(225, 100, 56, 0.12);
    box-shadow: inset 3px 0 0 var(--accent);
    font-weight: 700;
  }
}

/* The picker sits near the lower edge of both layouts, so always open upward. */
.profile-picker-menu {
  top: auto !important;
  bottom: calc(100% + 5px);
}

@media (max-width: 820px) {
  .connection-panel {
    background: linear-gradient(
      90deg,
      rgba(40, 122, 89, 0.5) 0%,
      rgba(40, 122, 89, 0.34) 18%,
      rgba(40, 122, 89, 0.19) 38%,
      rgba(40, 122, 89, 0.08) 50%,
      rgba(248, 250, 251, 0) 58%
    );
  }

  .connection-primary {
    background: transparent;
  }

  .connection-panel.is-offline {
    background: linear-gradient(
      90deg,
      rgba(185, 75, 71, 0.46) 0%,
      rgba(185, 75, 71, 0.31) 18%,
      rgba(185, 75, 71, 0.17) 38%,
      rgba(185, 75, 71, 0.07) 50%,
      rgba(248, 250, 251, 0) 58%
    );
  }

  .connection-primary,
  .connection-panel.is-offline .connection-primary {
    background: transparent;
  }
}

/* Consolidated compact phone overrides. */
@media (max-width: 560px) {
  .invalid-link-page {
    padding: 28px;
  }

  .invalid-link-content h1 {
    font-size: 30px;
  }

  .invalid-link-content p {
    margin-top: 10px;
    font-size: 14px;
  }

  .shell {
    padding: 10px 12px 8px;
  }

  .brandbar {
    flex-direction: column;
    gap: 4px;
    min-height: 0;
    padding-bottom: 8px;
  }

  .brand-kicker {
    margin-bottom: 3px;
    font-size: 8px;
  }

  .device-meta {
    text-align: left;
  }

  h1 {
    font-size: 24px;
  }

  .connection-primary {
    padding: 14px 14px 10px 24px;
  }

  .sync-meta {
    gap: 5px;
    padding: 0 12px 10px 4px;
    text-align: right;
  }

  .sync-meta time {
    margin-top: 0;
    font-size: 11px;
  }

  .connection-primary h2 {
    margin-top: 4px;
    font-size: 22px;
  }

  .connection-detail {
    margin-top: 4px;
    font-size: 10px;
  }

  .summary-section {
    min-height: 0;
    margin-top: 10px;
  }

  .summary-heading {
    padding: 9px 16px;
  }

  .summary-heading h2 {
    font-size: 10px;
  }

  .summary-state {
    margin-top: 4px;
    font-size: 19px;
  }

  .summary-heading p {
    margin-top: 4px;
    font-size: 10px;
  }

  .summary-grid,
  .action-group,
  .mode-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric:nth-child(2n) {
    border-right: 0;
  }

  .metric {
    min-height: 88px;
    padding: 10px 12px;
  }

  .metric-label {
    font-size: 10px;
  }

  .metric-value {
    margin-top: 4px;
    font-size: 20px;
  }

  .metric-meta {
    min-height: 12px;
    margin-top: 3px;
    font-size: 9px;
  }

  .workspace {
    gap: 12px;
    padding-top: 10px;
  }

  body[data-mobile-view="dashboard"] .control-row:first-of-type {
    padding: 10px 14px;
  }

  body[data-mobile-view="dashboard"] .action-group {
    gap: 6px;
  }

  .action,
  .mode {
    min-height: 40px;
    padding: 0 8px;
    font-size: 12px;
  }

  body[data-mobile-view="dashboard"] .activity-panel {
    padding-top: 10px;
  }

  body[data-mobile-view="dashboard"] .command-list {
    margin-top: 6px;
  }

  .activity-heading {
    min-height: 32px;
  }

  .command-item {
    grid-template-columns: 55px minmax(0, 1fr) auto;
    min-height: 36px;
    padding: 6px 0;
    font-size: 10px;
  }

  .command-item time,
  .command-status {
    font-size: 9px;
  }

  .command-empty {
    padding: 12px 0;
  }

  .connection-primary {
    padding: 14px 14px 10px 24px;
  }

  .connection-primary h2 {
    margin-top: 4px;
    font-size: 22px;
  }

  .sync-meta {
    gap: 5px;
    padding-right: 12px;
    padding-bottom: 10px;
  }

  .metric {
    min-height: 88px;
    padding: 10px 12px;
  }

  .metric-value {
    margin-top: 4px;
    font-size: 20px;
  }

  .shell {
    padding: 8px 10px 6px;
  }

  .brandbar {
    gap: 2px;
    padding-bottom: 6px;
  }

  .brand-kicker {
    margin-bottom: 2px;
    font-size: 7px;
  }

  h1 {
    font-size: 22px;
  }

  .connection-primary {
    padding: 10px 12px 8px 20px;
  }

  .connection-primary h2 {
    margin-top: 3px;
    font-size: 20px;
  }

  .connection-detail {
    margin-top: 3px;
    font-size: 9px;
  }

  .sync-meta {
    gap: 4px;
    padding: 0 10px 8px 3px;
  }

  .sync-meta .status-label,
  .sync-meta time {
    font-size: 9px;
  }

  .summary-section {
    margin-top: 8px;
  }

  .summary-heading {
    padding: 7px 12px;
  }

  .summary-heading h2 {
    font-size: 9px;
  }

  .summary-state {
    margin-top: 3px;
    font-size: 17px;
  }

  .summary-heading p {
    margin-top: 3px;
    font-size: 9px;
  }

  .metric {
    min-height: 76px;
    padding: 8px 10px;
  }

  .summary-grid .metric:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .summary-grid .metric:nth-child(n + 3) {
    border-bottom: 0;
  }

  .metric-label {
    font-size: 9px;
  }

  .metric-value {
    margin-top: 3px;
    font-size: 18px;
  }

  .metric-meta {
    min-height: 10px;
    margin-top: 2px;
    font-size: 8px;
  }

  .workspace {
    gap: 8px;
    padding-top: 8px;
  }

  body[data-mobile-view="dashboard"] .control-row:first-of-type {
    padding: 8px 10px;
  }

  body[data-mobile-view="dashboard"] .action-group {
    gap: 5px;
  }

  .action,
  .mode {
    min-height: 36px;
    padding: 0 6px;
    font-size: 11px;
  }

  body[data-mobile-view="dashboard"] .activity-panel {
    padding-top: 6px;
  }

  body[data-mobile-view="dashboard"] .command-list {
    margin-top: 4px;
  }

  .activity-heading {
    min-height: 28px;
    padding: 0 12px;
  }

  .activity-heading h2 {
    font-size: 16px;
  }

  .command-list {
    padding: 0 12px 4px;
  }

  .command-item {
    grid-template-columns: 52px minmax(0, 1fr) auto;
    min-height: 32px;
    padding: 4px 0;
  }

  .mobile-nav {
    min-height: 52px;
    padding: 1px 8px calc(1px + env(safe-area-inset-bottom));
  }

  .mobile-nav-button {
    min-height: 42px;
    gap: 1px;
    font-size: 9px;
  }

  .mobile-nav-icon {
    width: 19px;
    height: 19px;
  }

  body[data-mobile-view="details"] .shell {
    padding: 8px 10px 6px;
  }

  body[data-mobile-view="details"] .controls-panel {
    border-radius: 4px;
  }

  body[data-mobile-view="details"] .section-title {
    align-items: flex-start;
    min-height: 52px;
    flex-direction: column;
    gap: 4px;
    padding: 12px 18px;
  }

  body[data-mobile-view="details"] .section-title h2 {
    font-size: 17px;
  }

  body[data-mobile-view="details"] .section-title > span {
    font-size: 10px;
  }

  body[data-mobile-view="details"] .control-row {
    grid-template-columns: 1fr;
    gap: 9px;
    min-height: 0;
    padding: 13px 18px;
  }

  body[data-mobile-view="details"] .control-row h3 {
    font-size: 12px;
  }

  body[data-mobile-view="details"] .action-group,
  body[data-mobile-view="details"] .mode-list,
  body[data-mobile-view="details"] .plan-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  body[data-mobile-view="details"] .action,
  body[data-mobile-view="details"] .mode {
    min-height: 38px;
    padding: 0 8px;
    font-size: 11px;
  }

  body[data-mobile-view="details"] .hero-settings {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  body[data-mobile-view="details"] .profile-picker {
    gap: 4px;
    font-size: 10px;
  }

  body[data-mobile-view="details"] .profile-picker select {
    min-height: 38px;
    font-size: 11px;
  }

  body[data-mobile-view="details"] .activity-panel {
    padding-top: 8px;
  }

  body[data-mobile-view="details"] .activity-heading {
    min-height: 36px;
    padding: 0 18px;
  }

  body[data-mobile-view="details"] .activity-heading h2 {
    font-size: 17px;
  }

  body[data-mobile-view="details"] .command-list {
    margin-top: 4px;
    padding: 0 18px 4px;
  }

  body[data-mobile-view="details"] .command-item {
    grid-template-columns: 52px minmax(0, 1fr) auto;
    min-height: 34px;
    padding: 5px 0;
    font-size: 10px;
  }

  .profile-picker::after {
    right: 13px;
    bottom: 14px;
    width: 6px;
    height: 6px;
  }

  .profile-picker-button {
    min-height: 38px;
    border-radius: 3px;
    font-size: 11px;
  }

  .profile-picker-button::after {
    right: 12px;
    width: 6px;
    height: 6px;
  }

  .profile-picker-menu {
    max-height: 190px;
  }

  .profile-picker-option {
    min-height: 34px;
    font-size: 11px;
  }
}
