/* SparkAI design system — light "creamsicle" theme -------------------------- */
:root {
  --bg: #fff7ee;            /* warm cream */
  --surface: #ffffff;
  --surface-2: #fff3e6;     /* light peach */
  --surface-3: #ffe9d2;
  --border: #f4e3cf;
  --border-strong: #ecd2b3;
  --text: #3a2a1c;          /* warm near-black */
  --muted: #8a7560;
  --faint: #b3a08c;
  --accent: #ff7a18;        /* creamsicle orange */
  --accent-2: #ff9d4d;
  --accent-ink: #c4540a;    /* readable orange for text on light */
  --good: #1f9d57;
  --warn: #d98a00;
  --bad: #e0484d;
  --spark: linear-gradient(135deg, #ffb053, #ff7a18 60%, #ff6a2b);
  --spark-soft: linear-gradient(135deg, rgba(255,176,83,.22), rgba(255,122,24,.14));
  --shadow: 0 10px 30px rgba(214, 120, 40, .12);
  --shadow-sm: 0 2px 8px rgba(214, 120, 40, .08);
  --radius: 14px;
  --rail: 76px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1100px 560px at 85% -10%, rgba(255,154,77,.20), transparent 60%),
    radial-gradient(820px 480px at -8% 8%, rgba(255,122,24,.10), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.02em; color: var(--text); }
p { margin: 0 0 1em; }
code, pre { font-family: var(--mono); }
.lucide { width: 1em; height: 1em; stroke-width: 2; vertical-align: -.125em; }

/* Brand --------------------------------------------------------------------- */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800;
  font-size: 1.15rem; letter-spacing: -.02em; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .spark-dot { width: 28px; height: 28px; border-radius: 9px; background: var(--spark);
  box-shadow: 0 4px 14px rgba(255,122,24,.45); display: inline-grid; place-items: center;
  color: white; font-size: 16px; }
.brand .spark-dot .lucide { width: 17px; height: 17px; }
.grad { background: var(--spark); -webkit-background-clip: text; background-clip: text;
  color: transparent; }

/* Buttons ------------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  padding: 9px 16px; border-radius: 10px; font-size: .92rem; font-weight: 600;
  font-family: inherit; transition: .15s ease; text-decoration: none; }
.btn:hover { background: var(--surface-2); border-color: var(--accent-2); text-decoration: none; }
.btn .lucide { width: 16px; height: 16px; }
.btn-primary { background: var(--spark); border: none; color: #fff;
  box-shadow: 0 6px 18px rgba(255,122,24,.32); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 11px; font-size: .82rem; border-radius: 8px; }
.btn-danger { color: var(--bad); border-color: rgba(224,72,77,.4); background: var(--surface); }
.btn-danger:hover { background: rgba(224,72,77,.08); }
.btn-block { width: 100%; justify-content: center; }

/* Cards & layout ------------------------------------------------------------ */
.card { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); }
.card h2, .card h3 { margin-top: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.row { display: flex; gap: 18px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--muted); margin: 28px 0 12px; font-weight: 700; }

/* Public navbar ------------------------------------------------------------- */
.topnav { display: flex; align-items: center; justify-content: space-between;
  padding: 18px 32px; max-width: 1200px; margin: 0 auto; }
.topnav .links { display: flex; align-items: center; gap: 22px; }
/* Plain nav links use body text; buttons keep their own (e.g. white on .btn-primary). */
.topnav .links a:not(.btn) { color: var(--text); }

/* Hero ---------------------------------------------------------------------- */
.hero { max-width: 980px; margin: 70px auto 40px; padding: 0 24px; text-align: center; }
.hero .pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 14px;
  border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--accent-ink); font-size: .82rem; margin-bottom: 22px; font-weight: 600;
  box-shadow: var(--shadow-sm); }
.hero h1 { font-size: 3.4rem; margin-bottom: 18px; }
.hero p.lead { font-size: 1.2rem; color: var(--muted); max-width: 640px; margin: 0 auto 30px; }
.hero .cta { display: flex; gap: 14px; justify-content: center; }
.features { max-width: 1080px; margin: 60px auto; padding: 0 24px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.feature .ic { width: 46px; height: 46px; border-radius: 12px; background: var(--spark-soft);
  display: grid; place-items: center; margin-bottom: 12px; color: var(--accent-ink); }
.feature .ic .lucide { width: 22px; height: 22px; }
.code-hero { max-width: 760px; margin: 10px auto 80px; padding: 0 24px; }

/* Chart container: a fixed height is required for Chart.js responsive charts
   (maintainAspectRatio:false), otherwise the canvas grows on every resize. */
.chart-box { position: relative; height: 240px; width: 100%; }

/* Auth ---------------------------------------------------------------------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.auth-card .brand { margin-bottom: 8px; }

/* Forms --------------------------------------------------------------------- */
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number],
select, textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--text); padding: 11px 13px; border-radius: 10px; font-size: .95rem;
  font-family: inherit; margin-bottom: 16px; transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,122,24,.18); }
.field-row { display: flex; gap: 14px; }
.field-row > div { flex: 1; }
.checkbox { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; }
.checkbox input { width: auto; margin: 0; accent-color: var(--accent); }
.checkbox label { margin: 0; color: var(--text); }
.help { font-size: .8rem; color: var(--faint); margin: -10px 0 16px; }

/* App shell (icon rail) ----------------------------------------------------- */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border);
  padding: 18px 0; display: flex; flex-direction: column; align-items: center; }
.sidebar .brand { padding: 0 0 16px; justify-content: center; }
.sidebar .brand .wordmark { display: none; }  /* icon-only rail */
.sidebar nav { display: flex; flex-direction: column; gap: 6px; align-items: center; width: 100%; }
.navitem { position: relative; width: 48px; height: 48px; border-radius: 12px;
  display: grid; place-items: center; color: var(--muted); transition: .15s; }
.navitem .lucide { width: 21px; height: 21px; }
.navitem:hover { background: var(--surface-2); color: var(--accent-ink); text-decoration: none; }
.navitem.active { background: var(--spark); color: #fff; box-shadow: 0 5px 14px rgba(255,122,24,.35); }
.navitem .label { position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
  background: var(--text); color: #fff; padding: 5px 10px; border-radius: 7px; font-size: .8rem;
  font-weight: 600; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s;
  box-shadow: var(--shadow); z-index: 20; }
.navitem .label::before { content: ""; position: absolute; right: 100%; top: 50%;
  transform: translateY(-50%); border: 5px solid transparent; border-right-color: var(--text); }
.navitem:hover .label { opacity: 1; }
.sidebar .sep { width: 36px; height: 1px; background: var(--border-strong); margin: 12px 0; }
.sidebar .spacer { flex: 1; }

.main { padding: 30px 40px; max-width: 1140px; }
.main > header { display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.main > header h1 { font-size: 1.7rem; margin: 0; }
.main > header .sub { color: var(--muted); margin: 4px 0 0; }

/* Stat cards ---------------------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 8px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm); }
.stat .label { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 700; }
.stat .value { font-size: 1.85rem; font-weight: 800; margin-top: 8px; letter-spacing: -.02em; }

/* Tables -------------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .06em; padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.mono { font-family: var(--mono); font-size: .86em; }

/* Badges -------------------------------------------------------------------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .74rem;
  font-weight: 700; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--muted); }
.badge.ok { color: var(--good); border-color: rgba(31,157,87,.3); background: rgba(31,157,87,.1); }
.badge.warn { color: var(--warn); border-color: rgba(217,138,0,.3); background: rgba(217,138,0,.12); }
.badge.bad { color: var(--bad); border-color: rgba(224,72,77,.3); background: rgba(224,72,77,.1); }
.badge.accent { color: var(--accent-ink); border-color: rgba(255,122,24,.4); background: var(--spark-soft); }

/* Code blocks (deliberately dark for contrast on the light UI) -------------- */
pre.code { background: #2a2018; border: 1px solid #3a2c20; border-radius: 12px;
  padding: 18px 20px; overflow-x: auto; font-size: .86rem; line-height: 1.6;
  color: #f3e6d6; position: relative; }
pre.code .k { color: #ffb86c; } pre.code .s { color: #b5e08f; }
pre.code .c { color: #b08c6e; } pre.code .n { color: #ff9d4d; }
code.inline { background: var(--surface-3); padding: 2px 7px; border-radius: 6px;
  font-size: .86em; color: var(--accent-ink); }
.copy-btn { position: absolute; top: 10px; right: 10px; font-size: .72rem; padding: 4px 9px;
  background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.25); }
.copy-btn:hover { background: rgba(255,255,255,.22); }

/* Flash --------------------------------------------------------------------- */
.flashes { margin-bottom: 18px; display: flex; flex-direction: column; gap: 10px; }
.flash { padding: 12px 16px; border-radius: 10px; border: 1px solid var(--border-strong);
  font-size: .9rem; background: var(--surface-2); }
.flash.success { border-color: rgba(31,157,87,.4); background: rgba(31,157,87,.1); }
.flash.error { border-color: rgba(224,72,77,.4); background: rgba(224,72,77,.1); }

/* Misc ---------------------------------------------------------------------- */
.keyreveal { background: rgba(31,157,87,.08); border: 1px solid rgba(31,157,87,.4);
  border-radius: 12px; padding: 16px; margin-bottom: 20px; }
.keyreveal code { display: block; font-family: var(--mono); font-size: .9rem; background: #2a2018;
  padding: 12px; border-radius: 8px; margin-top: 8px; word-break: break-all; color: #b5e08f; }
.empty { text-align: center; padding: 40px; color: var(--muted); }
.inline-form { display: inline; }
.divider { height: 1px; background: var(--border); margin: 24px 0; }
footer.pub { text-align: center; padding: 40px; color: var(--faint); font-size: .85rem; }
.note { background: var(--spark-soft); border: 1px solid var(--border-strong); border-radius: 12px;
  padding: 14px 16px; font-size: .9rem; margin-bottom: 20px; }

/* Playground ---------------------------------------------------------------- */
.pg { display: grid; grid-template-rows: 1fr auto; gap: 0; height: calc(100vh - 150px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden; }
.pg-scroll { overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.pg-empty { margin: auto; text-align: center; color: var(--muted); max-width: 380px; }
.pg-empty .spark-dot { width: 52px; height: 52px; border-radius: 16px; margin: 0 auto 14px; }
.pg-empty .spark-dot .lucide { width: 28px; height: 28px; }
.msg { display: flex; gap: 12px; max-width: 80%; }
.msg .av { width: 30px; height: 30px; border-radius: 9px; flex: 0 0 auto; display: grid;
  place-items: center; font-size: .8rem; font-weight: 700; }
.msg .av .lucide { width: 17px; height: 17px; }
.msg .bubble { padding: 11px 15px; border-radius: 13px; font-size: .94rem; white-space: pre-wrap;
  word-wrap: break-word; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.user .av { background: var(--spark); color: #fff; }
.msg.user .bubble { background: var(--spark); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant .av { background: var(--surface-3); color: var(--accent-ink); }
.msg.assistant .bubble { background: var(--surface-2); border: 1px solid var(--border);
  border-bottom-left-radius: 4px; }
.msg .bubble .cursor { display: inline-block; width: 7px; height: 15px; background: var(--accent);
  vertical-align: -2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.pg-input { border-top: 1px solid var(--border); padding: 14px; display: flex; gap: 10px;
  align-items: flex-end; background: var(--surface); }
.pg-input textarea { margin: 0; resize: none; max-height: 160px; }
.pg-bar { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.pg-bar .sys { flex: 1; min-width: 220px; }
.pg-bar .sys input { margin: 0; }

@media (max-width: 860px) {
  .stat-grid, .features, .grid-2 { grid-template-columns: 1fr 1fr; }
  .hero h1 { font-size: 2.4rem; }
  .msg { max-width: 92%; }
}
