/* =========================================================
   Kapendeka Universe Hub v2 — modern theme
   Light: editorial daylight (linen + terracotta + magazine type)
   Dark:  midnight glass (indigo/pink + frosted + ambient glow)
   ========================================================= */

:root,
:root[data-theme="light"] {
  --bg: #faf9f6;
  --bg-elev: #ffffff;
  --bg-sunken: #f0eee8;
  --bg-card: #ffffff;
  --bg-card-hov: #fafaf7;
  --bg-glass: rgba(255,255,255,.7);

  --t-1: #1a1a1a;
  --t-2: #555555;
  --t-3: #888888;
  --t-4: #b4b2a9;
  --t-on-accent: #ffffff;

  --bd-1: rgba(0,0,0,.08);
  --bd-2: rgba(0,0,0,.12);
  --bd-3: rgba(0,0,0,.20);

  --acc: #cc5500;
  --acc-2: #e67033;
  --acc-soft: rgba(204,85,0,.10);
  --acc-glow: rgba(204,85,0,.18);

  --ok: #4a7c4e; --ok-soft: rgba(74,124,78,.12);
  --warn: #c89834; --warn-soft: rgba(200,152,52,.12);
  --info: #4a6d8c; --info-soft: rgba(74,109,140,.12);
  --danger: #b3392b; --danger-soft: rgba(179,57,43,.10);

  --c-rose-fg: #b3392b; --c-rose-bg: rgba(179,57,43,.10);
  --c-amber-fg: #b07a1f; --c-amber-bg: rgba(200,152,52,.14);
  --c-sage-fg: #4a7c4e; --c-sage-bg: rgba(74,124,78,.12);
  --c-indigo-fg: #4a4d8a; --c-indigo-bg: rgba(74,77,138,.12);
  --c-plum-fg: #6f4373; --c-plum-bg: rgba(111,67,115,.12);
  --c-teal-fg: #2b6b6b; --c-teal-bg: rgba(43,107,107,.12);

  --hero-1: #1a1a1a;
  --hero-2: #333333;

  --glow-1: transparent;
  --glow-2: transparent;

  --shadow-1: 0 1px 2px rgba(0,0,0,.04);
  --shadow-2: 0 6px 24px rgba(0,0,0,.06);
  --shadow-3: 0 20px 60px rgba(0,0,0,.12);

  --blur: blur(0);
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px;
  --sw: 280px; --tbh: 56px; --bnh: 66px;
}

:root[data-theme="dark"] {
  --bg: #0a0e1a;
  --bg-elev: #11162a;
  --bg-sunken: #060812;
  --bg-card: rgba(255,255,255,.04);
  --bg-card-hov: rgba(255,255,255,.07);
  --bg-glass: rgba(10,14,26,.65);

  --t-1: #ffffff;
  --t-2: rgba(255,255,255,.65);
  --t-3: rgba(255,255,255,.45);
  --t-4: rgba(255,255,255,.25);

  --bd-1: rgba(255,255,255,.08);
  --bd-2: rgba(255,255,255,.14);
  --bd-3: rgba(255,255,255,.22);

  --acc: #818cf8;
  --acc-2: #f472b6;
  --acc-soft: rgba(129,140,248,.16);
  --acc-glow: rgba(129,140,248,.30);

  --ok: #34d399; --ok-soft: rgba(52,211,153,.16);
  --warn: #fbbf24; --warn-soft: rgba(251,191,36,.16);
  --info: #60a5fa; --info-soft: rgba(96,165,250,.16);
  --danger: #fb7185; --danger-soft: rgba(251,113,133,.16);

  --c-rose-fg: #fda4af; --c-rose-bg: rgba(251,113,133,.16);
  --c-amber-fg: #fcd34d; --c-amber-bg: rgba(251,191,36,.16);
  --c-sage-fg: #6ee7b7; --c-sage-bg: rgba(52,211,153,.16);
  --c-indigo-fg: #a5b4fc; --c-indigo-bg: rgba(129,140,248,.16);
  --c-plum-fg: #f0abfc; --c-plum-bg: rgba(232,121,249,.16);
  --c-teal-fg: #5eead4; --c-teal-bg: rgba(45,212,191,.16);

  --hero-1: #6366f1;
  --hero-2: #ec4899;

  --glow-1: radial-gradient(circle at 100% 0%, rgba(99,102,241,.16) 0%, transparent 50%);
  --glow-2: radial-gradient(circle at 0% 80%, rgba(236,72,153,.12) 0%, transparent 50%);

  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 6px 24px rgba(0,0,0,.5);
  --shadow-3: 0 20px 60px rgba(0,0,0,.6);

  --blur: blur(20px);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0a0e1a; --bg-elev: #11162a; --bg-sunken: #060812;
    --bg-card: rgba(255,255,255,.04); --bg-card-hov: rgba(255,255,255,.07); --bg-glass: rgba(10,14,26,.65);
    --t-1: #ffffff; --t-2: rgba(255,255,255,.65); --t-3: rgba(255,255,255,.45); --t-4: rgba(255,255,255,.25);
    --bd-1: rgba(255,255,255,.08); --bd-2: rgba(255,255,255,.14); --bd-3: rgba(255,255,255,.22);
    --acc: #818cf8; --acc-2: #f472b6;
    --acc-soft: rgba(129,140,248,.16); --acc-glow: rgba(129,140,248,.30);
    --ok: #34d399; --ok-soft: rgba(52,211,153,.16);
    --warn: #fbbf24; --warn-soft: rgba(251,191,36,.16);
    --info: #60a5fa; --info-soft: rgba(96,165,250,.16);
    --danger: #fb7185; --danger-soft: rgba(251,113,133,.16);
    --c-rose-fg: #fda4af; --c-rose-bg: rgba(251,113,133,.16);
    --c-amber-fg: #fcd34d; --c-amber-bg: rgba(251,191,36,.16);
    --c-sage-fg: #6ee7b7; --c-sage-bg: rgba(52,211,153,.16);
    --c-indigo-fg: #a5b4fc; --c-indigo-bg: rgba(129,140,248,.16);
    --c-plum-fg: #f0abfc; --c-plum-bg: rgba(232,121,249,.16);
    --c-teal-fg: #5eead4; --c-teal-bg: rgba(45,212,191,.16);
    --hero-1: #6366f1; --hero-2: #ec4899;
    --glow-1: radial-gradient(circle at 100% 0%, rgba(99,102,241,.16) 0%, transparent 50%);
    --glow-2: radial-gradient(circle at 0% 80%, rgba(236,72,153,.12) 0%, transparent 50%);
    --shadow-1: 0 1px 2px rgba(0,0,0,.4);
    --shadow-2: 0 6px 24px rgba(0,0,0,.5);
    --shadow-3: 0 20px 60px rgba(0,0,0,.6);
    --blur: blur(20px);
  }
}

/* ============ BASE ============ */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg); color: var(--t-1); min-height: 100vh; overflow-x: hidden;
  padding-bottom: var(--bnh); font-size: 14px;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  transition: background-color .3s ease, color .3s ease;
}
button { cursor: pointer; font-family: inherit; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; border: none; outline: none; font-size: 16px; color: var(--t-1); }
a { color: var(--acc); text-decoration: none; }
h1, h2, h3 { font-family: 'Cormorant Garamond', serif; font-weight: 500; letter-spacing: -.01em; color: var(--t-1); }

body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: var(--glow-1), var(--glow-2);
}
#appShell, #authScreen { position: relative; z-index: 1; }

/* ============ SPLASH ============ */
#splash {
  position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 20px; z-index: 9999;
}
#splash .logo {
  width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg, var(--hero-1), var(--hero-2));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-family: 'Cormorant Garamond', serif; font-size: 26px; font-weight: 500;
  box-shadow: 0 8px 32px var(--acc-glow);
}
#splash .label { font-family: 'Cormorant Garamond', serif; font-size: 24px; font-weight: 500; color: var(--t-1); letter-spacing: -.01em; }
#splash .sub { font-size: 11px; color: var(--t-3); letter-spacing: .12em; text-transform: uppercase; }
#splash .ring { width: 28px; height: 28px; border: 2px solid var(--bd-2); border-top-color: var(--acc); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ AUTH ============ */
#authScreen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card {
  background: var(--bg-elev); border-radius: var(--r-xl); box-shadow: var(--shadow-3);
  max-width: 420px; width: 100%; padding: 32px 24px; border: 1px solid var(--bd-1);
}
.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-brand .logo {
  width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg, var(--hero-1), var(--hero-2));
  display: inline-flex; align-items: center; justify-content: center; color: #fff;
  font-family: 'Cormorant Garamond', serif; font-size: 26px; font-weight: 500;
  margin-bottom: 14px; box-shadow: 0 8px 32px var(--acc-glow);
}
.auth-brand h1 { font-size: 26px; line-height: 1.05; color: var(--t-1); margin-bottom: 6px; }
.auth-brand p { font-size: 11px; color: var(--t-3); letter-spacing: .14em; text-transform: uppercase; }

.auth-tabs { display: flex; gap: 4px; padding: 4px; background: var(--bg-sunken); border-radius: var(--r-md); margin-bottom: 20px; }
.auth-tab { flex: 1; padding: 10px 12px; border-radius: 9px; font-size: 13px; font-weight: 500; color: var(--t-3); text-align: center; cursor: pointer; transition: all .2s; min-height: 38px; }
.auth-tab.on { background: var(--bg-elev); color: var(--t-1); box-shadow: var(--shadow-1); }
.auth-err { background: var(--danger-soft); border: 1px solid var(--bd-1); color: var(--danger); padding: 11px 14px; border-radius: var(--r-md); font-size: 12.5px; margin-bottom: 12px; display: none; }
.auth-err.on { display: block; }
.auth-ok { background: var(--ok-soft); border: 1px solid var(--bd-1); color: var(--ok); padding: 11px 14px; border-radius: var(--r-md); font-size: 12.5px; margin-bottom: 12px; display: none; }
.auth-ok.on { display: block; }
.auth-foot { text-align: center; font-size: 11px; color: var(--t-3); margin-top: 20px; line-height: 1.6; }

/* ============ SIDEBAR ============ */
.sb {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--sw); max-width: 88vw;
  background: var(--bg-elev); display: flex; flex-direction: column;
  z-index: 300; overflow: hidden; transform: translateX(-100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  box-shadow: var(--shadow-3); border-right: 1px solid var(--bd-1);
}
.sb.on { transform: translateX(0); }

.sb-logo { padding: 22px 18px 14px; display: flex; align-items: center; gap: 12px; flex-shrink: 0; cursor: pointer; }
.sb-ic {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, var(--hero-1), var(--hero-2));
  display: flex; align-items: center; justify-content: center; color: #fff;
  font-family: 'Cormorant Garamond', serif; font-size: 19px; font-weight: 500; flex-shrink: 0;
  box-shadow: 0 4px 16px var(--acc-glow);
}
.sb-nm { font-family: 'Cormorant Garamond', serif; font-size: 19px; font-weight: 500; color: var(--t-1); line-height: 1.1; }
.sb-sub { font-size: 9px; color: var(--t-3); letter-spacing: .14em; text-transform: uppercase; margin-top: 2px; }

.sb-avs { padding: 10px 18px 14px; border-bottom: 1px solid var(--bd-1); flex-shrink: 0; }
.fav-lbl { font-size: 9px; color: var(--t-3); letter-spacing: .12em; text-transform: uppercase; font-weight: 500; margin-bottom: 8px; }
.avs { display: flex; gap: 7px; flex-wrap: wrap; }

.av { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 500; color: #fff; cursor: pointer; border: 1.5px solid transparent; transition: all .2s; flex-shrink: 0; position: relative; }
.av:hover { transform: scale(1.05); }
.av.adm::after { content: ''; position: absolute; top: -2px; right: -2px; width: 10px; height: 10px; background: var(--acc); border-radius: 50%; border: 2px solid var(--bg-elev); }

.nav-wrap { flex: 1; overflow-y: auto; padding: 6px 0; -webkit-overflow-scrolling: touch; }
.nav-wrap::-webkit-scrollbar { width: 0; }
.ns { font-size: 9px; color: var(--t-4); letter-spacing: .14em; text-transform: uppercase; padding: 14px 18px 6px; font-weight: 500; }
.ni {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 13px; color: var(--t-2); font-size: 13px; font-weight: 400;
  cursor: pointer; border-radius: 10px; margin: 1px 10px;
  transition: all .15s; min-height: 40px; border: none; background: none;
  width: calc(100% - 20px); text-align: left;
}
.ni:hover { background: var(--bg-card-hov); color: var(--t-1); }
.ni.on { background: var(--acc-soft); color: var(--acc); font-weight: 500; }
.ni i { font-size: 17px; flex-shrink: 0; opacity: .9; }
.ni span { flex: 1; }
.nbadge { background: var(--acc); color: var(--t-on-accent); font-size: 9px; font-weight: 500; padding: 2px 7px; border-radius: 8px; line-height: 1.4; }

.sb-foot { padding: 12px; border-top: 1px solid var(--bd-1); flex-shrink: 0; }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 9px 11px; background: var(--bg-card); border: 1px solid var(--bd-1); border-radius: 11px; font-size: 12px; }
.sb-user .av { width: 26px; height: 26px; font-size: 11px; }
.sb-user .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--t-1); font-weight: 500; }
.sb-user .nm small { display: block; font-size: 9px; color: var(--t-3); text-transform: uppercase; letter-spacing: .08em; font-weight: 400; margin-top: 1px; }
.sb-out { width: 28px; height: 28px; border-radius: 8px; background: transparent; color: var(--t-3); cursor: pointer; border: none; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.sb-out:hover { background: var(--danger-soft); color: var(--danger); }

/* ============ OVERLAY ============ */
.sb-ov { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 250; backdrop-filter: blur(4px); }
.sb-ov.on { display: block; }

/* ============ MAIN ============ */
.main { margin-left: 0; min-height: 100vh; display: flex; flex-direction: column; transition: margin-left .3s ease; position: relative; z-index: 1; }

/* ============ TOPBAR ============ */
.tb {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--bd-1);
  padding: 0 14px; height: var(--tbh); display: flex; align-items: center; gap: 9px; flex-shrink: 0;
}
.tb-title { font-family: 'Cormorant Garamond', serif; font-size: 19px; font-weight: 500; color: var(--t-1); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; letter-spacing: -.01em; }
.tb-actions { display: flex; align-items: center; gap: 6px; }
.tbtn {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--bg-card); border: 1px solid var(--bd-1);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer; transition: all .15s;
  color: var(--t-1); flex-shrink: 0;
}
.tbtn:hover { background: var(--bg-card-hov); border-color: var(--bd-2); }
.tbtn:active { transform: scale(.95); }
.tbtn.on { background: var(--acc); color: var(--t-on-accent); border-color: var(--acc); }
.burger {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--bg-card); border: 1px solid var(--bd-1);
  flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  display: flex; cursor: pointer; flex-shrink: 0;
}
.burger span { width: 14px; height: 1.5px; background: var(--t-1); border-radius: 1px; display: block; }
.burger:active { transform: scale(.95); }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex-shrink: 0; box-shadow: 0 0 8px var(--ok); }
.sync-dot.offline { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.sync-dot.syncing { background: var(--warn); animation: pulse 1s infinite; box-shadow: 0 0 8px var(--warn); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

/* ============ BOTTOM NAV (floating) ============ */
.bn {
  position: fixed; bottom: 14px; left: 14px; right: 14px; height: var(--bnh);
  background: var(--bg-glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--bd-1); border-radius: var(--r-lg); box-shadow: var(--shadow-2);
  display: flex; z-index: 140; padding: 8px 6px;
}
.bn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; cursor: pointer; color: var(--t-3); font-size: 9.5px; font-weight: 500;
  border-radius: 11px; padding: 4px 2px; transition: all .15s;
  min-height: 48px; border: none; background: none;
}
.bn-item i { font-size: 18px; transition: transform .2s; }
.bn-item.on { color: var(--acc); }
.bn-item.on i { transform: scale(1.1); }

/* ============ PAGES ============ */
.page { display: none; padding: 16px 14px; flex: 1; animation: fade .25s ease; padding-bottom: calc(var(--bnh) + 32px); }
.page.on { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ============ CARDS ============ */
.card {
  background: var(--bg-card); border: 1px solid var(--bd-1); border-radius: var(--r-lg);
  overflow: hidden; transition: all .2s;
}
.card:hover { border-color: var(--bd-2); }
.card-p { padding: 14px 16px; }
.ct { font-family: 'Cormorant Garamond', serif; font-size: 18px; font-weight: 500; color: var(--t-1); letter-spacing: -.01em; }
.cs { font-size: 11px; color: var(--t-3); margin-top: 3px; }

/* ============ GRIDS ============ */
.g2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
.g3 { display: grid; grid-template-columns: 1fr; gap: 12px; }
.g4 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.ga { display: grid; grid-template-columns: 1fr; gap: 12px; }

/* ============ STAT CARDS ============ */
.sc {
  background: var(--bg-card); border: 1px solid var(--bd-1); border-radius: var(--r-md);
  padding: 14px; position: relative; transition: all .2s;
}
.sc:hover { border-color: var(--bd-2); transform: translateY(-1px); }
.sc-i { width: 28px; height: 28px; border-radius: 9px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; font-size: 15px; }
.sc-i.rose   { background: var(--c-rose-bg);   color: var(--c-rose-fg); }
.sc-i.amber  { background: var(--c-amber-bg);  color: var(--c-amber-fg); }
.sc-i.sage   { background: var(--c-sage-bg);   color: var(--c-sage-fg); }
.sc-i.indigo { background: var(--c-indigo-bg); color: var(--c-indigo-fg); }
.sc-i.plum   { background: var(--c-plum-bg);   color: var(--c-plum-fg); }
.sc-i.teal   { background: var(--c-teal-bg);   color: var(--c-teal-fg); }
.sc-n { font-family: 'Cormorant Garamond', serif; font-size: 26px; font-weight: 500; line-height: 1; color: var(--t-1); letter-spacing: -.01em; }
.sc-l { font-size: 10.5px; color: var(--t-3); margin-top: 3px; }
.sc-s { font-size: 9.5px; color: var(--t-4); margin-top: 2px; }

/* ============ HERO ============ */
.hero {
  border-radius: var(--r-lg); padding: 20px 18px; margin-bottom: 18px;
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--hero-1), var(--hero-2));
  color: #fff; box-shadow: var(--shadow-2);
}
.hero::after { content: ''; position: absolute; right: -30px; top: -30px; width: 160px; height: 160px; background: rgba(255,255,255,.06); border-radius: 50%; pointer-events: none; }
.hero-tag { display: inline-block; font-size: 10px; color: rgba(255,255,255,.8); letter-spacing: .14em; text-transform: uppercase; margin-bottom: 8px; }
.hero h1 { font-family: 'Cormorant Garamond', serif; font-size: 26px; font-weight: 500; line-height: 1.1; color: #fff; margin-bottom: 6px; letter-spacing: -.01em; }
.hero h1 .accent { font-style: italic; opacity: .92; }
.hero p { font-size: 12.5px; color: rgba(255,255,255,.75); line-height: 1.5; max-width: 480px; }
.hero-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.hero-btn { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.2); padding: 8px 14px; border-radius: 10px; font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.hero-btn:hover { background: rgba(255,255,255,.22); }
.hero-btn i { font-size: 14px; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 16px; border-radius: 10px; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .15s; border: 1px solid transparent;
  font-family: inherit; min-height: 42px; white-space: nowrap;
}
.btn i { font-size: 15px; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.bf { background: var(--t-1); color: var(--bg); }
.bf:hover { opacity: .9; }
.ba { background: var(--acc); color: var(--t-on-accent); }
.ba:hover { background: var(--acc-2); }
.bgh { background: var(--bg-card); color: var(--t-1); border-color: var(--bd-1); }
.bgh:hover { background: var(--bg-card-hov); border-color: var(--bd-2); }
.bol { background: transparent; color: var(--t-1); border-color: var(--bd-2); }
.bol:hover { background: var(--bg-card); }
.bt { background: var(--danger); color: #fff; }
.bt:hover { opacity: .9; }
.bsm { padding: 8px 13px; font-size: 12px; border-radius: 9px; min-height: 36px; }
.bfw { width: 100%; }

/* Legacy aliases (so existing JS continues to work) */
.bg2 { background: var(--acc); color: var(--t-on-accent); }
.bs { background: var(--ok); color: #fff; }
.bsk { background: var(--info); color: #fff; }
.bp { background: var(--c-plum-fg); color: #fff; }

/* ============ TAGS ============ */
.tag { display: inline-flex; padding: 3px 9px; border-radius: 16px; font-size: 10px; font-weight: 500; letter-spacing: .02em; }
.tg, .tg-sage   { background: var(--c-sage-bg);   color: var(--c-sage-fg); }
.tt, .tg-rose   { background: var(--c-rose-bg);   color: var(--c-rose-fg); }
.tgo, .tg-amber { background: var(--c-amber-bg);  color: var(--c-amber-fg); }
.tp, .tg-plum   { background: var(--c-plum-bg);   color: var(--c-plum-fg); }
.tsk, .tg-indigo{ background: var(--c-indigo-bg); color: var(--c-indigo-fg); }
.tg-teal { background: var(--c-teal-bg); color: var(--c-teal-fg); }

/* ============ FORMS ============ */
.fg { margin-bottom: 13px; }
.fl { display: block; font-size: 10.5px; font-weight: 500; color: var(--t-2); margin-bottom: 6px; letter-spacing: .04em; }
.fi {
  width: 100%; padding: 12px 14px; border: 1px solid var(--bd-1); border-radius: 11px;
  font-size: 15px; background: var(--bg-card); color: var(--t-1);
  transition: all .2s; font-family: inherit; min-height: 44px;
}
.fi:focus { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); }
.fsl {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7' viewBox='0 0 11 7'%3E%3Cpath d='M1 1l4.5 4.5L10 1' stroke='%23888888' stroke-width='1.5' stroke-linecap='round' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}
textarea.fi { resize: vertical; min-height: 90px; line-height: 1.5; }

/* ============ MODAL ============ */
.mo-ov { position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(8px); z-index: 1000; display: none; align-items: flex-end; justify-content: center; padding: 0; }
.mo-ov.on { display: flex; animation: fade .2s ease; }
.mo-box {
  background: var(--bg-elev); border-radius: var(--r-xl) var(--r-xl) 0 0;
  max-width: 520px; width: 100%; max-height: 92vh; overflow-y: auto;
  box-shadow: var(--shadow-3); animation: slideUp .3s cubic-bezier(.4,0,.2,1);
  padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--bd-1);
}
@keyframes slideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.mo-hd { padding: 20px 22px 4px; display: flex; align-items: flex-start; justify-content: space-between; position: sticky; top: 0; background: inherit; z-index: 2; }
.mo-t { font-family: 'Cormorant Garamond', serif; font-size: 22px; font-weight: 500; color: var(--t-1); flex: 1; letter-spacing: -.01em; }
.mo-x { width: 32px; height: 32px; border-radius: 9px; background: var(--bg-card); display: flex; align-items: center; justify-content: center; font-size: 14px; color: var(--t-2); cursor: pointer; transition: all .2s; flex-shrink: 0; border: 1px solid var(--bd-1); }
.mo-x:hover { background: var(--danger-soft); color: var(--danger); }
.mo-bd { padding: 16px 22px 24px; }

/* ============ TASK ROWS ============ */
.ti {
  display: flex; align-items: center; gap: 11px; padding: 12px 14px;
  background: var(--bg-card); border: 1px solid var(--bd-1); border-radius: 12px;
  margin-bottom: 8px; transition: all .15s; min-height: 50px;
}
.ti:hover { border-color: var(--bd-2); }
.ti.dn .tc { background: var(--ok); border-color: var(--ok); color: #fff; }
.ti.dn .tt2 { text-decoration: line-through; opacity: .5; }
.tc {
  width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--bd-2);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: all .2s; font-size: 11px; color: #fff; cursor: pointer;
}
.tt2 { flex: 1; font-size: 13.5px; font-weight: 400; color: var(--t-1); }
.tm { font-size: 10.5px; color: var(--t-3); }

/* ============ QUICK ACTIONS ============ */
.qa {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 14px 8px; background: var(--bg-card); border: 1px solid var(--bd-1);
  border-radius: 12px; cursor: pointer; transition: all .2s;
  text-align: center; min-height: 76px; justify-content: center;
  font-family: inherit; color: var(--t-1);
}
.qa:hover { border-color: var(--bd-2); transform: translateY(-1px); }
.qa:active { transform: scale(.97); }
.qa i { font-size: 22px; color: var(--acc); }
.qa span { font-size: 10.5px; font-weight: 500; color: var(--t-1); }

/* Legacy emoji support inside qa */
.qa em { font-size: 22px; font-style: normal; }

/* ============ MEMBERS / AVATARS ============ */
.mem-r { display: flex; align-items: center; gap: 11px; padding: 10px 0; border-bottom: 1px solid var(--bd-1); cursor: pointer; }
.mem-r:last-child { border-bottom: none; }
.av2 { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 500; color: #fff; flex-shrink: 0; }
.av3 { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 500; color: #fff; flex-shrink: 0; position: relative; }
.av3.adm::after { content: ''; position: absolute; top: -2px; right: -2px; width: 11px; height: 11px; background: var(--acc); border-radius: 50%; border: 2px solid var(--bg); }

.c0 { background: linear-gradient(135deg, #cc5500, #e67033); }
.c1 { background: linear-gradient(135deg, #4a4d8a, #7b6db5); }
.c2 { background: linear-gradient(135deg, #c89834, #d4a854); }
.c3 { background: linear-gradient(135deg, #6f4373, #9067a3); }
.c4 { background: linear-gradient(135deg, #4a6d8c, #6889a8); }
.c5 { background: linear-gradient(135deg, #4a7c4e, #6e9e72); }

/* ============ EXPENSES ============ */
.ex { display: flex; align-items: center; gap: 11px; padding: 12px 0; border-bottom: 1px solid var(--bd-1); }
.ex:last-child { border-bottom: none; }
.ex-ic { width: 38px; height: 38px; border-radius: 11px; background: var(--bg-card); border: 1px solid var(--bd-1); display: flex; align-items: center; justify-content: center; font-size: 16px; color: var(--acc); flex-shrink: 0; }
.ex-amt { font-size: 13.5px; font-weight: 500; color: var(--acc); }

/* ============ BUDGET BAR ============ */
.bbar { height: 6px; background: var(--bg-sunken); border-radius: 3px; overflow: hidden; margin: 6px 0; }
.bfill { height: 100%; border-radius: 3px; transition: width .8s ease; }

/* ============ DIVIDER ============ */
.divider { border: none; border-top: 1px solid var(--bd-1); margin: 14px 0; }

/* ============ EMPTY STATE ============ */
.es { text-align: center; padding: 32px 18px; color: var(--t-3); }
.es i { font-size: 38px; color: var(--t-4); display: block; margin-bottom: 12px; }
.es em { font-size: 34px; font-style: normal; display: block; margin-bottom: 12px; opacity: .5; }
.es-t { font-size: 14px; font-weight: 500; color: var(--t-1); margin-bottom: 4px; }
.es-d { font-size: 12px; color: var(--t-3); }

/* ============ TABS ============ */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--bg-sunken); border-radius: var(--r-md); margin-bottom: 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { height: 0; }
.tabb { flex: 1; padding: 9px 12px; border-radius: 9px; font-size: 12px; font-weight: 500; color: var(--t-3); cursor: pointer; text-align: center; transition: all .2s; border: none; background: none; font-family: inherit; min-height: 38px; white-space: nowrap; }
.tabb.on { background: var(--bg-elev); color: var(--t-1); box-shadow: var(--shadow-1); }

/* ============ PILLS ============ */
.pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.pill { padding: 7px 14px; border-radius: 18px; font-size: 12px; font-weight: 500; background: var(--bg-card); border: 1px solid var(--bd-1); color: var(--t-2); cursor: pointer; transition: all .2s; font-family: inherit; min-height: 32px; }
.pill:hover { border-color: var(--bd-2); color: var(--t-1); }
.pill.on { background: var(--acc); color: var(--t-on-accent); border-color: var(--acc); }

/* ============ CALENDAR ============ */
.cal-g { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-dh { text-align: center; font-size: 9px; font-weight: 500; color: var(--t-3); letter-spacing: .05em; text-transform: uppercase; padding: 6px 0; }
.cal-d { min-height: 58px; padding: 5px 4px; border-radius: 8px; background: var(--bg-card); border: 1px solid var(--bd-1); cursor: pointer; transition: all .2s; overflow: hidden; text-align: left; color: var(--t-1); }
.cal-d:hover { border-color: var(--bd-2); }
.cal-d.other { opacity: .3; }
.cal-d.today { border-color: var(--acc); background: var(--acc-soft); }
.cal-dn { font-size: 11px; font-weight: 500; margin-bottom: 2px; }
.cal-ev { font-size: 8.5px; padding: 1px 4px; border-radius: 4px; margin-bottom: 1px; font-weight: 500; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; background: var(--c-rose-bg); color: var(--c-rose-fg); }

/* ============ MEMORIES / PETS CARDS ============ */
.mem-card { background: var(--bg-card); border: 1px solid var(--bd-1); border-radius: 14px; overflow: hidden; transition: all .2s; cursor: pointer; }
.mem-card:hover { border-color: var(--bd-2); transform: translateY(-2px); box-shadow: var(--shadow-2); }
.mem-img { height: 140px; display: flex; align-items: center; justify-content: center; font-size: 46px; background: var(--bg-sunken); background-size: cover; background-position: center; color: var(--t-3); }
.mem-meta { padding: 10px 13px; }
.mem-meta-t { font-weight: 500; font-size: 13px; color: var(--t-1); margin-bottom: 2px; }
.mem-meta-d { font-size: 11px; color: var(--t-3); }

/* ============ VAULT ============ */
.vault-it { display: flex; align-items: center; gap: 11px; padding: 13px 14px; background: var(--bg-card); border: 1px solid var(--bd-1); border-radius: 11px; margin-bottom: 7px; cursor: pointer; transition: all .2s; min-height: 54px; }
.vault-it:hover { border-color: var(--bd-2); }
.vault-ic { width: 40px; height: 40px; border-radius: 10px; background: var(--acc-soft); color: var(--acc); display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }

/* ============ WISHLIST ============ */
.wsh { display: flex; align-items: center; gap: 11px; padding: 12px 14px; background: var(--bg-card); border: 1px solid var(--bd-1); border-radius: 11px; margin-bottom: 7px; transition: all .2s; min-height: 56px; }
.wsh:hover { border-color: var(--bd-2); }

/* ============ SHOPPING ============ */
.shop-cat { padding: 8px 14px; background: var(--bg-sunken); font-size: 9.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .1em; color: var(--t-3); }
.shop-it { display: flex; align-items: center; gap: 11px; padding: 12px 14px; border-bottom: 1px solid var(--bd-1); cursor: pointer; user-select: none; min-height: 48px; }
.shop-it:last-child { border-bottom: none; }
.shop-it:active { background: var(--bg-card-hov); }
.schk { width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--bd-2); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; color: #fff; transition: all .2s; }
.shop-it.dn .schk { background: var(--ok); border-color: var(--ok); }
.shop-it.dn .snm { text-decoration: line-through; opacity: .5; }
.snm { flex: 1; font-size: 13.5px; color: var(--t-1); }

/* ============ NOTES ============ */
.note-card { border-radius: 12px; border: 1px solid var(--bd-1); padding: 14px; cursor: pointer; transition: all .2s; position: relative; background: var(--bg-card); color: var(--t-1); }
.note-card:hover { border-color: var(--bd-2); transform: translateY(-1px); }
.note-pin { position: absolute; top: 10px; right: 12px; font-size: 13px; opacity: .6; }

/* ============ VERSE / FAITH ============ */
.verse { background: linear-gradient(135deg, var(--c-plum-fg), var(--c-indigo-fg)); border-radius: var(--r-lg); padding: 22px; color: #fff; position: relative; overflow: hidden; }
.verse::before { content: '"'; position: absolute; top: -10px; left: 14px; font-family: 'Cormorant Garamond', serif; font-size: 100px; opacity: .12; line-height: 1; }
.vt { font-family: 'Cormorant Garamond', serif; font-size: 16px; font-style: italic; line-height: 1.7; position: relative; z-index: 1; margin-bottom: 10px; }
.vr { font-size: 10px; opacity: .75; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; }

/* ============ TRIP ============ */
.trip-hd { padding: 20px; background: linear-gradient(135deg, var(--c-indigo-fg), var(--c-plum-fg)); color: #fff; }

/* ============ TOAST ============ */
.toast-c { position: fixed; bottom: calc(var(--bnh) + 24px); right: 14px; left: 14px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; pointer-events: none; align-items: center; }
.toast {
  background: var(--bg-elev); color: var(--t-1); padding: 12px 18px; border-radius: 12px;
  font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 9px;
  box-shadow: var(--shadow-3); border: 1px solid var(--bd-1);
  animation: toastIn .3s ease; max-width: 340px; pointer-events: auto;
}
.toast.gold { border-color: var(--acc); color: var(--acc); }
.toast.red, .toast.error { border-color: var(--danger); color: var(--danger); }
.toast.success { border-color: var(--ok); color: var(--ok); }
@keyframes toastIn { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bd-2); border-radius: 2px; }

/* ============ SKELETON ============ */
.skel { background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--bg-card) 50%, var(--bg-sunken) 75%); background-size: 200% 100%; animation: skel 1.4s infinite; border-radius: 8px; height: 18px; }
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============ THEME TOGGLE ============ */
.theme-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 4px; background: var(--bg-sunken); border-radius: var(--r-md); }
.theme-opt { padding: 11px 8px; border-radius: 9px; font-size: 11px; font-weight: 500; color: var(--t-3); cursor: pointer; text-align: center; transition: all .2s; border: none; background: none; font-family: inherit; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.theme-opt i { font-size: 18px; }
.theme-opt.on { background: var(--bg-elev); color: var(--t-1); box-shadow: var(--shadow-1); }
.theme-opt.on i { color: var(--acc); }

/* ============ SUPERADMIN BADGE ============ */
.super-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: linear-gradient(135deg, var(--hero-1), var(--hero-2));
  color: #fff; padding: 3px 10px; border-radius: 12px;
  font-size: 9.5px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase;
  box-shadow: 0 2px 8px var(--acc-glow);
}
.super-badge i { font-size: 11px; }


/* === Inline-SVG icon (replaces Tabler webfont) === */
.ico{width:1em;height:1em;vertical-align:-.125em;flex-shrink:0;display:inline-block;color:currentColor;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.ni .ico{width:18px;height:18px;opacity:.9}
.bn-item .ico{width:18px;height:18px}
.tbtn .ico,.mo-x .ico{width:16px;height:16px}
.hero-btn .ico{width:14px;height:14px}
.theme-opt .ico{width:18px;height:18px}
.qa .ico{width:22px;height:22px;color:var(--acc)}
.sc-i .ico{width:15px;height:15px}
.btn .ico{width:15px;height:15px}
.super-badge .ico{width:11px;height:11px}
.sb-out .ico{width:13px;height:13px}
.sync-dot+.ico,.vault-ic .ico,.ex-ic .ico{width:17px;height:17px}

/* ============ TABLET ============ */
@media (min-width: 768px) {
  :root { --tbh: 60px; }
  .tb { padding: 0 20px; height: var(--tbh); gap: 12px; }
  .tb-title { font-size: 21px; }
  .page { padding: 22px; }
  .g2 { grid-template-columns: 1fr 1fr; gap: 14px; }
  .g3 { grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .g4 { grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .ga { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
  .hero { padding: 24px; }
  .hero h1 { font-size: 30px; }
  .sc-n { font-size: 30px; }
  .mo-ov { align-items: center; padding: 20px; }
  .mo-box { border-radius: var(--r-xl); max-height: 90vh; }
  @keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
  .toast-c { bottom: calc(var(--bnh) + 24px); right: 20px; left: auto; align-items: flex-end; }
  .cal-d { min-height: 80px; padding: 7px 5px; }
  .ct { font-size: 19px; }
}

/* ============ DESKTOP ============ */
@media (min-width: 1024px) {
  :root { --bnh: 0px; }
  body { padding-bottom: 0; }
  .sb { transform: translateX(0); box-shadow: none; max-width: var(--sw); }
  .main { margin-left: var(--sw); }
  .burger, .bn { display: none; }
  .sb-ov { display: none !important; }
  .tb { padding: 0 28px; height: 64px; }
  :root { --tbh: 64px; }
  .page { padding: 28px; padding-bottom: 28px; }
  .toast-c { bottom: 24px; right: 24px; left: auto; }
}
