/* =====================================================================
   Homex design tokens. Three themes, switched with <html data-theme="...">
     gold   = Gold Night   (black glass + gold)      <- default
     pearl  = Pearl White  (white + gold)
     chrome = Chrome Glass (shiny blurred black + silver)
   Everything else in the CSS only uses these variables.
   ===================================================================== */
:root,
:root[data-theme="gold"] {
  --bg: #07070a;
  --bg-glow-1: rgba(232, 190, 85, .17);
  --bg-glow-2: rgba(168, 116, 13, .15);
  --bg-extra: linear-gradient(transparent, transparent);
  --surface: rgba(26, 23, 30, .58);
  --surface-2: rgba(46, 40, 52, .62);
  --solid: #121016;
  --input-bg: rgba(0, 0, 0, .4);
  --border: rgba(236, 196, 100, .17);
  --border-strong: rgba(236, 196, 100, .42);
  --edge: rgba(255, 236, 170, .14);
  --text: #f8f3e6;
  --muted: #a9a190;
  --primary: #e9bf55;
  --primary-2: #a8740d;
  --accent-text: #f0cc6b;
  --grad: linear-gradient(135deg, #fff1be 0%, #e9bf55 34%, #b07a10 66%, #f4d675 100%);
  --on-primary: #1a1204;
  --glow: rgba(232, 190, 85, .28);
  --gloss: linear-gradient(160deg, rgba(255, 236, 170, .09), rgba(255, 236, 170, 0) 38%);
  --cover: radial-gradient(120% 150% at 82% 0%, rgba(244, 214, 117, .6), transparent 56%), linear-gradient(135deg, #1b1407, #3d2c0a);
  --shadow: 0 12px 32px rgba(0, 0, 0, .5);
  --nav-bg: rgba(10, 9, 13, .74);
  --top-bg: rgba(10, 9, 13, .7);
  --ok: #4ade80;
  --danger: #fb7185;
  --warn: #fbbf24;
  --focus: #f4d675;
  --logo-1: #fff1be; --logo-2: #e9bf55; --logo-3: #a8740d; --logo-4: #f4d675;
  --logo-shine: rgba(255, 255, 255, .9);
  color-scheme: dark;
}

:root[data-theme="pearl"] {
  --bg: #ffffff;
  --bg-glow-1: rgba(0, 0, 0, 0);
  --bg-glow-2: rgba(0, 0, 0, 0);
  --bg-extra: linear-gradient(transparent, transparent);
  --surface: #ffffff;
  --surface-2: #f3f3f5;
  --solid: #ffffff;
  --input-bg: #ffffff;
  --border: rgba(0, 0, 0, .1);
  --border-strong: rgba(0, 0, 0, .28);
  --edge: rgba(255, 255, 255, 0);
  --text: #111113;
  --muted: #6b6b73;
  --primary: #111113;
  --primary-2: #000000;
  --accent-text: #111113;
  --grad: linear-gradient(#111113, #111113);
  --on-primary: #ffffff;
  --glow: rgba(0, 0, 0, .08);
  --gloss: linear-gradient(transparent, transparent);
  --cover: linear-gradient(135deg, #e6e6ea, #cfcfd6);
  --shadow: 0 6px 18px rgba(0, 0, 0, .06);
  --nav-bg: rgba(255, 255, 255, .96);
  --top-bg: rgba(255, 255, 255, .96);
  --ok: #15803d;
  --danger: #be123c;
  --warn: #b45309;
  --focus: #111113;
  --logo-1: #2a2a2e; --logo-2: #111113; --logo-3: #000000; --logo-4: #2a2a2e;
  --logo-shine: rgba(255, 255, 255, .55);
  color-scheme: light;
}

:root[data-theme="chrome"] {
  --bg: #05060a;
  --bg-glow-1: rgba(170, 190, 225, .17);
  --bg-glow-2: rgba(90, 112, 160, .17);
  --bg-extra: linear-gradient(115deg, transparent 38%, rgba(255, 255, 255, .05) 49%, transparent 60%);
  --surface: rgba(20, 24, 34, .55);
  --surface-2: rgba(42, 50, 68, .55);
  --solid: #0d1018;
  --input-bg: rgba(0, 0, 0, .42);
  --border: rgba(205, 220, 245, .2);
  --border-strong: rgba(205, 220, 245, .48);
  --edge: rgba(255, 255, 255, .24);
  --text: #eef2f9;
  --muted: #9aa5b8;
  --primary: #c9d5e8;
  --primary-2: #7b8aa4;
  --accent-text: #dbe4f2;
  --grad: linear-gradient(135deg, #ffffff 0%, #c4cfdf 34%, #7b8aa4 66%, #e8eef8 100%);
  --on-primary: #0a0f18;
  --glow: rgba(190, 210, 245, .26);
  --gloss: linear-gradient(160deg, rgba(255, 255, 255, .15), rgba(255, 255, 255, 0) 36%);
  --cover: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .28) 46%, transparent 62%), linear-gradient(135deg, #131824, #3a4660);
  --shadow: 0 12px 32px rgba(0, 0, 0, .55);
  --nav-bg: rgba(8, 10, 16, .74);
  --top-bg: rgba(8, 10, 16, .7);
  --ok: #4ade80;
  --danger: #fb7185;
  --warn: #fbbf24;
  --focus: #dbe4f2;
  --logo-1: #ffffff; --logo-2: #c4cfdf; --logo-3: #7b8aa4; --logo-4: #e8eef8;
  --logo-shine: rgba(255, 255, 255, .95);
  color-scheme: dark;
}

:root {
  --radius: 18px;
  --nav-h: 66px;
  --top-h: 58px;
  --maxw: 720px;
  --blur: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { background: var(--bg); }
html, body { color: var(--text); min-height: 100%; }
body { line-height: 1.5; font-size: 16px; overflow-x: hidden; background: transparent; }

/* Fixed backdrop: soft glows + (chrome) a specular streak. One layer, no repaint on scroll. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    var(--bg-extra),
    radial-gradient(900px 540px at 88% -8%, var(--bg-glow-1), transparent 62%),
    radial-gradient(720px 500px at -12% 108%, var(--bg-glow-2), transparent 60%),
    var(--bg);
}

a { color: var(--accent-text); text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
h1 { font-size: 1.55rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; }
h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 10px; }

#app { max-width: var(--maxw); margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- Top bar & logo ---------- */
#topbar {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--top-h) + var(--safe-t)); padding: var(--safe-t) 16px 0;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--top-bg);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.4); backdrop-filter: blur(var(--blur)) saturate(1.4);
  border-bottom: 1px solid var(--border);
  box-shadow: inset 0 -1px 0 var(--edge);
}
.brand { display: inline-flex; align-items: center; }
.brand-logo { height: 24px; width: auto; display: block; overflow: visible; }
.brand--lg .brand-logo { height: 46px; }
.topbar__actions { display: flex; gap: 4px; }
.icon-btn {
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px;
  background: none; border: 1px solid transparent; color: var(--text); cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); border-color: var(--border); }
.theme-fab { position: fixed; top: calc(var(--safe-t) + 10px); right: 12px; z-index: 30; background: var(--surface); border-color: var(--border);
  -webkit-backdrop-filter: blur(var(--blur)); backdrop-filter: blur(var(--blur)); }
#app:not(.app--auth) ~ .theme-fab { display: none; }

#view { --gutter: 16px; flex: 1; padding: 18px var(--gutter) calc(var(--nav-h) + var(--safe-b) + 20px); outline: none; }
.app--profile #view { padding-top: 0; }
.app--auth #view { padding-bottom: 24px; display: flex; flex-direction: column; justify-content: center; }

/* ---------- Bottom navigation ---------- */
#bottomnav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--maxw); z-index: 20;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--nav-bg);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.4); backdrop-filter: blur(var(--blur)) saturate(1.4);
  border-top: 1px solid var(--border);
  box-shadow: inset 0 1px 0 var(--edge);
}
.nav__item { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: .7rem; font-weight: 600; }
.nav__item.is-active { color: var(--accent-text); }
.nav__item.is-active::before {
  content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 2px; border-radius: 0 0 4px 4px;
  background: var(--grad); box-shadow: 0 2px 12px var(--glow);
}

.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row--wrap { flex-wrap: wrap; }
.grid { display: grid; gap: 12px; }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.center { text-align: center; }

@media (min-width: 720px) {
  #view { --gutter: 24px; padding-left: var(--gutter); padding-right: var(--gutter); }
}

/* Homex logo: mascot in a sky-blue ring */
.brand-mascot { display: block; width: 38px; height: 38px; border-radius: 12px; object-fit: cover; border: 2px solid #7cc7ff; box-shadow: 0 0 0 3px rgba(124, 199, 255, .22), 0 4px 14px rgba(56, 160, 255, .45); background: #bfe6ff; }
.brand--lg .brand-mascot { width: 96px; height: 96px; border-radius: 26px; border-width: 3px; box-shadow: 0 0 0 5px rgba(124, 199, 255, .22), 0 10px 28px rgba(56, 160, 255, .5); }

/* Top bar: sky blue, bigger mascot */
#topbar {
  height: calc(76px + var(--safe-t));
  background: linear-gradient(180deg, #6fc0ff 0%, #9ad5ff 55%, #b7e3ff 100%);
  -webkit-backdrop-filter: none; backdrop-filter: none;
  border-bottom: 1px solid rgba(255, 255, 255, .55); box-shadow: 0 6px 18px rgba(40, 140, 230, .28);
}
#topbar .icon-btn { color: #0b2a4a; }
#topbar .icon-btn:active { background: rgba(255, 255, 255, .45); border-color: rgba(255, 255, 255, .7); }
#topbar .brand-mascot { width: 60px; height: 60px; border-radius: 18px; border: 3px solid #fff; box-shadow: 0 4px 14px rgba(20, 100, 200, .45); background: #fff; }
