/* ============================================================
   DESIGN TOKENS — LIGHT (default)
   ============================================================ */
:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --nav-bg: rgba(244, 244, 242, 0.92);
  --text-primary: #111113;
  --text-secondary: #66666e;
  --border: #e0e0e8;
  --accent: #ef4444;
  --accent-pressed: #dc2626;
}

/* ============================================================
   DESIGN TOKENS — DARK
   ============================================================ */
[data-theme="dark"] {
  --bg: #0c0c0e;
  --surface: #17171b;
  --nav-bg: rgba(12, 12, 14, 0.92);
  --text-primary: #f0f0ee;
  --text-secondary: #85858d;
  --border: #2d2d35;
}

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

html,
body {
  margin: 0;
  padding: 0;
}

/* ============================================================
   BASE
   ============================================================ */
body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ============================================================
   EMBEDDED MODE
   ============================================================ */
html.embedded .top-nav,
html.embedded footer {
  display: none;
}

html.embedded main {
  padding-top: 0;
  padding-bottom: 0;
}

html.embedded .container {
  max-width: none;
  padding: 0;
}

html.embedded .card {
  border: 0;
  border-radius: 0;
  padding: 16px;
}

/* ============================================================
   NAVIGATION — SHELL
   ============================================================ */
.top-nav {
  border-bottom: 1px solid var(--border);
  background: var(--nav-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 100;
}

/* ============================================================
   NAVIGATION — INNER LAYOUT (desktop: 3-col grid)
   ============================================================ */
.nav-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 60px;
}

.nav-brand {
  grid-column: 1;
  justify-self: start;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  transition: color 0.15s ease;
}

.nav-brand:hover {
  color: var(--accent);
  text-decoration: none;
}

.nav-links {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-controls {
  grid-column: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
}

/* ============================================================
   NAVIGATION — LINKS
   ============================================================ */
.nav-link {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: 8px;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-link:hover {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--text-primary) 6%, transparent);
  text-decoration: none;
}

.nav-link.active {
  color: var(--text-primary);
}

/* lang-switch sits inside nav-links, pushed to the right */
.nav-links .lang-switch {
  position: static;
  margin-left: 10px;
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.nav-links .lang-switch a {
  color: inherit;
  transition: color 0.15s ease;
}

.nav-links .lang-switch a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* lang-switch standalone (for pages without new nav structure) */
.lang-switch {
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.lang-switch a {
  color: inherit;
}

/* ============================================================
   NAVIGATION — THEME TOGGLE BUTTON
   ============================================================ */
.nav-theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: border-color 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}

.nav-theme-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Light mode: show moon (click to go dark) */
.nav-theme-btn .icon-sun { display: none; }
.nav-theme-btn .icon-moon { display: flex; }

/* Dark mode: show sun (click to go light) */
[data-theme="dark"] .nav-theme-btn .icon-sun { display: flex; }
[data-theme="dark"] .nav-theme-btn .icon-moon { display: none; }

/* ============================================================
   NAVIGATION — BURGER BUTTON (hidden on desktop)
   ============================================================ */
.nav-burger {
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  width: 34px;
  height: 34px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: border-color 0.15s ease;
}

.nav-burger:hover {
  border-color: var(--text-secondary);
}

.burger-line {
  display: block;
  width: 16px;
  height: 1.5px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.2s ease;
}

/* Animate to × when open */
.nav-burger[aria-expanded="true"] .burger-line:nth-child(1) {
  transform: translateY(6.5px) rotate(45deg);
}

.nav-burger[aria-expanded="true"] .burger-line:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.nav-burger[aria-expanded="true"] .burger-line:nth-child(3) {
  transform: translateY(-6.5px) rotate(-45deg);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
main {
  flex: 1;
  padding: 32px 0 48px;
}

/* ============================================================
   CARD
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}

.hero {
  text-align: center;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1 {
  font-size: 34px;
  line-height: 1.2;
  font-weight: 800;
  margin: 0 0 8px;
}

.subtitle {
  font-size: 20px;
  line-height: 1.3;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--text-secondary);
}

p {
  margin: 0 0 16px;
}

.description {
  color: var(--text-secondary);
  margin: 0 auto 24px;
  max-width: 56ch;
}

h2 {
  font-size: 22px;
  line-height: 1.3;
  font-weight: 700;
  margin: 28px 0 10px;
}

.section p {
  color: var(--text-secondary);
}

.updated {
  margin-top: -4px;
  margin-bottom: 24px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ============================================================
   LINK ROW
   ============================================================ */
.link-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.link-row--store {
  margin-bottom: 4px;
}

.hero .link-row + .link-row {
  margin-top: 16px;
}

/* ============================================================
   BUTTON LINK
   ============================================================ */
@keyframes button-link-spin {
  to {
    transform: rotate(360deg);
  }
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 500;
  position: relative;
  transition: border-color 0.15s ease, opacity 0.15s ease;
}

.button-link:hover {
  text-decoration: none;
  border-color: var(--accent);
}

.button-link--loading {
  pointer-events: none;
  opacity: 0.72;
}

.button-link--loading::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.25rem;
  height: 1.25rem;
  margin: -0.625rem 0 0 -0.625rem;
  border: 2px solid color-mix(in srgb, var(--text-primary) 12%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: button-link-spin 0.65s linear infinite;
}

.button-link--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.button-link--primary:hover {
  background: var(--accent-pressed);
  border-color: var(--accent-pressed);
  color: #fff;
}

.button-link--primary.button-link--loading::after {
  border-color: rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
}

/* ============================================================
   APP STORE BUTTON
   ============================================================ */
.app-store-button {
  display: inline-block;
  width: 240px;
  height: 72px;
  padding: 0;
  line-height: 0;
  text-decoration: none;
  border: none;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  vertical-align: middle;
  transition: opacity 0.15s ease;
}

.app-store-button::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: url("/app-store-badge.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  border-radius: inherit;
}

.app-store-button:hover {
  text-decoration: none;
  opacity: 0.88;
}

.app-store-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media (max-width: 280px) {
  .app-store-button {
    width: min(240px, calc(100vw - 32px));
    height: auto;
    aspect-ratio: 240 / 72;
  }
}

.app-store-button--loading {
  pointer-events: none;
  opacity: 0.85;
}

.app-store-button--loading::before {
  opacity: 0.35;
}

.app-store-button--loading::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  width: 1.35rem;
  height: 1.35rem;
  margin: -0.675rem 0 0 -0.675rem;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: button-link-spin 0.65s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .button-link--loading::after,
  .app-store-button--loading::after {
    animation: none;
    border-top-color: var(--accent);
  }

  .app-store-button--loading::after {
    border-top-color: rgba(255, 255, 255, 0.85);
  }
}

/* ============================================================
   TEMPLATE SHARE FALLBACK
   ============================================================ */
.template-share-fallback .share-code-line {
  margin: 16px 0;
  text-align: center;
}

.template-share-fallback .share-code-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.template-share-fallback .share-code-row {
  display: inline-flex;
  align-items: stretch;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 100%;
}

.template-share-fallback .share-code-value {
  display: inline-block;
  flex: 1 1 auto;
  min-width: min(100%, 12ch);
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 15px;
  word-break: break-all;
  text-align: left;
}

.template-share-fallback .share-code-copy {
  flex: 0 0 auto;
  align-self: center;
  white-space: nowrap;
}

.template-share-fallback .template-share-hint {
  margin-top: 20px;
  max-width: 56ch;
  margin-left: auto;
  margin-right: auto;
}

/* ============================================================
   FOOTER
   ============================================================ */
footer {
  border-top: 1px solid var(--border);
  padding: 28px 0 36px;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.footer-brand {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 0;
}

.footer-text {
  margin: 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field label {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.form-hint {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  color: var(--text-primary);
  background: var(--surface);
}

[data-theme="dark"] .form-input,
[data-theme="dark"] .form-textarea {
  color-scheme: dark;
}

.form-textarea {
  min-height: 160px;
  resize: vertical;
}

.form-input:focus,
.form-textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.form-input:disabled,
.form-textarea:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.field-error {
  margin: 0;
  font-size: 13px;
  color: #b91c1c;
}

[data-theme="dark"] .field-error {
  color: #f87171;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-pressed);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-text {
  display: inline;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
}

.btn-text:hover:not(:disabled) {
  color: var(--accent-pressed);
}

/* ============================================================
   SUPPORT ALERTS
   ============================================================ */
.support-alert {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 15px;
  line-height: 1.45;
}

.support-alert[hidden] {
  display: none !important;
}

.support-alert--error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.support-alert--success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

[data-theme="dark"] .support-alert--error {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

[data-theme="dark"] .support-alert--success {
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.2);
  color: #86efac;
}

.field-error[hidden] {
  display: none !important;
}

.btn-primary[aria-busy="true"] {
  cursor: wait;
  opacity: 0.85;
}

.support-success {
  padding: 8px 0 0;
}

.support-success[hidden] {
  display: none !important;
}

/* ============================================================
   NAV — BACKDROP OVERLAY (all screen sizes, JS-injected)
   ============================================================ */
.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 150;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.32s ease, visibility 0.32s ease;
}

.nav-backdrop.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

[data-theme="dark"] .nav-backdrop {
  background: rgba(0, 0, 0, 0.65);
}

body.menu-open {
  overflow: hidden;
}

/* ============================================================
   RESPONSIVE — NAVIGATION (mobile ≤ 768px)
   ============================================================ */
@media (max-width: 768px) {
  /* Keep nav bar above the slide panel */
  .top-nav {
    z-index: 300;
  }

  /* Switch from 3-col grid to simple flex row */
  .nav-inner {
    display: flex;
    align-items: center;
    min-height: 60px;
  }

  .nav-brand {
    flex: none;
  }

  .nav-controls {
    flex: none;
    margin-left: auto;
    justify-self: unset;
  }

  /* Show burger */
  .nav-burger {
    display: flex;
  }

  /* Nav links: full-height slide panel from the left */
  .nav-links {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: min(300px, 85vw);
    background: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.12);
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 84px 28px 40px;
    z-index: 200;
    overflow-y: auto;
    /* Always display:flex so the slide transition works */
    display: flex;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1),
      visibility 0.32s ease;
  }

  [data-theme="dark"] .nav-links {
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.45);
  }

  .nav-links.is-open {
    transform: translateX(0);
    visibility: visible;
  }

  .nav-links .nav-link {
    display: block;
    padding: 14px 0;
    font-size: 17px;
    font-weight: 600;
    border-radius: 0;
    width: 100%;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    background: none;
  }

  .nav-links .nav-link:hover {
    color: var(--accent);
    background: none;
  }

  /* Lang switch pinned to bottom of panel */
  .nav-links .lang-switch {
    margin-left: 0;
    margin-top: auto;
    padding-top: 20px;
    width: 100%;
    font-size: 13px;
  }
}

/* ============================================================
   RESPONSIVE — CONTENT
   ============================================================ */
@media (max-width: 640px) {
  .card {
    padding: 20px;
  }

  h1 {
    font-size: 28px;
  }

  .subtitle {
    font-size: 18px;
  }
}

/* ============================================================
   LANDING PAGE — ANIMATIONS
   ============================================================ */
@keyframes lp-rise {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   LANDING PAGE — HERO
   ============================================================ */
.lp-hero {
  position: relative;
  overflow: hidden;
  padding: 96px 0 80px;
  text-align: center;
}

.lp-hero__glow {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.lp-hero__glow--top {
  width: 900px;
  height: 900px;
  background: radial-gradient(
    circle,
    rgba(239, 68, 68, 0.08) 0%,
    transparent 60%
  );
  top: -420px;
  left: 50%;
  transform: translateX(-50%);
}

.lp-hero__glow--bottom {
  width: 500px;
  height: 500px;
  background: radial-gradient(
    circle,
    rgba(239, 68, 68, 0.05) 0%,
    transparent 70%
  );
  bottom: -200px;
  right: -80px;
}

.lp-hero__content {
  position: relative;
  z-index: 1;
}

.lp-eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 28px;
  opacity: 0;
  animation: lp-rise 0.7s 0.05s ease forwards;
}

.lp-heading {
  font-weight: 800;
  font-size: clamp(52px, 11vw, 96px);
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin: 0 0 36px;
  opacity: 0;
  animation: lp-rise 0.7s 0.15s ease forwards;
}

.lp-heading__accent {
  display: block;
  color: var(--accent);
}

.lp-hero__desc {
  font-size: 18px;
  line-height: 1.7;
  color: var(--text-secondary);
  max-width: 46ch;
  margin: 0 auto 44px;
  opacity: 0;
  animation: lp-rise 0.7s 0.27s ease forwards;
}

.lp-hero__cta {
  opacity: 0;
  animation: lp-rise 0.7s 0.38s ease forwards;
}

/* ============================================================
   LANDING PAGE — FEATURES
   ============================================================ */
.lp-features {
  padding: 72px 0;
  border-top: 1px solid var(--border);
}

.lp-features__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
}

.lp-feat {
  background: var(--bg);
  padding: 40px 36px;
  transition: background 0.2s ease;
}

.lp-feat:hover {
  background: var(--surface);
}

.lp-feat__num {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 18px;
}

.lp-feat__title {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text-primary);
  margin: 0 0 12px;
}

.lp-feat__body {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-secondary);
  margin: 0;
}

/* ============================================================
   LANDING PAGE — CTA
   ============================================================ */
.lp-cta {
  padding: 96px 0 80px;
  text-align: center;
  border-top: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.lp-cta__glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 70% 50% at 50% 100%,
    rgba(239, 68, 68, 0.07) 0%,
    transparent 70%
  );
  pointer-events: none;
}

.lp-cta__inner {
  position: relative;
  z-index: 1;
}

.lp-cta__eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 0 0 20px;
}

.lp-cta__heading {
  font-size: clamp(38px, 6vw, 60px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin: 0 0 44px;
}

.lp-cta__action {
  display: flex;
  justify-content: center;
}

/* ============================================================
   RESPONSIVE — LANDING PAGE
   ============================================================ */
@media (max-width: 640px) {
  .lp-hero {
    padding: 72px 0 64px;
  }

  .lp-heading {
    font-size: 52px;
    letter-spacing: -0.025em;
  }

  .lp-hero__desc {
    font-size: 16px;
  }

  .lp-features {
    padding: 56px 0;
  }

  .lp-features__grid {
    grid-template-columns: 1fr;
    border-radius: 16px;
  }

  .lp-feat {
    padding: 28px 24px;
  }

  .lp-cta {
    padding: 72px 0 64px;
  }

  .lp-cta__heading {
    font-size: 38px;
  }
}
