/* ==========================================================================
   Image Generation Studio — styles.css
   Design tokens + light-theme-only component styles.
   No Tailwind dependency: hand-authored so the demo works fully offline.
   ========================================================================== */

:root {
  --ink: #111111;          /* near-black — button bg */
  --on-ink: #ffffff;       /* text on dark bg */
  --paper: #ffffff;
  --paper-warm: #FAF8F5;   /* tinted well backgrounds */
  --muted: #6B6B6B;        /* labels — clears 4.5:1 on paper-warm */
  --muted-soft: #9B9B9B;   /* decorative/placeholder only */
  --night: #1A1A1A;        /* footer bg */
  --line: #E7E3DD;         /* hairline borders */
  --line-strong: #D6D0C7;
  --accent: #635bff;       /* interactive accent */
  --accent-soft: #eeedff;
  --ok: #1a7f4b;
  --warn: #b4690e;
  --err: #c0392b;
  --err-soft: #fdecea;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(17, 17, 17, 0.05), 0 1px 3px rgba(17, 17, 17, 0.06);
  --shadow-md: 0 6px 18px rgba(17, 17, 17, 0.08);
  --shadow-lg: 0 18px 50px rgba(17, 17, 17, 0.16);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, Menlo, Consolas, monospace;
}

/* overflow-x: clip (NOT hidden — hidden re-parents sticky elements to body) */
html, body { overflow-x: clip; }

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }

/* ---------- Layout shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 244px;
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--paper-warm);
}
.brandmark {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 15px; letter-spacing: -0.02em;
  padding: 6px 8px 18px;
}
.brandmark .dot {
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--ink); color: var(--on-ink);
  display: grid; place-items: center; font-size: 14px;
}
.navlink {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--muted); font-size: 14px; font-weight: 500;
  transition: background .12s, color .12s;
}
.navlink:hover { background: rgba(17,17,17,.05); color: var(--ink); }
.navlink.active { background: var(--ink); color: var(--on-ink); }
.navlink .ic { width: 18px; text-align: center; }
.sidebar .spacer { flex: 1; }
.sidebar .side-foot { font-size: 11px; color: var(--muted-soft); padding: 8px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topstrip { display: none; }

.content { flex: 1; padding: 34px clamp(18px, 4vw, 46px); max-width: 1240px; width: 100%; }

/* ---------- Typographic helpers ---------- */
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; }
.page-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.section-title { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 12px; }
.eyebrow { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 15px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--paper); color: var(--ink); font-size: 13.5px; font-weight: 600;
  transition: transform .05s, background .12s, border-color .12s, box-shadow .12s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.btn-primary:hover { box-shadow: var(--shadow-md); opacity: .94; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: rgba(17,17,17,.06); border-color: transparent; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-danger { color: var(--err); border-color: var(--line-strong); }
.btn-danger:hover { border-color: var(--err); background: var(--err-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---------- Cards / wells ---------- */
.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.well { background: var(--paper-warm); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Stats bar ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat { background: var(--paper-warm); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .n { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.stat .l { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---------- Forms ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field .lab { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
label.field .hint { font-size: 11.5px; color: var(--muted); font-weight: 400; }
input[type=text], input[type=url], input[type=password], input[type=number], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong);
  border-radius: 10px; font-size: 14px; font-family: inherit; color: var(--ink);
  background: var(--paper); transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; min-height: 88px; line-height: 1.55; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(17,17,17,.08);
}
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B6B6B' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }

/* ---------- Chips / badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--paper); font-size: 12.5px; font-weight: 500; color: var(--muted);
}
.chip.click { cursor: pointer; }
.chip.click:hover { border-color: var(--ink); color: var(--ink); }
.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); }

/* ---------- Swatches ---------- */
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 8px; border: 1px solid rgba(0,0,0,.1); position: relative; }
.swatch.removable { cursor: pointer; }
.swatch.removable::after { content: "×"; position: absolute; inset: 0; display: none; place-items: center; color: #fff; background: rgba(0,0,0,.45); border-radius: 8px; font-size: 15px; }
.swatch.removable:hover::after { display: grid; }

/* ---------- Brand grid cards ---------- */
.brand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.brand-card { display: flex; flex-direction: column; gap: 12px; }
.brand-card .logo-thumb { width: 46px; height: 46px; border-radius: 11px; border: 1px solid var(--line); background: var(--paper-warm); display: grid; place-items: center; font-weight: 700; overflow: hidden; }
.brand-card .logo-thumb img { width: 100%; height: 100%; object-fit: contain; }
.brand-card .bname { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-card .btag { font-size: 12.5px; color: var(--muted); }

/* ---------- Render grid ---------- */
.render-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.render-card { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--paper); transition: box-shadow .12s, transform .06s; }
.render-card:hover { box-shadow: var(--shadow-md); }
.render-card .thumb { aspect-ratio: 1 / 1; background: var(--paper-warm); display: grid; place-items: center; overflow: hidden; }
.render-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.render-card .meta { padding: 10px 12px; }
.render-card .meta .rf { font-size: 12.5px; font-weight: 600; }
.render-card .meta .rs { font-size: 11.5px; color: var(--muted); }
.render-card .meta .rt { font-size: 11px; color: var(--muted-soft); margin-top: 3px; }
.render-card .acts { display: flex; gap: 4px; padding: 0 8px 8px; }

/* ---------- Empty states ---------- */
.empty { text-align: center; padding: 46px 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--paper-warm); color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 10px; }
.empty .t { font-weight: 600; color: var(--ink); margin-bottom: 4px; }

/* ---------- Format cards (Studio step 1) ---------- */
.fmt-group { margin-bottom: 22px; }
.fmt-group h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
.fmt-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.fmt-card { border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 14px; cursor: pointer; transition: border-color .12s, background .12s; background: var(--paper); }
.fmt-card:hover { border-color: var(--line-strong); }
.fmt-card.sel { border-color: var(--ink); background: var(--paper-warm); }
.fmt-card .fi { font-size: 18px; }
.fmt-card .fn { font-weight: 600; font-size: 13.5px; margin-top: 8px; }
.fmt-card .fd { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.fmt-card .fr { display: inline-block; margin-top: 8px; font-size: 10.5px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 2px 7px; border-radius: 5px; }

/* ---------- Wizard ---------- */
.wizard-topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.85);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  padding: 12px clamp(18px, 4vw, 46px); display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.wizard-steps { display: flex; gap: 6px; flex-wrap: wrap; margin: 24px 0 26px; }
.wstep { display: flex; align-items: center; gap: 9px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; background: var(--paper); }
.wstep .num { font-size: 11px; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 6px; background: var(--paper-warm); border: 1px solid var(--line); }
.wstep.active { border-color: var(--ink); color: var(--ink); }
.wstep.active .num { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.wstep.done .num { background: var(--ok); color: #fff; border-color: var(--ok); }
.wpanel { display: none; }
.wpanel.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.wnav { display: flex; justify-content: space-between; margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }

/* ---------- Prompt preview drawer ---------- */
.drawer { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.drawer summary { padding: 13px 16px; font-weight: 600; font-size: 13.5px; cursor: pointer; background: var(--paper-warm); list-style: none; display: flex; justify-content: space-between; align-items: center; }
.drawer summary::-webkit-details-marker { display: none; }
.drawer .body { padding: 0; }
pre.prompt { margin: 0; padding: 18px; background: #0f1115; color: #e6e6e6; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; overflow-x: auto; max-height: 460px; }
pre.prompt .kw { color: #ff9e64; }
pre.prompt .tag { color: #7dcfff; }
pre.prompt .str { color: #9ece6a; }
pre.prompt .cm { color: #6b7089; }

/* ---------- Variants ---------- */
.variants { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.variant { border: 2px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; background: var(--paper-warm); }
.variant.sel { border-color: var(--ink); }
.variant img { width: 100%; aspect-ratio: 1/1; object-fit: cover; }
.variant .vlabel { padding: 8px 12px; font-size: 12px; font-weight: 600; display: flex; justify-content: space-between; }

/* ---------- Gen status ---------- */
.genstate { padding: 30px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--paper-warm); }
.genstate.err { border-color: var(--err); background: var(--err-soft); color: var(--err); }
.spinner { width: 26px; height: 26px; border: 3px solid var(--line-strong); border-top-color: var(--ink); border-radius: 50%; animation: spin .7s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Segmented control ---------- */
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; }
.segmented button { padding: 8px 16px; border: none; background: var(--paper); font-size: 13px; font-weight: 600; color: var(--muted); }
.segmented button.on { background: var(--ink); color: var(--on-ink); }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(17,17,17,.44); display: none; place-items: center; z-index: 100; padding: 20px; }
.modal-backdrop.open { display: grid; animation: fade .15s ease; }
.modal { background: var(--paper); border-radius: 18px; max-width: 540px; width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal .mhead { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal .mhead h3 { font-size: 16px; font-weight: 700; }
.modal .mbody { padding: 22px; }
.iconbtn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: var(--paper); display: grid; place-items: center; font-size: 16px; color: var(--muted); }
.iconbtn:hover { border-color: var(--ink); color: var(--ink); }

.keyrow { display: flex; justify-content: space-between; align-items: center; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; font-size: 13px; }
.keyrow .kmeta { display: flex; flex-direction: column; gap: 2px; }
.keyrow .kprov { font-weight: 600; }
.keyrow .kmodel { font-size: 11.5px; color: var(--muted); }

/* ---------- Faculty cards ---------- */
.faculty-strip { display: flex; gap: 10px; flex-wrap: wrap; }
.faculty-card { border: 1px solid var(--line); border-radius: 11px; padding: 8px; width: 118px; text-align: center; }
.faculty-card img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; margin-bottom: 6px; background: var(--paper-warm); }
.faculty-card input { font-size: 12px; padding: 5px 7px; text-align: center; }
.faculty-card .rm { font-size: 11px; color: var(--err); margin-top: 4px; cursor: pointer; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--ink); color: var(--on-ink); padding: 12px 16px; border-radius: 11px; font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lg); animation: toastin .2s ease; max-width: 340px; }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--err); }
@keyframes toastin { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ---------- Shortcuts overlay ---------- */
.shortcuts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; }
.shortcuts-grid .sk { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line); }
kbd { font-family: var(--mono); font-size: 11px; background: var(--paper-warm); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px; padding: 2px 7px; }

/* ---------- Footer ---------- */
.footer { background: var(--night); color: #cfcfcf; padding: 26px clamp(18px,4vw,46px); font-size: 12.5px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }

/* ---------- Utility ---------- */
.hidden { display: none !important; }
.tabbar { display: flex; gap: 8px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tab { padding: 10px 4px; font-size: 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; }
.tab.on { color: var(--ink); border-bottom-color: var(--ink); }
.filterbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.filterbar input, .filterbar select { width: auto; }
.filterbar input[type=text] { min-width: 220px; }
.statusdot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.statusdot.on { background: var(--ok); }
.statusdot.off { background: var(--muted-soft); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 30;
    flex-direction: row; align-items: center; gap: 4px; padding: 10px 12px;
    overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line);
  }
  .brandmark { padding: 0 12px 0 4px; }
  .sidebar .spacer, .sidebar .side-foot { display: none; }
  .navlink { padding: 8px 11px; }
  .navlink .lbl { display: none; }
  .two-col, .form-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .content { padding: 22px 16px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .fmt-cards { grid-template-columns: 1fr 1fr; }
  .wizard-topbar { flex-wrap: wrap; }
}
