:root {
  color-scheme: light;
  --paper: #f3f0e8;
  --panel: #faf8f2;
  --ink: #171a20;
  --muted: #696b70;
  --line: #cec9bd;
  --accent: #1547d1;
  --accent-strong: #0c35a7;
  --danger: #b42318;
  --success: #157347;
  --shadow: 0 20px 60px rgba(34, 35, 38, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.shell { width: min(1460px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 52px; }
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--ink); padding-bottom: 20px; }
.identity { display: flex; align-items: center; gap: 18px; }
.index { display: grid; place-items: center; min-width: 70px; height: 70px; background: var(--accent); color: white; font: 700 12px/1 monospace; letter-spacing: .08em; }
h1, h2, h3, p { margin: 0; }
h1 { font-family: Georgia, "Times New Roman", serif; font-size: clamp(28px, 4vw, 48px); font-weight: 500; letter-spacing: -.035em; line-height: .95; }
.identity p { margin-top: 8px; color: var(--muted); font-size: 14px; }
.health { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.health-dot { width: 9px; height: 9px; border-radius: 50%; border: 1px solid currentColor; }
.health-dot.ok { border-color: var(--success); background: var(--success); }
.health-dot.fail { border-color: var(--danger); background: var(--danger); }
.text-button { border: 0; border-bottom: 1px solid currentColor; padding: 4px 0; background: transparent; color: var(--accent); cursor: pointer; font-weight: 650; font-size: 13px; }
.text-button:hover { color: var(--accent-strong); }
.workspace { display: grid; grid-template-columns: minmax(340px, .78fr) minmax(460px, 1.22fr); min-height: 690px; border-bottom: 1px solid var(--ink); }
.composer, .result-panel { padding: 32px 30px; }
.composer { border-right: 1px solid var(--line); }
.result-panel { background: var(--panel); }
.section-heading { display: flex; align-items: flex-start; gap: 15px; margin-bottom: 26px; }
.section-heading > span:first-child { padding-top: 4px; color: var(--accent); font: 700 11px/1 monospace; }
.section-heading h2 { font-family: Georgia, "Times New Roman", serif; font-size: 26px; font-weight: 500; letter-spacing: -.02em; }
.section-heading p { margin-top: 5px; color: var(--muted); font-size: 13px; }
.result-heading .state-badge { margin-left: auto; padding: 6px 9px; border: 1px solid var(--line); color: var(--muted); font: 700 10px/1 monospace; letter-spacing: .08em; }
.state-badge.running { color: var(--accent); border-color: var(--accent); }
.state-badge.succeeded { color: var(--success); border-color: var(--success); }
.state-badge.failed { color: var(--danger); border-color: var(--danger); }
.field { display: grid; gap: 8px; margin-bottom: 22px; }
.field > span { font-size: 12px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.field small { color: var(--muted); font-size: 11px; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 0; outline: none; background: var(--panel); color: var(--ink); padding: 12px 13px; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 15%, transparent); }
textarea { min-height: 200px; resize: vertical; line-height: 1.55; }
.prompt-field small { text-align: right; }
.parameter-grid { display: grid; grid-template-columns: 1fr .75fr 1.2fr; gap: 12px; }
.static-field strong { min-height: 45px; display: flex; align-items: center; border: 1px solid var(--line); padding: 0 12px; background: rgba(255,255,255,.3); font-size: 13px; white-space: nowrap; }
.generate-button { width: 100%; min-height: 53px; display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--accent); background: var(--accent); color: white; padding: 0 17px; cursor: pointer; font-weight: 750; }
.generate-button:hover { background: var(--accent-strong); }
.generate-button:disabled { cursor: wait; opacity: .6; }
.form-error { min-height: 20px; margin-top: 12px; color: var(--danger); font-size: 13px; line-height: 1.45; }
.canvas { position: relative; min-height: 520px; display: grid; place-items: center; border: 1px solid var(--line); background-color: #e5e1d7; overflow: hidden; }
.canvas img { width: 100%; height: 100%; max-height: 620px; object-fit: contain; }
.empty-state, .loading-state { display: grid; justify-items: center; gap: 9px; padding: 32px; text-align: center; }
.empty-mark { display: grid; place-items: center; width: 66px; height: 66px; margin-bottom: 8px; background: var(--ink); color: var(--paper); font: 500 36px/1 Georgia, serif; }
.empty-state p, .loading-state p { font-family: Georgia, "Times New Roman", serif; font-size: 21px; }
.empty-state span, .loading-state span { max-width: 360px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.loader { width: 44px; height: 44px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.result-actions { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding-top: 16px; }
.secondary-button { display: inline-flex; align-items: center; min-height: 38px; border: 1px solid var(--ink); padding: 0 13px; color: var(--ink); text-decoration: none; font-size: 13px; font-weight: 650; }
.secondary-button.disabled { pointer-events: none; opacity: .35; }
.debug-panel { padding: 32px 30px; background: var(--ink); color: #f5f1e7; box-shadow: var(--shadow); }
.debug-panel .section-heading { align-items: center; }
.debug-panel .section-heading p { color: #a9abb2; }
.debug-panel .text-button { margin-left: auto; color: #8caaff; }
.metrics { display: grid; grid-template-columns: repeat(6, 1fr); margin: 0 0 30px; border: 1px solid #40434b; }
.metrics div { min-width: 0; padding: 14px; border-right: 1px solid #40434b; }
.metrics div:last-child { border-right: 0; }
.metrics dt { color: #8c8f97; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.metrics dd { margin: 9px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 12px/1.2 monospace; }
.debug-grid { display: grid; grid-template-columns: .8fr 1.2fr; gap: 30px; }
.debug-grid h3 { margin-bottom: 13px; color: #b7b9bf; font: 700 11px/1 monospace; letter-spacing: .08em; text-transform: uppercase; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 90px 1fr; gap: 12px; padding: 9px 0; border-top: 1px solid #34363d; font-size: 12px; }
.timeline time { color: #8caaff; font-family: monospace; }
pre { min-height: 210px; max-height: 330px; margin: 0; overflow: auto; border: 1px solid #40434b; padding: 16px; background: #101216; color: #d5d7dc; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; --paper: #111319; --panel: #181b22; --ink: #f1eee6; --muted: #a2a4aa; --line: #3d4048; --accent: #6f91ff; --accent-strong: #92aaff; --danger: #ff8a80; --success: #67d39b; }
  .index { color: #0d1530; }
  .canvas { background-color: #0c0e13; }
  .static-field strong { background: rgba(255,255,255,.02); }
  .debug-panel { background: #08090d; }
}

@media (max-width: 900px) {
  .shell { width: min(100% - 24px, 720px); padding-top: 16px; }
  .masthead { align-items: flex-start; }
  .workspace { grid-template-columns: 1fr; }
  .composer { border-right: 0; border-bottom: 1px solid var(--line); }
  .composer, .result-panel, .debug-panel { padding: 24px 18px; }
  .canvas { min-height: 360px; }
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .metrics div:nth-child(3) { border-right: 0; }
  .metrics div:nth-child(-n+3) { border-bottom: 1px solid #40434b; }
  .debug-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .masthead { display: grid; }
  .identity { align-items: flex-start; }
  .index { min-width: 54px; height: 54px; }
  .parameter-grid { grid-template-columns: 1fr 1fr; }
  .static-field { grid-column: 1 / -1; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metrics div { border-bottom: 1px solid #40434b; }
  .metrics div:nth-child(2n) { border-right: 0; }
  .metrics div:nth-last-child(-n+2) { border-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
