:root {
  color-scheme: dark;
  --bg: #070b16;
  --bg-accent: #0d1530;
  --surface: rgba(13, 19, 40, 0.92);
  --surface-strong: #111a38;
  --text: #e9eefc;
  --muted: #94a1c4;
  --line: rgba(126, 154, 255, 0.14);
  --brand: #4f8cff;
  --brand-strong: #9db9ff;
  --brand-soft: rgba(79, 140, 255, 0.16);
  --highlight: #6ee7ff;
  --accent-2: #7a5cff;
  --success: #34e29a;
  --success-soft: rgba(52, 226, 154, 0.14);
  --danger: #ff6f7d;
  --danger-soft: rgba(255, 111, 125, 0.14);
  --warning: #ffc86b;
  --warning-soft: rgba(255, 200, 107, 0.14);
  --shadow: 0 28px 72px rgba(1, 4, 14, 0.55);
  --glow-top: rgba(79, 140, 255, 0.14);
  --glow-bottom: rgba(122, 92, 255, 0.12);
  --chip-bg: rgba(126, 154, 255, 0.08);
}

body[data-theme="light"] {
  color-scheme: light;
  --bg: #eef2fc;
  --bg-accent: #e2e9fb;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: #ffffff;
  --text: #101a33;
  --muted: #5b6785;
  --line: rgba(16, 26, 51, 0.1);
  --brand: #2f6bff;
  --brand-strong: #1c4ed8;
  --brand-soft: rgba(47, 107, 255, 0.1);
  --highlight: #00b8d9;
  --accent-2: #6d4aff;
  --success: #0a9e6b;
  --success-soft: rgba(10, 158, 107, 0.1);
  --danger: #d6455a;
  --danger-soft: rgba(214, 69, 90, 0.1);
  --warning: #c07f16;
  --warning-soft: rgba(192, 127, 22, 0.12);
  --shadow: 0 24px 60px rgba(28, 42, 82, 0.14);
  --glow-top: rgba(47, 107, 255, 0.1);
  --glow-bottom: rgba(0, 184, 217, 0.08);
  --chip-bg: rgba(255, 255, 255, 0.72);
}

/* The original warm sand palette, kept on the new component design. */
body[data-theme="sand"] {
  color-scheme: light;
  --bg: #f7efe3;
  --bg-accent: #f3dfc9;
  --surface: rgba(255, 250, 244, 0.9);
  --surface-strong: #fff8f0;
  --text: #3d2c22;
  --muted: #7c685b;
  --line: rgba(61, 44, 34, 0.1);
  --brand: #b46a3a;
  --brand-strong: #7a4320;
  --brand-soft: #f3dfce;
  --highlight: #dfaa56;
  --accent-2: #8a4d22;
  --success: #5d8b57;
  --success-soft: rgba(93, 139, 87, 0.12);
  --danger: #b8513d;
  --danger-soft: rgba(184, 81, 61, 0.12);
  --warning: #cf8842;
  --warning-soft: rgba(207, 136, 66, 0.13);
  --shadow: 0 26px 64px rgba(84, 55, 34, 0.14);
  --glow-top: rgba(207, 136, 66, 0.18);
  --glow-bottom: rgba(223, 170, 86, 0.16);
  --chip-bg: rgba(255, 251, 247, 0.72);
}

body[data-theme="sand"] .phone-shell {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(61, 44, 34, 0.1);
  box-shadow: 0 28px 56px rgba(84, 55, 34, 0.14);
}

body[data-theme="sand"] .hero-chip,
body[data-theme="sand"] .metric,
body[data-theme="sand"] .checklist li,
body[data-theme="sand"] .decision-raw {
  background: rgba(255, 253, 250, 0.95);
  border-color: rgba(61, 44, 34, 0.09);
}

body[data-theme="sand"] .brand-logo-mark {
  box-shadow: 0 12px 30px rgba(180, 106, 58, 0.3);
}

body[data-theme="sand"] .primary-button {
  box-shadow: 0 14px 30px rgba(180, 106, 58, 0.26);
}

body[data-theme="sand"] .auth-tab.is-active {
  box-shadow: 0 8px 20px rgba(180, 106, 58, 0.26);
}

body[data-theme="sand"] .plan-flag {
  color: #3d2c22;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, var(--glow-top), transparent 28%),
    radial-gradient(circle at bottom left, var(--glow-bottom), transparent 30%),
    linear-gradient(180deg, var(--bg-accent), var(--bg));
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px 16px;
  overflow: hidden;
}

button {
  font: inherit;
  cursor: pointer;
}

.app-frame {
  width: min(100%, 430px);
  height: min(100%, calc(100dvh - 48px));
}

.hero {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.phone-shell {
  height: 100%;
  max-height: min(920px, calc(100dvh - 48px));
  background: var(--surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--line);
  border-radius: 32px;
  box-shadow: var(--shadow);
  padding: 22px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.hero,
.section,
.bottom-nav {
  animation: rise-in 500ms ease both;
}

.section:nth-of-type(2) {
  animation-delay: 90ms;
}

.section:nth-of-type(3) {
  animation-delay: 180ms;
}

.bottom-nav {
  animation-delay: 240ms;
}

.status-row,
.section-heading,
.metric,
.bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toolbar-controls,
.language-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-row {
  gap: 14px;
}

.decision-topline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding-right: 30px;
}

.decision-topline > div {
  display: grid;
  justify-items: center;
}

.card-label,
.section-heading span,
.metric span,
.checklist,
.helper-text {
  color: var(--muted);
}

.hero-highlights {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  align-self: center;
  margin-top: 6px;
}

.brand-logo-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand), var(--highlight));
  color: #f8fbf6;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}

.brand-logo-p {
  font-size: 1.55rem;
  line-height: 1;
  font-weight: 800;
}

.brand-logo-wordmark {
  font-size: clamp(1.9rem, 5vw, 2.4rem);
  line-height: 1;
  letter-spacing: -0.05em;
  font-weight: 800;
}

.brand-logo-park {
  color: var(--text);
}

.brand-logo-better {
  color: var(--brand);
}

.hero-chip {
  border-radius: 999px;
  padding: 7px 12px;
  background: var(--chip-bg);
  border: 1px solid var(--line);
  color: var(--brand-strong);
  font-size: 0.8rem;
  font-weight: 700;
}

.ghost-button,
.primary-button,
.sign-photo-button,
.nav-item {
  transition:
    transform 180ms ease,
    background-color 180ms ease,
    border-color 180ms ease,
    color 180ms ease;
}

.ghost-button,
.primary-button,
.sign-photo-button {
  border-radius: 999px;
  padding: 12px 14px;
}

.flag-button {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  line-height: 1;
  transition:
    transform 180ms ease,
    background-color 180ms ease,
    border-color 180ms ease,
    color 180ms ease,
    box-shadow 180ms ease;
}

.flag-icon {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.flag-button.is-active {
  background: var(--brand-soft);
  border-color: rgba(37, 95, 69, 0.32);
  box-shadow: inset 0 0 0 1px rgba(37, 95, 69, 0.08);
}

.ghost-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}

#themeToggle {
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
}

.theme-icon {
  width: 20px;
  height: 20px;
  display: block;
}

.primary-button {
  border: 0;
  background: linear-gradient(135deg, var(--brand), var(--highlight));
  color: #f8fbf6;
  font-weight: 700;
  box-shadow: 0 14px 28px rgba(20, 48, 66, 0.18);
}

.sign-photo-button {
  border: 0;
  background: linear-gradient(135deg, #2c5f6e, #3d8a7a);
  color: #f0f8f6;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(44, 95, 110, 0.22);
}

.ghost-button:hover,
.primary-button:hover,
.sign-photo-button:hover,
.flag-button:hover,
.ghost-button:focus-visible,
.primary-button:focus-visible,
.sign-photo-button:focus-visible,
.flag-button:focus-visible {
  transform: translateY(-1px);
}

.wide-button {
  width: 100%;
}

.demo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.demo-button {
  width: 100%;
  min-height: 48px;
}

.demo-button.is-loading {
  opacity: 0.6;
  cursor: wait;
}

.demo-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.hero h1,
.section h2,
.metric strong {
  margin: 0;
}

.hero h1 {
  font-size: clamp(1.7rem, 4.6vw, 2.35rem);
  line-height: 1;
  margin-top: 10px;
  text-align: center;
  white-space: nowrap;
}

.hero p,
.decision-copy {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.hero p {
  text-align: center;
  max-width: 34ch;
  margin-inline: auto;
}

.decision-copy {
  text-align: left;
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.decision-line {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.55;
}

.decision-line + .decision-line {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.decision-warning {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--warning-soft);
  border: 1px solid rgba(210, 138, 30, 0.28);
  color: var(--text);
}

.decision-warning[hidden] {
  display: none;
}

.decision-warning-chip {
  display: inline-flex;
  align-items: center;
  justify-self: center;
  max-width: calc(100% - 36px);
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(210, 138, 30, 0.16);
  border: 1px solid rgba(210, 138, 30, 0.28);
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.2;
  text-align: center;
}

.decision-warning-chip strong {
  font-size: 0.8rem;
  font-weight: 700;
}

.decision-warning-chip[hidden] {
  display: none;
}

.decision-warning strong {
  font-size: 0.98rem;
}

.decision-warning span {
  color: var(--muted);
}

.decision-card.has-warning.status-allowed {
  border-color: rgba(210, 138, 30, 0.38);
}

.decision-card,
.info-panel,
.bottom-nav {
  border-radius: 24px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.decision-card,
.info-panel {
  padding: 16px;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-heading {
  padding: 0 2px;
}

.section-heading h2 {
  font-size: 1.02rem;
  letter-spacing: -0.01em;
}

.section-heading span {
  font-size: 0.8rem;
  font-weight: 700;
}

.section-toggle {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
}

.section-subheading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.helper-label {
  color: var(--muted);
  font-size: 0.8rem;
}

.control-stack {
  display: grid;
  gap: 10px;
}

.control-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.compact-button {
  flex: 0 1 150px;
  min-height: 40px;
  padding: 9px 10px;
  font-size: 0.86rem;
}

.precision-panel {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-strong);
}

.precision-row,
.precision-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.precision-row span,
.precision-grid span {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.3;
}

.precision-row strong,
.precision-grid strong {
  font-size: 0.9rem;
  line-height: 1.2;
  white-space: nowrap;
}

.precision-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.precision-grid > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.accuracy-meter {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.accuracy-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--warning);
  transition:
    width 180ms ease,
    background-color 180ms ease;
}

.accuracy-meter.is-good span {
  background: var(--success);
}

.accuracy-meter.is-poor span {
  background: var(--danger);
}

.precision-toggle {
  width: fit-content;
  min-height: 34px;
  margin-top: 2px;
  border: 0;
  background: transparent;
  color: var(--brand-strong);
  padding: 4px 0;
  font-weight: 700;
  font-size: 0.88rem;
  text-align: left;
}

.precision-tools {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}

.precision-tools[hidden] {
  display: none;
}

.adjust-map {
  width: 100%;
  height: 220px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-accent);
}

.adjust-map .leaflet-control-zoom a {
  color: #1e2a21;
}

.adjust-map .leaflet-marker-icon {
  filter: hue-rotate(130deg) saturate(0.9);
}

.location-details {
  display: grid;
  gap: 12px;
}

.location-details[hidden] {
  display: none;
}

.explanation-details[hidden] {
  display: none;
}

.decision-explanation {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 2px;
}

.explanation-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: 2px 0;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.explanation-toggle:hover {
  color: var(--text);
}

.explanation-toggle-icon {
  font-size: 1rem;
  font-weight: 400;
  line-height: 1;
}

.security-banner {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 20px;
  border: 1px solid rgba(210, 138, 30, 0.28);
  background: linear-gradient(180deg, var(--surface-strong), var(--warning-soft));
}

.security-banner strong {
  font-size: 0.95rem;
}

.security-banner span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.security-banner.is-safe {
  border-color: rgba(25, 135, 84, 0.28);
  background: linear-gradient(180deg, var(--surface-strong), var(--success-soft));
}

.helper-text {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
}

.decision-card {
  display: grid;
  gap: 14px;
  position: relative;
  padding-top: 18px;
}

.decision-card.is-collapsed {
  gap: 0;
}

.decision-card.is-collapsed .decision-warning-chip {
  margin-top: 12px;
}

.decision-card.status-allowed {
  background:
    radial-gradient(circle at bottom right, var(--success-soft), transparent 42%),
    linear-gradient(180deg, var(--surface-strong), var(--success-soft));
  border-color: rgba(25, 135, 84, 0.28);
}

.decision-card.status-forbidden {
  background:
    radial-gradient(circle at bottom right, var(--danger-soft), transparent 42%),
    linear-gradient(180deg, var(--surface-strong), var(--danger-soft));
  border-color: rgba(204, 61, 49, 0.28);
}

.decision-card.status-unknown {
  background:
    radial-gradient(circle at bottom right, var(--warning-soft), transparent 42%),
    linear-gradient(180deg, var(--surface-strong), var(--warning-soft));
  border-color: rgba(210, 138, 30, 0.28);
}

.status-light {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 6px var(--warning-soft);
}

.status-allowed .status-light {
  background: var(--success);
  box-shadow: 0 0 0 6px var(--success-soft);
}

.status-forbidden .status-light {
  background: var(--danger);
  box-shadow: 0 0 0 6px var(--danger-soft);
}

.decision-meta,
.info-panel {
  gap: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.decision-details {
  display: grid;
  gap: 14px;
  padding-top: 4px;
}

.decision-details[hidden] {
  display: none;
}

.decision-toggle {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
}

.metric {
  align-items: flex-start;
  flex-direction: column;
  gap: 6px;
  padding: 12px 12px 13px;
  border-radius: 18px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.metric strong {
  font-size: 1rem;
  line-height: 1.25;
}

.checklist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.checklist li {
  border-radius: 18px;
  padding: 14px 14px 14px 42px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  position: relative;
  line-height: 1.45;
}

.checklist li::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  transform: translateY(-50%);
  background: linear-gradient(135deg, var(--brand), var(--highlight));
}

.bottom-nav {
  margin-top: auto;
  gap: 8px;
  padding: 8px;
}

.nav-item {
  flex: 1;
  border: 0;
  background: transparent;
  border-radius: 16px;
  padding: 12px 8px;
  color: var(--muted);
}

.nav-item.selected {
  background: var(--brand);
  color: #f8fbf6;
}

.ghost-button:active,
.primary-button:active,
.nav-item:active {
  transform: scale(0.98);
}

body[data-theme="light"] {
  background:
    radial-gradient(circle at 15% 0%, var(--glow-top), transparent 32%),
    radial-gradient(circle at 90% 100%, var(--glow-bottom), transparent 34%),
    linear-gradient(180deg, var(--bg-accent), var(--bg));
}

body[data-theme="light"] .phone-shell {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(16, 26, 51, 0.08);
  box-shadow: 0 28px 56px rgba(28, 42, 82, 0.14);
}

body[data-theme="light"] .hero-chip,
body[data-theme="light"] .metric,
body[data-theme="light"] .checklist li,
body[data-theme="light"] .decision-raw {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(16, 26, 51, 0.08);
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 700px) {
  body {
    padding: 32px;
  }

  .app-frame {
    height: min(100%, calc(100dvh - 64px));
  }

  .phone-shell {
    max-height: min(880px, calc(100dvh - 64px));
  }
}

@media (max-width: 420px) {
  body {
    padding: 0;
  }

  .app-frame {
    width: 100%;
    height: 100dvh;
  }

  .phone-shell {
    max-height: 100dvh;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .status-row {
    align-items: flex-start;
    gap: 10px;
  }

  .toolbar-controls {
    justify-content: flex-end;
  }

  .decision-meta,
  .info-panel {
    grid-template-columns: 1fr;
  }

  .demo-grid {
    grid-template-columns: 1fr;
  }
}

/* ------------------------------------------------------------------ */
/* Futuristic touches                                                  */
/* ------------------------------------------------------------------ */

.status-light {
  animation: pulse-light 2.6s ease-in-out infinite;
}

@keyframes pulse-light {
  0%, 100% { box-shadow: 0 0 0 6px var(--warning-soft), 0 0 18px 0 var(--warning-soft); }
  50% { box-shadow: 0 0 0 8px var(--warning-soft), 0 0 26px 2px var(--warning-soft); }
}

.status-allowed .status-light {
  animation: pulse-light-allowed 2.6s ease-in-out infinite;
}

@keyframes pulse-light-allowed {
  0%, 100% { box-shadow: 0 0 0 6px var(--success-soft), 0 0 18px 0 var(--success-soft); }
  50% { box-shadow: 0 0 0 8px var(--success-soft), 0 0 26px 2px var(--success-soft); }
}

.status-forbidden .status-light {
  animation: pulse-light-forbidden 2.6s ease-in-out infinite;
}

@keyframes pulse-light-forbidden {
  0%, 100% { box-shadow: 0 0 0 6px var(--danger-soft), 0 0 18px 0 var(--danger-soft); }
  50% { box-shadow: 0 0 0 8px var(--danger-soft), 0 0 26px 2px var(--danger-soft); }
}

.brand-logo-mark {
  background: linear-gradient(135deg, var(--brand), var(--accent-2));
  box-shadow: 0 12px 30px rgba(79, 140, 255, 0.35);
}

.brand-logo-better {
  background: linear-gradient(120deg, var(--brand), var(--highlight));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.primary-button {
  background: linear-gradient(120deg, var(--brand), var(--accent-2));
  color: #ffffff;
  box-shadow: 0 14px 30px rgba(79, 140, 255, 0.3);
}

/* ------------------------------------------------------------------ */
/* Account button (toolbar)                                            */
/* ------------------------------------------------------------------ */

.account-button {
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--brand-strong);
  background: var(--brand-soft);
  border-color: var(--line);
}

.account-button[hidden] {
  display: none;
}

/* ------------------------------------------------------------------ */
/* Overlays: sign-in and paywall                                       */
/* ------------------------------------------------------------------ */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px 16px;
  overflow-y: auto;
  background:
    radial-gradient(circle at 20% 10%, var(--glow-top), transparent 42%),
    radial-gradient(circle at 85% 90%, var(--glow-bottom), transparent 40%),
    var(--bg);
  backdrop-filter: blur(14px);
}

.overlay[hidden] {
  display: none;
}

body.overlay-open {
  overflow: hidden;
}

.auth-card {
  width: min(100%, 400px);
  margin: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 28px 24px;
  display: grid;
  gap: 14px;
  animation: rise-in 420ms ease both;
}

.auth-brand {
  margin-top: 0;
}

.auth-brand .brand-logo-mark {
  width: 40px;
  height: 40px;
  border-radius: 13px;
}

.auth-brand .brand-logo-wordmark {
  font-size: 1.7rem;
}

.auth-intro {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  border-radius: 999px;
  background: var(--chip-bg);
  border: 1px solid var(--line);
}

.auth-tab {
  border: 0;
  border-radius: 999px;
  padding: 10px 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.auth-tab.is-active {
  background: linear-gradient(120deg, var(--brand), var(--accent-2));
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(79, 140, 255, 0.3);
}

#authForm {
  display: grid;
  gap: 8px;
}

.auth-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

.auth-input {
  font: inherit;
  width: 100%;
  padding: 13px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-accent);
  color: var(--text);
}

.auth-input:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: transparent;
}

.auth-submit {
  margin-top: 8px;
  width: 100%;
}

.auth-error {
  margin: 0;
  min-height: 1.2em;
  text-align: center;
  color: var(--danger);
  font-size: 0.85rem;
}

.auth-notice {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 200, 107, 0.35);
  background: var(--warning-soft);
  font-size: 0.88rem;
}

.auth-notice[hidden] {
  display: none;
}

.auth-notice strong {
  color: var(--warning);
}

.auth-dev-link {
  color: var(--brand-strong);
  font-weight: 700;
  word-break: break-all;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.8rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.google-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--text);
  font-weight: 700;
  transition: transform 180ms ease, border-color 180ms ease;
}

.google-button:hover,
.google-button:focus-visible {
  transform: translateY(-1px);
  border-color: var(--brand);
}

.google-icon {
  width: 20px;
  height: 20px;
}

.auth-footnote {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.paywall-title {
  margin: 0;
  text-align: center;
  font-size: 1.3rem;
}

.paywall-actions {
  justify-content: center;
}

/* ------------------------------------------------------------------ */
/* Plans & account section                                             */
/* ------------------------------------------------------------------ */

.plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.plan-card {
  position: relative;
  display: grid;
  gap: 6px;
  justify-items: center;
  text-align: center;
  padding: 18px 12px 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--bg-accent);
}

.plan-flag {
  position: absolute;
  top: -9px;
  right: 10px;
  padding: 3px 10px;
  border-radius: 999px;
  background: linear-gradient(120deg, var(--highlight), var(--brand));
  color: #06121f;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.plan-name {
  font-size: 0.95rem;
}

.plan-price {
  color: var(--brand-strong);
  font-weight: 800;
  font-size: 1.1rem;
}

.plan-card .primary-button,
.plan-card .ghost-button {
  width: 100%;
  margin-top: 4px;
}

.account-card {
  display: grid;
  gap: 12px;
  padding: 18px 16px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.account-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.account-row strong {
  word-break: break-all;
}

.account-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.account-actions {
  flex-wrap: wrap;
}

.plan-badge.is-premium {
  color: var(--success);
  border-color: rgba(52, 226, 154, 0.4);
}

.plan-badge.is-trial {
  color: var(--brand-strong);
}

.plan-badge.is-expired {
  color: var(--danger);
  border-color: rgba(255, 111, 125, 0.4);
}

.admin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

/* ------------------------------------------------------------------ */
/* Toast                                                               */
/* ------------------------------------------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(8px);
  z-index: 1200;
  max-width: calc(100vw - 40px);
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--surface-strong);
  border: 1px solid var(--brand);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 300ms ease, transform 300ms ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 420px) {
  .plan-grid {
    grid-template-columns: 1fr;
  }
}

/* ------------------------------------------------------------------ */
/* Account panel (under the user badge) & auth toolbar                 */
/* ------------------------------------------------------------------ */

.account-panel {
  position: relative;
}

.account-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-right: 34px;
}

.account-panel-heading h2 {
  margin: 0;
  font-size: 1.05rem;
}

.overlay-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--chip-bg);
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1;
}

.overlay-close:hover,
.overlay-close:focus-visible {
  color: var(--text);
  border-color: var(--brand);
}

.auth-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.auth-theme-toggle {
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
}
