:root {
  --ink: #132033;
  --muted: #65738a;
  --line: #dce3ec;
  --soft-line: #e9eef4;
  --surface: #ffffff;
  --canvas: #f4f7fa;
  --navy: #0f1d2b;
  --blue: #316ff6;
  --blue-dark: #2159cf;
  --blue-soft: #edf4ff;
  --mint: #25a47b;
  --mint-soft: #e9f8f2;
  --amber: #a66c0a;
  --amber-soft: #fff7e8;
  --danger: #b53636;
  --danger-soft: #fff0f0;
  --shadow: 0 14px 34px rgba(15, 29, 43, .07);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(circle at 80% -12%, rgba(49, 111, 246, .10), transparent 28rem), var(--canvas);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
code, pre { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
[hidden] { display: none !important; }

.topbar {
  min-height: 74px;
  padding: 0 5vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: white;
  background: var(--navy);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 12px; background: linear-gradient(140deg, #73ddba, #2e77f6);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); font-weight: 900;
}
.brand-copy { display: grid; line-height: 1.15; }
.brand-copy strong { font-size: 17px; letter-spacing: -.02em; }
.brand-copy small { margin-top: 5px; color: #8fb0c4; font-size: 8px; letter-spacing: .2em; font-weight: 800; }
.header-meta { display: flex; align-items: center; gap: 12px; }
.poc-chip { padding: 6px 10px; border: 1px solid rgba(255,255,255,.14); border-radius: 999px; color: #c6d4df; font-size: 12px; }

.shell { width: min(1370px, calc(100% - 48px)); margin: 0 auto; padding: 42px 0 28px; }
.hero { display: flex; justify-content: space-between; align-items: end; gap: 40px; margin: 0 0 26px; }
.hero > div:first-child { max-width: 810px; }
.eyebrow { margin: 0 0 7px; color: #47708d; font-size: 10px; font-weight: 850; letter-spacing: .19em; }
.hero h1 { margin: 0; font-size: clamp(30px, 4vw, 50px); line-height: 1.06; letter-spacing: -.045em; }
.hero > div > p:last-child { max-width: 760px; margin: 14px 0 0; color: var(--muted); font-size: 16px; }
.hero-note {
  min-width: 310px; max-width: 390px; padding: 15px 17px; display: flex; gap: 14px;
  border: 1px solid #cbdaf5; border-radius: 13px; background: rgba(255,255,255,.72);
}
.hero-note > span {
  width: 31px; height: 31px; display: grid; place-items: center; flex: 0 0 auto;
  color: var(--blue); border-radius: 9px; background: var(--blue-soft); font-size: 11px; font-weight: 850;
}
.hero-note p { margin: 0; color: var(--muted); font-size: 12.5px; }
.hero-note strong { color: var(--ink); }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.settings-panel { margin-bottom: 22px; overflow: hidden; }
.panel-heading { padding: 22px 24px; display: flex; justify-content: space-between; align-items: center; gap: 20px; border-bottom: 1px solid var(--soft-line); }
.panel-heading.compact { padding: 20px 22px; }
.panel-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.025em; }
.panel-heading p:last-child { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.panel-heading .eyebrow { margin-bottom: 4px; }

.settings-grid { padding: 22px 24px 24px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 17px 18px; }
.field { min-width: 0; display: grid; align-content: start; gap: 7px; }
.field > span:first-child { font-size: 12px; font-weight: 720; }
.field small { min-height: 32px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.field code { padding: 1px 4px; border-radius: 4px; background: #eef2f6; color: #405169; }
.span-2 { grid-column: span 2; }
input, select, textarea {
  width: 100%; min-height: 42px; border: 1px solid #cbd5e2; border-radius: 9px;
  outline: 0; background: white; color: var(--ink); transition: border-color .16s, box-shadow .16s, background .16s;
}
input, select { padding: 0 12px; }
output { min-height: 42px; padding: 0 12px; display: flex; align-items: center; border: 1px solid #cbd5e2; border-radius: 9px; background: #f8fafc; color: #405169; }
textarea { padding: 11px 12px; line-height: 1.5; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(49,111,246,.12); }
.secret-wrap { display: flex; position: relative; }
.secret-wrap input { padding-right: 58px; }
.secret-wrap button { position: absolute; right: 5px; top: 5px; height: 32px; border: 0; border-radius: 6px; background: #eef2f7; color: #476078; font-size: 11px; font-weight: 750; cursor: pointer; }
.checkbox-field { align-content: center; }
.checkbox-inline { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 6px; border: 1px solid #cbd5e2; border-radius: 9px; }
.checkbox-inline input { width: 16px; min-height: auto; }
.checkbox-inline span { font-size: 13px; font-weight: 500; }

.button { min-height: 40px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 9px; font-weight: 760; cursor: pointer; transition: transform .14s, background .14s, border-color .14s, opacity .14s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .52; }
.button.primary { border: 1px solid var(--blue); color: white; background: var(--blue); box-shadow: 0 7px 16px rgba(49,111,246,.2); }
.button.primary:hover:not(:disabled) { background: var(--blue-dark); }
.button.secondary { border: 1px solid #c5d1df; background: white; color: #26384d; }
.button.secondary:hover:not(:disabled) { border-color: #9eb2c9; background: #f8fafc; }
.button.small { min-height: 34px; padding: 0 11px; font-size: 12px; }
.button.full { width: 100%; }

.status-badge { padding: 6px 10px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid; border-radius: 999px; white-space: nowrap; font-size: 11px; font-weight: 750; }
.status-badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-badge.neutral { color: #718096; border-color: #d5dde6; background: #f6f8fa; }
.status-badge.good { color: #18775b; border-color: #bde6d8; background: var(--mint-soft); }
.status-badge.busy { color: #94620d; border-color: #f0d9ab; background: var(--amber-soft); }
.status-badge.bad { color: #a02f2f; border-color: #efc1c1; background: var(--danger-soft); }
.topbar .status-badge.neutral { color: #a8bac7; border-color: #324558; background: #16293b; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.02fr) minmax(460px, .98fr); gap: 22px; align-items: start; }
.compose-panel { padding-bottom: 22px; overflow: hidden; }
.compose-panel > :not(.panel-heading) { margin-left: 22px; margin-right: 22px; }
.dropzone {
  min-height: 200px; margin-top: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  border: 1.5px dashed #aebed2; border-radius: 13px; background: linear-gradient(180deg,#fbfdff,#f6f9fc);
  cursor: pointer; transition: border-color .16s, background .16s, transform .16s;
}
.dropzone:hover, .dropzone.dragging { border-color: var(--blue); background: var(--blue-soft); transform: translateY(-1px); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-icon { width: 44px; height: 44px; margin-bottom: 7px; display: grid; place-items: center; border-radius: 12px; color: var(--blue); background: white; box-shadow: 0 5px 16px rgba(49,111,246,.13); font-size: 22px; font-weight: 700; }
.dropzone strong { font-size: 15px; }
.dropzone > span:not(.upload-icon) { color: #64748a; font-size: 12px; }
.dropzone small { margin-top: 9px; color: #8a96a7; font-size: 10px; letter-spacing: .04em; text-transform: uppercase; }
.selected-images { margin-top: 16px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.selected-image { overflow: hidden; border: 1px solid #cad8e7; border-radius: 12px; background: #f8fafc; }
.selected-image .stage { height: 150px; display: grid; place-items: center; padding: 10px; background: repeating-conic-gradient(#eef2f6 0 25%, #f8fafc 0 50%) 50% / 20px 20px; }
.selected-image .stage img { max-width: 100%; max-height: 130px; object-fit: contain; border-radius: 4px; box-shadow: 0 6px 22px rgba(15,29,43,.14); background: white; }
.selected-image .caption { padding: 10px 12px; border-top: 1px solid #dce4ed; background: white; }
.selected-image .caption strong, .selected-image .caption small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-image .caption strong { font-size: 12px; }
.selected-image .caption small { color: var(--muted); font-size: 10px; }
.prompt-preview { margin-top: 17px; margin-bottom: 17px; border: 1px solid #dbe3ec; border-radius: 10px; background: #fbfcfe; }
.prompt-preview summary { padding: 12px 14px; display: flex; justify-content: space-between; color: #3c5875; font-size: 12px; font-weight: 730; cursor: pointer; list-style: none; }
.prompt-preview summary::-webkit-details-marker { display: none; }
.prompt-preview[open] summary span { transform: rotate(45deg); }
.prompt-preview pre { max-height: 310px; margin: 0; padding: 14px; overflow: auto; border-top: 1px solid #e1e7ef; color: #31445b; background: white; white-space: pre-wrap; word-break: break-word; font-size: 11px; line-height: 1.55; }
.run-note { margin-top: 9px !important; margin-bottom: 0; color: var(--muted); text-align: center; font-size: 10px; }

.result-panel { min-height: 620px; overflow: hidden; position: sticky; top: 18px; }
.result-empty { min-height: 535px; padding: 52px 34px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); text-align: center; }
.result-empty h3 { margin: 7px 0 8px; color: var(--ink); font-size: 21px; letter-spacing: -.025em; }
.result-empty > p:not(.eyebrow) { max-width: 390px; margin: 0; }
.empty-graphic { width: 112px; height: 90px; margin-bottom: 22px; display: flex; align-items: end; justify-content: center; gap: 7px; position: relative; }
.empty-graphic:before { content: ""; position: absolute; inset: 7px 0 0; border: 1px solid #d5deea; border-radius: 14px; background: linear-gradient(145deg,#f8fbff,#eef4fa); transform: rotate(-3deg); }
.empty-graphic span { width: 17px; z-index: 1; border-radius: 5px 5px 2px 2px; background: #8db2f8; }
.empty-graphic span:nth-child(1) { height: 32px; }
.empty-graphic span:nth-child(2) { height: 54px; background: var(--blue); }
.empty-graphic span:nth-child(3) { height: 43px; background: #58c5a2; }
.feature-pills { margin-top: 21px; display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; }
.feature-pills span { padding: 5px 9px; border: 1px solid #dbe3ed; border-radius: 999px; background: #fbfcfe; color: #6f7d90; font-size: 10px; }
.result-working { margin: 24px; padding: 18px; display: flex; align-items: center; gap: 14px; border: 1px solid #f0d69d; border-radius: 11px; background: var(--amber-soft); }
.result-working strong { font-size: 13px; }
.result-working p { margin: 3px 0 0; color: #856b40; font-size: 11px; }
.spinner { width: 25px; height: 25px; flex: 0 0 auto; border: 3px solid #ebd7ae; border-top-color: #ae7314; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.alert { margin: 20px 22px; padding: 13px 14px; border-radius: 9px; white-space: pre-wrap; }
.alert.error { color: #8e2828; border: 1px solid #efc3c3; background: var(--danger-soft); }
.result-tabs { margin: 18px 22px 0; padding: 4px; display: inline-flex; gap: 4px; border-radius: 9px; background: #edf1f6; }
.result-tabs button { min-height: 33px; padding: 0 13px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 750; cursor: pointer; }
.result-tabs button.active { color: var(--ink); background: white; box-shadow: 0 1px 5px rgba(15,29,43,.08); }
.block { margin: 16px 22px 0; }
.block label { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 750; color: #32485f; }
.small-pre, .answer-text, .details-json {
  min-height: 90px; padding: 16px; overflow: auto; border: 1px solid #dfe6ee; border-radius: 10px; background: #fbfcfe;
  color: #26384d; white-space: pre-wrap; word-break: break-word; font: 12px/1.66 "SFMono-Regular", Consolas, monospace;
}
.answer-text { min-height: 160px; max-height: 320px; }
.details-json { min-height: 390px; max-height: 620px; background: #142131; color: #d8e7f3; }
.output-images { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.output-image { padding: 8px; display: grid; gap: 7px; border: 1px solid #dce4ed; border-radius: 10px; background: white; }
.output-image img { width: 100%; max-height: 260px; object-fit: contain; background: #f0f3f7; }
.output-image a { color: #386bb0; font-size: 11px; font-weight: 700; text-decoration: none; }
.result-actions { margin-top: 18px; padding: 15px 22px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-top: 1px solid var(--soft-line); }
.result-actions > span { color: var(--muted); font-size: 10px; }
.result-actions > div { display: flex; gap: 7px; }
.pending-controls { margin: 18px 22px 22px; padding: 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid #dce3ec; border-radius: 10px; background: #f8fafc; }
.pending-controls p { margin: 0; color: var(--muted); font: 10px/1.5 "SFMono-Regular", Consolas, monospace; overflow-wrap: anywhere; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 10; max-width: min(430px, calc(100vw - 48px)); padding: 12px 15px; border-radius: 9px; color: white; background: #172639; box-shadow: 0 13px 32px rgba(0,0,0,.2); font-size: 12px; }

@media (max-width: 1080px) {
  .settings-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .workspace-grid { grid-template-columns: 1fr; }
  .result-panel { min-height: auto; position: static; }
}
@media (max-width: 720px) {
  .topbar { padding: 0 18px; }
  .header-meta .poc-chip, .brand-copy small { display: none; }
  .shell { width: min(100% - 24px, 1370px); padding-top: 26px; }
  .hero { align-items: stretch; flex-direction: column; gap: 18px; }
  .hero-note { min-width: 0; max-width: none; }
  .settings-grid, .selected-images, .output-images { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .panel-heading .button { width: 100%; }
  .workspace-grid { display: block; }
  .result-panel { margin-top: 16px; }
  .result-actions { align-items: stretch; flex-direction: column; }
  .result-actions > div { display: grid; grid-template-columns: repeat(3, 1fr); }
  .pending-controls { align-items: stretch; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *:before, *:after { scroll-behavior: auto !important; transition: none !important; }
  .spinner { animation-duration: 1.5s; }
}
