:root, [data-theme="light"] {
  --accent: #4f46e5;
  --accent-dark: #3730a3;
  --accent-light: #eef2ff;
  --ink: #0f172a;
  --muted: #64748b;
  --bg: #f4f5f9;
  --card-bg: #ffffff;
  --radius-lg: 20px;
  --radius-md: 14px;
  --shadow: 0 20px 45px -15px rgba(15, 23, 42, 0.16);

  --border-color: #edeef3;
  --input-bg: #fbfcfe;
  --input-border: #e2e8f0;
  --label-color: #334155;
  --placeholder-color: #b0b8c4;
  --small-color: #94a3b8;
  --secondary-bg: #eef1f6;
  --secondary-bg-hover: #e2e6ee;
  --secondary-color: #334155;
  --table-border: #f1f2f6;
  --hero-1: #0f1729;
  --hero-2: #182238;
  --hero-nav-color: rgba(255,255,255,0.65);
  --hero-subtitle-color: rgba(255,255,255,0.72);
  --pill-bg: var(--accent-light);
  --pill-text: var(--accent-dark);
  --landing-bg: #ffffff;
  --toggle-track-bg: #d5dae3;
  --success-color: #16a34a;
  --error-color: #b91c1c;
  --google-btn-bg: #ffffff;
  --google-btn-border: #dadce0;
  --google-btn-color: #3c4043;
  --google-btn-hover-bg: #f8f9fa;
}

[data-theme="dark"] {
  --accent: #818cf8;
  --accent-dark: #6366f1;
  --accent-light: #312e81;
  --ink: #f1f5f9;
  --muted: #94a3b8;
  --bg: #0b1220;
  --card-bg: #161f32;
  --shadow: 0 20px 45px -15px rgba(0, 0, 0, 0.45);

  --border-color: #26324a;
  --input-bg: #0f1729;
  --input-border: #2b3b57;
  --label-color: #cbd5e1;
  --placeholder-color: #56637a;
  --small-color: #7c8aa5;
  --secondary-bg: #1f2a40;
  --secondary-bg-hover: #263349;
  --secondary-color: #cbd5e1;
  --table-border: #22304a;
  --hero-1: #05070d;
  --hero-2: #0c1420;
  --hero-nav-color: rgba(255,255,255,0.55);
  --hero-subtitle-color: rgba(255,255,255,0.6);
  --pill-bg: #312e81;
  --pill-text: #c7d2fe;
  --landing-bg: #161f32;
  --toggle-track-bg: #2c3a56;
  --success-color: #4ade80;
  --error-color: #f87171;
  --google-btn-bg: #202430;
  --google-btn-border: #3c4043;
  --google-btn-color: #e8eaed;
  --google-btn-hover-bg: #2a2e39;
}


* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  margin: 0;
  padding: 0;
  transition: background .15s, color .15s;
}

.container { max-width: 960px; margin: 0 auto; padding: 0 20px 40px; }

/* ---- Top utility bar (account status + theme switch, shared across all inner pages) ---- */
.topbar {
  background: var(--secondary-bg);
  border-bottom: 1px solid var(--border-color);
}
.topbar-inner {
  max-width: 960px; margin: 0 auto; padding: 10px 20px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.8rem; color: var(--muted);
}
.topbar-account { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar-account a { color: var(--accent); font-weight: 600; }
.topbar-left { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 7px; text-decoration: none; font-weight: 800; font-size: 1.05rem; letter-spacing: -0.02em; color: var(--text, inherit); flex-shrink: 0; }
.brand span { color: var(--accent); }
.brand-bar { max-width: 960px; margin: 0 auto; padding: 18px 20px 0; }
.link-btn {
  background: none; border: none; color: inherit; cursor: pointer; padding: 0;
  font-size: 0.78rem; text-decoration: underline; font-weight: 400;
}

/* ---- Hero (main dashboard page only) ---- */
.hero {
  background: linear-gradient(180deg, var(--hero-1) 0%, var(--hero-2) 100%);
  padding: 40px 20px 90px;
}
.hero-inner { max-width: 960px; margin: 0 auto; }
.hero h1 {
  font-size: 2.4rem; font-weight: 800; letter-spacing: -0.02em;
  margin: 0 0 12px; color: #fff; line-height: 1.15;
}
.hero p.subtitle {
  color: var(--hero-subtitle-color); font-size: 1.05rem; line-height: 1.5; margin: 0; max-width: 560px;
}

.flex-between.small {
  font-size: 0.8rem; color: var(--muted); margin-bottom: 8px;
}
.flex-between.small a { font-weight: 600; }

/* ---- Cards ---- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 28px;
  margin-bottom: 20px;
}

/* This pulls the WHOLE group (any verification/success banners plus the create card)
   up into the hero's bottom padding as one unit, so it floats over the hero the same
   way whether or not a banner is showing above the card. Putting the negative margin
   on .create-card-shell alone instead (an earlier version of this) meant the card would
   yank itself up 60px regardless of what came before it in .container - when a banner
   was present, the card overlapped and visually merged into the bottom of it. */
.dashboard-top {
  margin-top: -60px;
}
.create-card-shell {
  position: relative;
  z-index: 2;
}

/* ---- Tool tabs (Short Link / QR Code / Bulk Upload / Bio Page) ---- */
/* Left/right padding matches --radius-lg so the tab row's own edges clear the card's
   rounded corners underneath - at only 4px (the old value), the corner curve peeked out
   past the tab's flat bottom edge and left a small dark notch above the card. */
.tool-tabs { display: flex; gap: 4px; padding: 0 20px; }
.tool-tab {
  background: var(--secondary-bg); color: var(--muted); border: none;
  padding: 13px 18px 15px; border-radius: 14px 14px 0 0; font-weight: 700; font-size: 0.86rem;
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  transition: background .15s, color .15s;
}
.tool-tab svg { flex-shrink: 0; opacity: 0.8; }
.tool-tab:hover { color: var(--ink); }
.tool-tab.active { background: var(--card-bg); color: var(--ink); }
.tool-tab.active svg { opacity: 1; }

.create-card {
  box-shadow: var(--shadow);
  border: none;
  border-radius: var(--radius-lg);
  position: relative;
}

@media (max-width: 640px) {
  .tool-tab { font-size: 0.72rem; padding: 10px 10px 12px; gap: 5px; }
  .tool-tab svg { width: 15px; height: 15px; }
}

h1 { font-size: 1.6rem; margin: 0 0 4px; color: var(--ink); }
h2 { font-size: 1.15rem; margin-top: 0; font-weight: 700; }
.subtitle { color: var(--muted); margin-top: 0; margin-bottom: 20px; }

/* ---- Forms ---- */
label { display: block; font-size: 0.82rem; font-weight: 600; margin-top: 14px; margin-bottom: 6px; color: var(--label-color); }
input[type=text], input[type=url], input[type=password], input[type=email], textarea, input[type=file] {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--input-border); border-radius: 10px;
  font-size: 0.92rem; background: var(--input-bg); color: var(--ink); transition: border-color .15s, background .15s;
  font-family: inherit;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--card-bg); }
textarea { resize: vertical; min-height: 70px; }
input::placeholder, textarea::placeholder { color: var(--placeholder-color); }

/* ---- Buttons ---- */
button, .btn {
  background: var(--accent); color: #fff; border: none; padding: 11px 20px;
  border-radius: 999px; font-size: 0.9rem; font-weight: 600; cursor: pointer;
  text-decoration: none; display: inline-block; transition: background .15s, transform .12s, box-shadow .12s;
}
button:hover, .btn:hover { background: var(--accent-dark); transform: translateY(-1px); box-shadow: 0 6px 16px -8px var(--accent); }
button:active, .btn:active { transform: scale(0.98); box-shadow: none; }
.btn-secondary { background: var(--secondary-bg); color: var(--secondary-color); }
.btn-secondary:hover { background: var(--secondary-bg-hover); }

.mode-btn, .linkmode-btn { padding: 9px 16px; font-size: 0.85rem; border-radius: 999px; margin-right: 8px; }

/* ---- Theme selector ---- */
/* Single sliding pill instead of two separate circular buttons - the thumb slides
   between the two ends and swaps its icon (sun/moon) instantly via JS, no page reload,
   with the actual preference saved to the account in the background via fetch(). */
.theme-toggle {
  width: 44px; height: 24px; padding: 3px; border-radius: 999px; border: 1px solid var(--border-color);
  background: var(--toggle-track-bg); cursor: pointer; position: relative; display: inline-block;
  flex-shrink: 0; transition: background .15s;
}
.theme-toggle-thumb {
  width: 18px; height: 18px; border-radius: 50%; background: var(--card-bg);
  box-shadow: 0 1px 4px rgba(0,0,0,0.35); position: absolute; top: 2px; left: 2px;
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s ease;
}
.theme-toggle[data-theme="dark"] .theme-toggle-thumb { transform: translateX(20px); }

/* ---- Itty Page template picker ---- */
.template-swatch {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--card-bg); border: 2px solid var(--border-color); border-radius: var(--radius-md);
  padding: 10px 12px; cursor: pointer; font-size: 0.75rem; color: var(--secondary-color);
  transition: border-color .15s;
}
.template-swatch:hover { border-color: var(--accent); }
.template-swatch.active { border-color: var(--accent); }
.template-swatch-preview { width: 44px; height: 32px; border-radius: 8px; display: block; border: 1px solid rgba(0,0,0,0.08); }

/* ---- Analytics range selector ---- */
.range-switcher { display: flex; gap: 4px; }
.range-btn {
  padding: 5px 12px; font-size: 0.76rem; font-weight: 600; border-radius: 999px;
  background: var(--secondary-bg); color: var(--secondary-color); text-decoration: none;
  transition: background .15s, color .15s;
}
.range-btn:hover { background: var(--secondary-bg-hover); }
.range-btn.active { background: var(--accent); color: #fff; }

/* ---- Table ---- */
table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--table-border); font-size: 0.88rem; }
th { color: var(--muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--pill-bg); color: var(--pill-text); font-size: 0.75rem; font-weight: 600; }

/* ---- Batch list ---- */
.batch-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--table-border); }
.batch-row:last-child { border-bottom: none; }
.batch-row strong a { color: var(--ink); text-decoration: none; font-weight: 700; }
.batch-row strong a:hover { color: var(--accent); }

/* ---- Stats & chart ---- */
.stat { display: inline-block; margin-right: 28px; }
.stat strong { font-size: 1.5rem; display: block; color: var(--ink); }
.stat span { color: var(--muted); font-size: 0.78rem; }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 80px; margin-top: 12px; }
.chart .bar { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.chart-labels { display: flex; gap: 4px; font-size: 0.65rem; color: var(--placeholder-color); margin-top: 4px; }
.chart-labels span { flex: 1; text-align: center; }

.qr-thumb { width: 44px; height: 44px; border-radius: 6px; }
.qr-clickable { cursor: pointer; transition: transform .1s; }
.qr-clickable:hover { transform: scale(1.08); }

/* ---- QR modal ---- */
.qr-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.qr-modal-box {
  background: var(--card-bg); border-radius: var(--radius-lg); padding: 28px;
  text-align: center; max-width: 320px; width: 100%; position: relative; box-shadow: var(--shadow);
}
.qr-modal-box img { width: 220px; height: 220px; max-width: 100%; border-radius: 8px; }
.qr-modal-close {
  position: absolute; top: 10px; right: 14px; background: none; border: none;
  font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 0;
}
.qr-modal-close:hover { color: var(--ink); }

/* ---- Public landing page ---- */
.landing { max-width: 480px; margin: 60px auto; text-align: center; padding: 32px; background: var(--landing-card-bg, var(--landing-bg)); color: var(--ink); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.landing img { max-width: 100%; border-radius: 14px; margin-bottom: 18px; }
.landing h1 { font-size: 1.5rem; }
.landing p { color: var(--muted); }
.landing .btn { margin-top: 18px; padding: 13px 26px; }

/* ---- Itty Page style presets ----
   'default' (data-page-template="default") intentionally has no rules here - it just uses
   whatever the site's own light/dark theme already provides, unchanged from before this
   feature existed. Each preset below is scoped on <body> rather than just .landing, so the
   whole viewport takes on the style (immersive, full-page look like Linktree/Instagram bio
   pages) instead of a themed card floating on the app's own unrelated page background. The
   overridden CSS variables cascade down to .landing and its descendants (h1/p/.btn) same as
   before, so one override point still covers background, text, and button color together -
   body just also paints its own background with the same variable now. */
body[data-page-template="midnight"] {
  --landing-bg: #14161c;
  --landing-card-bg: #1c1f29;
  --ink: #f5f0e6;
  --muted: #b6ad97;
  --accent: #d7c9a3;
  --accent-dark: #c2b184;
  background: var(--landing-bg);
  font-family: Georgia, 'Times New Roman', serif;
}
body[data-page-template="midnight"] .btn { color: #14161c; }

body[data-page-template="cream-teal"] {
  --landing-bg: #f4ecdf;
  --landing-card-bg: #fffbf3;
  --ink: #2b2620;
  --muted: #786d5c;
  --accent: #1f6f6a;
  --accent-dark: #185753;
  background: var(--landing-bg);
  font-family: Georgia, 'Times New Roman', serif;
}

body[data-page-template="coffee-warm"] {
  --landing-bg: #f7ede1;
  --landing-card-bg: #fffaf4;
  --ink: #2a1f1a;
  --muted: #8a7a6c;
  --accent: #e2673f;
  --accent-dark: #c2532f;
  background: var(--landing-bg);
}
body[data-page-template="coffee-warm"] .btn { color: #2a1f1a; }

body[data-page-template="mint-fresh"] {
  --landing-bg: #f6f5f0;
  --landing-card-bg: #ffffff;
  --ink: #1f2b28;
  --muted: #75847e;
  --accent: #2f9e8f;
  --accent-dark: #257e72;
  background: var(--landing-bg);
}
.link-btn { display: flex; align-items: center; justify-content: center; gap: 10px; }
.link-btn-icon { display: inline-flex; flex-shrink: 0; }
.link-btn-icon svg { display: block; }

.small { font-size: 0.78rem; color: var(--small-color); }
a { color: var(--accent); }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* ---- Trust/feature strip ---- */
.feature-row { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 18px; font-size: 0.8rem; color: var(--muted); }
.feature-row span::before { content: "✓ "; color: var(--success-color); font-weight: 700; }

/* ---- Examples / how-it-works section ---- */
.examples-section { margin: 8px 0 28px; }
.examples-section h2 { margin-bottom: 4px; }
.examples-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 16px 0 24px;
}
@media (max-width: 800px) { .examples-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 460px) { .examples-grid { grid-template-columns: 1fr; } }
.example-card {
  background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius-md);
  padding: 16px;
}
.example-card svg { color: var(--accent); margin-bottom: 8px; }
.example-card h3 { font-size: 0.92rem; margin: 0 0 6px; }
.example-card p { font-size: 0.8rem; color: var(--muted); margin: 0; }
.example-card code {
  display: inline-block; margin-top: 8px; background: var(--secondary-bg); color: var(--ink);
  padding: 2px 7px; border-radius: 6px; font-size: 0.74rem;
}

.csv-example {
  background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius-md);
  padding: 20px;
}
.csv-example h3 { margin-top: 0; }
.csv-table-wrap { overflow-x: auto; margin: 12px 0; }
.csv-table-wrap table { margin-top: 0; font-size: 0.78rem; white-space: nowrap; }
.csv-table-wrap th, .csv-table-wrap td { padding: 7px 10px; }
.csv-table-wrap tr.continuation td { color: var(--muted); }
.csv-table-wrap tr.continuation td:first-child { font-style: italic; }

/* ---- "Continue with Google" button (matches Google brand guidelines) ---- */
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--google-btn-bg); color: var(--google-btn-color); border: 1px solid var(--google-btn-border);
  padding: 10px 16px; border-radius: 999px; font-size: 0.9rem; font-weight: 600;
  text-decoration: none; margin-bottom: 16px; transition: background .15s, box-shadow .15s;
}
.btn-google:hover { background: var(--google-btn-hover-bg); box-shadow: 0 1px 2px rgba(60,64,67,0.15); }
.btn-google svg { flex-shrink: 0; }
