* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --primary: #5b8af5;
  --primary-light: #7aa0f8;
  --primary-dark: #4070dc;
  --success: #4caf50;
  --warning: #ffb020;
  --danger: #ff5a6f;
  --bg: #f0f4f8;
  --bg-soft: #f8fafc;
  --surface: rgba(255, 255, 255, 0.76);
  --surface-strong: rgba(255, 255, 255, 0.9);
  --surface-muted: rgba(255, 255, 255, 0.48);
  --text: #2d3748;
  --text-muted: #718096;
  --text-faint: #a0aec0;
  --border: rgba(91, 138, 245, 0.18);
  --shadow-soft: 0 18px 45px rgba(64, 112, 220, 0.14);
  --shadow-card: 0 14px 32px rgba(45, 55, 72, 0.1);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --header-height: 76px;
  --content-width: min(1180px, calc(100vw - 40px));
  /* Soft / friendly stack:
     - DM Sans for Latin / numbers
     - Noto Sans SC for Chinese (loaded as web font so change is visible)
     - system CJK as fallback when offline */
  --font-sans: "DM Sans", "Noto Sans SC", "HarmonyOS Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  font-family: var(--font-sans);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  letter-spacing: 0.01em;
  font-weight: 400;
}

h1,
h2,
h3,
.brand-title,
.hero-title,
.nav-link,
.metric-label,
.settings-cards-title {
  letter-spacing: 0.02em;
  font-weight: 700;
}

.hero-title {
  font-weight: 700;
  letter-spacing: 0.03em;
}

.hero-subtitle,
.form-help,
.weather-city,
.shortcut-category,
.metric-caption {
  letter-spacing: 0.02em;
  font-weight: 500;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1e2330;
  --bg-soft: #252a37;
  --surface: rgba(37, 42, 55, 0.76);
  --surface-strong: rgba(43, 49, 64, 0.9);
  --surface-muted: rgba(43, 49, 64, 0.5);
  --text: #f3f7ff;
  --text-muted: #b6c0d4;
  --text-faint: #8491aa;
  --border: rgba(122, 160, 248, 0.2);
  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.26);
  --shadow-card: 0 14px 32px rgba(0, 0, 0, 0.22);
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 18px);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  letter-spacing: 0;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -4;
  content: "";
  background:
    radial-gradient(circle at 16% 18%, rgba(122, 160, 248, 0.2), transparent 30%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.52), rgba(240, 244, 248, 0.92) 56%, var(--bg));
  pointer-events: none;
}

:root[data-theme="dark"] body::before {
  background:
    radial-gradient(circle at 20% 12%, rgba(91, 138, 245, 0.28), transparent 34%),
    linear-gradient(180deg, rgba(18, 23, 36, 0.5), rgba(30, 35, 48, 0.92) 58%, var(--bg));
}

body.menu-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-card);
  transform: translateY(-160%);
  transition: transform 0.2s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

#day-sky,
.day-sky,
.day-sky-container,
#twinkling-stars,
.twinkling-stars,
.twinkling-stars-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

:root[data-theme="dark"] #day-sky,
:root[data-theme="dark"] .day-sky,
:root[data-theme="dark"] .day-sky-container {
  opacity: 0.08;
}

:root:not([data-theme="dark"]) #twinkling-stars,
:root:not([data-theme="dark"]) .twinkling-stars,
:root:not([data-theme="dark"]) .twinkling-stars-container {
  opacity: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: var(--header-height);
  border-bottom: 1px solid rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.66);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 10px 32px rgba(64, 112, 220, 0.08);
  transition:
    transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.35s ease,
    box-shadow 0.3s ease;
  will-change: transform, opacity;
}

.site-header.ui-hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
  position: absolute;
  width: 100%;
}

:root[data-theme="dark"] .site-header {
  border-color: rgba(122, 160, 248, 0.12);
  background: rgba(30, 35, 48, 0.68);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.2);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: var(--content-width);
  min-height: var(--header-height);
  margin: 0 auto;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
  font-weight: 700;
}

.brand-logo {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow:
    0 10px 22px rgba(91, 138, 245, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transition: transform 0.22s ease, box-shadow 0.22s ease, filter 0.22s ease;
}

.brand:hover .brand-logo {
  transform: translateY(-1px) scale(1.03);
  box-shadow:
    0 14px 28px rgba(91, 138, 245, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.34);
}

.brand-logo-icon {
  display: block;
  width: 100%;
  height: 100%;
}

/* Theme-aware logo palette (SVG hard colors alone would not follow light/dark). */
.brand-logo-stop--a { stop-color: #9ec4ff; }
.brand-logo-stop--b { stop-color: #5b8af5; }
.brand-logo-stop--c { stop-color: #3b66d8; }
.brand-logo-sheen-stop--a { stop-color: #ffffff; stop-opacity: 0.42; }
.brand-logo-sheen-stop--b { stop-color: #ffffff; stop-opacity: 0; }
.brand-logo-needle-stop--a { stop-color: #fff8d8; }
.brand-logo-needle-stop--b { stop-color: #ffffff; }
.brand-logo-needle-stop--c { stop-color: #d7e7ff; }

.brand-logo-rim { stroke: rgba(255, 255, 255, 0.28); }
.brand-logo-orbit { stroke: rgba(255, 255, 255, 0.34); }
.brand-logo-disc { fill: rgba(255, 255, 255, 0.12); }
.brand-logo-arm--s { fill: rgba(255, 255, 255, 0.78); }
.brand-logo-arm--w,
.brand-logo-arm--e { fill: rgba(255, 255, 255, 0.62); }
.brand-logo-jewel-outer { fill: #fff8d2; }
.brand-logo-jewel-inner { fill: #5b8af5; opacity: 0.9; }
.brand-logo-spark--a { fill: #fff4b8; opacity: 0.95; }
.brand-logo-spark--b { fill: rgba(255, 255, 255, 0.92); opacity: 0.85; }
.brand-logo-spark--c { fill: #fff7c8; opacity: 0; }

:root[data-theme="dark"] .brand-logo {
  box-shadow:
    0 12px 26px rgba(0, 0, 0, 0.34),
    0 0 0 1px rgba(148, 174, 255, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

:root[data-theme="dark"] .brand:hover .brand-logo {
  box-shadow:
    0 16px 30px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(168, 192, 255, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

:root[data-theme="dark"] .brand-logo-stop--a { stop-color: #6f89d8; }
:root[data-theme="dark"] .brand-logo-stop--b { stop-color: #3d4f8f; }
:root[data-theme="dark"] .brand-logo-stop--c { stop-color: #1e2748; }
:root[data-theme="dark"] .brand-logo-sheen-stop--a { stop-color: #d7e4ff; stop-opacity: 0.2; }
:root[data-theme="dark"] .brand-logo-sheen-stop--b { stop-color: #9db4ff; stop-opacity: 0; }
:root[data-theme="dark"] .brand-logo-needle-stop--a { stop-color: #ffe9a8; }
:root[data-theme="dark"] .brand-logo-needle-stop--b { stop-color: #f4f7ff; }
:root[data-theme="dark"] .brand-logo-needle-stop--c { stop-color: #a9bff5; }

:root[data-theme="dark"] .brand-logo-rim { stroke: rgba(186, 206, 255, 0.22); }
:root[data-theme="dark"] .brand-logo-orbit { stroke: rgba(190, 210, 255, 0.42); }
:root[data-theme="dark"] .brand-logo-disc { fill: rgba(120, 150, 230, 0.16); }
:root[data-theme="dark"] .brand-logo-arm--s { fill: rgba(220, 230, 255, 0.72); }
:root[data-theme="dark"] .brand-logo-arm--w,
:root[data-theme="dark"] .brand-logo-arm--e { fill: rgba(190, 208, 255, 0.55); }
:root[data-theme="dark"] .brand-logo-jewel-outer { fill: #ffe7a4; }
:root[data-theme="dark"] .brand-logo-jewel-inner { fill: #9db6ff; opacity: 0.95; }
:root[data-theme="dark"] .brand-logo-spark--a { fill: #ffe7a8; opacity: 1; }
:root[data-theme="dark"] .brand-logo-spark--b { fill: #eef3ff; opacity: 0.95; }
:root[data-theme="dark"] .brand-logo-spark--c { opacity: 0.9; }

.brand-title {
  position: relative;
  display: inline-block;
  overflow: visible;
  max-width: 100%;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  isolation: isolate;
  text-overflow: ellipsis;
  backface-visibility: hidden;
  transform: translateZ(0);
}

/* Keep brand title readable in the header; reuse shared .glitch-active effect. */
.brand-title.glitch-text {
  color: var(--text);
  font-weight: 700;
  -webkit-text-stroke: 0;
  text-shadow: none;
}

.brand-title.glitch-active {
  text-shadow: 1px 0 #0ff, -1px 0 #f0f;
}

.main-nav,
.mobile-nav {
  align-items: center;
  gap: 8px;
}

/* Flat tab row: no capsule/ellipse chrome behind the links. */
.main-nav {
  display: flex;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

:root[data-theme="dark"] .main-nav {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.nav-link,
.mobile-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #5b6578;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color 0.18s ease, opacity 0.18s ease;
}

.nav-link {
  min-height: 36px;
  padding: 6px 8px 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.nav-link-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  opacity: 0.92;
}

.nav-link-icon svg {
  display: block;
  width: 18px;
  height: 18px;
}

.nav-link-text {
  line-height: 1;
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 18px;
  height: 2.5px;
  border-radius: 999px;
  background: transparent;
  transform: translateX(-50%) scaleX(0.4);
  opacity: 0;
  transition: background 0.18s ease, opacity 0.18s ease, transform 0.18s ease, width 0.18s ease;
}

.nav-link:hover {
  color: #3f4b63;
  background: transparent;
}

.nav-link.active {
  color: #4f7ff0;
  background: transparent;
  box-shadow: none;
  font-weight: 700;
}

.nav-link.active::after {
  width: 22px;
  background: #4f7ff0;
  opacity: 1;
  transform: translateX(-50%) scaleX(1);
}

.nav-link.active .nav-link-icon {
  opacity: 1;
}

:root[data-theme="dark"] .nav-link,
:root[data-theme="dark"] .mobile-nav a {
  color: rgba(210, 220, 240, 0.72);
}

:root[data-theme="dark"] .nav-link:hover {
  color: rgba(230, 238, 255, 0.92);
  background: transparent;
}

:root[data-theme="dark"] .nav-link.active {
  color: #8eb4ff;
  background: transparent;
}

:root[data-theme="dark"] .nav-link.active::after {
  background: #7aa6ff;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.weather-pill,
.clock-pill,
.icon-button,
.menu-button,
.primary-button,
.secondary-button,
.danger-button,
.search-button,
.engine-button {
  border: 0;
  outline: 0;
  white-space: nowrap;
}

/* Flat header chips: match nav-link style (no capsule chrome). */
.weather-pill,
.clock-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 4px 6px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  box-shadow: none;
}

.weather-pill {
  gap: 8px;
  min-width: 0;
  max-width: 180px;
  color: var(--text);
}

.weather-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  font-size: 17px;
  line-height: 1;
  opacity: 0.95;
}

.weather-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
  line-height: 1.15;
}

.weather-temp {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.weather-city {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clock-pill {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.icon-button,
.menu-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 0;
  min-height: 36px;
  padding: 6px 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #5b6578;
  font-size: 14px;
  font-weight: 600;
  box-shadow: none;
  transition: color 0.18s ease, opacity 0.18s ease;
}

.header-action-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  opacity: 0.92;
}

.header-action-icon svg {
  display: block;
  width: 18px;
  height: 18px;
}

.header-action-text {
  line-height: 1;
}

.icon-button:hover,
.menu-button:hover {
  color: #4f7ff0;
  background: transparent;
  transform: none;
  box-shadow: none;
}

.icon-button:hover .header-action-icon,
.menu-button:hover .header-action-icon {
  opacity: 1;
}

:root[data-theme="dark"] .icon-button,
:root[data-theme="dark"] .menu-button {
  color: rgba(210, 220, 240, 0.78);
}

:root[data-theme="dark"] .icon-button:hover,
:root[data-theme="dark"] .menu-button:hover {
  color: #8eb4ff;
  background: transparent;
}

:root[data-theme="dark"] .weather-temp {
  color: rgba(236, 242, 255, 0.95);
}

:root[data-theme="dark"] .weather-city {
  color: rgba(210, 220, 240, 0.68);
}

.menu-button {
  display: none;
}

.mobile-nav {
  display: none;
  width: var(--content-width);
  margin: -2px auto 14px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  box-shadow: var(--shadow-card);
  gap: 6px;
}

.mobile-nav .nav-link {
  justify-content: flex-start;
  min-height: 44px;
  padding: 12px 14px 14px;
  border-radius: 14px;
}

.mobile-nav .nav-link:hover {
  background: rgba(91, 138, 245, 0.1);
  color: var(--primary-dark);
}

.mobile-nav .nav-link.active {
  background: rgba(91, 138, 245, 0.08);
}

.mobile-nav .nav-link::after {
  left: 16px;
  transform: none;
  width: 18px;
}

.mobile-nav .nav-link.active::after {
  transform: none;
  width: 22px;
}

:root[data-theme="dark"] .mobile-nav .nav-link:hover {
  background: rgba(122, 160, 248, 0.12);
  color: var(--primary-light);
}

:root[data-theme="dark"] .mobile-nav .nav-link.active {
  background: rgba(122, 160, 248, 0.1);
}

main {
  position: relative;
}

.hero {
  position: relative;
  display: grid;
  align-items: center;
  min-height: min(680px, calc(100vh - var(--header-height)));
  padding: 68px 0 96px;
  overflow: hidden;
}

.hero::before {
  position: absolute;
  inset: 0;
  z-index: -2;
  content: "";
  background:
    radial-gradient(900px 320px at 50% 6%, rgba(255, 255, 255, 0.72), transparent 66%),
    linear-gradient(180deg, rgba(234, 246, 255, 0.22), rgba(240, 244, 248, 0.74) 82%);
  opacity: 1;
}

:root[data-theme="dark"] .hero::before {
  background:
    radial-gradient(900px 320px at 50% 6%, rgba(91, 138, 245, 0.2), transparent 66%),
    linear-gradient(180deg, rgba(30, 35, 48, 0.12), rgba(30, 35, 48, 0.82) 82%);
}

.hero-overlay {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(248, 250, 252, 0.12), var(--bg) 96%),
    radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.68), transparent 42%);
  pointer-events: none;
}

:root[data-theme="dark"] .hero-overlay {
  background:
    linear-gradient(180deg, rgba(30, 35, 48, 0.1), var(--bg) 96%),
    radial-gradient(circle at 50% 20%, rgba(91, 138, 245, 0.2), transparent 48%);
}

.hero-content {
  width: min(860px, calc(100vw - 36px));
  margin: 0 auto;
  text-align: center;
}

.eyebrow,
.section-kicker,
.metric-label {
  display: block;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.3;
  text-transform: uppercase;
}

.hero h1 {
  margin: 16px 0 14px;
  color: var(--text);
  font-size: clamp(42px, 8vw, 76px);
  line-height: 1.03;
  letter-spacing: 0;
}

.hero-title,
.glitch-text {
  position: relative;
  display: inline-block;
  color: #fff;
  font-weight: 900;
  cursor: pointer;
  isolation: isolate;
  text-shadow:
    0 0 16px rgba(255, 255, 255, 0.28),
    0 10px 34px rgba(91, 138, 245, 0.22);
  -webkit-text-stroke: 0.5px rgba(255, 255, 255, 0.16);
  backface-visibility: hidden;
  transform: translateZ(0);
}

/* Reference-style glitch: only while .glitch-active is present */
.glitch-active {
  position: relative;
  animation: glitch-animation 0.5s infinite;
}

.glitch-active::before,
.glitch-active::after {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  border: none;
  content: attr(data-text);
  pointer-events: none;
}

.glitch-active::before {
  z-index: -1;
  color: #0ff;
  clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
  transform: translate(-2px, -2px);
  box-shadow: none;
  animation: glitch-animation-1 0.3s infinite;
}

.glitch-active::after {
  z-index: -2;
  color: #f0f;
  clip-path: polygon(0 60%, 100% 60%, 100% 100%, 0 100%);
  transform: translate(2px, 2px);
  box-shadow: none;
  animation: glitch-animation-2 0.3s infinite;
}

@keyframes glitch-animation {
  0% {
    text-shadow: 1px 0 #0ff, -1px 0 #f0f;
    transform: translate(1px);
  }
  25% {
    text-shadow: -1px 0 #0ff, 1px 0 #f0f;
    transform: translate(-1px, 1px);
  }
  50% {
    text-shadow: 2px 0 #0ff, -2px 0 #f0f;
    transform: translateY(-1px);
  }
  75% {
    text-shadow: -2px 0 #0ff, 2px 0 #f0f;
    transform: translate(1px, 1px);
  }
  100% {
    text-shadow: 1px 0 #0ff, -1px 0 #f0f;
    transform: translate(-1px);
  }
}

@keyframes glitch-animation-1 {
  0% {
    transform: translate(2px, -2px);
  }
  50% {
    transform: translate(-2px, 2px);
  }
  100% {
    transform: translate(2px, -2px);
  }
}

@keyframes glitch-animation-2 {
  0% {
    transform: translate(-2px, 2px);
  }
  50% {
    transform: translate(2px, -2px);
  }
  100% {
    transform: translate(-2px, 2px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .glitch-active,
  .glitch-active::before,
  .glitch-active::after {
    animation: none !important;
  }
}

.hero-subtitle {
  width: min(560px, 100%);
  margin: 0 auto 34px;
  color: var(--text-muted);
  font-size: clamp(17px, 2vw, 20px);
  line-height: 1.8;
  min-height: 1.8em;
}

.typewriter-text {
  white-space: pre-wrap;
}

.typewriter-caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 3px;
  vertical-align: -0.12em;
  border-radius: 1px;
  background: currentColor;
  opacity: 0.72;
  animation: typewriter-caret-blink 0.9s steps(1, end) infinite;
}

.hero-subtitle.is-typed .typewriter-caret {
  animation: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.hero-subtitle.is-holding .typewriter-caret {
  animation: typewriter-caret-blink 0.9s steps(1, end) infinite;
  opacity: 0.72;
}

@keyframes typewriter-caret-blink {
  0%,
  45% {
    opacity: 0.8;
  }
  50%,
  100% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .typewriter-caret {
    animation: none;
    opacity: 0;
  }
}

.search-shell {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  width: min(760px, 100%);
  min-height: 66px;
  margin: 0 auto;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 24px 60px rgba(64, 112, 220, 0.18);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

:root[data-theme="dark"] .search-shell {
  border-color: rgba(122, 160, 248, 0.18);
  background: rgba(37, 42, 55, 0.78);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.engine-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 999px;
  background: rgba(91, 138, 245, 0.1);
  color: var(--text);
  flex: 0 0 auto;
}

.engine-button:hover,
.engine-button[aria-expanded="true"] {
  background: rgba(91, 138, 245, 0.16);
  color: var(--primary-dark);
}

.engine-mark,
.engine-option-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
  color: #fff;
  font-size: 13px;
  line-height: 1;
}

:root[data-theme="dark"] .engine-mark,
:root[data-theme="dark"] .engine-option-icon {
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
}

.engine-brand-icon {
  display: block;
  width: 20px;
  height: 20px;
}

.engine-brand-letter {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.engine-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 8px;
  z-index: 80;
  min-width: 220px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  box-shadow: var(--shadow-card);
  text-align: left;
}

.engine-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text);
  text-align: left;
}

.engine-option:hover,
.engine-option.active {
  background: rgba(91, 138, 245, 0.1);
}

.engine-option-icon {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
}

.engine-option-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.engine-option-copy strong {
  margin-right: 0;
  font-size: 14px;
}

.engine-option-copy span {
  color: var(--text-muted);
  font-size: 12px;
}

#search-input {
  width: 100%;
  min-width: 0;
  height: 50px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 17px;
}

#search-input::placeholder {
  color: var(--text-faint);
}

.search-button,
.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  font-weight: 800;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.search-button,
.primary-button {
  background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
  color: #fff;
  box-shadow: 0 14px 30px rgba(91, 138, 245, 0.24);
}

.search-button {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  flex: 0 0 auto;
}

.search-button-icon {
  display: block;
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.secondary-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.danger-button {
  border: 1px solid rgba(255, 90, 111, 0.28);
  background: rgba(255, 90, 111, 0.1);
  color: var(--danger);
}

.search-button:hover,
.primary-button:hover,
.secondary-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 34px rgba(91, 138, 245, 0.18);
}

kbd {
  display: inline-grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--primary-dark);
  font-weight: 800;
}

.hero-wave {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 72px;
  background: linear-gradient(180deg, transparent, var(--bg));
  pointer-events: none;
}

.page-container {
  width: var(--content-width);
  margin: 0 auto;
  padding-bottom: 92px;
}

.content-section {
  position: relative;
  margin-top: 42px;
}

.content-section:not(.active-panel) {
  display: none;
}

.content-section.active-panel {
  display: flex;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 24px;
}

.section-heading h2 {
  margin: 8px 0 8px;
  color: var(--text);
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.15;
  letter-spacing: 0;
}

.section-heading p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.7;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.update-time {
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}

.shortcut-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.metric-card,
.network-card,
.system-card,
.empty-state {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.shortcut-card {
  --tilt-x: 0;
  --tilt-y: 0;
  --glare-x: 50%;
  --glare-y: 50%;
  --tilt-depth: 0;
  position: relative;
  min-height: 172px;
  padding: 0;
  overflow: visible;
  /* Invisible stable hit shell — all chrome lives on .shortcut-card-face */
  border: 0;
  border-radius: var(--radius-xl);
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  perspective: 720px;
  transform: none;
}

.shortcut-card-face {
  position: relative;
  display: block;
  height: 100%;
  min-height: inherit;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: inherit;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transform:
    rotateX(calc(var(--tilt-x) * 1deg))
    rotateY(calc(var(--tilt-y) * 1deg))
    translate3d(
      calc(var(--tilt-y) * 0.08px),
      calc(var(--tilt-depth) * 0.12px + var(--tilt-x) * 0.08px),
      0
    )
    scale(calc(1 - var(--tilt-depth) * 0.001));
  transform-style: preserve-3d;
  transform-origin: center center;
  transition:
    transform 0.18s ease-out,
    border-color 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
  will-change: transform;
}

.shortcut-card-face::after {
  position: absolute;
  inset: 0;
  z-index: 0;
  content: "";
  border-radius: inherit;
  background:
    radial-gradient(
      210px 160px at var(--glare-x) var(--glare-y),
      rgba(255, 255, 255, 0.48),
      transparent 62%
    ),
    linear-gradient(135deg, rgba(122, 160, 248, 0.22), transparent 48%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  mix-blend-mode: soft-light;
}

.shortcut-card:hover,
.shortcut-card.dragging,
.shortcut-card.is-tilting {
  z-index: 3;
}

.shortcut-card:hover .shortcut-card-face,
.shortcut-card.dragging .shortcut-card-face,
.shortcut-card.is-tilting .shortcut-card-face {
  border-color: rgba(91, 138, 245, 0.4);
  background: var(--surface-strong);
  box-shadow: var(--shadow-soft);
}

/* Pointer-driven press/tilt — applied on face only */
.shortcut-card.is-tilting .shortcut-card-face {
  transition:
    border-color 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
  box-shadow:
    var(--shadow-soft),
    calc(var(--tilt-y) * -1.2px) calc(var(--tilt-x) * 1.1px + 14px) 34px rgba(64, 112, 220, 0.26),
    inset calc(var(--tilt-y) * -0.3px) calc(var(--tilt-x) * 0.35px) 16px rgba(15, 23, 42, 0.12);
}

.shortcut-card.dragging .shortcut-card-face {
  --tilt-x: 0;
  --tilt-y: 0;
  --tilt-depth: 0;
  transform: translate3d(0, -4px, 0);
}

.shortcut-card:hover .shortcut-card-face::after,
.shortcut-card.is-tilting .shortcut-card-face::after {
  opacity: 1;
}

.shortcut-card.is-tilting .shortcut-link,
.shortcut-card.is-tilting .shortcut-actions {
  transform: translateZ(24px);
}

.shortcut-card .shortcut-link,
.shortcut-card .shortcut-actions {
  transition: transform 0.18s ease;
}

.shortcut-link {
  position: relative;
  z-index: 1;
  display: grid;
  height: 100%;
  align-content: start;
  gap: 14px;
}

.shortcut-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.shortcut-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  overflow: hidden;
  border-radius: 15px;
  background: rgba(91, 138, 245, 0.1);
  color: var(--primary-dark);
  font-size: 18px;
  font-weight: 900;
}

.shortcut-icon > span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  line-height: 1;
}

.shortcut-icon img {
  width: 30px;
  height: 30px;
  padding: 3px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
  box-sizing: border-box;
}

:root[data-theme="dark"] .shortcut-icon img {
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.shortcut-category {
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(91, 138, 245, 0.1);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
}

:root[data-theme="dark"] .shortcut-category,
:root[data-theme="dark"] .shortcut-icon {
  color: var(--primary-light);
}

.shortcut-card h3 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.25;
}

.shortcut-card p {
  display: -webkit-box;
  min-height: 44px;
  margin: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.shortcut-url {
  overflow: hidden;
  color: var(--text-faint);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shortcut-actions {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 2;
  display: flex;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

#shortcuts.manage-mode .shortcut-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.shortcut-action {
  min-width: 36px;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.shortcut-action:hover {
  color: var(--primary-dark);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 230px;
  padding: 36px;
  text-align: center;
}

.empty-state h3 {
  margin: 0 0 8px;
  font-size: 24px;
}

.empty-state p {
  margin: 0 0 20px;
  color: var(--text-muted);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.metric-card {
  padding: 22px;
}

.metric-card-top,
.card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.metric-card strong {
  display: block;
  margin-top: 9px;
  color: var(--text);
  font-size: clamp(34px, 5vw, 46px);
  line-height: 1;
}

.metric-caption {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.progress-track {
  height: 10px;
  margin: 22px 0 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(91, 138, 245, 0.12);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary-light), var(--primary-dark));
  transition: width 0.45s ease;
}

.metric-card[data-state="warn"] .progress-track span {
  background: linear-gradient(90deg, #ffd36c, #ff9f43);
}

.metric-card[data-state="danger"] .progress-track span {
  background: linear-gradient(90deg, #ff9aa8, var(--danger));
}

.metric-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

.server-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
  margin-top: 18px;
}

.network-card,
.system-card {
  padding: 22px;
}

.card-title-row h3 {
  margin: 7px 0 0;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

.live-badge,
.system-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(76, 175, 80, 0.12);
  color: var(--success);
  font-size: 12px;
  font-weight: 900;
}

.live-badge span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.system-state.offline {
  background: rgba(255, 90, 111, 0.12);
  color: var(--danger);
}

.speed-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 22px 0 18px;
}

.speed-item {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.46);
}

:root[data-theme="dark"] .speed-item {
  background: rgba(255, 255, 255, 0.04);
}

.speed-item span,
.speed-item small {
  display: block;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.speed-item strong {
  display: block;
  margin: 8px 0 6px;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1.1;
}

.speed-item b {
  color: var(--text);
}

.traffic-chart {
  display: grid;
  grid-template-columns: repeat(24, minmax(4px, 1fr));
  align-items: end;
  min-height: 132px;
  gap: 6px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(91, 138, 245, 0.08);
}

.traffic-bar {
  min-height: 10px;
  border-radius: 999px 999px 4px 4px;
  background: linear-gradient(180deg, var(--primary-light), var(--primary-dark));
  opacity: 0.82;
}

.traffic-bar.upload {
  background: linear-gradient(180deg, #9ad7ff, #3da5ff);
}

.system-list {
  display: grid;
  gap: 12px;
  margin: 22px 0 0;
}

.system-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.system-list div:last-child {
  border-bottom: 0;
}

.system-list dt {
  color: var(--text-muted);
  font-size: 14px;
}

.system-list dd {
  margin: 0;
  color: var(--text);
  font-weight: 800;
  text-align: right;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: var(--content-width);
  margin: 0 auto;
  padding: 28px 0 44px;
  color: var(--text-muted);
  font-size: 14px;
  gap: 16px;
}

.site-footer p {
  margin: 0;
}

.modal {
  width: min(560px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: 0 30px 90px rgba(45, 55, 72, 0.26);
}

.settings-modal {
  width: min(680px, calc(100vw - 32px));
}

.settings-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-muted);
}

.settings-tab {
  flex: 1 1 0;
  min-width: 0;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.settings-tab.active {
  background: var(--surface-strong);
  color: var(--primary-dark);
  box-shadow: 0 8px 18px rgba(91, 138, 245, 0.12);
}

:root[data-theme="dark"] .settings-tab.active {
  color: var(--primary-light);
}

.settings-panels {
  min-height: 0;
}

.settings-panel {
  display: none;
  gap: 16px;
}

.settings-panel.active {
  display: grid;
}

.settings-cards-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.settings-cards-title {
  margin: 0 0 4px;
  font-size: 16px;
}

.settings-cards-toolbar .form-help {
  max-width: 420px;
}

.settings-cards-list {
  display: grid;
  gap: 10px;
  max-height: min(420px, 48vh);
  overflow: auto;
  padding-right: 2px;
}

.settings-card-row {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.42);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}

:root[data-theme="dark"] .settings-card-row {
  background: rgba(255, 255, 255, 0.04);
}

.settings-card-handle {
  display: grid;
  place-items: center;
  width: 28px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-faint);
  cursor: grab;
  font-size: 14px;
  letter-spacing: -2px;
  line-height: 1;
  user-select: none;
  touch-action: none;
}

.settings-card-handle:hover,
.settings-card-handle:focus-visible {
  color: var(--text-muted);
  background: rgba(91, 138, 245, 0.1);
  outline: none;
}

.settings-card-handle:active {
  cursor: grabbing;
}

.settings-card-row.is-dragging {
  opacity: 0.45;
  transform: scale(0.99);
  box-shadow: 0 8px 20px rgba(30, 41, 59, 0.12);
}

.settings-card-row.is-drop-before::before,
.settings-card-row.is-drop-after::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  height: 3px;
  border-radius: 999px;
  background: var(--primary, #5b8af5);
  pointer-events: none;
}

.settings-card-row.is-drop-before::before {
  top: -2px;
}

.settings-card-row.is-drop-after::after {
  bottom: -2px;
}

.settings-card-main {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.settings-card-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border-radius: 12px;
  background: rgba(91, 138, 245, 0.12);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
}

.settings-card-icon img {
  width: 26px;
  height: 26px;
  padding: 3px;
  object-fit: contain;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
  box-sizing: border-box;
}

:root[data-theme="dark"] .settings-card-icon img {
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.settings-card-icon > span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

.settings-card-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.settings-card-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.settings-card-copy span {
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
}

:root[data-theme="dark"] .settings-card-copy span {
  color: var(--primary-light);
}

.settings-card-copy small {
  overflow: hidden;
  color: var(--text-faint);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.settings-card-actions .secondary-button,
.settings-card-actions .danger-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.settings-cards-empty {
  margin: 0;
  padding: 28px 16px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

#settings-panel-general {
  gap: 16px;
}

.server-config-summary {
  margin: 0 0 4px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(91, 138, 245, 0.08);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

:root[data-theme="dark"] .server-config-summary {
  background: rgba(91, 138, 245, 0.12);
}

.upstream-fields {
  display: grid;
  gap: 8px;
}

.server-config-result {
  display: grid;
  gap: 8px;
}

.server-config-result .form-help.is-error {
  color: var(--danger);
}

.server-config-sample {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.server-config-sample strong {
  color: var(--text);
  font-size: 14px;
}

.server-config-sample span {
  color: var(--text-muted);
  font-size: 12px;
}

.settings-choice-group {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-muted);
}

.settings-choice {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  display: block !important;
  gap: 0 !important;
  font-weight: 800;
  color: var(--text-muted);
  cursor: pointer;
}

.settings-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.settings-choice span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 999px;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.settings-choice input:checked + span {
  background: var(--surface-strong);
  color: var(--primary-dark);
  box-shadow: 0 8px 18px rgba(91, 138, 245, 0.12);
}

.settings-choice input:focus-visible + span {
  box-shadow: 0 0 0 4px rgba(91, 138, 245, 0.16);
}

:root[data-theme="dark"] .settings-choice input:checked + span {
  color: var(--primary-light);
}

@media (max-width: 680px) {
  .settings-tabs,
  .settings-choice-group {
    gap: 4px;
    padding: 4px;
  }

  .settings-tab,
  .settings-choice span {
    min-height: 34px;
    padding: 0 6px;
    font-size: 12px;
  }
}

.confirm-modal {
  width: min(430px, calc(100vw - 32px));
}

.confirm-message {
  margin: 0;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.7;
}

:root[data-theme="dark"] .modal {
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.45);
}

.modal::backdrop {
  background: rgba(20, 29, 48, 0.38);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal form {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 2px;
}

.modal-header h2 {
  margin: 6px 0 0;
  font-size: 26px;
  line-height: 1.2;
}

.close-button {
  min-width: 42px;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 800;
}

.close-button:hover {
  color: var(--primary-dark);
}

.modal label,
.modal fieldset {
  display: grid;
  gap: 8px;
}

.modal label {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.modal input,
.modal select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: 0;
  background: rgba(255, 255, 255, 0.62);
  color: var(--text);
  padding: 0 13px;
}

:root[data-theme="dark"] .modal input,
:root[data-theme="dark"] .modal select {
  background: rgba(255, 255, 255, 0.06);
}

.modal input:focus,
.modal select:focus {
  box-shadow: 0 0 0 4px rgba(91, 138, 245, 0.16);
}

#search-input:focus {
  box-shadow: none;
}

.search-shell:focus-within {
  border-color: rgba(91, 138, 245, 0.42);
  box-shadow:
    0 24px 60px rgba(64, 112, 220, 0.18),
    0 0 0 4px rgba(91, 138, 245, 0.16);
}

:root[data-theme="dark"] .search-shell:focus-within {
  border-color: rgba(122, 160, 248, 0.36);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.28),
    0 0 0 4px rgba(91, 138, 245, 0.18);
}

.modal fieldset {
  margin: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.modal legend {
  padding: 0 6px;
  color: var(--primary-dark);
  font-size: 14px;
  font-weight: 900;
}

:root[data-theme="dark"] .modal legend {
  color: var(--primary-light);
}

.form-help {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

.form-help code {
  padding: 2px 5px;
  border-radius: 6px;
  background: rgba(91, 138, 245, 0.11);
  color: var(--primary-dark);
}

.switch-row {
  display: flex !important;
  grid-template-columns: unset;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
}

.switch-row span {
  display: grid;
  gap: 3px;
}

.switch-row small {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.switch-row input {
  width: 50px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  appearance: none;
  border-radius: 999px;
  background: rgba(113, 128, 150, 0.25);
  transition: background 0.2s ease;
}

.switch-row input::before {
  display: block;
  width: 22px;
  height: 22px;
  margin: 2px;
  border-radius: 50%;
  background: #fff;
  content: "";
  transition: transform 0.2s ease;
}

.switch-row input:checked {
  background: var(--primary);
}

.switch-row input:checked::before {
  transform: translateX(22px);
}

.test-button {
  width: fit-content;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.split-actions {
  justify-content: space-between;
}

.split-actions > div {
  display: flex;
  gap: 10px;
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 40px));
}

.toast {
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: var(--shadow-card);
  font-size: 14px;
  line-height: 1.5;
  animation: toast-in 0.22s ease both;
}

.toast.success {
  border-color: rgba(76, 175, 80, 0.22);
}

.toast.error {
  border-color: rgba(255, 90, 111, 0.3);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  :root {
    --content-width: min(100vw - 28px, 760px);
  }

  .main-nav,
  .clock-pill {
    display: none;
  }

  .weather-pill {
    max-width: 132px;
    min-height: 34px;
    padding: 2px 4px;
    gap: 6px;
  }

  .weather-temp {
    font-size: 13px;
  }

  .weather-city {
    font-size: 10px;
  }

  .menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-nav:not([hidden]) {
    display: grid;
  }

  .hero {
    min-height: 610px;
    padding: 54px 0 82px;
  }

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

  .server-detail-grid {
    grid-template-columns: 1fr;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 680px) {
  :root {
    --content-width: calc(100vw - 24px);
    --header-height: 68px;
  }

  .header-inner {
    gap: 10px;
  }

  .brand-title {
    max-width: 120px;
    font-size: 16px;
  }

  .icon-button {
    min-width: 0;
    min-height: 34px;
    padding: 4px 6px;
  }

  .hero {
    min-height: auto;
    padding: 42px 0 72px;
  }

  .hero h1 {
    font-size: 42px;
  }

  .search-shell {
    grid-template-columns: 1fr;
    align-items: stretch;
    min-height: 0;
    padding: 10px;
    border-radius: var(--radius-xl);
    gap: 8px;
  }

  .engine-button,
  .search-button {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }

  #search-input {
    width: 100%;
    height: 48px;
    padding: 0 12px;
    border-radius: var(--radius-md);
    background: rgba(91, 138, 245, 0.08);
  }

  .engine-menu {
    top: 66px;
    right: 10px;
    left: 10px;
  }

  .section-heading,
  .section-heading.server-heading {
    align-items: stretch;
    flex-direction: column;
  }

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

  .shortcut-grid,
  .metric-grid,
  .speed-grid {
    grid-template-columns: 1fr;
  }

  .shortcut-actions {
    position: static;
    margin-top: 14px;
    opacity: 1;
    transform: none;
  }

  .traffic-chart {
    grid-template-columns: repeat(12, minmax(5px, 1fr));
  }

  .system-list div {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .system-list dd {
    text-align: left;
  }

  .modal form {
    padding: 18px;
  }

  .modal-actions,
  .split-actions,
  .split-actions > div {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-cards-toolbar {
    flex-direction: column;
  }

  .settings-cards-toolbar .primary-button {
    width: 100%;
  }

  .settings-card-row {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .settings-card-actions {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .settings-card-actions .secondary-button,
  .settings-card-actions .danger-button {
    flex: 1 1 auto;
  }
}

body {
  height: 100vh;
  overflow: hidden;
}

:root {
  --header-height: 64px;
  --content-width: min(1240px, calc(100vw - 36px));
  --home-panel-width: min(1120px, calc(100vw - 48px));
  --server-panel-width: min(1120px, calc(100vw - 48px));
}

.site-header,
.header-inner {
  min-height: var(--header-height);
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 12px;
}

main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: start;
  height: calc(100vh - var(--header-height));
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
}

main::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    radial-gradient(920px 360px at 50% 5%, rgba(255, 255, 255, 0.62), transparent 68%),
    linear-gradient(180deg, rgba(234, 246, 255, 0.14) 0%, rgba(240, 244, 248, 0.12) 42%, rgba(240, 244, 248, 0.04) 100%);
  pointer-events: none;
}

:root[data-theme="dark"] main::before {
  background:
    radial-gradient(920px 360px at 50% 5%, rgba(91, 138, 245, 0.2), transparent 68%),
    linear-gradient(180deg, rgba(30, 35, 48, 0.08) 0%, rgba(30, 35, 48, 0.04) 46%, rgba(30, 35, 48, 0) 100%);
}

.hero::before,
.hero-overlay {
  display: none;
}

.hero {
  position: relative;
  z-index: 6;
  display: grid;
  align-items: center;
  min-height: 0;
  padding: 22px 0 8px;
  overflow: visible;
}

.hero h1 {
  margin: 6px 0 6px;
  font-size: clamp(34px, 4.4vw, 48px);
}

.hero-subtitle {
  margin-bottom: 14px;
  font-size: 15px;
  line-height: 1.45;
}

.search-shell {
  position: relative;
  z-index: 7;
  min-height: 58px;
  width: min(760px, calc(100vw - 40px));
  box-shadow: 0 18px 44px rgba(64, 112, 220, 0.16);
}

.engine-button,
#search-input {
  height: 44px;
}

.weather-pill,
.clock-pill {
  min-height: 34px;
  padding: 2px 4px;
  font-size: 12px;
}

.weather-pill {
  max-width: 156px;
  gap: 6px;
}

.weather-icon {
  width: 20px;
  height: 20px;
  font-size: 16px;
}

.weather-temp {
  font-size: 13px;
}

.weather-city {
  font-size: 10px;
}

.hero-wave {
  display: none;
}

.dashboard-tabs {
  display: none;
}

.page-container {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 0;
  width: var(--home-panel-width);
  height: auto;
  min-height: 0;
  margin: 0 auto;
  padding-bottom: 0;
  overflow: visible;
}

.page-container[data-active-panel="server"] {
  width: var(--server-panel-width);
}

.content-section {
  display: flex;
  min-height: 0;
  flex-direction: column;
  margin-top: 0;
  overflow: visible;
}

.section-heading {
  align-items: flex-start;
  margin-bottom: 10px;
}

.section-heading h2 {
  margin: 5px 0 4px;
  font-size: clamp(23px, 2.6vw, 32px);
}

.section-heading p {
  font-size: 13px;
  line-height: 1.45;
}

/* Hide helper copy on the shortcuts panel to reduce vertical noise */
#shortcuts .section-heading > div > p:not(.section-kicker) {
  display: none;
}

.section-actions {
  gap: 8px;
}

#shortcuts .section-heading {
  align-items: center;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

#shortcuts .section-heading .primary-button,
#shortcuts .section-heading .secondary-button {
  min-height: 36px;
  padding: 0 14px;
  font-size: 12px;
}

.shortcut-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(104px, 1fr);
  align-content: start;
  flex: 0 0 auto;
  min-height: 0;
  gap: 12px;
  /* Room for hover lift without clipping top borders */
  overflow: visible;
  padding: 8px 4px 10px;
  margin: -8px -4px -2px;
}

.shortcut-card {
  min-height: 0;
  border-radius: var(--radius-lg);
}

.shortcut-card-face {
  padding: 12px;
}

.shortcut-link {
  gap: 8px;
}

.shortcut-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
}

.shortcut-icon img {
  width: 24px;
  height: 24px;
  padding: 2px;
  border-radius: 6px;
}

.shortcut-card h3 {
  font-size: 14px;
}

.shortcut-card p {
  display: none;
  min-height: 0;
  font-size: 12px;
  line-height: 1.45;
  -webkit-line-clamp: 1;
}

.shortcut-url {
  display: none;
  font-size: 10px;
}

.shortcut-actions {
  right: 8px;
  bottom: 8px;
  gap: 5px;
}

.shortcut-action {
  min-width: 30px;
  min-height: 26px;
  padding: 0 7px;
  font-size: 10px;
}

.shortcut-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 40px;
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.shortcut-pager[hidden] {
  display: none;
}

.shortcut-pager .secondary-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

.empty-state {
  flex: 1;
  min-height: 0;
}

.add-shortcut-wide {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  margin-top: 14px;
  border: 1px dashed rgba(91, 138, 245, 0.36);
  border-radius: 14px;
  background: rgba(91, 138, 245, 0.06);
  color: var(--primary-dark);
  font-weight: 800;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.add-shortcut-wide:hover {
  border-color: rgba(91, 138, 245, 0.5);
  border-style: solid;
  background: rgba(91, 138, 245, 0.12);
  transform: translateY(-1px);
}

:root[data-theme="dark"] .add-shortcut-wide {
  border-color: rgba(122, 160, 248, 0.34);
  color: var(--primary-light);
  background: rgba(91, 138, 245, 0.1);
}

.metric-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.metric-card {
  padding: 12px;
}

.metric-card strong {
  margin-top: 5px;
  font-size: clamp(24px, 2.8vw, 32px);
}

.metric-caption {
  font-size: 12px;
}

.progress-track {
  height: 8px;
  margin: 11px 0 7px;
}

.metric-card p {
  font-size: 12px;
  line-height: 1.4;
}

.server-detail-grid {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 1fr);
  flex: 0 0 auto;
  min-height: 0;
  gap: 10px;
  margin-top: 10px;
  overflow: visible;
}

.network-card,
.system-card {
  min-height: 0;
  padding: 12px;
  overflow: hidden;
}

.card-title-row h3 {
  margin-top: 5px;
  font-size: 17px;
}

.speed-grid {
  gap: 8px;
  margin: 9px 0 8px;
}

.speed-item {
  padding: 10px;
}

.speed-item strong {
  margin: 4px 0 2px;
  font-size: clamp(19px, 2.4vw, 25px);
}

.traffic-chart {
  min-height: 44px;
  padding: 8px;
  gap: 4px;
}

.system-list {
  gap: 4px;
  margin-top: 8px;
}

.system-list div {
  padding: 7px 0;
}

.system-list dt {
  font-size: 12px;
}

.system-list dd {
  font-size: 13px;
}

.site-footer {
  display: none;
}

@media (max-width: 980px) {
  :root {
    --content-width: calc(100vw - 24px);
    --header-height: 64px;
  }

  .brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 11px;
  }

  .brand-title {
    font-size: 17px;
  }

  main {
    grid-template-rows: auto 42px minmax(0, 1fr);
  }

  .hero {
    min-height: 0;
    padding: 14px 0 8px;
  }

  .hero h1 {
    font-size: 38px;
  }

  .hero-subtitle {
    margin-bottom: 12px;
  }

  .dashboard-tabs {
    display: flex;
    align-items: center;
    width: var(--content-width);
    min-height: 38px;
    margin: 0 auto 6px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }

  .dashboard-tabs button {
    flex: 1;
    min-height: 30px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 900;
  }

  .dashboard-tabs button.active {
    background: var(--surface-strong);
    color: var(--primary-dark);
    box-shadow: 0 8px 18px rgba(91, 138, 245, 0.12);
  }

  :root[data-theme="dark"] .dashboard-tabs button.active {
    color: var(--primary-light);
  }

  .page-container {
    grid-template-columns: 1fr;
    gap: 0;
    padding-bottom: 10px;
  }

  .content-section {
    display: none;
  }

  .content-section.active-panel {
    display: flex;
  }

  .section-heading {
    align-items: center;
    flex-direction: row;
    gap: 12px;
    margin-bottom: 10px;
  }

  .section-heading h2 {
    font-size: 26px;
  }

  .shortcut-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: 92px;
  }

  .server-detail-grid {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 0.8fr);
  }
}

@media (max-width: 680px) {
  :root {
    --content-width: calc(100vw - 18px);
    --header-height: 58px;
  }

  .header-inner {
    min-height: var(--header-height);
  }

  .brand-logo {
    width: 30px;
    height: 30px;
    border-radius: 10px;
  }

  .brand-title {
    max-width: 116px;
    font-size: 15px;
  }

  .icon-button,
  .menu-button {
    min-width: 0;
    min-height: 34px;
    padding: 4px 6px;
    font-size: 13px;
  }

  main {
    grid-template-rows: 192px 38px 1fr;
  }

  .hero {
    padding: 12px 0 8px;
  }

  .hero h1 {
    margin: 8px 0 6px;
    font-size: 30px;
  }

  .eyebrow {
    font-size: 10px;
  }

  .hero-subtitle {
    margin-bottom: 10px;
    font-size: 13px;
    line-height: 1.35;
  }

  .search-shell {
    grid-template-columns: auto minmax(0, 1fr) auto;
    min-height: 50px;
    padding: 5px;
    border-radius: 999px;
    gap: 3px;
  }

  .engine-button,
  #search-input,
  .search-button {
    width: auto;
    height: 40px;
    min-height: 40px;
  }

  .engine-button {
    width: 36px;
    min-width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
  }

  .engine-mark {
    width: 24px;
    height: 24px;
  }

  .engine-brand-icon {
    width: 16px;
    height: 16px;
  }

  #search-input {
    padding: 0 8px;
    border-radius: 999px;
    background: transparent;
    font-size: 13px;
  }

  .search-button {
    width: 36px;
    min-width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
  }

  .search-button-icon {
    width: 16px;
    height: 16px;
  }

  .dashboard-tabs {
    min-height: 34px;
    margin-bottom: 5px;
  }

  .dashboard-tabs button {
    min-height: 26px;
    font-size: 12px;
  }

  .page-container {
    padding-bottom: 8px;
  }

  .section-heading {
    margin-bottom: 8px;
  }

  .server-heading .section-actions {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
  }

  .section-heading h2 {
    margin: 3px 0 2px;
    font-size: 22px;
  }

  .section-heading p {
    font-size: 12px;
  }

  #server .section-heading p,
  #shortcuts .section-heading p {
    display: none;
  }

  .primary-button,
  .secondary-button,
  .danger-button {
    min-height: 36px;
    padding: 0 13px;
    font-size: 12px;
  }

  .shortcut-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 82px;
    gap: 8px;
  }

  .shortcut-card-face {
    padding: 9px;
  }

  .shortcut-link {
    gap: 5px;
  }

  .shortcut-icon {
    width: 30px;
    height: 30px;
    border-radius: 9px;
  }

  .shortcut-category {
    padding: 4px 7px;
    font-size: 11px;
  }

  .shortcut-card h3 {
    font-size: 14px;
  }

  .shortcut-card p,
  .shortcut-url {
    display: none;
  }

  .shortcut-actions {
    position: absolute;
    right: 8px;
    bottom: 8px;
    gap: 4px;
    margin-top: 6px;
    opacity: 1;
    transform: none;
  }

  .shortcut-action {
    min-width: 28px;
    min-height: 24px;
    padding: 0 5px;
    font-size: 10px;
  }

  .shortcut-pager {
    min-height: 34px;
    margin-top: 6px;
  }

  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .metric-card {
    padding: 10px;
    border-radius: var(--radius-lg);
  }

  .metric-card-top {
    display: block;
  }

  .metric-card strong {
    margin-top: 4px;
    font-size: 22px;
  }

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

  .metric-caption,
  .metric-card p {
    display: none;
  }

  .progress-track {
    height: 7px;
    margin: 8px 0 0;
  }

  .server-detail-grid {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 8px;
    margin-top: 8px;
  }

  .network-card,
  .system-card {
    padding: 10px;
    border-radius: var(--radius-lg);
  }

  .card-title-row h3 {
    font-size: 16px;
  }

  .live-badge,
  .system-state {
    min-height: 24px;
    padding: 0 8px;
    font-size: 10px;
  }

  .speed-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 8px 0;
  }

  .speed-item {
    padding: 9px;
  }

  .speed-item span,
  .speed-item small {
    font-size: 11px;
  }

  .speed-item strong {
    font-size: 18px;
  }

  .traffic-chart {
    min-height: 44px;
    padding: 8px;
    gap: 3px;
  }

  .system-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 10px;
    margin-top: 8px;
  }

  .system-list div {
    padding: 5px 0;
    gap: 2px;
  }

  .system-list dt,
  .system-list dd {
    font-size: 11px;
  }
}

@media (max-height: 760px) and (min-width: 681px) {
  main {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .hero {
    padding: 10px 0 4px;
  }

  .hero h1 {
    margin: 4px 0 4px;
    font-size: 34px;
  }

  .hero-subtitle {
    display: none;
  }

  .shortcut-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: minmax(96px, 104px);
  }

  .traffic-chart {
    min-height: 54px;
  }
}

.heading-title-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
}

.heading-title-line .section-kicker {
  margin: 0;
}

@media (min-width: 981px) {
  main {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .hero {
    padding: 18px 0 6px;
  }

  .page-container {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 0;
    width: var(--home-panel-width);
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .page-container[data-active-panel="server"] {
    width: var(--server-panel-width);
  }

  .content-section {
    min-height: 0;
    padding: 12px 8px 10px;
    border: 1px solid transparent;
    border-radius: 30px;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    overflow: visible;
  }

  :root[data-theme="dark"] .content-section {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
  }

  .section-heading {
    align-items: center;
    min-height: 40px;
    margin-bottom: 14px;
  }

  #server .section-heading {
    margin-bottom: 16px;
  }

  .section-heading h2 {
    margin: 0;
    font-size: clamp(22px, 2vw, 28px);
    letter-spacing: -0.02em;
  }

  .section-heading p:not(.section-kicker) {
    margin-top: 8px;
    font-size: 13px;
  }

  .section-kicker {
    color: var(--text-faint);
    font-size: 12px;
  }

  .section-actions .secondary-button {
    min-height: 38px;
    padding: 0 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.58);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.68);
  }

  :root[data-theme="dark"] .section-actions .secondary-button {
    background: rgba(255, 255, 255, 0.08);
  }

  .update-time {
    font-size: 13px;
  }

  #shortcuts .section-heading {
    align-items: center;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  #shortcuts .section-heading .secondary-button {
    min-height: 38px;
    padding: 0 16px;
    font-size: 13px;
  }

  .shortcut-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: minmax(108px, 118px);
    flex: 0 0 auto;
    gap: 14px;
    overflow: visible;
    padding: 10px 6px 12px;
    margin: -10px -6px -2px;
  }

  #shortcuts {
    overflow: visible;
  }

  .metric-card,
  .network-card,
  .system-card {
    border-radius: 16px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.68)),
      var(--surface-strong);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.72),
      0 10px 24px rgba(64, 112, 220, 0.08);
  }

  :root[data-theme="dark"] .metric-card,
  :root[data-theme="dark"] .network-card,
  :root[data-theme="dark"] .system-card {
    background:
      linear-gradient(180deg, rgba(50, 56, 73, 0.92), rgba(38, 44, 59, 0.76)),
      var(--surface-strong);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.08),
      0 10px 24px rgba(0, 0, 0, 0.18);
  }

  .shortcut-card {
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 16px;
    background: transparent;
    box-shadow: none;
    transform: none;
  }

  .shortcut-card-face {
    min-height: inherit;
    padding: 14px 14px 12px;
    border-radius: inherit;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.68)),
      var(--surface-strong);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.72),
      0 10px 24px rgba(64, 112, 220, 0.08);
    will-change: transform, border-color, box-shadow;
  }

  :root[data-theme="dark"] .shortcut-card-face {
    background:
      linear-gradient(180deg, rgba(50, 56, 73, 0.92), rgba(38, 44, 59, 0.76)),
      var(--surface-strong);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.08),
      0 10px 24px rgba(0, 0, 0, 0.18);
  }

  /* Drag handle only in manage mode */
  .shortcut-card-face::before {
    position: absolute;
    top: 20px;
    right: 16px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text-faint);
    box-shadow:
      0 7px 0 var(--text-faint),
      0 14px 0 var(--text-faint),
      6px 0 0 var(--text-faint),
      6px 7px 0 var(--text-faint),
      6px 14px 0 var(--text-faint);
    content: "";
    opacity: 0;
    transition: opacity 0.18s ease, transform 0.18s ease;
    pointer-events: none;
  }

  #shortcuts.manage-mode .shortcut-card-face::before {
    opacity: 0.72;
  }

  .shortcut-card-face::after {
    position: absolute;
    inset: -1px;
    z-index: 0;
    display: block;
    border-radius: inherit;
    background:
      radial-gradient(
        200px 150px at var(--glare-x) var(--glare-y),
        rgba(255, 255, 255, 0.28),
        transparent 60%
      ),
      radial-gradient(circle at 18% 18%, rgba(122, 160, 248, 0.18), transparent 24%),
      linear-gradient(125deg, transparent 24%, rgba(122, 160, 248, 0.12) 46%, rgba(255, 255, 255, 0.1) 50%, rgba(122, 160, 248, 0.08) 54%, transparent 72%);
    content: "";
    opacity: 0;
    pointer-events: none;
    mix-blend-mode: soft-light;
    transition: opacity 0.22s ease;
  }

  .shortcut-card:hover,
  .shortcut-card:focus-within,
  .shortcut-card.dragging,
  .shortcut-card.is-tilting {
    z-index: 3;
  }

  .shortcut-card:hover .shortcut-card-face,
  .shortcut-card:focus-within .shortcut-card-face,
  .shortcut-card.dragging .shortcut-card-face,
  .shortcut-card.is-tilting .shortcut-card-face {
    border-color: rgba(122, 160, 248, 0.55);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.82),
      0 16px 34px rgba(64, 112, 220, 0.2),
      0 0 0 1px rgba(122, 160, 248, 0.08);
  }

  .shortcut-card.is-tilting .shortcut-card-face {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.82),
      inset calc(var(--tilt-y) * -0.35px) calc(var(--tilt-x) * 0.4px) 18px rgba(15, 23, 42, 0.14),
      calc(var(--tilt-y) * -1.25px) calc(var(--tilt-x) * 1.1px + 15px) 36px rgba(64, 112, 220, 0.28),
      0 0 0 1px rgba(122, 160, 248, 0.12);
  }

  .shortcut-card.dragging .shortcut-card-face {
    --tilt-x: 0;
    --tilt-y: 0;
    --tilt-depth: 0;
    transform: translate3d(0, -5px, 0);
  }

  #shortcuts.manage-mode .shortcut-card:hover .shortcut-card-face::before,
  #shortcuts.manage-mode .shortcut-card:focus-within .shortcut-card-face::before {
    opacity: 0.95;
    transform: translate3d(1px, -1px, 0);
  }

  .shortcut-card:hover .shortcut-card-face::after,
  .shortcut-card:focus-within .shortcut-card-face::after,
  .shortcut-card.is-tilting .shortcut-card-face::after {
    opacity: 0.78;
  }

  .shortcut-link {
    position: relative;
    z-index: 1;
    display: flex;
    height: 100%;
    flex-direction: column;
    gap: 12px;
  }

  .shortcut-top {
    display: block;
  }

  .shortcut-icon {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 13px;
    background: rgba(91, 138, 245, 0.08);
    box-shadow: 0 0 0 rgba(122, 160, 248, 0);
    transition: transform 0.35s ease, background 0.35s ease, box-shadow 0.35s ease;
  }

  .shortcut-icon > span,
  .shortcut-icon img {
    grid-area: 1 / 1;
  }

  .shortcut-icon img {
    width: 24px;
    height: 24px;
  }

  .shortcut-card:hover .shortcut-icon,
  .shortcut-card:focus-within .shortcut-icon {
    background: rgba(91, 138, 245, 0.16);
    box-shadow: 0 0 16px rgba(122, 160, 248, 0.24);
    transform: translate3d(0, -3px, 0) rotate(-2deg) scale(1.04);
  }

  .shortcut-card h3 {
    margin-top: auto;
    padding-right: 56px;
    font-size: 14px;
    transition: color 0.25s ease, transform 0.25s ease, text-shadow 0.25s ease;
  }

  .shortcut-card:hover h3,
  .shortcut-card:focus-within h3 {
    color: var(--primary-dark);
    text-shadow: 0 0 18px rgba(122, 160, 248, 0.22);
    transform: translate3d(0, -2px, 0);
  }

  .shortcut-card p,
  .shortcut-url {
    display: none;
  }

  .shortcut-category {
    position: absolute;
    right: 0;
    bottom: 0;
    padding: 6px 11px;
    background: rgba(91, 138, 245, 0.1);
    font-size: 12px;
    transition: opacity 0.18s ease, transform 0.24s ease, background 0.24s ease;
  }

  .shortcut-card:hover .shortcut-category,
  .shortcut-card:focus-within .shortcut-category {
    background: rgba(91, 138, 245, 0.16);
    transform: translate3d(0, -2px, 0);
  }

  :root[data-theme="dark"] .shortcut-card:hover .shortcut-card-face,
  :root[data-theme="dark"] .shortcut-card:focus-within .shortcut-card-face,
  :root[data-theme="dark"] .shortcut-card.dragging .shortcut-card-face {
    border-color: rgba(122, 160, 248, 0.52);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.12),
      0 18px 42px rgba(0, 0, 0, 0.34),
      0 0 28px rgba(91, 138, 245, 0.18);
  }

  :root[data-theme="dark"] .shortcut-card:hover .shortcut-card-face::after,
  :root[data-theme="dark"] .shortcut-card:focus-within .shortcut-card-face::after {
    opacity: 0.3;
  }

  :root[data-theme="dark"] .shortcut-card:hover h3,
  :root[data-theme="dark"] .shortcut-card:focus-within h3 {
    color: var(--primary-light);
    text-shadow: 0 0 20px rgba(122, 160, 248, 0.28);
  }

  .shortcut-actions {
    right: 14px;
    bottom: 14px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(6px);
  }

  /* Actions only in manage mode — not on every hover */
  #shortcuts.manage-mode .shortcut-actions {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  #shortcuts.manage-mode .shortcut-category {
    opacity: 0;
  }

  .add-shortcut-wide {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    margin-top: 16px;
    border: 1px dashed rgba(91, 138, 245, 0.34);
    border-radius: 14px;
    background: rgba(91, 138, 245, 0.06);
    color: var(--primary-dark);
    font-weight: 800;
    box-shadow: none;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  }

  .add-shortcut-wide:hover {
    border-color: rgba(91, 138, 245, 0.48);
    border-style: solid;
    background: rgba(91, 138, 245, 0.12);
    transform: translateY(-1px);
  }

  :root[data-theme="dark"] .add-shortcut-wide {
    border-color: rgba(122, 160, 248, 0.34);
    color: var(--primary-light);
    background: rgba(91, 138, 245, 0.1);
    box-shadow: none;
  }

  :root[data-theme="dark"] .add-shortcut-wide:hover {
    border-color: rgba(122, 160, 248, 0.48);
    background: rgba(91, 138, 245, 0.16);
  }

  .shortcut-pager {
    min-height: 32px;
    margin-top: 10px;
  }

  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }

  .metric-card {
    min-height: 0;
    padding: 14px 16px 12px;
  }

  .metric-card strong {
    margin-top: 8px;
    font-size: clamp(28px, 2.6vw, 34px);
    letter-spacing: -0.03em;
  }

  .metric-caption {
    margin-top: 2px;
    font-size: 12px;
  }

  .progress-track {
    height: 8px;
    margin: 12px 0 8px;
  }

  .metric-card p {
    font-size: 12px;
  }

  .server-detail-grid {
    grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.9fr);
    align-items: stretch;
    flex: 0 0 auto;
    gap: 12px;
    margin-top: 12px;
  }

  .network-card,
  .system-card {
    display: flex;
    min-height: 0;
    flex-direction: column;
    padding: 16px;
  }

  .card-title-row h3 {
    margin-top: 6px;
    font-size: 17px;
  }

  .speed-grid {
    gap: 10px;
    margin: 12px 0 10px;
  }

  .speed-item {
    padding: 12px;
    border-radius: 13px;
  }

  .speed-item strong {
    margin: 4px 0 4px;
    font-size: clamp(20px, 1.9vw, 26px);
    letter-spacing: -0.03em;
    white-space: nowrap;
  }

  .traffic-chart-wrap {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    gap: 8px;
  }

  .traffic-chart {
    flex: 1 1 auto;
    min-height: 88px;
    max-height: 120px;
    padding: 10px 12px;
    align-items: end;
    gap: 4px;
  }

  .traffic-chart-meta {
    margin: 0;
    color: var(--text-faint);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
  }

  .system-card {
    justify-content: flex-start;
  }

  .system-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 14px;
    margin-top: 12px;
  }

  .system-list div {
    display: grid;
    gap: 4px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
  }

  .system-list div:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .system-list dt {
    font-size: 12px;
  }

  .system-list dd {
    text-align: left;
    font-size: 14px;
  }
}

/* Server panel: dedicated monitor dashboard, no search chrome */
body[data-active-panel="server"] .hero {
  display: none;
}

body[data-active-panel="server"] main {
  grid-template-rows: minmax(0, 1fr);
}

body[data-active-panel="server"] .page-container {
  width: min(1180px, calc(100vw - 40px));
  height: 100%;
  align-content: start;
}

body[data-active-panel="server"] #server {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  padding: 10px 4px 12px;
  overflow: auto;
}

.server-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1.2fr) auto;
  gap: 16px;
  align-items: stretch;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(91, 138, 245, 0.14), rgba(255, 255, 255, 0.58) 48%, rgba(141, 232, 255, 0.12)),
    var(--surface-strong);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 16px 36px rgba(64, 112, 220, 0.1);
}

:root[data-theme="dark"] .server-hero {
  background:
    linear-gradient(135deg, rgba(91, 138, 245, 0.18), rgba(38, 44, 59, 0.88) 52%, rgba(88, 217, 255, 0.08)),
    var(--surface-strong);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 16px 36px rgba(0, 0, 0, 0.22);
}

.server-hero-identity {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.server-status-block {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.server-hero-copy h2 {
  margin: 4px 0 6px;
  font-size: clamp(24px, 2.8vw, 34px);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.server-hero-copy p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.server-hero-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.server-stat {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid rgba(91, 138, 245, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.48);
}

:root[data-theme="dark"] .server-stat {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.server-stat-label {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.server-stat-value {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
}

.server-hero-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  min-width: 132px;
}

.server-hero-actions .update-time {
  text-align: right;
  white-space: nowrap;
}

.server-board {
  display: grid;
  gap: 14px;
  min-height: 0;
}

body[data-active-panel="server"] .metric-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

body[data-active-panel="server"] .metric-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 148px;
  padding: 16px;
}

.metric-ring {
  position: relative;
  width: 84px;
  height: 84px;
  flex: 0 0 auto;
  border-radius: 50%;
  background:
    conic-gradient(
      from 210deg,
      var(--primary-light) 0 calc(var(--metric-value) * 1%),
      rgba(91, 138, 245, 0.12) calc(var(--metric-value) * 1%) 100%
    );
  box-shadow: inset 0 0 0 1px rgba(91, 138, 245, 0.08);
}

.metric-card[data-state="warn"] .metric-ring {
  background:
    conic-gradient(
      from 210deg,
      #ffd36c 0 calc(var(--metric-value) * 1%),
      rgba(255, 163, 67, 0.14) calc(var(--metric-value) * 1%) 100%
    );
}

.metric-card[data-state="danger"] .metric-ring {
  background:
    conic-gradient(
      from 210deg,
      #ff9aa8 0 calc(var(--metric-value) * 1%),
      rgba(255, 90, 111, 0.14) calc(var(--metric-value) * 1%) 100%
    );
}

.metric-ring-track {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.72)),
    var(--surface-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

:root[data-theme="dark"] .metric-ring-track {
  background:
    linear-gradient(180deg, rgba(50, 56, 73, 0.96), rgba(38, 44, 59, 0.88)),
    var(--surface-strong);
}

.metric-ring-value {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.metric-card-body {
  min-width: 0;
}

body[data-active-panel="server"] .metric-card strong,
body[data-active-panel="server"] .metric-card .metric-ring-value {
  margin-top: 0;
  font-size: 18px;
}

body[data-active-panel="server"] .metric-label {
  display: block;
  margin-bottom: 4px;
}

body[data-active-panel="server"] .metric-caption {
  display: block;
  margin-top: 0;
  white-space: normal;
}

body[data-active-panel="server"] .progress-track {
  margin: 12px 0 8px;
}

body[data-active-panel="server"] .server-detail-grid {
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.9fr);
  gap: 12px;
  margin-top: 0;
}

body[data-active-panel="server"] .network-card,
body[data-active-panel="server"] .system-card {
  min-height: 0;
  padding: 16px;
}

.server-containers-card .card-title-row {
  align-items: center;
}

.container-count-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(91, 138, 245, 0.1);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

:root[data-theme="dark"] .container-count-badge {
  color: var(--primary-light);
  background: rgba(122, 160, 248, 0.12);
}

.container-count-badge[data-state="warn"] {
  color: #d9891d;
  background: rgba(255, 183, 77, 0.14);
}

.container-count-badge[data-state="muted"] {
  color: var(--text-muted);
  background: rgba(148, 163, 184, 0.12);
}

.container-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  max-height: 280px;
  overflow: auto;
  padding-right: 2px;
}

.container-empty {
  padding: 18px 14px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
}

.container-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 12px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.42);
}

:root[data-theme="dark"] .container-row {
  background: rgba(255, 255, 255, 0.04);
}

.container-row-main,
.container-row-meta {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.container-row-meta {
  justify-items: end;
  text-align: right;
}

.container-name {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.container-image,
.container-uptime {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.container-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(113, 128, 150, 0.14);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
}

.container-row[data-status="running"] .container-status {
  background: rgba(52, 199, 123, 0.14);
  color: #1f9d5a;
}

.container-row[data-status="exited"] .container-status,
.container-row[data-status="dead"] .container-status {
  background: rgba(255, 90, 111, 0.12);
  color: var(--danger);
}

.container-row[data-status="restarting"] .container-status {
  background: rgba(255, 183, 77, 0.16);
  color: #d9891d;
}

.server-summary-note {
  margin: 14px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}

.live-badge.is-offline {
  background: rgba(255, 90, 111, 0.12);
  color: var(--danger);
}

.traffic-chart-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.traffic-chart-meta {
  margin: 0;
  color: var(--text-faint);
  font-size: 11px;
}

@media (max-width: 1100px) {
  .server-hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .server-hero-actions {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
  }
}

@media (max-width: 980px) {
  body[data-active-panel="server"] main {
    grid-template-rows: 42px minmax(0, 1fr);
  }

  body[data-active-panel="server"] .page-container {
    width: var(--content-width);
    height: auto;
  }

  body[data-active-panel="server"] #server {
    padding: 4px 0 10px;
  }

  body[data-active-panel="server"] .metric-grid {
    grid-template-columns: 1fr;
  }

  body[data-active-panel="server"] .metric-card {
    min-height: 0;
  }

  body[data-active-panel="server"] .server-detail-grid {
    grid-template-columns: 1fr;
  }

  .server-hero-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .server-hero {
    padding: 14px;
    border-radius: 18px;
  }

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

  .server-hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .server-hero-actions .update-time {
    text-align: left;
  }

  body[data-active-panel="server"] .metric-card {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
  }

  .metric-ring {
    width: 72px;
    height: 72px;
  }

  .metric-ring-track {
    inset: 8px;
  }

  .metric-ring-value {
    font-size: 15px;
  }
}

@media (min-width: 981px) and (max-width: 1260px) {
  :root {
    --home-panel-width: min(1000px, calc(100vw - 40px));
    --server-panel-width: min(1040px, calc(100vw - 40px));
  }

  .page-container {
    width: var(--home-panel-width);
    gap: 0;
  }

  .page-container[data-active-panel="server"] {
    width: var(--server-panel-width);
  }

  .content-section {
    padding: 12px 4px 8px;
  }

  .shortcut-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: minmax(100px, 110px);
    gap: 12px;
  }

  .metric-grid,
  .server-detail-grid {
    gap: 10px;
  }
}

@media (max-width: 980px) {
  .heading-title-line {
    align-items: center;
    gap: 9px;
  }

  .add-shortcut-wide {
    display: none;
  }
}

/* Auth / admin chrome — account controls live in settings dialog */
.settings-account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.settings-account-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.settings-account-copy strong {
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.3;
}

.settings-account-copy .form-help {
  margin: 0;
}

.settings-account-row .primary-button,
.settings-account-row .secondary-button {
  flex: 0 0 auto;
  min-width: 96px;
}

.settings-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.admin-block {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.35);
}

:root[data-theme="dark"] .admin-block {
  background: rgba(255, 255, 255, 0.04);
}

.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.admin-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.admin-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.42);
}

:root[data-theme="dark"] .admin-list-row {
  background: rgba(255, 255, 255, 0.03);
}

.admin-list-row strong {
  display: block;
  margin-bottom: 4px;
}

.admin-list-row small {
  color: var(--text-muted);
  font-size: 12px;
}

.admin-row-actions {
  display: inline-flex;
  gap: 8px;
}

.admin-role-row .switch-row {
  width: 100%;
  align-items: flex-start;
}

.admin-role-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.admin-role-copy strong {
  margin-bottom: 0;
}

.admin-role-fixed {
  color: var(--primary-light) !important;
}

.admin-role-control {
  display: inline-flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 0 0 auto;
  min-width: 72px;
  padding-top: 2px;
}

.admin-role-control-label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.admin-role-switch input[disabled] {
  opacity: 0.72;
  cursor: not-allowed;
}

#admin-user-role {
  text-overflow: ellipsis;
}

#install-error,
#login-error {
  color: var(--danger);
}

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

  .settings-account-row {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-account-row .primary-button,
  .settings-account-row .secondary-button {
    width: 100%;
  }
}

@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;
  }

  .hero-title,
  .hero-title::before,
  .hero-title::after {
    animation: none !important;
  }

  .shortcut-card,
  .shortcut-card-face,
  .shortcut-card-face::before,
  .shortcut-card-face::after,
  .shortcut-icon,
  .shortcut-card h3,
  .shortcut-category {
    transform: none !important;
  }

  .shortcut-card:hover:not(.dragging),
  .shortcut-card:focus-within:not(.dragging),
  .shortcut-card.is-tilting,
  .shortcut-card:hover:not(.dragging) .shortcut-card-face,
  .shortcut-card:focus-within:not(.dragging) .shortcut-card-face,
  .shortcut-card.is-tilting .shortcut-card-face {
    animation: none !important;
    transform: none !important;
  }

  .shortcut-card {
    --tilt-x: 0 !important;
    --tilt-y: 0 !important;
    --tilt-depth: 0 !important;
  }

  .header-toggle-tag,
  .header-toggle-tag.is-pulling,
  .header-toggle-tag__tail-group,
  .header-toggle-tag__paper-group,
  .header-toggle-tag__star,
  .header-toggle-tag__dot {
    animation: none !important;
  }

  .header-toggle-tag__graphic {
    transition: none !important;
  }
}

/* Hanging header toggle tag (right-top pull cord) */
.header-toggle-tag {
  position: fixed;
  top: 28px;
  right: 8px;
  /* Sit behind the sticky header so the cord peeks out from under it. */
  z-index: 30;
  width: 64px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  transform-origin: top center;
  transition:
    top 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55),
    filter 0.3s ease;
  animation: header-toggle-tag-sway 5.4s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
}


.header-toggle-tag.is-pulling {
  animation: header-toggle-tag-pull 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.header-toggle-tag:hover .header-toggle-tag__graphic {
  transform: translateY(6px);
}

.header-toggle-tag:focus-visible {
  outline: 2px solid rgba(91, 138, 245, 0.28);
  outline-offset: 2px;
}

.header-toggle-tag__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.header-toggle-tag__graphic {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  transition: transform 0.22s ease;
  filter: drop-shadow(0 8px 14px rgba(64, 112, 220, 0.18));
}

.header-toggle-tag__string,
.header-toggle-tag__thread {
  fill: none;
  stroke: rgba(141, 181, 194, 0.88);
  stroke-width: 2.1;
  stroke-linecap: round;
}

.header-toggle-tag__bead {
  fill: #91d2df;
  stroke: rgba(255, 255, 255, 0.72);
  stroke-width: 1.6;
}

.header-toggle-tag__paper {
  fill: url(#headerToggleTagPaper);
  stroke: rgba(106, 186, 206, 0.78);
  stroke-width: 2;
}

.header-toggle-tag__paper-hole {
  fill: rgba(255, 255, 255, 0.78);
}

.header-toggle-tag__shine {
  fill: none;
  stroke: rgba(255, 255, 255, 0.82);
  stroke-width: 2.2;
  stroke-linecap: round;
  opacity: 0.28;
}

.header-toggle-tag__sparkles {
  fill: rgba(255, 249, 184, 0.92);
  opacity: 0.72;
}

/* Night ornament (moon + stars) is hidden in light theme. */
.header-toggle-tag__night {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.header-toggle-tag__day-only {
  transition: opacity 0.28s ease;
}

.header-toggle-tag__moon-glow {
  fill: rgba(255, 236, 170, 0.18);
}

.header-toggle-tag__moon-body {
  fill: url(#headerToggleTagMoon);
  stroke: rgba(255, 248, 220, 0.72);
  stroke-width: 1.2;
}

.header-toggle-tag__moon-cut {
  fill: #1a2238;
}

.header-toggle-tag__moon-crater {
  fill: rgba(176, 148, 84, 0.28);
}

.header-toggle-tag__star,
.header-toggle-tag__dot {
  transform-box: fill-box;
  transform-origin: center;
}

.header-toggle-tag__star {
  fill: rgba(255, 246, 196, 0.95);
}

.header-toggle-tag__dot {
  fill: rgba(255, 250, 230, 0.9);
}

.header-toggle-tag__star--a {
  animation: header-toggle-tag-twinkle 2.4s ease-in-out infinite;
}

.header-toggle-tag__star--b {
  animation: header-toggle-tag-twinkle 2.8s ease-in-out infinite 0.35s;
}

.header-toggle-tag__star--c {
  animation: header-toggle-tag-twinkle 3.1s ease-in-out infinite 0.7s;
}

.header-toggle-tag__dot--a {
  animation: header-toggle-tag-twinkle 2.2s ease-in-out infinite 0.2s;
}

.header-toggle-tag__dot--b {
  animation: header-toggle-tag-twinkle 2.6s ease-in-out infinite 0.55s;
}

.header-toggle-tag__dot--c {
  animation: header-toggle-tag-twinkle 2.9s ease-in-out infinite 0.9s;
}

.header-toggle-tag__dot--d {
  animation: header-toggle-tag-twinkle 3.3s ease-in-out infinite 1.1s;
}

:root[data-theme="dark"] .header-toggle-tag__graphic {
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.35));
}

:root[data-theme="dark"] .header-toggle-tag__string,
:root[data-theme="dark"] .header-toggle-tag__thread {
  stroke: rgba(170, 190, 230, 0.72);
}

:root[data-theme="dark"] .header-toggle-tag__bead {
  fill: #7f92c8;
  stroke: rgba(230, 238, 255, 0.55);
}

:root[data-theme="dark"] .header-toggle-tag__paper {
  fill: url(#headerToggleTagPaperDark);
  stroke: rgba(132, 152, 206, 0.62);
}

:root[data-theme="dark"] .header-toggle-tag__paper-hole {
  fill: rgba(18, 24, 40, 0.88);
}

:root[data-theme="dark"] .header-toggle-tag__shine {
  stroke: rgba(190, 210, 255, 0.34);
  opacity: 0.2;
}

:root[data-theme="dark"] .header-toggle-tag__day-only {
  opacity: 0;
}

:root[data-theme="dark"] .header-toggle-tag__night {
  opacity: 1;
}

:root[data-theme="dark"] .header-toggle-tag__moon-cut {
  fill: #1a2238;
}

.header-toggle-tag__tail-group {
  transform-origin: 60px 159px;
  transform-box: view-box;
  animation: header-toggle-tag-tail 3.9s ease-in-out infinite;
}

.header-toggle-tag__paper-group {
  transform-origin: 60px 173px;
  transform-box: view-box;
  animation: header-toggle-tag-paper 4.2s ease-in-out infinite;
}

.header-toggle-tag.is-pulling .header-toggle-tag__paper-group {
  animation-duration: 0.9s;
  animation-timing-function: cubic-bezier(0.24, 0.9, 0.3, 1);
}

.header-toggle-tag__flower {
  transform-box: fill-box;
}

.header-toggle-tag__flower--left {
  transform: translate(51px, 244px) rotate(-10deg) scale(0.84);
}

.header-toggle-tag__flower--right {
  transform: translate(65px, 234px) rotate(8deg) scale(0.98);
}

.flower-petal {
  fill: rgba(255, 255, 255, 0.94);
}

.flower-core {
  fill: #ffe58a;
}

.flower-leaf {
  fill: none;
  stroke: #80dca3;
  stroke-width: 2;
  stroke-linecap: round;
}

@keyframes header-toggle-tag-sway {
  0%,
  100% {
    transform: rotate(0);
  }
  20% {
    transform: rotate(4deg);
  }
  46% {
    transform: rotate(-5.5deg);
  }
  72% {
    transform: rotate(3deg);
  }
}

@keyframes header-toggle-tag-tail {
  0%,
  100% {
    transform: rotate(-2deg) translate(0);
  }
  25% {
    transform: rotate(8deg) translate(2px);
  }
  50% {
    transform: rotate(-10deg) translate(-3px);
  }
  75% {
    transform: rotate(4deg) translate(1px);
  }
}

@keyframes header-toggle-tag-paper {
  0%,
  100% {
    transform: rotate(-1.5deg) translate(0);
  }
  30% {
    transform: rotate(5deg) translate(1px);
  }
  62% {
    transform: rotate(-6deg) translate(-2px);
  }
  82% {
    transform: rotate(2deg) translate(1px);
  }
}

@keyframes header-toggle-tag-pull {
  0% {
    transform: rotate(0) translateY(0);
  }
  18% {
    transform: rotate(9deg) translateY(2px);
  }
  38% {
    transform: rotate(-8deg) translateY(6px);
  }
  62% {
    transform: rotate(5deg) translateY(2px);
  }
  100% {
    transform: rotate(0) translateY(0);
  }
}

@keyframes header-toggle-tag-twinkle {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.88);
  }
  45% {
    opacity: 1;
    transform: scale(1.08);
  }
  70% {
    opacity: 0.62;
    transform: scale(0.96);
  }
}

@media (max-width: 768px) {
  .header-toggle-tag {
    top: 20px;
    right: 2px;
    width: 54px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .header-toggle-tag,
  .header-toggle-tag.is-pulling,
  .header-toggle-tag__tail-group,
  .header-toggle-tag__paper-group,
  .header-toggle-tag__star,
  .header-toggle-tag__dot {
    animation: none !important;
  }

  .header-toggle-tag__graphic {
    transition: none !important;
  }

  .site-header {
    transition: opacity 0.2s ease;
  }
}
