/* Plotwise design tokens.
   "Aurora" (dark, default): ink-black with violet → pink → amber light.
   "Paper" (light): warm off-white, the same accents with more contrast. */
:root,
:root[data-theme="dark"] {
  --bg: #08070f;
  --bg-2: #0d0b18;
  --surface: #13111f;
  --surface-2: #1b1830;
  --surface-3: #241f3d;
  --ink: #f6f3ff;
  --ink-2: #cfc8ec;
  --muted: #8f88b3;
  --line: #29243f;
  --line-2: #3a3358;
  --brand: #9b7bff;
  --brand-ink: #0b0814;
  --brand-soft: rgba(155, 123, 255, 0.16);
  --pink: #ff5fb8;
  --amber: #ffb84d;
  --lime: #d4ff4f;
  --accent: #5ee0ff;
  --danger: #ff6680;
  --success: #3ee6a0;
  --gradient: linear-gradient(105deg, #9b7bff 0%, #ff5fb8 52%, #ffb84d 100%);
  --gradient-soft: linear-gradient(105deg, rgba(155, 123, 255, 0.22), rgba(255, 95, 184, 0.18) 55%, rgba(255, 184, 77, 0.16));
  --glow: 0 0 0 1px rgba(155, 123, 255, 0.35), 0 10px 40px -10px rgba(255, 95, 184, 0.55);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.8), 0 2px 8px rgba(0, 0, 0, 0.4);
  --glass: rgba(19, 17, 31, 0.72);

  --graph-bg: #0b0a14;
  --grid-minor: #15131f;
  --grid-major: #24203a;
  --grid-axis: #b9b2dd;
  --grid-label: #8f88b3;
  --poi: #8f88b3;
  --tip-bg: #f6f3ff;
  --tip-ink: #0b0814;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #fbf8f2;
  --bg-2: #f4efe5;
  --surface: #ffffff;
  --surface-2: #f6f2ea;
  --surface-3: #ede6d9;
  --ink: #17131f;
  --ink-2: #3e3850;
  --muted: #736b85;
  --line: #e7dfd1;
  --line-2: #d6ccba;
  --brand: #6b3df5;
  --brand-ink: #ffffff;
  --brand-soft: rgba(107, 61, 245, 0.1);
  --pink: #e0338a;
  --amber: #e58a00;
  --lime: #d4ff4f;
  --accent: #0094c6;
  --danger: #d12a4a;
  --success: #0b9a63;
  --gradient: linear-gradient(105deg, #6b3df5 0%, #e0338a 55%, #f08c00 100%);
  --gradient-soft: linear-gradient(105deg, rgba(107, 61, 245, 0.12), rgba(224, 51, 138, 0.1) 55%, rgba(240, 140, 0, 0.1));
  --glow: 0 0 0 1px rgba(107, 61, 245, 0.25), 0 12px 32px -14px rgba(224, 51, 138, 0.45);
  --shadow-sm: 0 1px 2px rgba(23, 19, 31, 0.06);
  --shadow: 0 24px 50px -28px rgba(46, 26, 80, 0.35), 0 2px 6px rgba(23, 19, 31, 0.06);
  --glass: rgba(255, 255, 255, 0.78);

  --graph-bg: #fffdf9;
  --grid-minor: #f3eee4;
  --grid-major: #e3dacb;
  --grid-axis: #2c2638;
  --grid-label: #6c6479;
  --poi: #8a8299;
  --tip-bg: #17131f;
  --tip-ink: #ffffff;
  color-scheme: light;
}

:root {
  --radius: 14px;
  --font: 'Inter Variable', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Bricolage Grotesque Variable', 'Inter Variable', ui-sans-serif, system-ui, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}
a { color: var(--brand); }
h1, h2, h3 { font-family: var(--display); line-height: 1.1; margin: 0 0 0.5em; letter-spacing: -0.02em; font-weight: 750; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.75em; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }
::selection { background: var(--pink); color: #fff; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.spacer { flex: 1; }
.grad-text { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 650; font-size: 0.9rem; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.08s, box-shadow 0.2s, filter 0.15s;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--ink); color: var(--bg); }
.btn.primary:hover { filter: brightness(0.92); }
.btn.gradient { position: relative; background: var(--gradient); color: #fff; box-shadow: var(--glow); text-shadow: 0 1px 0 rgba(0, 0, 0, 0.12); }
.btn.gradient:hover { filter: brightness(1.08) saturate(1.1); }
.btn.lime { background: var(--lime); color: #12100a; }
.btn.lime:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { height: 30px; padding: 0 12px; font-size: 0.82rem; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  border: none; background: transparent; color: var(--ink-2); cursor: pointer; font-size: 1.05rem;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn.on { background: var(--brand-soft); color: var(--brand); }
.icon-btn.danger:hover { color: var(--danger); }

.badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px;
  font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; background: var(--surface-2); color: var(--muted);
}
.badge.pro { background: var(--gradient); color: #fff; }

/* Forms */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 650; font-size: 0.88rem; }
.input, .field input, textarea.input {
  min-height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--surface-2); width: 100%;
}
textarea.input { padding: 10px 14px; resize: vertical; min-height: 84px; }
.input:focus, .field input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
select.input { padding-right: 32px; }
.form-error { color: var(--danger); font-weight: 600; font-size: 0.9rem; }

/* Modal */
.overlay {
  position: fixed; inset: 0; background: rgba(5, 4, 12, 0.6); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade 0.15s ease-out;
}
.modal {
  position: relative; width: min(480px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  background: var(--surface); border-radius: 22px; box-shadow: var(--shadow); padding: 28px;
  border: 1px solid var(--line); animation: pop 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.modal.wide { width: min(780px, 100%); }
.modal-close { position: absolute; top: 12px; right: 12px; font-size: 1.4rem; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-right: 36px; margin-bottom: 12px; }
.modal-head h2 { margin: 0; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.97); } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--tip-bg); color: var(--tip-ink); padding: 11px 18px; border-radius: 999px; font-weight: 650;
  box-shadow: var(--shadow); transition: opacity 0.2s, transform 0.2s; z-index: 60; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--gradient); color: #fff; }

.spinner {
  display: inline-block; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--line-2); border-top-color: var(--pink); animation: spin 0.7s linear infinite; vertical-align: -3px; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { color: var(--muted); padding: 24px 0; text-align: center; }

.avatar {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--gradient); color: #fff; font-weight: 800; font-size: 0.8rem;
}
.avatar.lg { width: 44px; height: 44px; font-size: 1.1rem; }

/* Subtle film grain used on hero/auth backgrounds */
.grain::after {
  content: ""; position: fixed; inset: -50%; pointer-events: none; z-index: 0; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

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