:root {
  --bg: #0b0e10;
  --surface: #131719;
  --surface-2: #191e21;
  --line: #293135;
  --line-strong: #3b474c;
  --ink: #f3f5f4;
  --muted: #a1aaad;
  --dim: #737e82;
  --accent: #62d0c0;
  --accent-ink: #06241f;
  --warm: #d8b282;
  --danger: #ff9292;
  --sans: "IBM Plex Sans", -apple-system, sans-serif;
  --serif: Fraunces, Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --nav-h: 54px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  padding-top: var(--nav-h);
  background:
    radial-gradient(circle at 12% 2%, rgba(98, 208, 192, .055), transparent 28rem),
    var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
code { color: var(--accent); font: 500 .9em/1 var(--mono); }

.nav {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 14, 16, .92);
  backdrop-filter: blur(14px);
}
.nav-links a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}
.nav-links a:hover, .nav-links a.active { background: var(--surface-2); color: var(--ink); }
.nav-right { display: flex; margin-left: auto; }

.primary-btn, .secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  font-weight: 650;
}
.primary-btn { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.primary-btn:hover { background: #87ded2; }
.primary-btn:disabled { cursor: not-allowed; opacity: .42; }
.secondary-btn { background: var(--surface); color: var(--ink); }
.secondary-btn:hover { border-color: var(--line-strong); }

main { width: min(1500px, 100%); margin: 0 auto; padding: 30px 24px 60px; }
.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 26px;
  margin-bottom: 22px;
}
.eyebrow {
  display: block;
  margin-bottom: 8px;
  color: var(--warm);
  font: 600 10px/1 var(--mono);
  letter-spacing: .11em;
  text-transform: uppercase;
}
h1 { margin: 0; font: 560 clamp(30px, 4vw, 44px)/1.05 var(--serif); letter-spacing: -.02em; }
.page-head p { max-width: 660px; margin: 10px 0 0; color: var(--muted); font-size: 15px; }

.tool-switch {
  display: grid;
  grid-auto-flow: column;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.tool-switch button {
  min-width: 98px;
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
}
.tool-switch button[aria-selected="true"] { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }

.lab {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  min-height: calc(100vh - 178px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .25);
}
.canvas-panel {
  position: relative;
  min-width: 0;
  min-height: 650px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(45deg, rgba(255,255,255,.017) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.017) 75%),
    linear-gradient(45deg, rgba(255,255,255,.017) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.017) 75%),
    #0d1113;
  background-position: 0 0, 13px 13px;
  background-size: 26px 26px;
}
.canvas-panel.dragover { box-shadow: inset 0 0 0 2px var(--accent); }
.canvas-empty {
  position: absolute;
  inset: 24px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 9px;
  border: 1px dashed var(--line-strong);
  border-radius: 11px;
  color: var(--muted);
  text-align: center;
}
.canvas-empty strong { color: var(--ink); font-size: 17px; }
.canvas-empty small { max-width: 410px; }
.canvas-empty .primary-btn { margin-top: 8px; }
.upload-mark {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 5px;
  place-items: center;
  border: 1px solid rgba(98,208,192,.3);
  border-radius: 50%;
  background: rgba(98,208,192,.08);
  color: var(--accent);
  font-size: 28px;
  font-weight: 300;
}
.comparison {
  height: calc(100% - 58px);
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.comparison.has-result { grid-template-columns: 1fr 1fr; }
.comparison figure {
  position: relative;
  min-width: 0;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #080a0b;
}
.comparison img { width: 100%; height: 100%; display: block; object-fit: contain; }
.comparison figcaption {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 6px 9px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 6px;
  background: rgba(8, 10, 11, .8);
  color: var(--muted);
  font: 500 10px/1 var(--mono);
  backdrop-filter: blur(8px);
}
.render-state {
  position: absolute;
  inset: 24px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  border-radius: 11px;
  background: rgba(7, 10, 11, .78);
  text-align: center;
  backdrop-filter: blur(7px);
}
.render-state small { color: var(--muted); }
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(98,208,192,.16);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.result-actions {
  position: absolute;
  right: 24px;
  bottom: 20px;
  left: 24px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.controls { min-width: 0; overflow-y: auto; background: #111517; }
.control-section { padding: 20px; border-bottom: 1px solid var(--line); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head > div { display: flex; align-items: center; gap: 9px; }
.section-head > div > span { color: var(--dim); font: 600 9px/1 var(--mono); }
.section-head strong { font-size: 13px; }
.text-btn {
  min-height: 34px;
  padding: 0 9px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
}
.element-list { display: grid; gap: 7px; }
.empty-note { margin: 0; color: var(--dim); font-size: 12px; }
.element-chip {
  display: grid;
  grid-template-columns: 45px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 4px 6px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.element-chip img { width: 45px; height: 43px; border-radius: 6px; object-fit: cover; background: #090b0c; }
.element-name { min-width: 0; }
.element-name button {
  max-width: 100%;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: 600 11px/1.3 var(--mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.element-name small { display: block; overflow: hidden; color: var(--dim); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.remove-element {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--dim);
}
.remove-element:hover { background: rgba(255,255,255,.05); color: var(--ink); }
.library-toggle {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 9px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}
.recent-grid { grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 8px; }
.recent-grid:not([hidden]) { display: grid; }
.recent-grid button {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #090b0c;
}
.recent-grid button:hover { border-color: var(--accent); }
.recent-grid img { width: 100%; height: 100%; display: block; object-fit: cover; }
.recent-grid button[disabled] { opacity: .35; cursor: default; }

.field { display: grid; gap: 7px; min-width: 0; }
.field > span { color: var(--muted); font: 600 9px/1 var(--mono); letter-spacing: .05em; text-transform: uppercase; }
.field textarea, .field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: #0c1012;
  color: var(--ink);
}
.field textarea:focus, .field select:focus { border-color: rgba(98,208,192,.65); box-shadow: 0 0 0 3px rgba(98,208,192,.08); }
.field textarea { min-height: 112px; padding: 11px; resize: vertical; line-height: 1.5; }
.field select { height: 42px; padding: 0 10px; }
.field > small { color: var(--dim); font-size: 10.5px; }
.upscale-controls, .relight-controls { margin-top: 13px; }
.upscale-controls:not([hidden]) { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.relight-controls:not([hidden]) { display: grid; gap: 12px; }
.light-stack { display: grid; gap: 7px; }
.light-row {
  display: grid;
  grid-template-columns: 72px 1fr 1fr 36px;
  gap: 7px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  transition: opacity .15s;
}
.light-row.disabled > :not(.light-enable) { pointer-events: none; opacity: .28; }
.light-enable { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 650; }
.light-enable input, .enhance-row input { accent-color: var(--accent); }
.light-row select { min-width: 0; height: 34px; border: 1px solid var(--line); border-radius: 6px; background: #0c1012; color: var(--ink); font-size: 10px; }
.light-color { width: 36px; height: 34px; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: #0c1012; }
.light-power { grid-column: 2 / -1; display: grid; grid-template-columns: 36px 1fr; align-items: center; gap: 7px; color: var(--dim); font: 500 9px/1 var(--mono); }
.light-power input { width: 100%; accent-color: var(--accent); }
.field-grid { display: grid; grid-template-columns: 1fr 112px; gap: 9px; }
.enhance-row { display: flex; align-items: center; gap: 8px; min-height: 38px; margin-top: 10px; font-size: 12px; }
.referenceWarning { min-height: 17px; margin: 2px 0 0; color: var(--warm); font-size: 10.5px; }
.submit-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.quote { color: var(--muted); font: 500 10.5px/1.4 var(--mono); }
.quote.ready { color: var(--accent); }
.error { min-height: 18px; margin: 9px 0 0; color: var(--danger); font-size: 11.5px; }
.toast {
  position: fixed;
  top: 68px;
  left: 50%;
  z-index: 200;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(25,30,33,.97);
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px);
  transition: .16s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1000px) {
  .lab { grid-template-columns: 1fr 390px; }
  .canvas-panel { min-height: 570px; }
}
@media (max-width: 820px) {
  body { padding-top: 104px; }
  .nav { height: 104px; flex-wrap: wrap; align-content: center; }
  .nav-links { order: 3; width: 100%; overflow-x: auto; }
  .nav-links a { flex: 0 0 auto; }
  .nav-right { display: none; }
  main { padding: 22px 14px 50px; }
  .page-head { align-items: stretch; flex-direction: column; }
  .tool-switch { width: 100%; }
  .lab { display: flex; flex-direction: column; }
  .canvas-panel { min-height: 500px; border-right: 0; border-bottom: 1px solid var(--line); }
  .controls { overflow: visible; }
}
@media (max-width: 560px) {
  .page-head p { font-size: 13px; }
  .tool-switch button { min-width: 0; padding: 0 9px; }
  .canvas-panel { min-height: 420px; padding: 12px; }
  .canvas-empty, .render-state { inset: 12px; }
  .comparison.has-result { grid-template-columns: 1fr; }
  .comparison.has-result figure:first-child { display: none; }
  .result-actions { right: 12px; bottom: 12px; left: 12px; flex-wrap: wrap; }
  .control-section { padding: 17px 14px; }
  .light-row { grid-template-columns: 68px 1fr 1fr 34px; padding: 7px; }
  .field-grid { grid-template-columns: 1fr; }
}

/* Embedded in the Studio side workspace: Studio owns the global navigation and the
   drawer chrome, while this document keeps the production Image Lab UI and state. */
html.image-tools-embed body { min-height: 100vh; padding-top: 0; background: var(--bg); }
html.image-tools-embed .nav { display: none; }
html.image-tools-embed main { width: 100%; padding: 18px; }
html.image-tools-embed .page-head { align-items: center; margin-bottom: 14px; }
html.image-tools-embed .eyebrow { display: none; }
html.image-tools-embed h1 { font-size: clamp(24px, 3vw, 32px); }
html.image-tools-embed .page-head p { max-width: 600px; margin-top: 5px; font-size: 12px; }
html.image-tools-embed .lab { min-height: calc(100vh - 102px); border-radius: 10px; }
html.image-tools-embed .canvas-panel { min-height: 520px; }
html.image-tools-embed .toast { top: 14px; }

@media (max-width: 820px) {
  html.image-tools-embed body { padding-top: 0; }
  html.image-tools-embed main { padding: 14px; }
  html.image-tools-embed .page-head { gap: 12px; }
  html.image-tools-embed .lab { min-height: calc(100vh - 140px); }
}
@media (max-width: 560px) {
  html.image-tools-embed main { padding: 12px; }
  html.image-tools-embed h1 { font-size: 23px; }
  html.image-tools-embed .page-head p { display: none; }
  html.image-tools-embed .lab { min-height: calc(100vh - 105px); }
}
