:root {
  color-scheme: dark;
  --bg: #070707;
  --panel: #0d0d0d;
  --panel-2: #111111;
  --panel-3: #151515;
  --line: #232323;
  --line-strong: #303030;
  --text: #f4f4f2;
  --muted: #8a8a86;
  --muted-2: #656560;
  --accent: #c8ff47;
  --accent-ink: #101700;
  --danger: #ff6b61;
  --warning: #ffcc66;
  --success: #7fe7a5;
  --radius: 18px;
  --radius-sm: 11px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }

body {
  font-weight: 400;
  background:
    radial-gradient(circle at 80% -10%, rgba(200, 255, 71, .055), transparent 30rem),
    var(--bg);
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(7, 7, 7, .9);
  backdrop-filter: blur(22px);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 28px; }
.brand-mark { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 9px; background: var(--accent); color: var(--accent-ink); }
.brand-mark svg { width: 17px; height: 17px; }
.brand-name { font-size: 14px; line-height: 1.1; font-weight: 500; letter-spacing: -.01em; }
.brand-name small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; font-weight: 400; letter-spacing: .05em; text-transform: uppercase; }

.nav-label { color: var(--muted-2); font-size: 10px; letter-spacing: .11em; text-transform: uppercase; padding: 0 10px 8px; }
.nav { display: grid; gap: 3px; }
.nav-button {
  width: 100%;
  appearance: none;
  border: 0;
  background: transparent;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 11px;
  color: #8d8d89;
  cursor: pointer;
  text-align: left;
  transition: 160ms ease;
}
.nav-button:hover { color: var(--text); background: #101010; }
.nav-button.active { color: var(--text); background: #151515; box-shadow: inset 0 0 0 1px #1f1f1f; }
.nav-button svg { width: 17px; height: 17px; stroke-width: 1.7; }
.nav-button span { font-size: 13px; }

.sidebar-bottom { margin-top: auto; display: grid; gap: 10px; }
.system-card { padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: #0a0a0a; }
.system-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; }
.system-line + .system-line { margin-top: 8px; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(127, 231, 165, .08); }

.main { min-width: 0; }
.topbar {
  height: 72px;
  padding: 0 clamp(22px, 4vw, 58px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(7, 7, 7, .72);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 8;
}
.topbar-title { font-size: 13px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.content { width: min(1180px, 100%); margin: 0 auto; padding: 42px clamp(22px, 4vw, 58px) 80px; }

h1, h2, h3, h4, p { margin-top: 0; }
h1 { font-size: clamp(29px, 4vw, 44px); line-height: 1.05; letter-spacing: -.045em; font-weight: 500; margin-bottom: 12px; }
h2 { font-size: 20px; letter-spacing: -.025em; font-weight: 500; margin-bottom: 8px; }
h3 { font-size: 14px; letter-spacing: -.01em; font-weight: 500; margin-bottom: 7px; }
p { color: var(--muted); line-height: 1.6; font-size: 13px; }
.lede { max-width: 650px; font-size: 14px; margin-bottom: 0; }
.eyebrow { display: flex; align-items: center; gap: 8px; color: var(--accent); font-size: 10px; text-transform: uppercase; letter-spacing: .13em; margin-bottom: 16px; }
.eyebrow::before { content: ''; width: 18px; height: 1px; background: currentColor; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 34px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.button {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: #121212;
  color: var(--text);
  min-height: 39px;
  border-radius: 10px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: 160ms ease;
}
.button:hover { border-color: #444; background: #171717; transform: translateY(-1px); }
.button:disabled { opacity: .42; cursor: not-allowed; transform: none; }
.button svg { width: 15px; height: 15px; }
.button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.button.primary:hover { background: #d2ff68; border-color: #d2ff68; }
.button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.button.danger { color: #ff8b83; }
.button.small { min-height: 32px; padding: 0 11px; font-size: 11px; border-radius: 8px; }
.icon-button { width: 39px; padding: 0; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { border: 1px solid var(--line); background: linear-gradient(145deg, #101010, #0c0c0c); border-radius: var(--radius); }
.card-pad { padding: 22px; }

.upload-card { overflow: hidden; }
.upload-form { display: grid; grid-template-columns: .85fr 1.15fr; min-height: 370px; }
.upload-copy { padding: 31px; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.upload-copy .mini-flow { margin-top: auto; }
.upload-panel { padding: 24px; background: #0b0b0b; display: flex; flex-direction: column; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.input, .textarea, .select {
  width: 100%;
  border: 1px solid var(--line);
  background: #0a0a0a;
  color: var(--text);
  border-radius: 10px;
  outline: 0;
  padding: 11px 12px;
  font-size: 13px;
  transition: 160ms ease;
}
.input:focus, .textarea:focus, .select:focus { border-color: #505050; box-shadow: 0 0 0 3px rgba(200, 255, 71, .04); }
.input::placeholder, .textarea::placeholder { color: #4f4f4c; }
.textarea { resize: vertical; min-height: 140px; line-height: 1.55; }
.document-editor { min-height: 500px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.dropzone {
  border: 1px dashed #343434;
  border-radius: 13px;
  min-height: 137px;
  margin-top: 14px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 20px;
  cursor: pointer;
  transition: 160ms ease;
  background: #0d0d0d;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: rgba(200, 255, 71, .025); }
.dropzone input { display: none; }
.dropzone-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: #171717; margin: 0 auto 10px; color: var(--accent); }
.dropzone-icon svg { width: 17px; }
.dropzone strong { display: block; font-size: 12px; font-weight: 500; }
.dropzone span { display: block; color: var(--muted-2); font-size: 10px; margin-top: 5px; }
.file-summary { min-height: 24px; color: var(--muted); font-size: 11px; margin: 10px 0 0; }
.upload-submit { margin-top: auto; padding-top: 16px; }

.mini-flow { display: grid; gap: 12px; }
.mini-flow-row { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; }
.mini-flow-number { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; border: 1px solid var(--line); color: var(--text); font-size: 10px; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 34px 0 14px; }
.section-head h2 { margin: 0; font-size: 15px; }
.section-head span { color: var(--muted-2); font-size: 11px; }

.project-list { display: grid; gap: 8px; }
.project-row {
  width: 100%;
  border: 1px solid var(--line);
  background: #0d0d0d;
  border-radius: 13px;
  min-height: 76px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 20px;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: 160ms ease;
}
.project-row:hover { border-color: #383838; transform: translateY(-1px); background: #101010; }
.project-name { min-width: 0; }
.project-name strong { font-size: 13px; font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-name span { display: block; color: var(--muted); font-size: 10px; margin-top: 5px; }
.project-meta { color: var(--muted); font-size: 11px; white-space: nowrap; }
.status { display: inline-flex; align-items: center; gap: 7px; border-radius: 99px; border: 1px solid var(--line); padding: 6px 9px; font-size: 10px; color: var(--muted); white-space: nowrap; }
.status::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: #666; }
.status.working::before { background: var(--accent); box-shadow: 0 0 0 4px rgba(200, 255, 71, .07); animation: pulse 1.2s infinite; }
.status.done::before { background: var(--success); }
.status.failed::before { background: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }

.empty { border: 1px dashed var(--line); border-radius: 15px; text-align: center; padding: 44px 20px; color: var(--muted); font-size: 12px; }

.stepper { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin-bottom: 24px; }
.step { padding: 13px 15px; display: flex; align-items: center; gap: 9px; background: #0b0b0b; color: var(--muted-2); font-size: 11px; border-right: 1px solid var(--line); }
.step:last-child { border-right: 0; }
.step-number { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; border: 1px solid #333; font-size: 9px; }
.step.active { color: var(--text); background: #10100e; }
.step.active .step-number { border-color: var(--accent); color: var(--accent); }
.step.done { color: #b8b8b2; }
.step.done .step-number { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.project-head { margin-bottom: 26px; }
.back { border: 0; background: 0; color: var(--muted); display: inline-flex; align-items: center; gap: 7px; padding: 0; margin-bottom: 23px; cursor: pointer; font-size: 11px; }
.back svg { width: 14px; }
.head-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.head-row h1 { font-size: 31px; margin-bottom: 7px; }
.head-row p { margin: 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 19px; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 11px 13px; font-size: 11px; cursor: pointer; border-bottom: 1px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.progress-card { padding: 34px; text-align: center; }
.spinner { width: 30px; height: 30px; border: 2px solid #252525; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 17px; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-track { width: min(420px, 100%); height: 4px; background: #202020; border-radius: 99px; margin: 18px auto 0; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); transition: width .4s ease; }

.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.metric { border: 1px solid var(--line); border-radius: 12px; background: #0d0d0d; padding: 16px; }
.metric span { display: block; color: var(--muted); font-size: 10px; margin-bottom: 7px; }
.metric strong { font-size: 19px; font-weight: 500; }

.analysis-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.analysis-card { border: 1px solid var(--line); background: #0d0d0d; border-radius: 14px; padding: 18px; }
.analysis-card.wide { grid-column: 1 / -1; }
.analysis-card h3 { display: flex; align-items: center; justify-content: space-between; }
.count { color: var(--muted-2); font-size: 10px; font-weight: 400; }
.evidence-list { display: grid; gap: 8px; margin: 13px 0 0; padding: 0; list-style: none; }
.evidence-item { background: #111; border-radius: 9px; padding: 10px 11px; color: #cfcfca; font-size: 11px; line-height: 1.5; }
.sources { color: #62625f; font-size: 9px; display: block; margin-top: 5px; }
.summary-box { border-left: 2px solid var(--accent); padding: 3px 0 3px 15px; color: #cecec8; font-size: 12px; line-height: 1.65; }

.alert { border: 1px solid #48302e; background: #17100f; color: #ffaaa3; border-radius: 11px; padding: 12px 14px; font-size: 11px; line-height: 1.45; margin-bottom: 16px; }
.alert.info { border-color: #343a26; background: #11140d; color: #cfe89a; }

.shopify-connect { max-width: 610px; }
.connection-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.connection-title { display: flex; gap: 12px; align-items: center; }
.shopify-mark { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: #132414; color: #8dda75; }
.shopify-mark svg { width: 20px; }
.connection-title h3 { margin: 0 0 3px; }
.connection-title p { margin: 0; font-size: 10px; }
.scope { font-family: ui-monospace, monospace; font-size: 9px; color: var(--muted-2); word-break: break-all; }

.template-plan { display: grid; grid-template-columns: .8fr 1.2fr; gap: 14px; }
.plan-summary { padding: 18px; }
.replacements { max-height: 560px; overflow: auto; }
.replacement { padding: 13px 0; border-bottom: 1px solid var(--line); }
.replacement:last-child { border-bottom: 0; }
.replacement-path { font-family: ui-monospace, monospace; font-size: 9px; color: var(--muted-2); word-break: break-all; }
.replacement-value { font-size: 11px; color: #d0d0cb; line-height: 1.5; margin-top: 6px; }

.image-url-card { padding: 0; overflow: hidden; }
.image-url-form { display: grid; grid-template-columns: .85fr 1.15fr; }
.image-url-form > div { padding: 27px; }
.image-url-form > div:first-child { border-right: 1px solid var(--line); background: linear-gradient(145deg, #111, #0c0c0c); }
.image-url-form h2 { margin-bottom: 8px; }
.image-url-fields { display: grid; gap: 13px; align-content: center; background: #0b0b0b; }
.image-url-fields .button { justify-self: start; }

.image-feature-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin: 14px 0 4px; }
.feature-chip { border: 1px solid var(--line); border-radius: 12px; background: #0b0b0b; padding: 14px; min-width: 0; }
.feature-chip > span { display: block; color: var(--accent); font-size: 9px; margin-bottom: 18px; }
.feature-chip strong { display: block; font-size: 11px; font-weight: 500; }
.feature-chip small { display: block; color: var(--muted-2); font-size: 9px; line-height: 1.45; margin-top: 4px; }
.image-source-link { max-width: 620px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.image-toolbar { padding: 13px 15px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.image-toolbar > div:first-child { display: grid; gap: 3px; }
.image-toolbar strong { font-size: 12px; font-weight: 500; }
.image-toolbar span { color: var(--muted); font-size: 10px; }
.brand-generation-field { display: flex !important; align-items: end; gap: 18px; flex: 1; }
.brand-generation-field > div:first-child { min-width: 120px; }
.brand-generation-field .field { width: min(230px, 100%); }
.brand-generation-field .input { min-height: 34px; padding-block: 7px; }
.image-gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.image-card { position: relative; border: 1px solid var(--line); background: #0c0c0c; border-radius: 15px; padding: 12px; transition: 160ms ease; }
.image-card.selected { border-color: #465428; box-shadow: inset 0 0 0 1px rgba(200, 255, 71, .05); }
.image-select { position: absolute; z-index: 2; top: 20px; left: 20px; width: 28px; height: 28px; border-radius: 8px; background: rgba(8,8,8,.88); border: 1px solid #343434; display: grid; place-items: center; cursor: pointer; backdrop-filter: blur(8px); }
.image-select input { position: absolute; opacity: 0; pointer-events: none; }
.image-select span { font-size: 9px; color: var(--muted); }
.image-card.selected .image-select { background: var(--accent); border-color: var(--accent); }
.image-card.selected .image-select span { color: var(--accent-ink); }
.image-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.image-pair figure { margin: 0; min-width: 0; }
.image-pair img, .image-placeholder { width: 100%; aspect-ratio: 1 / 1; object-fit: contain; border-radius: 10px; background: #080808; border: 1px solid #1b1b1b; display: block; }
.image-pair figcaption { color: var(--muted-2); font-size: 9px; margin: 7px 2px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-placeholder { display: grid; place-items: center; color: var(--muted-2); font-size: 10px; }
.image-error { color: #ff928a; font-size: 10px; line-height: 1.45; padding: 6px 2px 10px; }
.image-card > .button { margin-top: 2px; }
.image-delivery { margin-top: 25px; }
.shopify-upload-row { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 12px; padding-top: 17px; border-top: 1px solid var(--line); }
.shopify-upload-row .field { min-width: 0; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(410px, 100%); border: 1px solid var(--line); border-radius: 22px; background: rgba(14, 14, 14, .92); padding: 34px; box-shadow: 0 30px 80px rgba(0,0,0,.38); }
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 52px; }
.login-card h1 { font-size: 29px; }
.login-card .button { width: 100%; margin-top: 12px; }
.login-error { min-height: 20px; color: var(--danger); font-size: 11px; margin-top: 10px; }

.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: grid; gap: 8px; }
.toast { width: min(360px, calc(100vw - 40px)); border: 1px solid var(--line-strong); background: #151515; border-radius: 11px; padding: 13px 15px; font-size: 11px; box-shadow: 0 18px 55px rgba(0,0,0,.45); animation: toast-in .2s ease; }
.toast.error { border-color: #55302d; color: #ffaaa3; }
@keyframes toast-in { from { transform: translateY(6px); opacity: 0; } }

.modal-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.72); backdrop-filter: blur(8px); display: grid; place-items: center; padding: 24px; }
.modal { width: min(520px, 100%); max-height: calc(100vh - 48px); overflow: auto; background: #0f0f0f; border: 1px solid var(--line-strong); border-radius: 18px; padding: 23px; box-shadow: 0 30px 90px rgba(0,0,0,.58); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.modal-head h2 { font-size: 17px; margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 74px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .brand { padding-inline: 9px; justify-content: center; }
  .brand-name, .nav-label, .nav-button span, .system-card { display: none; }
  .nav-button { justify-content: center; padding: 11px; }
  .upload-form { grid-template-columns: 1fr; }
  .upload-copy { border-right: 0; border-bottom: 1px solid var(--line); min-height: 260px; }
  .template-plan { grid-template-columns: 1fr; }
  .image-url-form { grid-template-columns: 1fr; }
  .image-url-form > div:first-child { border-right: 0; border-bottom: 1px solid var(--line); }
  .image-feature-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 650px) {
  .shell { display: block; padding-bottom: 70px; }
  .sidebar { position: fixed; inset: auto 0 0; height: 64px; border-right: 0; border-top: 1px solid var(--line); padding: 7px 12px; flex-direction: row; align-items: center; }
  .brand, .sidebar-bottom, .nav-label { display: none; }
  .nav { grid-template-columns: repeat(5, 1fr); width: 100%; }
  .nav-button { display: grid; place-items: center; gap: 3px; padding: 6px; }
  .nav-button span { display: block; font-size: 9px; }
  .nav-button svg { width: 15px; height: 15px; }
  .topbar { height: 60px; }
  .content { padding-top: 27px; }
  .page-head, .head-row { align-items: flex-start; flex-direction: column; }
  .grid.two, .grid.three, .analysis-grid { grid-template-columns: 1fr; }
  .analysis-card.wide { grid-column: auto; }
  .upload-copy, .upload-panel { padding: 22px; }
  .field-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .project-row { grid-template-columns: 1fr auto; }
  .project-meta { display: none; }
  .stepper { grid-template-columns: repeat(4, minmax(54px, 1fr)); }
  .step { justify-content: center; padding: 11px 5px; }
  .step > span:last-child { display: none; }
  .metric-grid { grid-template-columns: 1fr; }
  .image-gallery { grid-template-columns: 1fr; }
  .image-toolbar { align-items: flex-start; flex-direction: column; }
  .brand-generation-field { align-items: stretch; flex-direction: column; width: 100%; }
  .shopify-upload-row { grid-template-columns: 1fr; }
}
