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

html, body {
  min-height: 100%;
  color-scheme: dark;
}

body {
  background: var(--bg);
  color: var(--t1);
  font-family: 'Exo 2', sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Dark scrollbars (Firefox + Chromium/WebKit) */
* {
  scrollbar-width: thin;
  scrollbar-color: #31424F #0c141b;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: #0c141b;
}

*::-webkit-scrollbar-thumb {
  background: #31424F;
  border-radius: 6px;
  border: 2px solid #0c141b;
}

*::-webkit-scrollbar-thumb:hover {
  background: #4a5f70;
}

#app {
  position: relative;
  min-height: 100dvh;
  max-width: 420px;
  margin: 0 auto;
  background: var(--slate);
  overflow-x: hidden;
}

#app::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/></filter><rect width='120' height='120' filter='url(%23n)' opacity='0.7'/></svg>");
  background-size: 120px;
}

.brand-wm {
  width: 220px;
  height: 220px;
  object-fit: contain;
  filter: grayscale(1);
}

/* Decorative watermark — parent should be the layout / rightmost column block */
.page-wm {
  position: absolute;
  right: -40px;
  top: 40px;
  width: 240px;
  height: 240px;
  opacity: 0.07;
  pointer-events: none;
  z-index: 1;
}

.brand-wm.page-wm {
  width: 220px;
  height: 220px;
  top: 0;
  right: -36px;
}

#view {
  position: relative;
  z-index: 2;
  padding: 56px 24px calc(96px + env(safe-area-inset-bottom, 0px));
  min-height: 100dvh;
}

/* Core auth bar — top shell strip (tokens mapped for auth-bar.css) */
.shell-top {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 420px;
  z-index: 32;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 40px;
  padding: calc(6px + env(safe-area-inset-top, 0px)) 12px 6px;
  background: rgba(12, 19, 26, 0.92);
  border-bottom: 1px solid var(--hair);
  backdrop-filter: blur(8px);
  --text: var(--t1);
  --border: var(--hair);
  --cyan: var(--blue);
  --panel: var(--slate);
  --muted: var(--t3);
  --amber: var(--gold);
}

.dev-actions {
  position: relative;
  margin-right: auto;
  flex: 0 0 auto;
}

.cloud-authbar {
  margin-left: auto;
}

.dev-actions-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  min-width: 168px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--hair);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.dev-actions-menu[hidden] {
  display: none;
}

.dev-actions-item {
  display: block;
  width: 100%;
  text-align: left;
  height: 36px;
  padding: 0 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--t1);
  font: 700 12px Rajdhani, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
}

.dev-actions-item:hover {
  background: var(--card);
  color: var(--blue);
}

.dev-actions-item.is-danger {
  color: var(--red, #e0564e);
}

.dev-actions-item.is-danger:hover {
  color: var(--red, #e0564e);
  background: rgba(224, 86, 78, 0.12);
}

#app.onboarding-mode .shell-top,
#app.session-mode .shell-top,
#app.system-overlay-mode .shell-top {
  display: none;
}

/* Sign-in gate: form is the only account chrome; hide top bar + tabs */
#app.signin-mode .tabbar,
#app.signin-mode .shell-top {
  display: none;
}

#app.signin-mode #view {
  padding-top: 28px;
}

.auth-gate {
  max-width: 360px;
  margin: 0 auto;
  padding-bottom: 32px;
}

.auth-mode-tabs {
  display: flex;
  gap: 0;
  margin-top: 20px;
  border: 1.5px solid var(--hair);
  border-radius: 14px;
  overflow: hidden;
  background: var(--card);
}

.auth-mode-tab {
  flex: 1;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--t3);
  font: 700 13px Rajdhani, sans-serif;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
}

.auth-mode-tab.on {
  background: rgba(77, 168, 218, 0.16);
  color: var(--t1);
}

.auth-form {
  margin-top: 8px;
}

.auth-form .inputf-real.auth-input {
  text-transform: none;
  letter-spacing: 0.02em;
  font: 500 15px 'Exo 2', sans-serif;
}

.auth-form .inlb:first-of-type {
  margin-top: 18px;
}

.auth-error {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(220, 80, 80, 0.12);
  border: 1px solid rgba(220, 80, 80, 0.35);
  color: #f0a8a8;
  font: 500 13px/1.4 'Exo 2', sans-serif;
}

.auth-hint {
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--t3);
}

.auth-hint code {
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  color: var(--t2);
}

.auth-google,
.auth-demo {
  margin-top: 12px;
}

.auth-google:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.auth-g {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-right: 8px;
  border-radius: 6px;
  background: #fff;
  color: #4285f4;
  font: 700 13px Rajdhani, sans-serif;
  letter-spacing: 0;
}

#app.onboarding-mode #view,
#app.session-mode #view {
  padding-top: 20px;
}

.home-shell {
  width: 100%;
}

.home-layout {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 15px;
  position: relative;
  z-index: 2;
}

.home-col-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.home-col-aside {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 15px;
}

.home-session-actions {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 10px;
}

.home-session-actions .btn {
  flex: 1;
  min-width: 0;
  width: auto;
}

.home-session-actions .btn.ghost {
  height: 56px;
  letter-spacing: 0.08em;
  font-size: 13px;
  text-align: center;
  line-height: 1.15;
}

.home-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-top: 8px;
  gap: 10px;
  position: relative;
  z-index: 2;
}

.home-stats {
  display: flex;
  gap: 9px;
  flex-shrink: 0;
}

/* Narrow phone frame when viewport is wider than the mobile shell but still below desktop */
@media (min-width: 421px) and (max-width: 767px) {
  body {
    background:
      radial-gradient(80% 50% at 50% -10%, rgba(77, 168, 218, 0.12), transparent 55%),
      #060a10;
  }

  #app {
    min-height: 100dvh;
    box-shadow: 0 0 0 1px rgba(49, 66, 79, 0.6), 0 24px 80px rgba(0, 0, 0, 0.45);
  }
}

/* Desktop / laptop: full-width shell + left nav */
@media (min-width: 768px) {
  html, body {
    height: 100%;
    overflow: hidden;
  }

  body {
    background:
      radial-gradient(60% 45% at 20% -10%, rgba(77, 168, 218, 0.1), transparent 50%),
      radial-gradient(50% 40% at 90% 0%, rgba(226, 168, 75, 0.05), transparent 45%),
      #060a10;
  }

  #app {
    --nav-w: 200px;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    max-width: none;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    min-height: 0;
    box-shadow: none;
    overflow: hidden;
  }

  #app::before {
    left: var(--nav-w);
  }

  #view {
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: auto;
    padding: 56px 48px 48px;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .shell-top {
    left: var(--nav-w);
    transform: none;
    width: auto;
    right: 0;
    max-width: none;
  }

  .home-shell {
    max-width: 920px;
  }

  .home-layout {
    flex-direction: row;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 20px;
    width: 100%;
    margin-top: 24px;
  }

  .home-col {
    flex: 1 1 0;
    min-width: 0;
    max-width: 460px;
  }

  .home-col-aside {
    margin-top: 0;
  }

  .stub-panel {
    max-width: 920px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
