/* ============================================================
   InfographAI — editorial / data-viz design system
   Fonts: Archivo (grotesk UI), Fraunces (display serif), Space Grotesk (numerals)
   ============================================================ */

:root {
  /* palette */
  --ink:        #14110f;
  --ink-soft:   #4a443f;
  --ink-faint:  #625c55;
  --paper:      #fbfaf7;
  --paper-2:    #f3f1ea;
  --white:      #ffffff;
  --line:       #e7e3da;
  --line-strong:#cfc8bb;

  --accent:      #c7351b;   /* accessible vermilion */
  --accent-deep: #982712;
  --accent-soft: #fff0eb;

  /* chrome (cool slate for the pro-tool feel) */
  --chrome:      #1b1a18;
  --chrome-2:    #232220;
  --chrome-line: #34322e;
  --chrome-text: #e9e6df;
  --chrome-faint:#9a948a;

  --radius:   14px;
  --radius-sm:9px;
  --radius-lg:22px;

  --shadow-sm: 0 1px 2px rgba(20,17,15,.06), 0 1px 1px rgba(20,17,15,.04);
  --shadow-md: 0 4px 16px rgba(20,17,15,.08), 0 1px 3px rgba(20,17,15,.06);
  --shadow-lg: 0 24px 60px -16px rgba(20,17,15,.28), 0 8px 24px -12px rgba(20,17,15,.18);

  --font-ui: 'Archivo', system-ui, sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
  --font-num: 'Space Grotesk', monospace;

  --topbar-h: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.01em;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; }
::selection { background: var(--accent); color: #fff; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute !important; width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important; overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important;
}
.skip-link {
  position: fixed; inset: 10px auto auto 10px; z-index: 1000; padding: 10px 14px;
  border-radius: 8px; background: var(--ink); color: #fff; text-decoration: none;
  transform: translateY(-160%); transition: transform .15s ease;
}
.skip-link:focus { transform: translateY(0); }
.sync-status {
  position: sticky; top: var(--topbar-h); z-index: 35; padding: 10px 20px;
  background: #fff3cd; border-bottom: 1px solid #8a6100; color: #5f4300;
  font-size: 13px; font-weight: 700; text-align: center;
}
:where(button, a, input, textarea, select, [tabindex]):focus-visible {
  outline: 3px solid #2f6bff;
  outline-offset: 3px;
}
button:disabled { cursor: not-allowed; }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px;
  font-weight: 600; font-size: 14px; letter-spacing: -0.01em;
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease, color .15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn-accent { background: var(--accent); color: #fff; box-shadow: 0 2px 0 var(--accent-deep), var(--shadow-sm); }
.btn-accent:hover { background: var(--accent-deep); box-shadow: 0 2px 0 #b8300f; }
.btn-ghost { background: var(--white); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { background: var(--paper-2); border-color: var(--line-strong); }
.btn-block { width: 100%; justify-content: center; height: 46px; font-size: 15px; }

/* ---------------- topbar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 24px;
  padding: 0 22px;
  background: rgba(251,250,247,.82);
  backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; text-align: left; }
.brand-mark { display: grid; place-items: center; }
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: -0.03em; }
.brand-ai { color: var(--accent); }
.topnav { display: flex; gap: 4px; }
.topnav-link {
  height: 34px; padding: 0 14px; border-radius: 8px;
  font-weight: 600; font-size: 14px; color: var(--ink-soft);
  transition: background .15s, color .15s;
}
.topnav-link:hover { background: var(--paper-2); color: var(--ink); }
.topnav-link.is-active { background: var(--ink); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* editor mode hides hero nav slightly differently — handled via body class */
body.mode-editor .topbar { background: var(--chrome); border-bottom-color: var(--chrome-line); }
body.mode-editor .brand-name { color: #fff; }
body.mode-editor .topnav-link { color: var(--chrome-faint); }
body.mode-editor .topnav-link:hover { background: var(--chrome-2); color: #fff; }
body.mode-editor .topnav-link.is-active { background: var(--accent); color: #fff; }
body.mode-editor .btn-ghost { background: var(--chrome-2); color: var(--chrome-text); border-color: var(--chrome-line); box-shadow: none; }
body.mode-editor .btn-ghost:hover { background: var(--chrome-line); }

/* ---------------- views ---------------- */
.view { display: none; }
.view.is-visible { display: block; animation: viewIn .35s cubic-bezier(.2,.7,.2,1); }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============================================================
   GALLERY
   ============================================================ */
.hero {
  position: relative; overflow: hidden;
  padding: 64px 40px 56px;
  max-width: 1180px; margin: 0 auto;
}
.hero-inner { position: relative; z-index: 2; max-width: 720px; }
.hero-eyebrow {
  display: inline-block; font-weight: 700; font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft);
  padding: 6px 11px; border-radius: 100px; margin-bottom: 22px;
}
.hero-title {
  font-family: var(--font-display);
  font-weight: 600; font-size: clamp(38px, 6vw, 64px); line-height: 1.02;
  letter-spacing: -0.025em;
}
.hero-title em { font-style: italic; color: var(--accent); }
.hero-sub {
  margin-top: 20px; font-size: 18px; line-height: 1.55; color: var(--ink-soft); max-width: 560px;
}
.hero-prompt {
  margin-top: 30px; display: flex; align-items: center; gap: 10px;
  background: var(--white); border: 1px solid var(--line); border-radius: 14px;
  padding: 8px 8px 8px 16px; box-shadow: var(--shadow-md); max-width: 620px;
}
.hero-prompt-icon { color: var(--accent); flex: none; }
.hero-prompt input {
  flex: 1; border: none; outline: none; background: none;
  font-size: 16px; color: var(--ink); min-width: 0;
}
.hero-prompt input::placeholder { color: var(--ink-faint); }
.hero-chips { margin-top: 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.hero-chips-label { font-size: 13px; color: var(--ink-faint); font-weight: 600; }
.chip {
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
  background: var(--white); border: 1px solid var(--line); border-radius: 100px; padding: 7px 13px;
  transition: all .15s; box-shadow: var(--shadow-sm);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.hero-decor {
  position: absolute; right: -120px; top: -40px; width: 540px; height: 540px; z-index: 1;
  background:
    radial-gradient(circle at 70% 30%, rgba(255,77,46,.10), transparent 60%),
    repeating-linear-gradient(135deg, transparent 0 22px, rgba(20,17,15,.025) 22px 23px);
  pointer-events: none;
}

.section-head { max-width: 1180px; margin: 0 auto; padding: 6px 40px 22px; }
.section-title { font-family: var(--font-display); font-weight: 600; font-size: 27px; letter-spacing: -0.02em; }
.section-desc { margin-top: 6px; color: var(--ink-soft); font-size: 15px; }

.template-grid {
  max-width: 1180px; margin: 0 auto 80px; padding: 0 40px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px;
}
.tpl-card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform .18s cubic-bezier(.2,.7,.2,1), box-shadow .18s, border-color .18s;
  display: flex; flex-direction: column; width: 100%; text-align: left;
}
.tpl-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--line-strong); }
.tpl-thumb { display: block; aspect-ratio: 4 / 3; background: var(--paper-2); border-bottom: 1px solid var(--line); position: relative; overflow: hidden; }
.tpl-thumb svg { width: 100%; height: 100%; display: block; }
.tpl-meta { padding: 14px 16px 16px; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.tpl-title { display: block; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.tpl-tagline { display: block; margin-top: 3px; font-size: 13px; color: var(--ink-faint); line-height: 1.4; }
.tpl-use {
  flex: none; font-size: 12px; font-weight: 700; color: var(--accent);
  opacity: 0; transform: translateX(-4px); transition: all .18s;
  display: inline-flex; align-items: center; gap: 4px; padding-top: 2px;
}
.tpl-card:hover .tpl-use { opacity: 1; transform: none; }

/* ============================================================
   EDITOR
   ============================================================ */
.editor-grid {
  display: grid;
  grid-template-columns: 248px 1fr 320px;
  height: calc(100vh - var(--topbar-h));
  background: var(--chrome);
}

/* left rail */
.rail {
  background: var(--chrome); border-right: 1px solid var(--chrome-line);
  overflow-y: auto; padding: 18px 14px;
}
.rail-label { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--chrome-faint); margin: 4px 4px 12px; }
.rail-templates { display: grid; gap: 10px; }
.rail-tpl {
  display: flex; align-items: center; gap: 11px; padding: 8px; border-radius: 10px;
  border: 1px solid transparent; transition: all .14s; text-align: left; width: 100%;
}
.rail-tpl:hover { background: var(--chrome-2); }
.rail-tpl.is-active { background: var(--chrome-2); border-color: var(--accent); }
.rail-tpl-thumb { width: 52px; height: 40px; border-radius: 6px; background: #fff; flex: none; overflow: hidden; }
.rail-tpl-thumb svg { width: 100%; height: 100%; }
.rail-tpl-name { font-size: 13px; font-weight: 600; color: var(--chrome-text); }
.rail-tpl-name small { display: block; color: var(--chrome-faint); font-weight: 500; font-size: 11px; margin-top: 1px; }

/* stage */
.stage { display: flex; flex-direction: column; min-width: 0; background: #2a2926; }
.stage-toolbar {
  height: 52px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 14px;
  background: var(--chrome); border-bottom: 1px solid var(--chrome-line);
}
.stage-toolbar-center { flex: 1; display: flex; justify-content: center; }
.stage-toolbar-right { display: flex; align-items: center; gap: 8px; }
.design-name-input {
  background: transparent; border: 1px solid transparent; color: var(--chrome-text);
  font-weight: 600; font-size: 14px; text-align: center; border-radius: 8px;
  padding: 6px 12px; width: 280px; transition: all .14s;
}
.design-name-input:hover { background: var(--chrome-2); }
.design-name-input:focus { outline: none; background: var(--chrome-2); border-color: var(--accent); }

.export-wrap { position: relative; }
.export-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30;
  background: var(--white); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 6px; min-width: 180px;
  opacity: 0; transform: translateY(-6px) scale(.98); pointer-events: none;
  transition: all .16s cubic-bezier(.2,.7,.2,1);
}
.export-menu.is-open { opacity: 1; transform: none; pointer-events: auto; }
.export-menu button {
  display: block; width: 100%; text-align: left; padding: 9px 11px; border-radius: 8px;
  font-size: 14px; font-weight: 500; color: var(--ink); transition: background .12s;
}
.export-menu button:hover { background: var(--paper-2); }

.canvas-scroll {
  flex: 1; overflow: auto; display: grid; place-items: center; padding: 40px;
  background-image: radial-gradient(rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 22px 22px;
}
.canvas-frame {
  width: 600px; max-width: 100%; flex: none;
  border-radius: 8px; overflow: hidden; box-shadow: var(--shadow-lg);
  background: #fff;
}
.canvas-svg-host { width: 100%; }
.canvas-svg-host svg { display: block; width: 100%; height: auto; }

/* inspector */
.inspector { background: var(--white); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.inspector-tabs { display: flex; padding: 10px 12px 0; gap: 4px; border-bottom: 1px solid var(--line); flex: none; }
.itab {
  flex: 1; height: 38px; font-size: 13px; font-weight: 600; color: var(--ink-faint);
  border-bottom: 2px solid transparent; transition: all .14s; border-radius: 8px 8px 0 0;
}
.itab:hover { color: var(--ink); }
.itab.is-active { color: var(--ink); border-bottom-color: var(--accent); }
.inspector-body { flex: 1; overflow-y: auto; padding: 18px 16px 40px; }

.field { margin-bottom: 16px; }
.field-label { display: block; font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; letter-spacing: .01em; }
.field-input, .field-textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; background: var(--paper);
  padding: 9px 11px; font-size: 14px; color: var(--ink); transition: all .14s;
}
.field-input:focus, .field-textarea:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-soft); }
.field-textarea { resize: vertical; min-height: 60px; line-height: 1.4; }

.insp-section-title {
  font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint);
  margin: 6px 0 12px; display: flex; align-items: center; justify-content: space-between;
}

/* items editor */
.item-card {
  border: 1px solid var(--line); border-radius: 11px; padding: 11px; margin-bottom: 10px;
  background: var(--paper); position: relative;
}
.item-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.item-card-num { font-size: 11px; font-weight: 700; color: var(--ink-faint); }
.item-card-tools { display: flex; align-items: center; gap: 2px; }
.item-tool, .item-del {
  width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: var(--ink-faint);
  transition: all .14s;
}
.item-tool:hover:not(:disabled) { background: var(--paper-2); color: var(--ink); }
.item-tool:disabled { opacity: .3; cursor: not-allowed; }
.item-del:hover { background: var(--accent-soft); color: var(--accent); }
.item-row { display: grid; gap: 7px; }
.item-row.two { grid-template-columns: 1fr 86px; }
.btn-add-item {
  width: 100%; height: 40px; border: 1.5px dashed var(--line-strong); border-radius: 10px;
  font-weight: 600; font-size: 13px; color: var(--ink-soft); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: all .14s;
}
.btn-add-item:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* style: color themes */
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.theme-swatch {
  border: 2px solid var(--line); border-radius: 11px; padding: 8px; transition: all .14s; background: #fff;
}
.theme-swatch:hover { border-color: var(--line-strong); }
.theme-swatch.is-active { border-color: var(--ink); }
.theme-swatch-bars { display: flex; gap: 4px; height: 32px; align-items: flex-end; border-radius: 6px; padding: 4px; }
.theme-swatch-bars span { flex: 1; border-radius: 3px; }
.theme-swatch-name { font-size: 11px; font-weight: 600; color: var(--ink-soft); margin-top: 6px; text-align: center; }

.accent-row { display: flex; flex-wrap: wrap; gap: 8px; }
.accent-dot {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--white);
  box-shadow: 0 0 0 1px var(--line); transition: transform .12s, box-shadow .12s;
}
.accent-dot:hover { transform: scale(1.1); }
.accent-dot.is-active { box-shadow: 0 0 0 2px var(--ink); }

.seg { display: flex; background: var(--paper-2); border-radius: 9px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; height: 32px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--ink-soft); transition: all .14s;
}
.seg button.is-active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }

/* AI tab */
.ai-panel-intro { font-size: 14px; line-height: 1.5; color: var(--ink-soft); margin-bottom: 14px; }
.ai-suggest { display: grid; gap: 8px; margin-top: 14px; }
.ai-suggest-btn {
  text-align: left; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; font-weight: 500;
  color: var(--ink-soft); transition: all .14s; background: var(--paper); line-height: 1.35;
}
.ai-suggest-btn:hover { border-color: var(--accent); color: var(--ink); background: #fff; }

/* ============================================================
   MY DESIGNS
   ============================================================ */
.designs-head { display: flex; align-items: flex-end; justify-content: space-between; padding-top: 36px; }
.designs-grid {
  max-width: 1180px; margin: 0 auto 80px; padding: 0 40px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px;
}
.design-card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm); transition: transform .16s, box-shadow .16s, border-color .16s;
  display: flex; flex-direction: column;
}
.design-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.design-card-thumb { aspect-ratio: 4 / 3; background: var(--paper-2); cursor: pointer; border-bottom: 1px solid var(--line); overflow: hidden; }
.design-card-thumb { width: 100%; display: block; }
.design-card-thumb svg { width: 100%; height: 100%; display: block; }
.design-card-body { padding: 12px 14px 14px; }
.design-card-name { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.design-card-meta { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.design-card-actions { display: flex; gap: 4px; margin-top: 11px; }
.dc-act {
  flex: 1; height: 32px; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--ink-soft);
  border: 1px solid var(--line); transition: all .14s; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
}
.dc-act:hover { background: var(--paper-2); color: var(--ink); }
.dc-act.danger:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); }

.designs-empty {
  max-width: 520px; margin: 60px auto; text-align: center;
}
.designs-empty-art { margin-bottom: 22px; opacity: .9; display: inline-block; }
.designs-empty h3 { font-family: var(--font-display); font-size: 24px; font-weight: 600; }
.designs-empty p { color: var(--ink-soft); margin: 8px 0 22px; }

/* ============================================================
   MODAL / THINKING / TOAST
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px;
  background: rgba(20,17,15,.42); backdrop-filter: blur(4px);
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative; width: 100%; max-width: 480px; background: var(--white);
  border-radius: var(--radius-lg); padding: 32px 30px; box-shadow: var(--shadow-lg);
  animation: modalIn .28s cubic-bezier(.2,.8,.2,1); max-height: calc(100vh - 48px); overflow-y: auto;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.modal-close { position: absolute; top: 16px; right: 16px; width: 32px; height: 32px; border-radius: 8px; color: var(--ink-faint); display: grid; place-items: center; transition: all .14s; }
.modal-close:hover { background: var(--paper-2); color: var(--ink); }
.modal-spark { width: 46px; height: 46px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: 16px; }
.modal-title { font-family: var(--font-display); font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.modal-sub { color: var(--ink-soft); margin: 6px 0 18px; font-size: 15px; line-height: 1.45; }
.modal-textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--paper);
  padding: 13px 14px; font-size: 15px; line-height: 1.45; resize: none; transition: all .14s;
}
.modal-textarea:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-soft); }
.modal-field-label { margin-top: 14px; }
.source-notice, .field-help {
  color: var(--ink-soft); font-size: 12px; line-height: 1.5; margin-top: 7px;
}
.modal-templ { margin: 16px 0 20px; }
.modal-templ-label { font-size: 12px; font-weight: 700; color: var(--ink-soft); display: block; margin-bottom: 8px; }
.modal-templ-row { display: flex; flex-wrap: wrap; gap: 7px; }
.modal-templ-pill {
  font-size: 12px; font-weight: 600; color: var(--ink-soft); border: 1px solid var(--line);
  border-radius: 100px; padding: 6px 12px; transition: all .14s;
}
.modal-templ-pill:hover { border-color: var(--line-strong); }
.modal-templ-pill.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }

.thinking {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  background: rgba(20,17,15,.55); backdrop-filter: blur(6px); animation: fadeIn .2s;
}
.thinking-card {
  background: var(--white); border-radius: var(--radius-lg); padding: 36px 40px; text-align: center;
  box-shadow: var(--shadow-lg); width: 340px; max-width: 90vw;
}
.thinking-orb { display: flex; gap: 9px; justify-content: center; margin-bottom: 22px; }
.thinking-orb span {
  width: 13px; height: 13px; border-radius: 50%; background: var(--accent);
  animation: orbPulse 1s ease-in-out infinite;
}
.thinking-orb span:nth-child(2) { animation-delay: .15s; background: var(--accent-deep); }
.thinking-orb span:nth-child(3) { animation-delay: .3s; background: var(--ink); }
@keyframes orbPulse { 0%, 100% { transform: scale(.6); opacity: .4; } 50% { transform: scale(1); opacity: 1; } }
.thinking-status { font-size: 15px; font-weight: 600; color: var(--ink); min-height: 22px; margin-bottom: 16px; }
.thinking-bar { height: 6px; border-radius: 100px; background: var(--paper-2); overflow: hidden; }
.thinking-bar-fill { height: 100%; width: 100%; background: var(--accent); border-radius: 100px; transform: scaleX(0); transform-origin: left; transition: transform .4s ease; }

.toast-stack { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast {
  display: flex; align-items: center; gap: 10px; background: var(--ink); color: #fff;
  padding: 11px 16px; border-radius: 11px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg);
  animation: toastIn .3s cubic-bezier(.2,.8,.2,1);
}
.toast.is-out { animation: toastOut .25s ease forwards; }
.toast svg { color: var(--accent); flex: none; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px); } }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
  .template-grid { grid-template-columns: repeat(2, 1fr); }
  .designs-grid { grid-template-columns: repeat(3, 1fr); }
  .editor-grid { grid-template-columns: 200px 1fr 280px; }
}
@media (max-width: 860px) {
  .designs-grid { grid-template-columns: repeat(2, 1fr); }
  .hero { padding: 44px 24px 40px; }
  .section-head, .template-grid, .designs-grid { padding-left: 24px; padding-right: 24px; }
  .editor-grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr auto; height: auto; }
  .editor-grid > * { min-width: 0; }
  /* rail becomes a horizontal layout strip on mobile so layout switching still works */
  .rail {
    border-right: none; border-bottom: 1px solid var(--chrome-line);
    overflow-x: auto; overflow-y: hidden; padding: 12px 14px;
    -webkit-overflow-scrolling: touch;
    min-width: 0; max-width: 100vw;
  }
  .rail-section { display: flex; align-items: center; gap: 12px; }
  .rail-label { margin: 0; flex: none; }
  .rail-templates {
    display: flex; gap: 8px; grid-auto-flow: column;
  }
  .rail-tpl { flex: none; width: auto; padding: 6px 8px; }
  .rail-tpl-thumb { width: 38px; height: 30px; }
  .rail-tpl-name small { display: none; }
  .inspector { max-height: 46vh; border-left: none; border-top: 1px solid var(--line); }
  .canvas-scroll { padding: 24px; }
  .canvas-frame { width: 100%; max-width: 440px; }
  .topnav { display: none; }
}
@media (max-width: 560px) {
  .template-grid, .designs-grid { grid-template-columns: 1fr; }
  .hero-prompt { flex-wrap: wrap; }
  .hero-prompt input { flex-basis: 100%; padding: 8px 4px; }
  .hero-prompt .btn { width: 100%; justify-content: center; }
  #btnNewBlank { display: none; }

  /* keep the editor toolbar inside the viewport on phones */
  .stage-toolbar { gap: 6px; padding: 0 10px; overflow: hidden; }
  .stage-toolbar-center { flex: 1 1 auto; min-width: 0; }
  .design-name-input { width: 100%; max-width: 100%; min-width: 0; }
  .stage-toolbar .btn-sm { padding: 0 9px; }
  #btnBackToGallery span { display: none; }   /* arrow-only back button */
  .export-menu { right: auto; left: auto; }
}

/* ============================================================
   ACCOUNT MENU (topbar)
   ============================================================ */
.acct-wrap { position: relative; }
.acct-btn {
  display: inline-flex; align-items: center; gap: 5px; height: 40px; padding: 0 8px 0 6px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--white);
  color: var(--ink-soft); box-shadow: var(--shadow-sm); transition: all .14s;
}
.acct-btn:hover { border-color: var(--line-strong); background: var(--paper-2); }
.acct-avatar {
  width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: 0;
}
body.mode-editor .acct-btn { background: var(--chrome-2); color: var(--chrome-text); border-color: var(--chrome-line); box-shadow: none; }
body.mode-editor .acct-btn:hover { background: var(--chrome-line); }
.acct-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; min-width: 230px;
  background: var(--white); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow-lg);
  padding: 6px; opacity: 0; transform: translateY(-6px) scale(.98); pointer-events: none;
  transition: all .16s cubic-bezier(.2,.7,.2,1);
}
.acct-menu.is-open { opacity: 1; transform: none; pointer-events: auto; }
.acct-menu-head { padding: 10px 11px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.acct-menu-name { font-weight: 700; font-size: 14px; }
.acct-menu-sub { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.acct-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 11px; border-radius: 9px; font-size: 14px; font-weight: 500; color: var(--ink);
  text-decoration: none; transition: background .12s;
}
.acct-menu-item:hover { background: var(--paper-2); }
.acct-menu-item svg { color: var(--ink-faint); flex: none; }

.verification-box {
  border: 1px solid var(--line-strong); border-radius: 12px; background: var(--paper-2);
  padding: 13px 14px; margin-top: 18px;
}
.verification-box.is-verified { border-color: #16734f; background: #e8f6ef; }
.verification-label { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; font-weight: 700; line-height: 1.4; cursor: pointer; }
.verification-label input { width: 18px; height: 18px; margin-top: 1px; accent-color: #16734f; flex: none; }
.verification-box p { margin-top: 7px; color: var(--ink-soft); font-size: 12px; line-height: 1.45; }
.accent-custom {
  position: relative; overflow: hidden;
  background: conic-gradient(#c7351b, #e0a423, #0fae7a, #2f6bff, #7c5cff, #c7351b);
}

/* gallery extras */
.tpl-badge {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  background: var(--accent); color: #fff; padding: 4px 8px; border-radius: 100px;
  box-shadow: var(--shadow-sm);
}
.gallery-empty {
  grid-column: 1 / -1; text-align: center; color: var(--ink-faint);
  padding: 60px 20px; font-size: 15px;
}

/* ============================================================
   HOME / DASHBOARD
   ============================================================ */
.dash { max-width: 1180px; margin: 0 auto; padding: 40px 40px 80px; }
.dash-hello { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.dash-eyebrow { font-weight: 700; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.dash-greeting { font-family: var(--font-display); font-weight: 600; font-size: clamp(30px, 4vw, 44px); letter-spacing: -0.02em; line-height: 1.05; }
.dash-sub { margin-top: 10px; color: var(--ink-soft); font-size: 16px; max-width: 520px; }
.dash-hello-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.dash-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 34px 0 30px; }
.dash-stat {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow-sm);
}
.dash-stat-ico { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); margin-bottom: 12px; }
.dash-stat-v { font-family: var(--font-num); font-weight: 700; font-size: 32px; letter-spacing: -0.02em; line-height: 1; }
.dash-stat-k { font-size: 13px; color: var(--ink-faint); margin-top: 6px; font-weight: 600; }

.dash-cols { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 22px; }
.dash-panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); min-width: 0; }
.dash-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.dash-panel-head h2 { font-family: var(--font-display); font-weight: 600; font-size: 20px; letter-spacing: -0.01em; }
.dash-link { font-size: 13px; font-weight: 700; color: var(--accent); }
.dash-link:hover { text-decoration: underline; }

.dash-recent { display: grid; gap: 10px; }
.dash-recent-card {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--paper); transition: all .14s;
}
.dash-recent-card:hover { border-color: var(--line-strong); background: #fff; box-shadow: var(--shadow-sm); }
.dash-recent-thumb { width: 56px; height: 70px; border-radius: 7px; overflow: hidden; flex: none; background: #fff; border: 1px solid var(--line); }
.dash-recent-thumb svg { width: 100%; height: 100%; display: block; }
.dash-recent-meta { flex: 1; min-width: 0; }
.dash-recent-name { display: block; font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-recent-sub { display: block; font-size: 12px; color: var(--ink-faint); margin-top: 3px; }
.dash-recent-go { color: var(--ink-faint); flex: none; }
.dash-recent-card:hover .dash-recent-go { color: var(--accent); }
.dash-recent-empty { text-align: center; padding: 30px 10px; }
.dash-recent-empty p { color: var(--ink-soft); margin-bottom: 14px; font-size: 14px; }

.dash-quick { display: grid; gap: 16px; }
.dash-quick-prompt {
  display: flex; align-items: center; gap: 8px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 12px; padding: 6px 6px 6px 12px;
}
.dash-quick-prompt .hero-prompt-icon { color: var(--accent); flex: none; }
.dash-quick-prompt input { flex: 1; border: none; outline: none; background: none; font-size: 14px; color: var(--ink); min-width: 0; }
.dash-quick-prompt input::placeholder { color: var(--ink-faint); }
.dash-quick-label { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); }
.dash-quick-templates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.dash-quick-tpl { border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: var(--paper); transition: all .14s; }
.dash-quick-tpl:hover { border-color: var(--accent); background: #fff; }
.dash-quick-tpl-thumb { display: block; aspect-ratio: 4/5; border-radius: 6px; overflow: hidden; background: #fff; border: 1px solid var(--line); }
.dash-quick-tpl-thumb svg { width: 100%; height: 100%; display: block; }
.dash-quick-tpl-name { display: block; font-size: 11px; font-weight: 600; color: var(--ink-soft); margin-top: 6px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   ONBOARDING
   ============================================================ */
body.onb-open { overflow: hidden; }
.auth-gate {
  position: fixed; inset: 0; z-index: 250; display: grid; place-items: center; padding: 24px;
  background: rgba(20,17,15,.72); backdrop-filter: blur(8px);
}
.auth-gate-card {
  width: 100%; max-width: 440px; background: var(--white); border-radius: var(--radius-lg);
  padding: 34px; box-shadow: var(--shadow-lg);
}
.auth-gate-card a { text-decoration: none; }
.onb {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px;
  background: rgba(20,17,15,.55); backdrop-filter: blur(8px); animation: fadeIn .25s ease;
}
.onb-card {
  position: relative; width: 100%; max-width: 480px; background: var(--white);
  border-radius: var(--radius-lg); padding: 38px 34px 30px; box-shadow: var(--shadow-lg);
  animation: modalIn .3s cubic-bezier(.2,.8,.2,1); overflow: hidden;
}
.onb-progress { display: flex; gap: 6px; margin-bottom: 26px; }
.onb-dot { flex: 1; height: 4px; border-radius: 100px; background: var(--paper-2); transition: background .2s; }
.onb-dot.is-done { background: var(--accent-soft); }
.onb-dot.is-active { background: var(--accent); }
.onb-skip { position: absolute; top: 22px; right: 22px; font-size: 13px; font-weight: 600; color: var(--ink-faint); padding: 4px 8px; border-radius: 7px; transition: all .14s; }
.onb-skip:hover { color: var(--ink); background: var(--paper-2); }
.onb-step { display: none; animation: viewIn .3s cubic-bezier(.2,.7,.2,1); }
.onb-step.is-active { display: block; }
.onb-mark { margin-bottom: 18px; }
.onb-step-eyebrow { font-weight: 700; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.onb-title { font-family: var(--font-display); font-weight: 600; font-size: 28px; letter-spacing: -0.02em; line-height: 1.1; }
.onb-text { color: var(--ink-soft); margin: 10px 0 22px; font-size: 15px; line-height: 1.5; }
.onb-input {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--paper);
  padding: 13px 14px; font-size: 16px; color: var(--ink); transition: all .14s; margin-bottom: 22px;
}
.onb-input:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-soft); }
.onb-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 22px; }
.onb-choice {
  border: 1px solid var(--line); border-radius: 11px; padding: 14px 14px; text-align: left;
  font-weight: 600; font-size: 14px; color: var(--ink-soft); background: var(--paper); transition: all .14s;
}
.onb-choice:hover { border-color: var(--line-strong); color: var(--ink); }
.onb-choice.is-active { border-color: var(--accent); color: var(--ink); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.onb-templates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 22px; max-height: 300px; overflow-y: auto; }
.onb-tpl { border: 1px solid var(--line); border-radius: 10px; padding: 7px; background: var(--paper); transition: all .14s; }
.onb-tpl:hover { border-color: var(--line-strong); }
.onb-tpl.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: #fff; }
.onb-tpl-thumb { display: block; aspect-ratio: 4/5; border-radius: 6px; overflow: hidden; background: #fff; border: 1px solid var(--line); }
.onb-tpl-thumb svg { width: 100%; height: 100%; display: block; }
.onb-tpl-name { display: block; font-size: 11px; font-weight: 600; color: var(--ink-soft); margin-top: 5px; text-align: center; }
.onb-actions { display: flex; justify-content: space-between; gap: 10px; }
.onb-actions .btn-accent { margin-left: auto; }

@media (max-width: 980px) {
  .dash-cols { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .dash { padding: 28px 24px 60px; }
  .dash-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .dash-stats { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .dash-hello-actions { width: 100%; }
  .dash-hello-actions .btn { flex: 1; justify-content: center; }
  .dash-quick-templates { grid-template-columns: repeat(2, 1fr); }
  .onb-card { padding: 30px 22px 24px; }
  .onb-choices { grid-template-columns: 1fr; }
  .onb-templates { grid-template-columns: repeat(2, 1fr); }
  .acct-menu { right: -6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .thinking-orb span { animation: none; opacity: 1; transform: none; }
}
