@font-face {
  font-family: Geist;
  src: url('/vendor/geist-latin.woff2') format('woff2');
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --typeface: Geist, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  --ink: #18213a;
  --muted: #57647b;
  --line: #e1e6f0;
  --surface: #fff;
  --stage: #eef1f8;
  --accent: #4939d0;
  --accent-soft: #eeebff;
  --header-height: 64px;
  font: 14px/1.55 var(--typeface);
  color: var(--ink);
  background: var(--stage);
}
* { box-sizing: border-box; }
body { margin: 0; }
button, select, textarea, input { font: inherit; color: inherit; }
button, select {
  min-height: 34px;
  padding: 5px 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
button, select, summary { cursor: pointer; }
button:hover, select:hover { border-color: #aeb7d1; background-color: #f6f7fd; }
:focus-visible { outline: 2px solid #6957e9; outline-offset: 3px; }
button:disabled { cursor: default; opacity: .55; }
button[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
h1, h2, p { margin: 0; }
h1 { font-size: 20px; line-height: 1.3; font-weight: 680; }
h2 { font-size: 16px; line-height: 1.35; font-weight: 680; }
p { color: var(--muted); }
label { display: block; font-weight: 540; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-inline: clamp(16px, 2.4vw, 34px);
  background: #161a2b;
  color: #fff;
  border-bottom: 1px solid #2c324a;
}
.brand, .environment { display: flex; align-items: center; min-width: 0; gap: 13px; }
.brand strong { white-space: nowrap; font-size: 15px; font-weight: 660; }
.brand-mark {
  flex: 0 0 31px;
  height: 31px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  padding-bottom: 8px;
  border-radius: 9px;
  background: linear-gradient(140deg, #9a8bff, #5c46ed 78%);
  box-shadow: inset 0 0 0 1px #ffffff2e;
}
.brand-mark i { width: 3px; height: 8px; background: white; border-radius: 3px; transform: skew(-17deg); }
.brand-mark i:nth-child(2) { height: 14px; }
.brand-mark i:nth-child(3) { height: 11px; }
.brand-divider { height: 19px; width: 1px; background: #3b435d; }
.site { color: #dbe0f4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.environment { gap: 10px; }
.environment-label { display: flex; align-items: center; gap: 6px; color: #e0dcff; white-space: nowrap; font-size: 12px; }
.environment-label::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #a99aff; }
#version { color: #abb5d1; white-space: nowrap; font: 11px/1.5 var(--typeface); letter-spacing: .015em; }
#version:empty { display: none; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(335px, 31vw, 441px);
  height: calc(100dvh - var(--header-height));
}
.workspace.review-mode { grid-template-columns: minmax(0, 1fr); }
.review-mode .request-pane, .review-mode .tabs, .review-mode #preview-login-note,
.review-mode #undo-draft, .review-mode #redo-draft, .review-mode #reset-page-draft { display: none; }
.tabs { display: none; }
.preview-pane, .request-pane { min-width: 0; min-height: 0; }
.preview-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 25%, #f8f9fe 0%, transparent 67%),
    radial-gradient(circle, #c8cfe3 0.7px, transparent 0.9px) 0 0 / 17px 17px,
    var(--stage);
}
.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 9px 15px;
  padding: 14px clamp(13px, 2.05vw, 27px);
  border-bottom: 1px solid #dce2ef;
  background: #fbfcff;
}
.stage-heading, .toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.stage-heading { gap: 10px; }
.stage-header select { font-size: 12px; max-width: 142px; }
.group { padding: 3px; display: inline-flex; align-items: stretch; gap: 2px; border: 1px solid var(--line); border-radius: 9px; background: #f1f3fa; }
.group button { min-height: 28px; padding: 3px 10px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: #4d5870; font-size: 12px; white-space: nowrap; }
.group button:hover { background: #e6e9f6; }
.group button[aria-pressed="true"] { color: var(--ink); background: white; border-color: #e1e5ef; box-shadow: 0 1px 3px #26345610; font-weight: 620; }
.mode-switch button[data-mode="select"][aria-pressed="true"] { color: #fff; background: var(--accent); border-color: var(--accent); }

.stage-context {
  position: relative;
  min-height: 51px;
  padding: 7px clamp(13px, 2.05vw, 27px);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
}
#pick-hint { font-size: 12px; color: #4d5972; }
#preview-login-note { position: relative; font-size: 12px; color: var(--muted); }
#preview-login-note summary { padding: 4px 2px; }
.login-info {
  position: absolute;
  z-index: 2;
  top: 100%;
  left: 0;
  width: min(260px, 85vw);
  padding: 12px 14px;
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  box-shadow: 0 12px 32px #20284524;
}
.login-info code { font-weight: 650; color: var(--accent); }
#draft-field { padding-inline: 24px; }
.preview-state { display: flex; align-items: center; gap: 9px; margin-left: auto; color: #3e4964; }
#inline-preview-status { display: flex; align-items: center; gap: 6px; font-size: 12px; }
#inline-preview-status::before { content: ''; background: var(--accent); width: 6px; height: 6px; border-radius: 50%; flex: 0 0 6px; }
#compare-original { min-height: 29px; padding: 3px 8px; font-size: 12px; white-space: nowrap; }
.preview-state { flex-wrap: wrap; }
.preview-actions, .chat-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.preview-actions button, .chat-actions button { min-height: 30px; padding: 3px 8px; font-size: 12px; white-space: nowrap; }
.chat-actions { margin-bottom: 9px; }
#chat-version-context { margin: -3px 0 7px; color: var(--muted); font-size: 11px; }
#chat-pick { color: var(--accent); background: var(--accent-soft); border-color: #e0d9ff; }
.viewport-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px 9px;
  padding: 8px clamp(12px, 2.05vw, 27px);
  border-bottom: 1px solid #dce2ef;
  background: #f3f5fa;
}
.viewport-toolbar select, .viewport-toolbar button, .viewport-dimensions input { min-height: 32px; font-size: 12px; }
.viewport-dimensions { display: flex; align-items: center; gap: 5px; color: var(--muted); }
.viewport-dimensions input { width: 58px; padding: 4px 5px; text-align: center; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.viewport-dimensions input::-webkit-inner-spin-button { appearance: none; }
#device-scale { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.canvas {
  --device-width: 390px;
  --device-height: 844px;
  --device-scale: .6;
  --screen-width: 234px;
  --screen-height: 506px;
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: safe center;
  align-items: flex-start;
  gap: 15px;
  padding: 8px 20px 19px;
  overflow: auto;
}
.comparison-caption { display: block; color: #eeeefa; text-align: center; padding: 2px 4px 7px; font-size: 12px; }
.preview-device {
  flex: none;
  padding: 7px;
  border: 1px solid #373e55;
  border-radius: 20px;
  background: #161a2a;
  box-shadow: 0 10px 25px #1319372e, 0 2px 8px #13193725;
}
.device-screen {
  position: relative;
  width: var(--screen-width);
  height: var(--screen-height);
  overflow: hidden;
  border-radius: 13px;
  background: #171b27;
}
#preview, #comparison-preview {
  position: absolute;
  inset: 0 auto auto 0;
  width: var(--device-width);
  height: var(--device-height);
  transform: scale(var(--device-scale));
  transform-origin: top left;
  border: 0;
}
.canvas[data-wide="true"] .preview-device { border-radius: 11px; }
.canvas[data-wide="true"] .device-screen { border-radius: 6px; }

.request-pane { overflow: auto; border-left: 1px solid #d9e0ee; background: var(--surface); padding: 20px clamp(15px, 1.7vw, 24px); }
.intro { display: flex; align-items: center; gap: 11px; margin-bottom: 17px; }
.intro p { font-size: 12px; margin-top: 3px; }
.assistant-mark { flex: 0 0 35px; height: 35px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); border: 1px solid #e0d9ff; border-radius: 10px; font-size: 21px; }
.selection {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-left: 3px solid #a69af6;
  border-radius: 9px;
  background: #f7f8fd;
}
.selection > div { min-width: 0; overflow-wrap: anywhere; }
.selection-label, #selection-source { color: var(--muted); font-size: 11px; }
#selection-name { font-size: 13px; font-weight: 620; }
#selection-source:empty { display: none; }
#selection-path { display: block; max-height: 3.8em; overflow: auto; color: #515b76; font: 11px/1.45 ui-monospace, monospace; }
#clear, #select-carousel { white-space: nowrap; min-height: 28px; padding: 3px 7px; font-size: 12px; }
#select-carousel { color: var(--accent); margin: 4px 0; }
#element-inspector { margin-bottom: 12px; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.element-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 7px 9px; background: #f7f8fc; }
.element-tools strong { margin-right: auto; font-size: 12px; }
.element-tools button { min-height: 27px; padding: 3px 6px; font-size: 11px; }
#element-edit { color: var(--accent); border-color: #e0dbfb; }
#element-empty { padding: 8px 10px; font-size: 12px; }
#element-ancestors, #element-children { max-height: 70px; overflow: auto; padding: 3px 5px; }
.element-subhead { border-top: 1px solid var(--line); padding: 4px 9px 0; font-size: 11px; color: var(--muted); }
.element-row { display: block; width: 100%; min-height: 27px; text-align: left; padding: 4px 5px 4px calc(5px + 7px * var(--indent)); border: 0; border-radius: 5px; font: 11px/1.4 ui-monospace, monospace; overflow-wrap: anywhere; }
.element-row:hover, .element-row[aria-current="true"] { background: var(--accent-soft); color: var(--accent); }
#scope-label { margin-bottom: 8px; }
#design-chat { min-width: 0; margin-bottom: 9px; }
#design-chat > deep-chat { width: 100%; height: clamp(300px, calc(100dvh - 304px), 570px); border-color: var(--line); border-radius: 12px; font: inherit; }
#status, #design-result { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
#design-result:empty { display: none; }
#brief-form label { margin-bottom: 5px; }
textarea { display: block; width: 100%; padding: 9px; border: 1px solid var(--line); border-radius: 8px; resize: vertical; }
.primary { background: var(--accent); color: white; border-color: var(--accent); width: 100%; margin-block: 8px; }
.primary:hover { background: #382ab1; }
#versions { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 9px; }
#versions h2 { margin-bottom: 6px; }
#design-login input { display: block; width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
#design-login label:not(:first-child) { margin-top: 8px; }
.version-controls, .dialog-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#design-history > summary { min-height: 30px; padding-block: 3px; font-weight: 600; }
#history-scope { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
#history-filter { min-height: 27px; padding: 2px 5px; }
.version-row { margin: 7px 0; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.version-row p { overflow-wrap: anywhere; margin: 3px 0; }
.version-current { margin-left: 7px; color: var(--accent); font-weight: 650; }
.version-row time { margin-left: 7px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.version-row button { margin: 3px 4px 0 0; min-height: 29px; padding: 2px 8px; }
.simple-history #versions-title, .simple-history #design-provider, .simple-history .version-controls { display: none; }
#version-preview { border: 1px solid var(--line); border-radius: 14px; width: min(100% - 20px, 1050px); }
#version-preview::backdrop { background: #151b3a9c; }
.dialog-controls { justify-content: space-between; margin-bottom: 9px; }
#version-frames { display: flex; gap: 8px; overflow: auto; }
#version-frames iframe { width: 100%; flex: 1 1 0; height: 66vh; border: 1px solid var(--line); border-radius: 8px; background: white; }

@media (max-width: 700px) {
  :root { --header-height: 55px; }
  .header { padding-inline: 12px; gap: 8px; }
  .brand { gap: 8px; }
  .brand strong { font-size: 13px; }
  .brand-mark { height: 27px; flex-basis: 27px; padding-bottom: 6px; }
  .site, .environment-label { font-size: 11px; }
  #version { display: none; }
  .workspace { display: block; height: auto; min-height: calc(100dvh - var(--header-height)); }
  .tabs { position: sticky; top: 0; z-index: 3; display: flex; gap: 6px; padding: 7px 12px; background: #fbfcff; border-bottom: 1px solid var(--line); }
  .tabs button { flex: 1; }
  .tabs button[aria-pressed="true"] { border-color: #d6cefa; font-weight: 640; }
  .stage-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 9px 12px; gap: 8px 9px; }
  .stage-heading { gap: 6px; }
  .stage-heading h2 { font-size: 14px; }
  #locale-field { grid-column: 2; grid-row: 1; }
  .toolbar { grid-column: 1 / -1; grid-row: 2; justify-content: space-between; gap: 7px; }
  .group button { min-height: 30px; padding-inline: 11px; }
  .stage-context { min-height: 35px; padding-inline: 12px; }
  .preview-state { margin-left: 0; }
  .preview-actions button, .chat-actions button { min-height: 32px; }
  .canvas { flex: none; height: max(335px, calc(100dvh - 255px)); padding: 3px 10px 15px; }
  .preview-device { padding: 4px; border-radius: 14px; }
  .device-screen { border-radius: 9px; }
  .request-pane { overflow: visible; border: 0; padding: 15px 12px 19px; }
  #design-chat > deep-chat { height: clamp(285px, 45dvh, 470px); }
  .workspace[data-tab="preview"] .request-pane { display: none; }
  .workspace[data-tab="request"] .preview-pane { position: absolute; top: 0; left: 0; width: 100%; visibility: hidden; pointer-events: none; }
  #version-frames { flex-direction: column; }
  #version-frames iframe { flex: auto; height: 46vh; min-height: 255px; }
}
@media (max-width: 899px) {
  #compare-split { display: none; }
}
@media (min-width: 701px) {
  #element-inspector:not([hidden]) ~ #design-chat > deep-chat { height: clamp(290px, calc(100dvh - 430px), 510px); }
}
@media (prefers-reduced-motion: no-preference) {
  button, select { transition: background-color .15s ease, border-color .15s ease; }
}
