/* ─────────────────────────────────────────────────────────────
   Scarlett · Aurora Glass — shared theme
   ───────────────────────────────────────────────────────────── */

@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Serif:ital,wght@0,400;0,500;1,400&family=IBM+Plex+Mono:wght@400;500&family=Noto+Sans+SC:wght@400;500;600;700&display=swap");

:root {
  /* surfaces */
  --bg:        #F6F5F8;
  --bg-elev:   #FFFFFF;
  --bg-sunk:   #ECEAF1;

  /* ink */
  --ink:       #1A1726;
  --ink-2:     #2B2832;
  --ink-soft:  #4B475C;
  --muted:     #8A869A;
  --faint:     #B6B2C0;

  /* hairlines */
  --line:       rgba(26, 23, 38, 0.08);
  --line-soft:  rgba(26, 23, 38, 0.05);

  /* accents */
  --accent:       #6B5BFF;
  --accent-hover: #5848EA;
  --accent-soft:  #EFECFF;
  --accent-ink:   #FFFFFF;
  --rose:         #FF8DB6;
  --teal:         #5FB8C4;
  --success:      #5BA86E;
  --danger:       #D55570;

  /* shadow elevations */
  --shadow-xs: 0 1px 2px rgba(20, 18, 40, 0.04);
  --shadow-sm: 0 1px 2px rgba(20, 18, 40, 0.04), 0 4px 12px rgba(20, 18, 40, 0.04);
  --shadow-md: 0 1px 2px rgba(20, 18, 40, 0.05), 0 12px 32px rgba(20, 18, 40, 0.08);
  --shadow-lg: 0 2px 4px rgba(20, 18, 40, 0.06), 0 24px 60px rgba(20, 18, 40, 0.12);
  --shadow-inset: inset 0 0 0 1px rgba(255,255,255,0.65);

  /* radius scale */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;
  --r-pill: 999px;

  /* fonts */
  --font-sans:  "IBM Plex Sans", "Noto Sans SC", "PingFang SC", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-serif: "IBM Plex Serif", "Source Han Serif SC", Georgia, serif;
  --font-mono:  "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;

  /* easings + durations */
  --ease-out:  cubic-bezier(.2, .7, .2, 1);
  --ease-soft: cubic-bezier(.4, 0, .2, 1);
  --dur-1: 120ms;
  --dur-2: 220ms;
  --dur-3: 380ms;
}

/* ── reset ─────────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
*, *::before, *::after { -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: var(--font-sans);
  font-weight: 400;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.005em;
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; }

::selection { background: var(--accent-soft); color: var(--ink); }

/* slim scrollbars where allowed */
.scroll-clean {
  scrollbar-width: thin;
  scrollbar-color: var(--faint) transparent;
}
.scroll-clean::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-clean::-webkit-scrollbar-thumb {
  background: var(--faint);
  border-radius: 999px;
  border: 2px solid var(--bg);
}
.scroll-clean::-webkit-scrollbar-track { background: transparent; }

/* hide scrollbars (for chat lists, message stream) */
.scroll-hide { scrollbar-width: none; }
.scroll-hide::-webkit-scrollbar { display: none; }

/* ── ambient aurora background (opt-in via body class) ────── */
body.has-aurora { position: relative; overflow-x: hidden; }
body.has-aurora::before {
  content: "";
  position: fixed;
  inset: -10% -10% auto -10%;
  height: 70vh;
  background:
    radial-gradient(60% 50% at 20% 20%, rgba(195, 175, 255, 0.55), transparent 70%),
    radial-gradient(50% 50% at 85% 10%, rgba(255, 195, 220, 0.45), transparent 70%),
    radial-gradient(55% 60% at 50% 80%, rgba(170, 220, 255, 0.40), transparent 75%);
  filter: blur(40px);
  z-index: 0;
  pointer-events: none;
}
body.has-aurora > * { position: relative; z-index: 1; }

/* ── reusable: topbar / brand / pill / eyebrow ────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--ink);
}
.brand-dot {
  width: 28px; height: 28px;
  border-radius: 9px;
  background: conic-gradient(from 140deg, #C9B9FF, #FFC0D6, #B6E0FF, #C9B9FF);
  box-shadow: 0 4px 14px rgba(107, 91, 255, 0.30), inset 0 0 0 1px rgba(255,255,255,0.6);
  flex-shrink: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-soft);
  background: rgba(255,255,255,0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.9);
  padding: 5px 10px;
  border-radius: var(--r-pill);
  letter-spacing: 0.02em;
}
.pill .dot {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(107, 91, 255, 0.18);
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.eyebrow .num { color: var(--ink); font-weight: 500; }
.eyebrow .rule { flex: 1; height: 1px; background: var(--line); }

/* ── reusable: card ───────────────────────────────────────── */
.card {
  background: var(--bg-elev);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card-md {
  background: var(--bg-elev);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}

/* ── reusable: button ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  padding: 9px 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  cursor: pointer;
  transition: transform var(--dur-1) var(--ease-out),
              background var(--dur-1) var(--ease-out),
              box-shadow var(--dur-1) var(--ease-out),
              color var(--dur-1) var(--ease-out);
  box-shadow: var(--shadow-xs);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.btn.primary:hover { background: var(--ink-2); }

.btn.accent {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.btn.accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn.ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--muted);
}
.btn.ghost:hover { color: var(--ink); background: var(--bg-sunk); box-shadow: none; }

.btn.danger {
  color: var(--danger);
}
.btn.danger:hover { color: #fff; background: var(--danger); border-color: var(--danger); }

.btn.sm { font-size: 11px; padding: 6px 11px; letter-spacing: 0; }
.btn.xs { font-size: 10.5px; padding: 4px 9px; letter-spacing: 0; }

/* ── reusable: text input ─────────────────────────────────── */
.input {
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  color: var(--ink);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  outline: none;
  transition: border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out);
  width: 100%;
}
.input::placeholder { color: var(--faint); }
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ── reusable: top header for sub-pages ───────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(246, 245, 248, 0.72);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  z-index: 20;
}
.app-header .brand {
  flex-shrink: 0;
  min-width: 0;
}
.app-header .nav-links {
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
  justify-content: flex-end;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  /* fade out the right edge so users sense there's more if it scrolls */
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
          mask-image: linear-gradient(to right, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
}
.app-header .nav-links::-webkit-scrollbar { display: none; }
.app-header .nav-links a {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 8px;
  border-radius: var(--r-xs);
  white-space: nowrap;
  flex-shrink: 0;
  transition: color var(--dur-1) var(--ease-out), background var(--dur-1) var(--ease-out);
}
.app-header .nav-links a:hover { color: var(--ink); background: var(--bg-sunk); }
.app-header .nav-links a.current {
  color: var(--ink);
  background: var(--bg-sunk);
  font-weight: 500;
}

/* ── motion primitives ────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}
.anim-fade-up { animation: fadeUp 600ms var(--ease-out) both; }
.anim-fade-in { animation: fadeIn 400ms var(--ease-out) both; }

/* small print */
.mono-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* form section heading (settings, etc) */
.section-title {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* reduce motion respect */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
