@import url('../styles/tokens.css');
@import url('../styles/atoms.css');
@import url('../styles/molecules.css');
@import url('../styles/organisms.css');
@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,500;0,600;1,400;1,500&family=Plus+Jakarta+Sans:wght@300;400;500;600&display=swap');

:root {
  /* ── THEME COLORS — mutated at runtime by the theme panel scripts ── */
  --bg:      #131110;
  --bg2:     #1a1714;
  --card:    #1f1c19;
  --card2:   #252119;
  --border:  #2e2a24;
  --border2: #3a3530;
  --blue:    #468DCB;
  --teal:    #14b8a6;
  --amber:   #e8a74a;
  --red:     #e06c75;
  --green:   #6ec99a;
  --purple:  #9b8af0;
  --push-c:  #e8934a;
  --pull-c:  #9b8af0;
  --legs-c:  #14b8a6;
  --upper-c: #61afef;
  --text:    #ede8e2;
  --text2:   #b8b0a6;
  --text3:   #7a7268;
  --text4:   #4a443e;
  --white:   #f5f0eb;
  --font-display: 'Lora';
  --font-body: 'Plus Jakarta Sans';

  /* ── RADIUS — base value mutated by the theme panel scripts ── */
  --radius: 10px;
  /* Named scale defined in tokens.css; listed here as reference:
     --radius-sm: 6px | --radius-md: 10px | --radius-lg: 16px | --radius-xl: 24px */

  /* ── TEXT SIZE SCALE ── */
  --text-2xs:  8px;
  --text-xs:   10px;
  --text-sm:   12px;
  --text-base: 14px;
  --text-md:   16px;
  --text-lg:   20px;
  --text-xl:   24px;
  --duration-fast:  0.15s;
  --duration-base:  0.2s;
  --duration-slow:  0.3s;
  --duration-enter: 0.28s;
  --ease-out: cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.35);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.28);
  --shadow-lg:  0 8px 28px rgba(0,0,0,0.36);
  --shadow-floating: 0 12px 40px rgba(0,0,0,0.42);
  --card-highlight: rgba(255,255,255,0.05);
  --card-highlight-hover: rgba(255,255,255,0.07);
  --card-overlay: linear-gradient(135deg, transparent 0%, transparent 55%);
  --card-bg: var(--card);
  --card-bg-hover: var(--card2);
  --z-base:    1;
  --z-overlay: 99;
  --z-noise:   100;
  --z-header:  300;
  --z-nav-bg:  310;
  --z-nav:     320;
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue);
  --card-opacity:  0.1;
  --card-blur:     10px;
  --noise-opacity: 0.03;
  --vig-opacity:   0.4;
  --nav-w:    220px;
  --header-h: 52px;

  /* ── Density ── */
  --density-page-x: 28px;
  --density-page-y: 20px;
  --density-card-x: 22px;
  --density-card-y: 20px;
  --density-gap:    10px;
  --density-card-inner: 14px;
}

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

@view-transition {
  navigation: auto;
}

::view-transition-old(dashboard-nav),
::view-transition-new(dashboard-nav),
::view-transition-old(dashboard-mobile-header),
::view-transition-new(dashboard-mobile-header) {
  animation-duration: 0ms;
}

::view-transition-old(dashboard-page),
::view-transition-new(dashboard-page) {
  animation-duration: 160ms;
}

html, body {
  width: 100%; height: 100%;
  touch-action: manipulation;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 75% 55% at 12% 18%, color-mix(in srgb, var(--blue) 7%, transparent), transparent),
    radial-gradient(ellipse 65% 45% at 88% 82%, color-mix(in srgb, var(--teal) 5%, transparent), transparent);
  color: var(--text);
  font-family: var(--font-body), sans-serif;
  overflow: hidden;
}

body::after {
  content: ''; position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none; z-index: var(--z-noise);
  opacity: var(--noise-opacity);
}
body::before {
  content: ''; position: fixed; inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,1) 100%);
  pointer-events: none; z-index: var(--z-overlay);
  opacity: var(--vig-opacity);
}

/* ── LAYOUT ── */
.app {
  position: relative; z-index: var(--z-base);
  width: 100vw; height: 100vh;
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
}

/* ── NAV ── */
.nav {
  display: flex; flex-direction: column;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  position: relative; overflow: hidden;
  overflow-y: auto;
  scrollbar-width: none; /* Firefox */
  view-transition-name: dashboard-nav;
}
.nav::-webkit-scrollbar { display: none; } /* Chrome/Safari/Edge */
.nav::after {
  content: '';
  position: absolute; top: 0; right: -1px; bottom: 0; width: 1px;
  background: linear-gradient(180deg, transparent 5%, var(--blue) 35%, var(--blue) 65%, transparent 95%);
  opacity: 0.2;
}

.nav-top { padding: 24px 20px 16px; border-bottom: 1px solid var(--border); }
.nav-brand-name { font-size: 10px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text2); }
.nav-brand-sub { font-size: 9px; color: var(--text3); margin-top: 2px; letter-spacing: 0.05em; opacity: 0.7; }

.nav-links { padding: 12px 12px 0; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 11px; border-radius: var(--radius-sm);
  text-decoration: none; font-size: 12px; font-weight: 500;
  color: var(--text2); transition: all var(--duration-fast);
  letter-spacing: 0.01em; border: 1px solid transparent;
}
.nav-link:hover { background: var(--card); color: var(--white); }
.nav-link:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  background: var(--card);
}
.nav-link.active {
  background: color-mix(in srgb, var(--blue) 10%, transparent);
  color: var(--blue);
  border-color: color-mix(in srgb, var(--blue) 20%, transparent);
}
.nav-icon { width: 15px; height: 15px; flex-shrink: 0; transition: transform var(--duration-fast) ease; }
.nav-link:hover .nav-icon { transform: scale(1.2); }
.nav-link:hover .nav-icon-gear { transform: rotate(30deg) scale(1.1); }
.nav-link.active .nav-icon { transform: scale(1.1); }

/* Quick links */
.nav-section-label {
  font-size: 8px; font-weight: 700; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--text3);
  padding: 16px 12px 6px;
}
.nav-divider { height: 1px; background: var(--border); margin: 8px 12px; }

.nav-links-quick { padding: 0 12px 18px; display: flex; flex-direction: column; gap: 2px; }
.quick-link {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 11px; border-radius: var(--radius-sm);
  text-decoration: none; font-size: 11px; font-weight: 400;
  color: var(--text2); transition: all var(--duration-fast); letter-spacing: 0.01em;
}
.quick-link:hover { background: var(--card); color: var(--blue); }
.quick-link:focus-visible { outline: none; box-shadow: var(--focus-ring); background: var(--card); }
.quick-link-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--border2); flex-shrink: 0; transition: background var(--duration-fast);
}
.quick-link:hover .quick-link-dot { background: var(--blue); }

/* ── NAV FOOTER — Services + VPS health ── */
.nav-footer { margin-top: auto; padding: 14px 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }

.nav-footer-label {
  font-size: 8px; font-weight: 700; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--text3);
  margin-bottom: 4px;
}

/* Service status dots */
.nav-services { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.nav-svc-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  transition: background var(--duration-base), box-shadow var(--duration-base);
}
.nav-svc-ok          { background: var(--teal); box-shadow: 0 0 6px color-mix(in srgb, var(--teal) 55%, transparent); }
.nav-svc-error        { background: var(--red);  box-shadow: 0 0 6px color-mix(in srgb, var(--red)  55%, transparent); }
.nav-svc-unknown      { background: var(--border2); }
.nav-svc-unconfigured { background: var(--border); opacity: 0.5; }

/* VPS bars */
.nav-vps { display: flex; flex-direction: column; gap: 7px; }
.nav-vps-row {
  display: grid; grid-template-columns: 26px 1fr 32px;
  align-items: center; gap: 6px;
}
.nav-vps-label { font-size: 9px; color: var(--text3); font-weight: 600; letter-spacing: 0.06em; }
.nav-vps-bar   { height: 3px; background: var(--border); border-radius: 99px; overflow: hidden; }
.nav-vps-fill  {
  height: 100%; width: 0; border-radius: 99px;
  background: var(--blue); transition: width 0.6s ease, background var(--duration-slow);
}
.nav-vps-fill.warn { background: var(--amber); }
.nav-vps-fill.crit { background: var(--red); }
.nav-vps-pct { font-size: 9px; color: var(--text3); text-align: right; font-variant-numeric: tabular-nums; }

/* ── MOBILE TOP BAR ── */
.mobile-header {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  z-index: var(--z-header);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  view-transition-name: dashboard-mobile-header;
}
.mobile-header-brand { font-size: 10px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text2); }
.mobile-header-right { display: flex; align-items: center; gap: 10px; }
.mobile-time { font-family: var(--font-display), serif; font-style: italic; font-size: 18px; color: var(--white); }

.hamburger {
  width: 36px; height: 36px;
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 5px;
  transition: all var(--duration-fast);
}
.hamburger:hover { border-color: var(--blue); }
.hamburger span {
  display: block; width: 16px; height: 1.5px;
  background: var(--text2); border-radius: 2px;
  transition: all var(--duration-slow);
}
.hamburger.open span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.open span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* ── NAV OVERLAY (mobile) ── */
.nav-overlay {
  display: block;
  position: fixed;
  top: var(--header-h);
  left: min(var(--nav-w), 280px);
  right: 0;
  bottom: 0;
  background: var(--overlay-scrim);
  z-index: var(--z-nav-bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-enter);
}
.nav-overlay.visible { 
  opacity: 1;
  pointer-events: all; 
}

/* ── PAGE ── */
.page { display: flex; flex-direction: column; overflow: hidden; height: 100vh; opacity: 1; view-transition-name: dashboard-page; }
.page-header {
  padding: var(--density-page-y) var(--density-page-x) calc(var(--density-page-y) * 0.75);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: baseline; justify-content: space-between;
  flex-shrink: 0;
  gap: 16px;
  position: relative;
}
.page-header::after {
  content: '';
  position: absolute;
  left: var(--density-page-x);
  right: var(--density-page-x);
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--blue) 38%, transparent), transparent);
  opacity: 0.45;
  pointer-events: none;
}
.page-heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.page-kicker {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text3);
}
.page-title { font-family: var(--font-display), serif; font-style: italic; font-size: 24px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.page-subtitle { font-size: 10px; color: var(--text3); letter-spacing: 0.05em; }
.page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}
.toolbar-meta {
  font-size: 11px;
  color: var(--text3);
  letter-spacing: 0.03em;
}
.toolbar-input {
  width: 100%;
  min-height: 34px;
  padding: 8px 12px;
  background: color-mix(in srgb, var(--bg2) 85%, transparent);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 1px);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color var(--duration-fast), background var(--duration-fast), box-shadow var(--duration-fast);
}
.toolbar-input::placeholder { color: var(--text3); }
.toolbar-input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--blue) 55%, var(--border));
  background: color-mix(in srgb, var(--card2) 88%, transparent);
  box-shadow: var(--focus-ring);
}
.toolbar-button,
.refresh-btn {
  min-height: 34px;
  font-size: 11px;
  font-family: inherit;
  font-weight: 600;
  color: var(--text2);
  background: linear-gradient(180deg, color-mix(in srgb, var(--card2) 92%, transparent), color-mix(in srgb, var(--bg2) 92%, transparent));
  border: 1px solid color-mix(in srgb, var(--border2) 88%, var(--blue) 12%);
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: border-color var(--duration-base), color var(--duration-base), transform var(--duration-fast), background var(--duration-base), box-shadow var(--duration-base);
  letter-spacing: 0.04em;
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--white) 8%, transparent);
}
.toolbar-button:hover,
.refresh-btn:hover {
  border-color: color-mix(in srgb, var(--blue) 60%, var(--border2));
  color: var(--white);
  background: linear-gradient(180deg, color-mix(in srgb, var(--card2) 88%, var(--blue) 12%), color-mix(in srgb, var(--bg2) 88%, transparent));
  box-shadow: 0 4px 14px rgba(0,0,0,0.28), 0 0 0 1px color-mix(in srgb, var(--blue) 18%, transparent), inset 0 1px 0 color-mix(in srgb, var(--white) 10%, transparent);
}
.toolbar-button:active,
.refresh-btn:active { transform: translateY(0); }
.toolbar-button:focus-visible,
.refresh-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.page-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: var(--density-page-y) var(--density-page-x);
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
  display: flex; flex-direction: column;
}
.page-body > * { flex: 1; }

/* Thin overlay-style scrollbars — page body and all card scroll areas */
.page-body::-webkit-scrollbar,
.card ::-webkit-scrollbar { width: 3px; }
.page-body::-webkit-scrollbar-track,
.card ::-webkit-scrollbar-track { background: transparent; }
.page-body::-webkit-scrollbar-thumb,
.card ::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }
@media (max-width: 900px) {
  .page-body::-webkit-scrollbar,
  .card ::-webkit-scrollbar { width: 2px; }
}

/* ── CARDS ── */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(var(--card-blur));
  -webkit-backdrop-filter: blur(var(--card-blur));
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: var(--density-card-y) var(--density-card-x);
  position: relative;
  overflow: hidden;
  transition: transform var(--duration-base), border-color var(--duration-base), box-shadow var(--duration-base);
  box-shadow:
    var(--shadow-sm),
    var(--shadow-md),
    inset 0 1px 0 var(--card-highlight);
}
.card:hover {
  background: var(--card-bg-hover);
  border-color: color-mix(in srgb, var(--blue) 28%, var(--border2));
  box-shadow:
    var(--shadow-sm),
    var(--shadow-lg),
    0 0 0 1px color-mix(in srgb, var(--blue) 12%, transparent),
    inset 0 1px 0 var(--card-highlight-hover);
  transform: translateY(-1px);
}
.card::before {
  content: ''; position: absolute; inset: 0;
  background: var(--card-overlay);
  pointer-events: none;
}
.card.accent-top::after {
  content: ''; position: absolute; top: 0; left: 22px; right: 22px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--blue) 40%, var(--blue) 60%, transparent);
  opacity: 0.5;
}

/* .card-label defined in molecules.css */

/* ── GRIDS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--density-gap); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--density-gap); }
.col-2 { grid-column: span 2; }
.col-3 { grid-column: span 3; }

/* ── SKELETON ── */
.skel {
  background: linear-gradient(90deg, var(--border) 25%, var(--border2) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.8s infinite;
  border-radius: var(--radius-sm);
}
.skel-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.skel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.skel-list {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.skel-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.skel-list-item:last-child { border-bottom: none; }
.skel-chip {
  height: 20px;
  border-radius: var(--radius-pill);
}
.skel-circle { border-radius: 999px; }
.skel-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 64px;
  padding: 12px 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── TAGS ── */
.felt-tag { font-size: 9px; font-weight: 600; padding: 2px 7px; border-radius: var(--radius-pill); text-transform: uppercase; letter-spacing: 0.08em; }
.felt-Easy { background: var(--tone-success-bg); color: var(--tone-success-text); border: 1px solid var(--tone-success-border); }
.felt-Good { background: var(--tone-accent-bg); color: var(--tone-accent-text); border: 1px solid var(--tone-accent-border); }
.felt-Hard { background: var(--tone-danger-bg); color: var(--tone-danger-text); border: 1px solid var(--tone-danger-border); }

/* ── MISC ── */
.error-note { font-size: 10px; color: var(--red); font-style: italic; margin-top: 8px; }
.setup-note { font-size: 10px; color: var(--text3); font-style: italic; margin-top: 8px; }

/* ── CONTROLS ── */

/* Underline tab nav — used for multi-view panels within a card */
.tab-bar {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--density-card-inner);
}
.tab-btn {
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  color: var(--text3);
  background: none;
  border: none;
  padding: 9px 18px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--duration-fast), border-color var(--duration-fast);
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--blue); }
.tab-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 4px 4px 0 0; }

/* Ghost pill button — filter chips, toggles, genre tags, sort selectors */
.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-family: inherit;
  font-weight: 600;
  color: var(--text3);
  background: none;
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  letter-spacing: 0.03em;
  white-space: nowrap;
  transition: border-color var(--duration-fast), color var(--duration-fast), background var(--duration-fast);
}
.pill-btn:hover {
  border-color: color-mix(in srgb, var(--blue) 50%, var(--border));
  color: var(--text);
}
.pill-btn.active {
  background: color-mix(in srgb, var(--blue) 16%, transparent);
  border-color: color-mix(in srgb, var(--blue) 42%, var(--border2));
  color: var(--blue);
}
.pill-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Solid action button — form submits, primary CTAs */
.btn-primary {
  display: inline-flex;
  align-items: center;
  padding: 7px 16px;
  background: var(--blue);
  color: var(--bg);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: filter var(--duration-fast), transform var(--duration-fast), box-shadow var(--duration-fast);
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--blue) 32%, transparent);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Ghost action button — secondary actions, cancel, edit */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color var(--duration-fast), color var(--duration-fast);
}
.btn-ghost:hover { border-color: color-mix(in srgb, var(--blue) 50%, var(--border)); color: var(--blue); }
.btn-ghost:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Size modifiers — apply alongside btn-primary or btn-ghost */
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px;  font-size: 11px; }

/* ── FADE IN ── */
.fade-in {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 220ms ease, transform 220ms ease;
}
.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — TABLET (≤ 900px)
══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    padding-top: var(--header-h);
  }

  .page-body { padding-bottom: 32px; }

  /* Show mobile header */
  .mobile-header { display: flex; }

  /* Hide desktop nav, show as slide-in drawer */
  .nav {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(var(--nav-w), 280px);
    z-index: var(--z-nav);
    transform: translateX(-100%);
    transition: transform var(--duration-enter) var(--ease-out);
    overflow-y: auto;
    overflow-x: clip; /* override base overflow:hidden — clip doesn't block position:sticky */
    padding-top: var(--header-h); /* nav is below .app (z:1) in root; header (z:300) always paints above it */
  }
  .nav.open { transform: translateX(0); }
  .nav-overlay { display: block; }

  /* Page takes full width */
  .page { height: calc(100vh - var(--header-h)); }
  .page-header { padding: 16px 18px 12px; }
  .page-body { padding: 14px 18px; }
  .page-title { font-size: 20px; }
  .page-header::after { left: 18px; right: 18px; }

  /* Grids go 2-col on tablet */
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .col-2 { grid-column: span 2; }
  .col-3 { grid-column: span 2; }

  .card { padding: 16px 18px; }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — PHONE (≤ 520px)
══════════════════════════════════════════════════════════════ */
@media (max-width: 520px) {
  .page-header {
    padding: 12px 14px 10px;
    align-items: center;
  }
  .page-body { padding: 10px 12px; }
  .page-title { font-size: 18px; }
  .page-body { padding-bottom: 32px; }
  .page-header::after { left: 14px; right: 14px; }
  .toolbar-meta { font-size: 10px; }

  /* All grids go single column */
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .col-2, .col-3 { grid-column: span 1; }

  .card { padding: 14px 16px; }
  .card-label { margin-bottom: 10px; }

  .toolbar-input,
  .toolbar-button,
  .refresh-btn,
  .btn-primary,
  .btn-ghost { padding: 6px 12px; font-size: 11px; }
}

/* ── QUICK LINKS CARD ── */
.ql-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
}
.ql-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 12px 8px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-md); text-decoration: none;
  transition: border-color var(--duration-fast), background var(--duration-fast); min-width: 0;
}
.ql-tile:hover {
  border-color: var(--blue);
  background: color-mix(in srgb, var(--blue) 6%, var(--bg2));
}
.ql-favicon { width: 20px; height: 20px; border-radius: 4px; object-fit: contain; }
.ql-favicon-fallback {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--blue); color: var(--bg);
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ql-label {
  font-size: 9px; color: var(--text2); text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%; line-height: 1.2; letter-spacing: 0.02em;
}
.ql-empty { font-size: 10px; color: var(--text3); font-style: italic; margin-top: 8px; }


/* ── CLAUDE USAGE CARD ── */
#card-claude-usage .ty-hero-metric,
#card-codex-usage .ty-hero-metric { font-size: 22px; line-height: 0.95; }
#card-claude-usage .ty-label,
#card-codex-usage .ty-label { font-size: 9px; letter-spacing: 0.12em; }
#card-claude-usage .ty-meta-text,
#card-codex-usage .ty-meta-text { font-size: 10px; line-height: 1.35; }
.cu-bars {
  display: flex; align-items: flex-end; gap: 3px;
  height: 44px; margin-top: 10px;
}
.cu-bar-wrap {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 3px; height: 100%; min-width: 0; cursor: default;
}
.cu-bar {
  width: 100%; background: var(--blue); border-radius: 2px 2px 0 0;
  min-height: 4px; opacity: 0.6; transition: opacity var(--duration-fast);
  flex-shrink: 0;
}
.cu-bar-wrap:hover .cu-bar { opacity: 1; }
.cu-bar-lbl {
  font-size: 8px; color: var(--text3); text-align: center;
  white-space: nowrap; letter-spacing: 0.04em;
}

/* ══════════════════════════════════════════════════════════════
   NAV FOOTER — mobile sticky fix
══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  /* Stick the footer to the bottom of the scrolling nav drawer */
  .nav-footer {
    position: sticky;
    bottom: 0;
    background: var(--bg2);
    z-index: 2;
    box-shadow: 0 -12px 20px 4px var(--bg2);
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  }

  /* Merge SERVICES + VPS into one compact two-column row */
  .nav-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    column-gap: 12px;
    row-gap: 6px;
    align-items: start;
  }

  /* Labels sit on row 1 */
  .nav-footer .nav-footer-label:first-child {
    grid-column: 1; grid-row: 1;
    margin-bottom: 0;
  }
  .nav-footer .nav-footer-label:last-of-type,
  .nav-footer .nav-footer-label[style] {
    grid-column: 2; grid-row: 1;
    margin-top: 0 !important;
    margin-bottom: 0;
  }

  /* Dots on left col, bars on right */
  .nav-services {
    grid-column: 1; grid-row: 2;
    gap: 5px;
    align-content: start;
  }
  .nav-vps {
    grid-column: 2; grid-row: 2;
    gap: 5px;
  }

  /* Tighter bar rows */
  .nav-vps-row {
    grid-template-columns: 22px 1fr 28px;
    gap: 4px;
  }
}
