/* ============================================================================
   Proxy Panel — visual system
   Direction: Apple-neutral. Light-first, system-blue accent used only for
   actions, generous whitespace, SF-style type, soft depth, iOS grouped lists
   in Settings, bottom-sheet modals on phones, sidebar + bottom tab bar nav.

   The legacy dark "acid-lime terminal" tokens (--void/--carbon/--ash/…) are
   kept as NAMES because the markup references them directly in hundreds of
   `text-[var(--ash)]`-style utilities — they're just remapped onto the new
   neutral palette here so the whole app re-skins from one place.
   ========================================================================== */

/* ---- Tokens: light (default) ---------------------------------------------- */
:root {
  --void:      #f5f5f7;   /* app background                    */
  --void-glass: rgba(245,245,247,.82); /* translucent bg for blur bars */
  --carbon:    #ffffff;   /* card / elevated surface           */
  --obsidian:  #ececef;   /* hovered surface                   */
  --graphite:  rgba(0,0,0,.10);   /* hairline / separator      */
  --smoke:     rgba(0,0,0,.20);   /* stronger border / hover   */
  --ash:       rgba(60,60,67,.45);   /* tertiary / placeholder */
  --fog:       rgba(60,60,67,.62);   /* secondary text         */
  --mist:      #1d1d1f;   /* primary body text                 */
  --bone:      #1d1d1f;   /* high-emphasis text                */
  --paper:     #000000;   /* headings / max emphasis           */

  --accent:      #0071e3;             /* system blue — actions only */
  --accent-hover:#0077ed;
  --accent-ink:  #ffffff;             /* text/icon on accent        */
  --accent-wash: rgba(0,113,227,.10); /* selected / active tint     */

  --success:    #1d9d4f;
  --success-bg: rgba(29,157,79,.12);
  --danger:     #d70015;
  --danger-bg:  rgba(215,0,21,.10);
  --info:       #0071e3;
  --violet:     #7c5cff;
  --neon-yellow:#b25000;              /* "warning" ramp for res-chips */

  --shadow-card: 0 1px 2px rgba(0,0,0,.05), 0 12px 32px -16px rgba(0,0,0,.16);
  --shadow-pop:  0 8px 24px -6px rgba(0,0,0,.14), 0 24px 64px -16px rgba(0,0,0,.24);

  --radius-card: 18px;
  --radius-md:   12px;
  --radius-sm:   8px;
  --radius-pill: 999px;

  --sidebar-w: 232px;
  --content-max: 1120px;

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter",
               "Segoe UI", system-ui, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", ui-monospace, "Menlo", monospace;

  color-scheme: light;
}

/* ---- Tokens: dark ------------------------------------------------------------
   Applied when the user picked dark (:root.dark) OR when they haven't picked
   anything and the OS is dark (:root:not(.light) under the media query). ---- */
@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --void:     #000000;
    --void-glass: rgba(0,0,0,.8);
    --carbon:   #1c1c1e;
    --obsidian: #2c2c2e;
    --graphite: rgba(255,255,255,.11);
    --smoke:    rgba(255,255,255,.22);
    --ash:      rgba(235,235,245,.35);
    --fog:      rgba(235,235,245,.60);
    --mist:     #e5e5ea;
    --bone:     #f5f5f7;
    --paper:    #ffffff;

    --accent:      #0a84ff;
    --accent-hover:#409cff;
    --accent-ink:  #ffffff;
    --accent-wash: rgba(10,132,255,.16);

    --success:    #30d158;
    --success-bg: rgba(48,209,88,.16);
    --danger:     #ff453a;
    --danger-bg:  rgba(255,69,58,.16);
    --info:       #0a84ff;
    --violet:     #bf5af2;
    --neon-yellow:#ffd60a;

    --shadow-card: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px -16px rgba(0,0,0,.6);
    --shadow-pop:  0 8px 24px -6px rgba(0,0,0,.5), 0 24px 64px -16px rgba(0,0,0,.7);

    color-scheme: dark;
  }
}
:root.dark {
  --void:     #000000;
  --void-glass: rgba(0,0,0,.8);
  --carbon:   #1c1c1e;
  --obsidian: #2c2c2e;
  --graphite: rgba(255,255,255,.11);
  --smoke:    rgba(255,255,255,.22);
  --ash:      rgba(235,235,245,.35);
  --fog:      rgba(235,235,245,.60);
  --mist:     #e5e5ea;
  --bone:     #f5f5f7;
  --paper:    #ffffff;

  --accent:      #0a84ff;
  --accent-hover:#409cff;
  --accent-ink:  #ffffff;
  --accent-wash: rgba(10,132,255,.16);

  --success:    #30d158;
  --success-bg: rgba(48,209,88,.16);
  --danger:     #ff453a;
  --danger-bg:  rgba(255,69,58,.16);
  --info:       #0a84ff;
  --violet:     #bf5af2;
  --neon-yellow:#ffd60a;

  --shadow-card: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px -16px rgba(0,0,0,.6);
  --shadow-pop:  0 8px 24px -6px rgba(0,0,0,.5), 0 24px 64px -16px rgba(0,0,0,.7);

  color-scheme: dark;
}

/* ---- Base -------------------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--void);
  color: var(--mist);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.47;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-wash); }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-thumb { background: var(--smoke); border-radius: 999px; border: 3px solid var(--void); }
::-webkit-scrollbar-track { background: transparent; }
a { color: inherit; text-decoration: none; }

.mono { font-family: var(--font-mono); font-size: .8125rem; letter-spacing: 0; }

/* ---- App shell: sidebar (desktop) + main + tab bar (mobile) --------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; align-self: flex-start;
  width: var(--sidebar-w); height: 100vh; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 2px;
  padding: 20px 12px calc(16px + env(safe-area-inset-bottom));
  background: var(--void);
  border-right: 1px solid var(--graphite);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 18px;
  font-weight: 650; font-size: 1.0625rem; color: var(--paper);
  letter-spacing: -0.02em;
}
.sidebar-spacer { flex: 1; }
.sidebar-foot {
  border-top: 1px solid var(--graphite);
  margin-top: 8px; padding-top: 12px;
  display: flex; flex-direction: column; gap: 4px;
}

.main-col {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}
.main-inner {
  width: 100%; max-width: var(--content-max);
  margin: 0 auto;
  padding: 24px 28px 64px;
}

/* Sticky contextual header inside main */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 28px;
  min-height: 60px;
  background: var(--void);              /* solid — must never be see-through */
  border-bottom: 1px solid var(--graphite);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar { background: var(--void-glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); }
}
.topbar-title { font-size: 1.375rem; font-weight: 680; color: var(--paper); letter-spacing: -0.021em; }

/* Bottom tab bar — phones only */
.tabbar { display: none; }

/* ---- Nav items (shared by sidebar) --------------------------------------- */
.navlink {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 10px;
  font-size: .9375rem; font-weight: 500; color: var(--fog);
  cursor: pointer; user-select: none;
  transition: background .12s ease, color .12s ease;
}
.navlink svg { width: 20px; height: 20px; flex-shrink: 0; stroke-width: 1.8; }
.navlink:hover { background: var(--obsidian); color: var(--bone); }
.navlink.active { background: var(--accent-wash); color: var(--accent); font-weight: 600; }

/* ---- Typography helpers ------------------------------------------------------ */
.section-title { font-size: 1.0625rem; font-weight: 650; color: var(--paper); letter-spacing: -0.014em; }
.label {
  font-size: .8125rem; font-weight: 590; color: var(--fog);
  text-transform: none; letter-spacing: 0;
}
.hairline { border-color: var(--graphite); }

/* ---- Surfaces ------------------------------------------------------------- */
.card {
  background: var(--carbon);
  border: 1px solid var(--graphite);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}
.card-flat {
  background: var(--carbon);
  border: 1px solid var(--graphite);
  border-radius: var(--radius-md);
}
.surface {
  background: var(--void);
  border: 1px solid var(--graphite);
  border-radius: var(--radius-md);
}

/* ---- Buttons ------------------------------------------------------------------
   Pill-ish, 44px min height for touch, spring on press. ------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 38px; padding: .5rem 1.05rem;
  border: 1px solid transparent; border-radius: var(--radius-md);
  font-family: inherit; font-size: .9375rem; font-weight: 550; letter-spacing: -0.01em;
  cursor: pointer; white-space: nowrap;
  transition: background .14s ease, border-color .14s ease, transform .1s ease, opacity .14s ease;
}
.btn:active { transform: scale(.965); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); filter: brightness(.94); }
.btn-ghost { background: var(--carbon); color: var(--bone); border-color: var(--graphite); }
.btn-ghost:hover { background: var(--obsidian); border-color: var(--smoke); }
.btn-sm { min-height: 32px; padding: .32rem .7rem; font-size: .8125rem; border-radius: var(--radius-sm); }
.btn-icon { padding: .4rem; min-height: 34px; aspect-ratio: 1; }

/* ---- Inputs --------------------------------------------------------------- */
.input {
  width: 100%;
  background: var(--void);
  border: 1px solid var(--graphite);
  border-radius: var(--radius-md);
  padding: .6rem .8rem; min-height: 40px;
  color: var(--bone); font-family: inherit; font-size: .9375rem;
  transition: border-color .12s ease, box-shadow .12s ease;
}
:root.dark .input { background: #000; }
.input::placeholder { color: var(--ash); }
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-wash);
}
select.input { -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%238e8e93' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center; padding-right: 2rem;
}

/* ---- iOS-style grouped list (Settings) ---------------------------------- */
.grouped {
  background: var(--carbon);
  border: 1px solid var(--graphite);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.grouped-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 16px; min-height: 48px;
}
.grouped-row + .grouped-row { border-top: 1px solid var(--graphite); }
.grouped-row .grouped-main { min-width: 0; }
/* A row that is nothing but one full-width field: drop the field's own chrome
   and let the row separators carry the structure (iOS text-field lists). */
.grouped-row > .input:only-child {
  border-color: transparent; background: transparent;
  padding-left: 0; padding-right: 0; min-height: 22px;
}
.grouped-row > .input:only-child:focus { box-shadow: none; }
.grouped-row .grouped-title { font-size: .9375rem; color: var(--bone); font-weight: 500; }
.grouped-row .grouped-sub { font-size: .8125rem; color: var(--fog); margin-top: 1px; }
.group-head {
  font-size: .8125rem; font-weight: 600; color: var(--fog);
  padding: 0 4px 8px; letter-spacing: -0.006em;
}
.group-foot { font-size: .8125rem; color: var(--fog); padding: 8px 4px 0; }

/* iOS switch */
.switch { position: relative; width: 51px; height: 31px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--smoke); transition: background .18s ease;
}
.switch .knob {
  position: absolute; top: 2px; left: 2px; width: 27px; height: 27px;
  border-radius: 999px; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .18s cubic-bezier(.3,1.4,.5,1);
}
.switch input:checked ~ .track { background: var(--success); }
.switch input:checked ~ .knob { transform: translateX(20px); }

/* ---- Status dot ---------------------------------------------------------- */
.dot { width: .5rem; height: .5rem; border-radius: 999px; display: inline-block; flex-shrink: 0; }
.dot-live { background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); animation: dotPulse 2.4s ease-in-out infinite; }
.dot-off  { background: var(--ash); }
@keyframes dotPulse {
  0%,100% { box-shadow: 0 0 0 3px var(--success-bg); }
  50%     { box-shadow: 0 0 0 7px transparent; }
}

/* ---- Console / log block ------------------------------------------------- */
.log {
  background: var(--void);
  border: 1px solid var(--graphite);
  border-radius: var(--radius-md);
  font-family: var(--font-mono); font-size: .78rem; line-height: 1.6;
  white-space: pre-wrap; color: var(--fog);
}
:root.dark .log { background: #000; }

/* ---- Chips / pills ------------------------------------------------------- */
.chip {
  font-size: .8125rem; font-weight: 500;
  border-radius: var(--radius-pill); padding: .32rem .8rem;
  background: var(--carbon); color: var(--fog);
  border: 1px solid var(--graphite);
  cursor: pointer; user-select: none;
  transition: all .12s ease;
}
.chip:hover { color: var(--bone); border-color: var(--smoke); }
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

.res-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  background: var(--void); border: 1px solid var(--graphite);
  border-radius: var(--radius-sm); padding: .28rem .55rem;
  font-size: .8125rem; white-space: nowrap;
}
:root.dark .res-chip { background: #000; }
.res-label { color: var(--ash); font-size: .6875rem; text-transform: uppercase; letter-spacing: .04em; }
.res-chip b { font-weight: 650; color: var(--mist); }
.res-chip.res-warn { border-color: var(--neon-yellow); }
.res-chip.res-warn b { color: var(--neon-yellow); }
.res-chip.res-crit { border-color: var(--danger); }
.res-chip.res-crit b { color: var(--danger); }

.proto-pill {
  display: inline-block; font-family: var(--font-mono);
  font-size: .6875rem; border-radius: var(--radius-sm); padding: .12rem .5rem;
}

/* Rounded "app icon" tile so emoji glyphs read as intentional, not clip-art */
.app-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 9px; font-size: 1.0625rem; line-height: 1;
  background: var(--void); border: 1px solid var(--graphite);
}
:root.dark .app-icon { background: #000; }

/* Real per-protocol brand marks (web/static/logos/*.svg) — replaces the
   flat emoji. Rendered as <img>; keeps the same footprint as .app-icon. */
.app-logo {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 7px; object-fit: contain; display: block;
  background: #fff; padding: 2px; box-shadow: 0 0 0 1px var(--graphite);
}
.app-logo.lg { width: 34px; height: 34px; border-radius: 9px; }

/* ---- Overlays ---------------------------------------------------------------
   Desktop: centered card. Phones: bottom sheet that slides up. ----------- */
.backdrop { background: rgba(0,0,0,.32); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
:root.dark .backdrop { background: rgba(0,0,0,.55); }
.fade-in { animation: fadeIn .18s cubic-bezier(.2,.8,.2,1); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- Node cards -------------------------------------------------------------- */
.node-card {
  background: var(--carbon); border: 1px solid var(--graphite);
  border-radius: var(--radius-card); padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow-card);
  cursor: pointer; position: relative; overflow: hidden;
  transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s ease, border-color .18s ease;
  animation: cardIn .28s cubic-bezier(.2,.8,.2,1) backwards;
}
.node-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-pop); border-color: var(--smoke); }
.node-card:active { transform: translateY(-1px) scale(.992); }
.node-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: transparent; transition: background .3s;
}
.node-card.is-online::before { background: linear-gradient(90deg, var(--success), transparent 85%); }
@keyframes cardIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---- Service rows ------------------------------------------------------------
   Actions wrap below the label on narrow screens instead of overflowing. -- */
.svc-row {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  background: var(--void); border: 1px solid var(--graphite);
  border-radius: var(--radius-md); padding: .7rem .9rem;
  transition: border-color .15s ease, background .15s ease;
  animation: cardIn .2s ease backwards;
}
:root.dark .svc-row { background: #000; }
.svc-item { animation: cardIn .2s ease backwards; }
.svc-access {
  margin-top: .4rem; border: 1px solid var(--graphite); border-radius: var(--radius-md);
  background: var(--void); padding: .55rem .75rem; display: flex; flex-direction: column; gap: .35rem;
}
:root.dark .svc-access { background: #000; }
.svc-access-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.svc-access-k {
  min-width: 5.5rem; font-size: .68rem; color: var(--ash);
  text-transform: uppercase; letter-spacing: .04em;
}
.svc-access-v { font-size: .8rem; color: var(--bone); word-break: break-all; flex: 1 1 12rem; }
a.svc-access-v { color: var(--accent); }
.svc-access-btns { display: flex; gap: .3rem; margin-left: auto; }
.svc-row:hover { border-color: var(--smoke); }
.svc-row.focus-pulse { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); animation: focusPulse 1.3s ease-in-out 2; }
@keyframes focusPulse { 0%,100% { box-shadow: 0 0 0 2px var(--accent-wash); } 50% { box-shadow: 0 0 0 5px var(--accent-wash); } }

/* ---- Node-detail tiles ------------------------------------------------------- */
.node-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: .1rem;
  background: var(--carbon); border: 1px solid var(--graphite);
  border-radius: var(--radius-md); padding: .95rem 1rem; min-height: 84px;
  text-align: left; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.node-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); border-color: var(--smoke); }
.node-tile:active { transform: translateY(0) scale(.99); }
.node-tile-icon { font-size: 1.2rem; line-height: 1; color: var(--accent); }
.node-tile-icon svg { width: 22px; height: 22px; display: block; }
.node-tile-label { font-weight: 600; font-size: .9375rem; color: var(--bone); margin-top: .3rem; }
.node-tile-sub { font-size: .8125rem; color: var(--fog); }

/* ---- Protocol picker ------------------------------------------------------- */
.proto-card {
  background: var(--void); border: 1px solid var(--graphite);
  border-radius: var(--radius-md); padding: .95rem .7rem;
  text-align: center; cursor: pointer;
  transition: border-color .12s ease, background .12s ease, transform .12s ease;
}
:root.dark .proto-card { background: #000; }
.proto-card:hover { border-color: var(--smoke); transform: translateY(-2px); }
.proto-card.selected { border-color: var(--accent); background: var(--accent-wash); }
.proto-icon { font-size: 1.6rem; line-height: 1; margin-bottom: .4rem; }
.proto-logo {
  width: 40px; height: 40px; margin: 0 auto .45rem; display: block;
  border-radius: 10px; object-fit: contain; background: #fff; padding: 3px;
  box-shadow: 0 0 0 1px var(--graphite);
}
.proto-label { font-size: .75rem; font-weight: 600; color: var(--mist); line-height: 1.25; }
.cat-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ash); margin: 1.1rem 0 .55rem; }
.cat-label:first-child { margin-top: 0; }

/* ---- Reverse-proxy control panel ---------------------------------------- */
.rp-tab {
  position: relative; padding: .55rem 1.05rem;
  font-size: .9375rem; font-weight: 550; color: var(--fog);
  cursor: pointer; transition: color .15s ease;
}
.rp-tab:hover { color: var(--bone); }
.rp-tab.active { color: var(--paper); }
.rp-tab.active::after {
  content: ''; position: absolute; left: .4rem; right: .4rem; bottom: -1px;
  height: 2px; border-radius: 2px; background: var(--rp-accent, var(--accent));
}
.rp-panel { border-top: 1px solid var(--graphite); }
.rp-route {
  display: flex; align-items: center; gap: .7rem; flex-wrap: wrap;
  padding: .65rem .85rem; border-radius: var(--radius-md);
  background: var(--void); border: 1px solid var(--graphite);
  transition: border-color .15s ease;
}
:root.dark .rp-route { background: #000; }
.rp-route:hover { border-color: var(--smoke); }
.rp-endpoint {
  font-family: var(--font-mono); font-size: .78rem;
  padding: .2rem .55rem; border-radius: var(--radius-sm);
  background: var(--obsidian); color: var(--mist);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.rp-arrow { color: var(--ash); flex-shrink: 0; }
.rp-badge { font-size: 9px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; }
.rp-empty {
  text-align: center; padding: 2.25rem 1rem;
  color: var(--fog); font-size: .9375rem;
  border: 1px dashed var(--graphite); border-radius: var(--radius-md);
}

[x-cloak] { display: none !important; }

/* ============================================================================
   Responsive — phones & small tablets
   ========================================================================== */
@media (max-width: 900px) {
  .main-inner { padding: 20px 18px 96px; }
  .topbar { padding: 12px 18px; }
}

@media (max-width: 720px) {
  /* Sidebar → hidden; nav moves to a fixed bottom tab bar */
  .sidebar { display: none; }
  .app-shell { display: block; }
  .main-inner { padding: 16px 14px calc(80px + env(safe-area-inset-bottom)); }

  .topbar {
    padding: 10px 16px; min-height: 52px;
    position: sticky; top: 0;
  }
  .topbar-title { font-size: 1.1875rem; }

  .tabbar {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--void);              /* solid — must never be see-through */
    border-top: 1px solid var(--graphite);
  }
  @supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .tabbar { background: var(--void-glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); }
  }
  .tabbar-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 2px; border-radius: 10px;
    font-size: 10px; font-weight: 550; color: var(--fog);
    cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
  }
  .tabbar-item svg { width: 24px; height: 24px; stroke-width: 1.7; }
  .tabbar-item.active { color: var(--accent); }

  /* Grids collapse to one column */
  .grid-cols-3, .sm\:grid-cols-2, .lg\:grid-cols-3,
  .grid-cols-2.sm\:grid-cols-3, .grid-cols-3.sm\:grid-cols-4 { grid-template-columns: 1fr !important; }

  /* Service-row actions wrap under the label, each comfortably tappable */
  .svc-row { flex-direction: column; align-items: stretch; }
  .svc-row > div:last-child { flex-wrap: wrap; }
  .svc-row .btn-sm { flex: 1 1 auto; }

  /* Center-modal → bottom sheet, above the tab bar */
  .backdrop { align-items: flex-end !important; justify-content: stretch !important; z-index: 60 !important; }
  .backdrop.p-4 { padding: 0 !important; }
  .backdrop .card {
    position: relative;
    max-width: 100% !important; width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 92vh; overflow-y: auto;
    padding-top: 1.75rem !important;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom)) !important;
    animation: sheetUp .26s cubic-bezier(.2,.85,.25,1);
  }
  .backdrop .card::before {
    content: ''; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 38px; height: 4px; border-radius: 999px; background: var(--smoke);
  }
  .backdrop > .w-full, .backdrop > div { width: 100% !important; max-width: 100% !important; }
  .backdrop .my-8 { margin: 0 !important; }
  @keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }

  .topbar .btn span.hide-sm { display: none; }
}

@media (max-width: 420px) {
  .tabbar-item span { font-size: 9px; }
}

/* Respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* --- Progress bar for streaming actions (install / uninstall / updates) --- */
.opbar { display: flex; flex-direction: column; gap: 6px; }
.opbar-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px; color: var(--mist);
}
.opbar-head .mono { color: var(--ash); font-size: 11px; }
.opbar-track {
  height: 6px; border-radius: 999px; overflow: hidden;
  background: var(--graphite);
}
.opbar-fill {
  height: 100%; border-radius: 999px;
  background: var(--accent);
  transition: width .45s cubic-bezier(.16,1,.3,1), background-color .3s;
}
.opbar.running .opbar-fill {
  background-image: linear-gradient(90deg,
    rgba(255,255,255,0) 0%, rgba(255,255,255,.35) 50%, rgba(255,255,255,0) 100%);
  background-size: 200% 100%;
  animation: opbarShimmer 1.15s linear infinite;
}
.opbar.done  .opbar-fill { background: var(--success); }
.opbar.error .opbar-fill { background: var(--danger); }
.opbar.done  .opbar-head, .opbar.done  .opbar-head .mono { color: var(--success); }
.opbar.error .opbar-head, .opbar.error .opbar-head .mono { color: var(--danger); }
@keyframes opbarShimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .opbar.running .opbar-fill { animation: none; } }
