:root,
.login-screen {
  color-scheme: dark;
  --bg: #07080b;
  --window: #0d1016;
  --chrome: #12161f;
  --chrome-2: #161b26;
  --canvas: #090b10;
  --field: #0d1118;
  --field-2: #0a0d12;
  --panel: rgba(18, 22, 31, 0.98);
  --text: #f3f5f8;
  --muted: #9aa3b2;
  --placeholder: #6d7686;
  --accent: #6ea8ff;
  --accent-rgb: 110, 168, 255;
  --on-accent: #0b0e14;
  --accent-2: #8b7bff;
  /* Base of every translucent overlay (hovers, hairlines): white on dark, ink on light. */
  --tint: 255, 255, 255;
  --line: rgba(var(--tint), 0.07);
  --line-strong: rgba(var(--tint), 0.12);
  --ok: #3dd68c;
  --danger: #ff6b6b;
  --lock: #3dd68c;
  --shadow: 0 40px 90px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.05);
  --shadow-pop: 0 18px 40px rgba(0, 0, 0, 0.5);
  --aura-1: 110, 80, 210, 0.28;
  --aura-2: 50, 110, 220, 0.22;
  --aura-3: 40, 80, 170, 0.16;
}

:root {
  --radius: 16px;
  --font: "SF Pro Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Light theme. The sign-in screen re-declares the dark tokens above on itself, so that
   hero stays dark; the remote page and the wallpaper are never themed. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #e6eaf2;
  --window: #ffffff;
  --chrome: #f1f3f8;
  --chrome-2: #f8f9fc;
  --canvas: #eef1f7;
  --field: #ffffff;
  --field-2: #ffffff;
  --panel: rgba(255, 255, 255, 0.98);
  --text: #131823;
  --muted: #5d6676;
  --placeholder: #8a93a3;
  --accent: #2563eb;
  --accent-rgb: 37, 99, 235;
  --on-accent: #ffffff;
  --accent-2: #6d5ae6;
  --tint: 15, 23, 42;
  --line: rgba(var(--tint), 0.1);
  --line-strong: rgba(var(--tint), 0.17);
  --ok: #12a05f;
  --danger: #d93838;
  --lock: #12a05f;
  --shadow: 0 30px 70px rgba(30, 41, 80, 0.22), 0 0 0 1px rgba(15, 23, 42, 0.08);
  --shadow-pop: 0 18px 40px rgba(30, 41, 80, 0.2);
  --aura-1: 120, 100, 230, 0.2;
  --aura-2: 70, 130, 240, 0.18;
  --aura-3: 90, 120, 210, 0.14;
}

.login-screen {
  color: var(--text);
}

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

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

html {
  /* Phones must not inflate text on rotation. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  /* No rubber-banding or pull-to-refresh: this is an app surface, and a stray refresh
     would drop the live stream. */
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* Removes the double-tap-to-zoom wait, so taps on controls register immediately. */
button,
a,
input,
select,
label {
  touch-action: manipulation;
}

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1100px 640px at 12% -8%, rgba(var(--aura-1)), transparent 55%),
    radial-gradient(900px 560px at 92% 8%, rgba(var(--aura-2)), transparent 52%),
    radial-gradient(800px 480px at 50% 115%, rgba(var(--aura-3)), transparent 50%),
    var(--bg);
  overflow: hidden;
}

button,
input {
  font-family: inherit;
}

.screen {
  min-height: 100%;
}

/* ——— Login ——— */

.login-screen {
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  /* Premium near-black navy base with two soft ambient glows: deep blue from the
     upper-right, indigo/purple from the upper-left. Large radii + low alpha keep the
     falloff smooth (no banding), and the centre stays dark so the card reads clearly. */
  background:
    radial-gradient(1200px 900px at 88% 52%, rgba(40, 80, 200, 0.12), transparent 55%),
    radial-gradient(900px 820px at 4% 84%, rgba(96, 64, 200, 0.10), transparent 55%),
    linear-gradient(160deg, #070b1a 0%, #04060f 55%, #05060e 100%);
}

/* Flowing light-streak backdrop (blurred inline SVG), sitting behind everything. */
.login-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -3;
  pointer-events: none;
}

/* A gentle vignette to deepen the far corners — cinematic, but subtle enough to keep
   contrast and never crush the ambient glows. */
.login-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: radial-gradient(1300px 980px at 50% 42%, transparent 60%, rgba(2, 4, 12, 0.55));
}

.login-screen[hidden],
html[data-session="remembered"] .login-screen {
  display: none;
}

/* Soft radial glow sitting directly behind the login card, tying the light to it. */
.login-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, 92vw);
  height: min(560px, 92vw);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(96, 132, 240, 0.20), transparent 70%);
  filter: blur(24px);
  pointer-events: none;
  z-index: -1;
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  /* Frosted glass: translucent so the light streaks bleed softly through the edges,
     a bright inset top edge, and a deep soft shadow to lift it off the scene. */
  background: linear-gradient(180deg, rgba(30, 37, 56, 0.55), rgba(14, 18, 30, 0.48));
  -webkit-backdrop-filter: blur(22px) saturate(135%);
  backdrop-filter: blur(22px) saturate(135%);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 24px;
  padding: 36px 32px 30px;
  box-shadow:
    0 44px 100px rgba(2, 6, 20, 0.62),
    0 2px 10px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  text-align: center;
}

/* Fallback for engines without backdrop-filter: keep the card solid enough to read. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .login-card {
    background: linear-gradient(180deg, rgba(22, 27, 42, 0.94), rgba(12, 15, 25, 0.94));
  }
}

.login-mark {
  display: grid;
  place-items: center;
  margin-bottom: 14px;
}

.login-mark svg {
  filter: drop-shadow(0 12px 26px rgba(110, 123, 255, 0.35));
}

.brand {
  margin: 0;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}

.login-card h1 {
  margin: 8px 0 0;
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.login-lead {
  margin: 10px 0 26px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.field {
  display: block;
  text-align: left;
  margin-bottom: 16px;
}

.field span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field-input {
  position: relative;
  display: flex;
  align-items: center;
}

.field-lock {
  position: absolute;
  left: 13px;
  color: var(--muted);
  pointer-events: none;
}

.field input {
  width: 100%;
  height: 46px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(8, 11, 20, 0.55);
  color: var(--text);
  padding: 0 44px 0 38px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field-toggle {
  position: absolute;
  right: 6px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.field-toggle:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.field-toggle.is-on {
  color: var(--accent);
}

/* Show exactly one eye: open by default, crossed-out when the password is revealed. */
.field-toggle svg {
  grid-area: 1 / 1;
}

.field-toggle .eye-closed {
  display: none;
}

.field-toggle.is-on .eye-open {
  display: none;
}

.field-toggle.is-on .eye-closed {
  display: block;
}

.login-foot {
  margin: 18px 0 0;
  color: var(--muted);
  opacity: 0.7;
  font-size: 11px;
  letter-spacing: 0.02em;
}

.field input:focus {
  border-color: rgba(110, 168, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(110, 168, 255, 0.18);
}

.primary-btn {
  position: relative;
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #7eb4ff, #5b96f0);
  color: #071018;
  font-weight: 650;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: filter 0.15s ease;
}

.btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(7, 16, 24, 0.35);
  border-top-color: #071018;
  animation: spin 0.7s linear infinite;
}

.primary-btn.is-loading .btn-spinner {
  display: block;
}

.primary-btn:hover {
  filter: brightness(1.06);
}

.primary-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.error {
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.login-card.shake {
  animation: card-shake 0.4s ease;
}

@keyframes card-shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

.login-screen .login-card {
  animation: card-in 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .login-screen .login-card,
  .login-card.shake,
  .btn-spinner {
    animation: none;
  }
}

/* ——— App / window ——— */

.app-screen {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 28px 20px;
}

.app-screen[hidden] {
  display: none;
}

.browser-window {
  position: relative;
  width: min(1200px, 100%);
  height: min(820px, calc(100vh - 56px));
  /* dvh tracks mobile browsers' collapsing toolbars; vh above is the fallback. */
  height: min(820px, calc(100dvh - 56px));
  background: var(--window);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
}

body.is-maximized .app-screen {
  padding: 0;
  place-items: stretch;
}

body.is-maximized .browser-window {
  width: 100%;
  height: 100%;
  max-width: none;
  border-radius: 0;
  border: 0;
}

body.is-fullscreen .app-screen {
  padding: 0;
  place-items: stretch;
}

body.is-fullscreen .browser-window {
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: 0;
}

body.is-focus .titlebar,
body.is-focus .statusbar {
  display: none;
}

/* A remote video is fullscreen: nothing but the stream, edge to edge. */
body.is-immersive .titlebar,
body.is-immersive .toolbar,
body.is-immersive .statusbar {
  display: none;
}

body.is-immersive .app-screen {
  padding: 0;
}

body.is-immersive .browser-window {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 42px;
  padding: 0 12px 0 14px;
  background: var(--chrome);
  border-bottom: 1px solid var(--line);
  user-select: none;
  flex-shrink: 0;
}

.traffic-lights {
  display: flex;
  gap: 7px;
  padding-right: 4px;
}

.tl {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: block;
}

.tl.red { background: #ff5f57; }
.tl.yellow { background: #febc2e; }
.tl.green { background: #28c840; }

/* Tab strip hugs the left; the + sits right after the last tab, then an empty
   flexible region fills the rest of the title bar (Chrome layout). */
.tabstrip {
  display: flex;
  align-items: flex-end;
  min-width: 0;
  flex: 0 1 auto;
  height: 100%;
}

.titlebar-flex {
  flex: 1 1 auto;
  min-width: 8px;
  align-self: stretch;
}

.tabs {
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

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

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 220px;
  max-width: 220px;
  min-width: 90px;
  height: 30px;
  margin-bottom: 0;
  padding: 0 8px 0 12px;
  border-radius: 8px 8px 0 0;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.tab:hover {
  background: rgba(var(--tint), 0.04);
  color: var(--text);
}

.tab.active {
  background: var(--window);
  border-color: var(--line);
  border-bottom-color: var(--window);
  color: var(--text);
  cursor: default;
}

.tab-close {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font-size: 14px;
  line-height: 18px;
  cursor: pointer;
  opacity: 0.55;
}

.tab-close:hover {
  background: rgba(var(--tint), 0.1);
  opacity: 1;
}

.tab-new {
  flex-shrink: 0;
  align-self: flex-end;
  width: 30px;
  height: 30px;
  margin: 0 0 0 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.tab-new:hover {
  background: rgba(var(--tint), 0.06);
  color: var(--text);
}

.tab-new.is-stale {
  color: var(--danger);
}

.latency-wrap {
  position: relative;
}

.latency-btn {
  position: relative;
}

/* Speedometer whose needle follows the measured round trip: right and green when fast,
   upright and amber when fair, left and red when slow. Upright and neutral until the
   first measurement. */
.lat-needle {
  transform-origin: 12px 14px;
  transition: transform 350ms cubic-bezier(0.3, 1.3, 0.5, 1), color 200ms ease;
}

.latency-btn[data-level="good"] .lat-needle {
  transform: rotate(52deg);
  color: var(--ok);
}

.latency-btn[data-level="fair"] .lat-needle {
  color: #e0a21b;
}

.latency-btn[data-level="poor"] .lat-needle {
  transform: rotate(-52deg);
  color: var(--danger);
}

@media (prefers-reduced-motion: reduce) {
  .lat-needle {
    transition: none;
  }
}

/* The needle carries the state now, so the old corner dot is redundant. */
.latency-btn .latency-dot {
  display: none;
}

.latency-dot {
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
}

.adblock-btn {
  position: relative;
}

.adblock-btn.is-loading svg {
  animation: adblock-pulse 1s ease-in-out infinite;
}

.adblock-btn.is-error {
  color: var(--danger);
}

.adblock-btn path[hidden] {
  display: none;
}

.adblock-count {
  position: absolute;
  right: 1px;
  bottom: 1px;
  min-width: 13px;
  padding: 0 3px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 9px;
  font-weight: 700;
  line-height: 13px;
  text-align: center;
  pointer-events: none;
}

.adblock-count[hidden] {
  display: none;
}

@keyframes adblock-pulse {
  50% { opacity: 0.35; }
}

.latency-dot.good { background: var(--ok); }
.latency-dot.fair { background: #febc2e; }
.latency-dot.poor { background: var(--danger); }

.latency-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  width: 210px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-pop);
  font-size: 12px;
  color: var(--muted);
}

.latency-panel[hidden] {
  display: none;
}

.latency-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
}

.latency-row strong {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
}

.tab-favicon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.tab.active .tab-favicon {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.7);
}

.tab-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.titlebar-actions {
  display: flex;
  gap: 4px;
}

/* Phones only (see the small-screen block): opens the tools tray. Needs to out-rank
   `.icon-btn { display: grid }`, which comes later in this file. */
.icon-btn.more-btn {
  display: none;
  flex-shrink: 0;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn:hover {
  background: rgba(var(--tint), 0.06);
  color: var(--text);
}

.icon-btn svg[hidden] {
  display: none;
}

.icon-btn.is-on {
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.12);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--chrome-2);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.nav {
  display: flex;
  gap: 2px;
}

.omnibox {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 6px 0 12px;
  border-radius: 999px;
  background: var(--field-2);
  border: 1px solid var(--line-strong);
  gap: 8px;
}

.omnibox:focus-within {
  border-color: rgba(var(--accent-rgb), 0.65);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.14);
}

.omnibox-lock {
  color: var(--lock);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.omnibox-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  height: 100%;
}

.omnibox-input::placeholder {
  color: var(--placeholder);
}

.go-btn {
  height: 26px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: rgba(var(--accent-rgb), 0.16);
  color: var(--accent);
  font-weight: 650;
  font-size: 12px;
  cursor: pointer;
}

.go-btn:hover {
  background: rgba(var(--accent-rgb), 0.28);
}

.viewport {
  flex: 1;
  min-height: 0;
  position: relative;
  background: var(--canvas);
  outline: none;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.viewport.is-live {
  cursor: default;
}

/* Off-screen textarea that receives phone/virtual keyboard input for the remote page. */
.kbd {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  margin: 0;
  opacity: 0.01;
  resize: none;
  overflow: hidden;
  font-size: 16px;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  pointer-events: none;
  z-index: 3;
}

.viewport:not(.is-live) .kbd {
  display: none;
}

.start-page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px 96px;
  background:
    radial-gradient(600px 280px at 50% 0%, rgba(var(--accent-rgb), 0.08), transparent 70%),
    var(--canvas);
  isolation: isolate;
}

/* Wallpaper and its dimming layer sit behind the content; `cover` crops any image
   shape to the viewport, so no particular aspect ratio is required. */
.start-page.has-bg::before,
.start-page.has-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
}

.start-page.has-bg::before {
  background: #090b10 var(--start-bg) center / cover no-repeat;
}

.start-page.has-bg::after {
  background: rgba(5, 7, 12, var(--start-dim, 0.35));
}

.start-page.has-bg h2 {
  --h-from: #fff;
  --h-to: #b9c8ff;
  filter: drop-shadow(0 2px 14px rgba(0, 0, 0, 0.55));
}

.start-page.has-bg .start-sub {
  color: rgba(255, 255, 255, 0.84);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
}

.start-page.has-bg .dial-label {
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.65);
}

.start-page.has-bg .start-kicker {
  color: #9cc2ff;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.6);
}

/* Light theme without a wallpaper: dark glass turns muddy on a pale canvas, so the tiles
   become frosted white and the glyphs take ink colours. */
:root[data-theme="light"] .start-page:not(.has-bg) .dial-icon {
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(15, 23, 42, 0.09);
  box-shadow:
    inset 0 1px 0 #fff,
    0 10px 26px rgba(30, 41, 80, 0.13),
    0 0 22px rgba(99, 102, 241, 0.06);
}

:root[data-theme="light"] .start-page:not(.has-bg) .dial:hover .dial-icon,
:root[data-theme="light"] .start-page:not(.has-bg) .dial:focus-visible .dial-icon {
  background: #fff;
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow:
    inset 0 1px 0 #fff,
    0 16px 32px rgba(30, 41, 80, 0.17),
    0 0 28px rgba(99, 102, 241, 0.16);
}

:root[data-theme="light"] .start-page:not(.has-bg) .dial-icon.ip {
  color: #2563eb;
}

:root[data-theme="light"] .start-page:not(.has-bg) .dial-icon.wiki {
  color: #131823;
}

/* Without a wallpaper the labels sit on the themed canvas, not on a photo. */
.start-page:not(.has-bg) .dial-label {
  color: var(--muted);
}

.start-page:not(.has-bg) .dial:hover .dial-label,
.start-page:not(.has-bg) .dial:focus-visible .dial-label {
  color: var(--text);
}

.start-page.no-search .start-search,
.start-page.no-shortcuts .dials {
  display: none;
}

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

.start-kicker {
  margin: 0;
  /* Tracking adds space after the last letter too; this keeps the line optically centred. */
  padding-left: 3px;
  letter-spacing: 3px;
  text-transform: uppercase;
  font-size: 16px;
  line-height: 1.2;
  color: var(--accent);
  font-weight: 600;
  text-align: center;
}

/* Display heading. The gradient fill is clipped to the glyphs, so depth over a wallpaper
   comes from a drop-shadow filter — text-shadow would show through transparent text. */
.start-page h2 {
  --h-from: var(--text);
  --h-to: #93a4c8;
  margin: 10px 0 0;
  font-family: Inter, "SF Pro Display", var(--font);
  font-size: 36px;
  line-height: 1.1;
  letter-spacing: -1.1px;
  font-weight: 650;
  text-align: center;
  color: var(--h-from);
  background: linear-gradient(180deg, var(--h-from) 35%, var(--h-to) 115%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  /* Room for descenders, which background-clip would otherwise shave. */
  padding-bottom: 0.08em;
}

/* On the plain light page the title is solid ink, like a native app's. */
:root[data-theme="light"] .start-page:not(.has-bg) h2 {
  --h-from: #111827;
  --h-to: #111827;
}

.start-sub {
  margin: 8px 0 24px;
  color: var(--muted);
  font-family: Inter, var(--font);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: -0.01em;
  text-align: center;
  max-width: 560px;
  line-height: 1.35;
}

:root[data-theme="light"] .start-page:not(.has-bg) .start-sub {
  color: #667085;
}

/* Search bar: one glass pill. The label is the visual field, so a click anywhere on it
   (icon and shortcut hint included) lands in the input. */
.start-search {
  --bar-bg: rgba(15, 23, 42, 0.5);
  --bar-border: rgba(255, 255, 255, 0.14);
  --bar-border-hover: rgba(255, 255, 255, 0.24);
  --bar-shadow: 0 8px 30px rgba(0, 0, 0, 0.28);
  --bar-shadow-hover: 0 10px 34px rgba(0, 0, 0, 0.34);
  --bar-text: #fff;
  --bar-muted: rgba(255, 255, 255, 0.56);
  --bar-ring: rgba(110, 168, 255, 0.2);
  --bar-ring-border: rgba(110, 168, 255, 0.55);
  --kbd-bg: rgba(255, 255, 255, 0.08);
  --kbd-border: rgba(255, 255, 255, 0.14);
  width: min(600px, 70vw);
  margin-bottom: 28px;
}

:root[data-theme="light"] .start-search {
  --bar-bg: rgba(255, 255, 255, 0.72);
  --bar-border: rgba(15, 23, 42, 0.12);
  --bar-border-hover: rgba(15, 23, 42, 0.2);
  --bar-shadow: 0 8px 30px rgba(30, 64, 175, 0.08);
  --bar-shadow-hover: 0 10px 34px rgba(30, 64, 175, 0.12);
  --bar-text: #111827;
  --bar-muted: #667085;
  --bar-ring: rgba(37, 99, 235, 0.12);
  --bar-ring-border: rgba(37, 99, 235, 0.45);
  --kbd-bg: rgba(15, 23, 42, 0.045);
  --kbd-border: rgba(15, 23, 42, 0.1);
}

.start-search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 50px;
  padding: 0 14px 0 20px;
  border-radius: 25px;
  background: var(--bar-bg);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid var(--bar-border);
  box-shadow: var(--bar-shadow);
  cursor: text;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.start-search-bar:hover {
  border-color: var(--bar-border-hover);
  box-shadow: var(--bar-shadow-hover);
}

.start-search-bar:focus-within {
  border-color: var(--bar-ring-border);
  box-shadow:
    0 0 0 3px var(--bar-ring),
    0 10px 35px rgba(30, 64, 175, 0.1);
}

.start-search-icon {
  flex-shrink: 0;
  color: var(--bar-muted);
}

.start-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--bar-text);
  font-family: Inter, var(--font);
  font-size: 15.5px;
  letter-spacing: -0.005em;
  outline: none;
}

.start-search input::placeholder {
  color: var(--bar-muted);
}

.start-search-kbd {
  flex-shrink: 0;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--kbd-border);
  background: var(--kbd-bg);
  color: var(--bar-muted);
  font-family: var(--font);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
  user-select: none;
  transition: opacity 160ms ease;
}

/* The hint is for getting to the field; once you are in it, it steps back. */
.start-search-bar:focus-within .start-search-kbd {
  opacity: 0;
}

/* No hardware keyboard, no shortcut to advertise. */
@media (hover: none) {
  .start-search-kbd {
    display: none;
  }
}

.dials {
  display: grid;
  grid-template-columns: repeat(4, minmax(88px, 110px));
  gap: 18px;
}

.dial {
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0;
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}

/* Floating glass tile. The brand lives in the glyph colour, not in a filled background,
   so every tile is the same material and the wallpaper shows through all of them. */
.dial-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-weight: 750;
  font-size: 22px;
  line-height: 1;
  background: rgba(15, 23, 42, 0.45);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
  border: 1px solid rgba(186, 210, 255, 0.16);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 10px 28px rgba(2, 6, 18, 0.42),
    0 0 22px rgba(124, 138, 255, 0.07);
  transition:
    transform 200ms cubic-bezier(0.2, 0.7, 0.2, 1),
    border-color 200ms ease,
    box-shadow 200ms ease,
    background-color 200ms ease,
    backdrop-filter 200ms ease,
    -webkit-backdrop-filter 200ms ease;
}

.dial:hover .dial-icon,
.dial:focus-visible .dial-icon {
  transform: translateY(-3px);
  background: rgba(24, 34, 58, 0.5);
  /* Brightens the glass rather than the glyph, so the icon itself stays crisp. */
  -webkit-backdrop-filter: blur(14px) saturate(1.4) brightness(1.18);
  backdrop-filter: blur(14px) saturate(1.4) brightness(1.18);
  border-color: rgba(170, 196, 255, 0.4);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 16px 34px rgba(2, 6, 18, 0.48),
    0 0 30px rgba(124, 138, 255, 0.2);
}

.dial:active .dial-icon {
  transform: translateY(0) scale(0.97);
  transition-duration: 90ms;
}

.dial:focus-visible {
  outline: none;
}

.dial:focus-visible .dial-icon {
  border-color: rgba(170, 196, 255, 0.75);
}

.dial-icon svg {
  display: block;
}

.dial-icon.ip {
  color: #9cc2ff;
  font-size: 16px;
  letter-spacing: 0.04em;
}

.dial-icon.wiki {
  color: #f3f5f8;
  font-family: "Times New Roman", Times, serif;
  font-style: italic;
  font-size: 26px;
}

.dial-label {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.72);
  transition: color 200ms ease;
}

.dial:hover .dial-label,
.dial:focus-visible .dial-label {
  color: rgba(255, 255, 255, 0.95);
}

@media (prefers-reduced-motion: reduce) {
  .dial-icon {
    transition: none;
  }

  .dial:hover .dial-icon,
  .dial:focus-visible .dial-icon,
  .dial:active .dial-icon {
    transform: none;
  }
}

.stream {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  user-select: none;
  pointer-events: none;
  background: #fff;
}

.loading-page {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.02em;
  background: var(--canvas);
}

.viewport.is-live .start-page {
  display: none;
}

.viewport.is-live.is-waiting .loading-page {
  display: grid;
  z-index: 2;
}

.loading-page .loading-url {
  display: block;
  margin-top: 8px;
  max-width: 80%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: rgba(154, 163, 178, 0.7);
}

.loading-page .spinner {
  width: 22px;
  height: 22px;
  margin: 0 auto 12px;
  border-radius: 50%;
  border: 2px solid rgba(var(--accent-rgb), 0.25);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.viewport.is-live .stream.has-frame {
  display: block;
}

.viewport.is-waiting .stream {
  display: none !important;
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 28px;
  padding: 0 12px;
  background: var(--chrome);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  flex-shrink: 0;
  user-select: none;
}

/* The URL on the left gives way (with an ellipsis); the IP chip on the right never
   shrinks or wraps, however long the address is. */
.status-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 0;
  min-width: 0;
}

.status-right {
  flex-shrink: 0;
}

.ws-dot {
  flex-shrink: 0;
}

#status-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #555d6a;
  flex-shrink: 0;
}

.ws-dot.on {
  background: var(--ok);
  box-shadow: 0 0 8px rgba(61, 214, 140, 0.7);
}

.ip-chip {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* ——— settings page ——— */

.settings-page {
  position: absolute;
  inset: 42px 0 0;
  z-index: 30;
  display: flex;
  background: var(--window);
  color: var(--text);
}

.settings-page[hidden] {
  display: none;
}

.settings-nav {
  width: 210px;
  flex-shrink: 0;
  padding: 22px 12px;
  border-right: 1px solid var(--line);
  background: var(--chrome);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-nav h2 {
  margin: 0 10px 14px;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.settings-nav a {
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13.5px;
}

.settings-nav a:hover {
  color: var(--text);
  background: rgba(var(--tint), 0.05);
}

.settings-nav a.is-current {
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.12);
}

.settings-body {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 0 28px 64px;
  scroll-behavior: smooth;
}

.settings-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding: 14px 0 10px;
  background: linear-gradient(var(--window) 75%, transparent);
}

.settings-saved {
  margin: 0;
  font-size: 12.5px;
  color: var(--ok);
  opacity: 0;
  transition: opacity 0.25s;
}

.settings-saved.is-visible {
  opacity: 1;
}

.settings-saved.is-error {
  color: var(--danger);
}

.set-section {
  max-width: 660px;
  margin: 0 auto 34px;
  scroll-margin-top: 58px;
}

.set-section h3 {
  margin: 0 0 4px;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.set-section h4 {
  margin: 22px 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.set-lead {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.set-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--chrome);
  margin-top: 10px;
}

.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 16px;
  cursor: default;
}

.set-row + .set-row {
  border-top: 1px solid var(--line);
}

label.set-row {
  cursor: pointer;
}

.set-row-stack {
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  cursor: default;
}

.set-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.set-title {
  font-size: 14px;
}

.set-desc {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
}

.set-lock {
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 10.5px;
  vertical-align: 1px;
}

.set-switch {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 38px;
  height: 22px;
  margin: 0;
  border-radius: 999px;
  background: rgba(var(--tint), 0.14);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}

.set-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}

.set-switch:checked {
  background: var(--accent);
}

.set-switch:checked::after {
  transform: translateX(16px);
}

.set-switch:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.set-switch:focus-visible,
.set-btn:focus-visible,
.bg-choice:focus-visible,
.set-select:focus-visible,
.set-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.set-segment {
  display: flex;
  flex-shrink: 0;
  padding: 3px;
  gap: 2px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--field);
}

.set-segment button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

.set-segment button:hover {
  color: var(--text);
}

.set-segment button[aria-checked="true"] {
  background: rgba(var(--accent-rgb), 0.16);
  color: var(--accent);
}

.set-segment button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.set-range {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.set-range input {
  width: 150px;
  accent-color: var(--accent);
}

.set-range output {
  width: 38px;
  text-align: right;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.set-select,
.set-input {
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--field);
  color: var(--text);
  padding: 0 10px;
  font: inherit;
  font-size: 13.5px;
}

.set-input {
  width: 100%;
}

.set-btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: rgba(var(--tint), 0.06);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}

.set-btn:hover {
  background: rgba(var(--tint), 0.11);
}

.set-btn:disabled {
  opacity: 0.5;
  cursor: progress;
}

.set-btn[hidden] {
  display: none;
}

/* The feature list outgrew a bold one-liner. */
#about-server {
  max-width: 58%;
  text-align: right;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--muted);
}

.set-btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--on-accent);
  font-weight: 600;
}

.set-btn-primary:hover {
  background: var(--accent);
  filter: brightness(1.08);
}

.pw-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  max-width: 380px;
}

.pw-input {
  position: relative;
  display: flex;
}

.pw-input input {
  width: 100%;
  height: 38px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--field);
  color: var(--text);
  padding: 0 40px 0 12px;
  font: inherit;
  font-size: 14px;
  outline: none;
}

.pw-input input:focus {
  border-color: rgba(var(--accent-rgb), 0.65);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.14);
}

.pw-input input.is-invalid {
  border-color: var(--danger);
}

.pw-reveal {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.pw-reveal:hover,
.pw-reveal[aria-pressed="true"] {
  color: var(--accent);
}

.pw-status {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--ok);
  max-width: 380px;
}

.pw-status.is-error {
  color: var(--danger);
}

.pw-status[hidden] {
  display: none;
}

.set-btn-quiet {
  border-color: transparent;
  color: var(--muted);
}

.set-btn-danger {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.35);
}

.set-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.set-error {
  margin: 0;
  font-size: 12.5px;
  color: var(--danger);
}

.set-error[hidden] {
  display: none;
}

.bg-choices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 10px;
}

.bg-choice {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 6px 6px 8px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

.bg-choice[aria-checked="true"] {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(var(--accent-rgb), 0.08);
}

.bg-choice:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.bg-thumb {
  display: block;
  aspect-ratio: 16 / 9;
  border-radius: 7px;
  background: #090b10 center / cover no-repeat;
}

.bg-thumb-dark {
  background-image: url("img/newtab-dark.webp?v=4138a08b05e1f276");
}

.bg-thumb-light {
  background-image: url("img/newtab-light.webp?v=75c36a5aba0a939c");
}

.bg-thumb-custom {
  background-image: repeating-linear-gradient(45deg, rgba(var(--tint), 0.04) 0 8px, transparent 8px 16px);
}

.bg-thumb-none {
  background: radial-gradient(120px 60px at 50% 0%, rgba(var(--accent-rgb), 0.18), transparent 70%), #090b10;
}

@media (max-width: 720px) {
  /* Installed to the home screen the page runs edge to edge, under the notch and the
     home indicator; keep the controls out from under them. */
  .app-screen {
    height: 100dvh;
    /* --kb-inset: height of the on-screen keyboard while it is open (set from app.js). */
    height: calc(100dvh - var(--kb-inset, 0px));
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
      env(safe-area-inset-left);
  }

  /* The title bar keeps what a phone needs at all times — tabs and "new tab" — and the
     tools move into a tray behind "⋯", instead of eight icons squeezing the tabs away. */
  .traffic-lights,
  .titlebar-flex,
  #btn-maximize {
    display: none;
  }

  .titlebar {
    position: relative;
    gap: 4px;
    padding: 0 6px 0 8px;
  }

  .tabstrip {
    flex: 1 1 auto;
  }

  .icon-btn.more-btn {
    display: grid;
    width: 38px;
    height: 38px;
  }

  .titlebar-actions {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 6px;
    z-index: 40;
    gap: 2px;
    padding: 6px;
    border-radius: 14px;
    background: var(--panel);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-pop);
  }

  .titlebar.is-tools-open .titlebar-actions {
    display: flex;
  }

  /* Finger-sized targets. */
  .titlebar-actions .icon-btn {
    width: 42px;
    height: 42px;
  }

  .toolbar {
    gap: 4px;
    padding: 6px 6px;
  }

  .toolbar .icon-btn {
    width: 36px;
    height: 36px;
  }

  /* The keyboard's own Go/Enter key submits; the space is better spent on the address. */
  .go-btn {
    display: none;
  }

  .toolbar .nav {
    gap: 0;
  }

  /* Anchor the stats panel to the tray, not to its first button, so it stays on screen. */
  .latency-wrap {
    position: static;
  }

  /* iOS zooms the whole page into any field whose text is smaller than 16px. */
  .omnibox-input,
  .start-search input,
  .field input,
  .set-input,
  .set-select,
  .pw-input input {
    font-size: 16px;
  }

  .settings-page {
    flex-direction: column;
  }

  .settings-nav {
    width: auto;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 8px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    white-space: nowrap;
  }

  .settings-nav h2 {
    display: none;
  }

  .settings-body {
    padding: 0 14px 48px;
  }

  .set-range input {
    width: 110px;
  }

  .browser-window {
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: 0;
  }

  .dials {
    grid-template-columns: repeat(2, minmax(88px, 110px));
  }

  .start-page {
    padding-bottom: 56px;
  }

  .start-kicker {
    font-size: 13px;
    letter-spacing: 2.5px;
    padding-left: 2.5px;
  }

  .start-page h2 {
    font-size: 30px;
    letter-spacing: -0.9px;
  }

  .start-sub {
    margin: 8px 0 22px;
    font-size: 14.5px;
  }

  .start-search {
    width: 100%;
  }

  .start-search-bar {
    height: 48px;
    padding: 0 14px 0 18px;
    gap: 10px;
    border-radius: 24px;
  }

  .start-search input {
    font-size: 16px;
  }

  .tab {
    max-width: 140px;
    min-width: 70px;
  }
}
