:root {
  --ink: #18201e;
  --muted: #6e7773;
  --line: #dce2df;
  --paper: #f5f7f6;
  --white: #ffffff;
  --green: #167d5b;
  --green-dark: #0e6045;
  --blue: #245fc7;
  --red: #bd3d3d;
  --shadow: 0 12px 30px rgba(21, 36, 31, 0.08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}
body.lightbox-open { overflow: hidden; }

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.topbar {
  height: 72px;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 36px; height: 36px; display: grid; place-items: center;
  background: var(--ink); color: white; font-weight: 800; border-radius: 5px;
}
.brand div { display: flex; flex-direction: column; line-height: 1.15; }
.brand strong { font-size: 14px; }
.brand div span { margin-top: 4px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.privacy { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.privacy-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px #dff1e9; }
.topbar-actions { display: flex; align-items: center; gap: 24px; }
.guide-button { height: 34px; padding: 0 13px; border: 1px solid #bfcac5; border-radius: 4px; color: var(--green-dark); background: white; font-size: 11px; font-weight: 700; }
.guide-button:hover { border-color: var(--green); background: #f0f7f4; }

main { max-width: 1180px; margin: 0 auto; padding: 48px 24px 64px; }
section { background: var(--white); border: 1px solid var(--line); box-shadow: var(--shadow); }
.connection { padding: 30px; }
.test-area { margin-top: 20px; padding: 30px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; }
.section-heading > div { display: flex; align-items: center; gap: 12px; }
.step { color: var(--green); font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
h1, h2 { margin: 0; font-size: 20px; line-height: 1.2; }
.status { padding: 6px 9px; border-radius: 4px; font-size: 11px; font-weight: 650; }
.status.idle { color: var(--muted); background: #eef1f0; }
.status.success { color: var(--green-dark); background: #dff1e9; }
.status.error { color: var(--red); background: #f8e6e6; }
.status.loading { color: var(--blue); background: #e5ecf9; }
.latency { color: var(--muted); font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; }

.connection-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.field { display: flex; min-width: 0; flex-direction: column; gap: 8px; }
.field > span, .mode-row > span, .task-row > span { color: #3e4945; font-size: 12px; font-weight: 700; }
.field small { color: var(--muted); font-size: 11px; }
input, select, textarea {
  width: 100%; color: var(--ink); background: #fbfcfc; border: 1px solid #cfd7d3;
  border-radius: 4px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input, select { height: 44px; padding: 0 13px; }
textarea { padding: 13px; resize: vertical; min-height: 150px; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(22, 125, 91, .1); }
.key-input { position: relative; }
.key-input input { padding-right: 46px; }
.icon-button { position: absolute; right: 3px; top: 3px; width: 38px; height: 38px; border: 0; background: transparent; color: var(--muted); }
.primary-button {
  margin-top: 24px; height: 44px; padding: 0 16px; display: inline-flex; align-items: center; gap: 28px;
  color: white; background: var(--ink); border: 0; border-radius: 4px; font-size: 12px; font-weight: 700;
}
.primary-button:hover { background: #29332f; }
.primary-button:disabled, .run-button:disabled { cursor: not-allowed; opacity: .5; }
.button-arrow { font-size: 18px; font-weight: 400; }

.test-grid { display: grid; grid-template-columns: minmax(300px, .85fr) minmax(380px, 1.15fr); gap: 28px; }
.composer { min-width: 0; }
.select-wrap { position: relative; }
.task-row, .mode-row { display: flex; align-items: center; justify-content: space-between; }
.task-row { margin-bottom: 20px; }
.mode-row { margin: 20px 0; }
.segmented { padding: 3px; display: flex; background: #edf1ef; border-radius: 5px; }
.mode, .task-mode { min-width: 62px; height: 30px; padding: 0 12px; border: 0; border-radius: 3px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 700; }
.mode.active, .task-mode.active { color: var(--ink); background: white; box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.image-options { margin: 20px 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.compact-field { gap: 6px; }
.compact-field select { height: 40px; padding: 0 9px; font-size: 11px; }
.prompt-field small { align-self: flex-end; }
.request-previews { margin-top: 18px; display: grid; gap: 12px; }
.request-export-bar { min-height: 34px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.request-export-bar > span { color: #3e4945; font-size: 12px; font-weight: 700; }
.export-button {
  height: 32px; padding: 0 11px; display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid #bfcac5; border-radius: 4px; color: var(--green-dark); background: white;
  font-size: 11px; font-weight: 700;
}
.export-button:hover { border-color: var(--green); background: #f0f7f4; }
.request-preview { min-width: 0; border: 1px solid #d4dcd8; background: #f4f7f5; }
.request-preview-header {
  height: 38px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid #d4dcd8; color: #3e4945; font-size: 11px; font-weight: 700;
}
.preview-copy { padding: 4px 0; border: 0; color: var(--green-dark); background: transparent; font-size: 11px; font-weight: 700; }
#request-info,
#request-json {
  margin: 0; padding: 13px; overflow: auto;
  color: #31413b; white-space: pre-wrap; word-break: break-word;
  font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
#request-info { min-height: 92px; word-break: break-all; }
#request-json { min-height: 160px; max-height: 240px; }
.run-button {
  width: 100%; height: 46px; margin-top: 20px; display: flex; align-items: center; justify-content: center; gap: 10px;
  color: white; background: var(--green); border: 0; border-radius: 4px; font-size: 12px; font-weight: 750;
}
.run-button:hover:not(:disabled) { background: var(--green-dark); }
.run-icon { font-size: 10px; }

.result-panel { min-height: 390px; display: flex; flex-direction: column; border: 1px solid #27332f; background: #111916; color: #d7e2dd; }
.result-header { height: 48px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #2a3732; font-size: 11px; font-weight: 700; }
.result-actions { display: flex; align-items: center; gap: 14px; }
.copy-button { border: 0; color: #9eafa7; background: transparent; font-size: 11px; }
.copy-button:disabled { opacity: .35; cursor: not-allowed; }
.empty-result { flex: 1; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; color: #788981; }
.empty-result strong { color: #aab8b2; font-size: 13px; }
.empty-result span:last-child { font-size: 11px; }
.terminal-icon { margin-bottom: 6px; color: #6ba68f; font: 24px ui-monospace, SFMono-Regular, Menlo, monospace; }
#result { flex: 1; margin: 0; padding: 18px; overflow: auto; white-space: pre-wrap; word-break: break-word; font: 12px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.image-result { flex: 1; min-height: 320px; padding: 18px; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; overflow: hidden; background: #0d1512; }
.image-result img { display: block; max-width: 100%; max-height: 560px; object-fit: contain; border: 1px solid #34433d; background: #fff; }
.image-result img { cursor: zoom-in; }
.image-result span { max-width: 100%; color: #8da098; text-align: center; font: 10px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.image-raw { border-top: 1px solid #2a3732; }
.image-raw summary { padding: 11px 16px; color: #8da098; cursor: pointer; font-size: 10px; }
.image-raw pre { max-height: 180px; margin: 0; padding: 0 16px 14px; overflow: auto; white-space: pre-wrap; word-break: break-word; color: #aebdb7; font: 10px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.image-lightbox { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 24px; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(5, 12, 9, .88); backdrop-filter: blur(4px); }
.lightbox-content { position: relative; z-index: 1; width: min(1200px, 100%); height: min(900px, calc(100vh - 48px)); display: flex; flex-direction: column; border: 1px solid #35443e; background: #101a16; box-shadow: 0 24px 70px rgba(0,0,0,.35); }
.lightbox-toolbar { min-height: 50px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; color: #d7e2dd; border-bottom: 1px solid #2a3732; font-size: 11px; font-weight: 700; }
.lightbox-toolbar div { display: flex; gap: 14px; }
.lightbox-toolbar button { padding: 4px 0; border: 0; color: #aebdb7; background: transparent; font-size: 11px; }
.lightbox-toolbar button:hover { color: white; }
#lightbox-image { flex: 1; width: 100%; height: auto; min-height: 0; padding: 20px 24px 28px; object-fit: contain; background: #0b120f; }
.guide-modal { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; padding: 24px; }
.guide-backdrop { position: absolute; inset: 0; background: rgba(18, 28, 24, .58); backdrop-filter: blur(5px); }
.guide-sheet { position: relative; z-index: 1; width: min(1040px, 100%); max-height: min(860px, calc(100vh - 48px)); display: flex; flex-direction: column; overflow: hidden; border: 1px solid #cfd8d3; background: var(--white); box-shadow: 0 24px 70px rgba(21,36,31,.22); }
.guide-header { padding: 26px 30px 22px; display: flex; align-items: flex-start; justify-content: space-between; border-bottom: 1px solid var(--line); }
.guide-kicker { color: var(--green); font: 700 10px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .05em; }
.guide-header h2 { margin-top: 8px; font-size: 24px; }
.guide-header p { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.guide-close { border: 0; color: var(--muted); background: transparent; font-size: 11px; }
.guide-layout { min-height: 0; display: grid; grid-template-columns: 170px minmax(0, 1fr); overflow: auto; }
.guide-nav { padding: 22px 18px; border-right: 1px solid var(--line); }
.guide-nav a { display: block; padding: 9px 10px; color: var(--muted); text-decoration: none; font-size: 11px; }
.guide-nav a:hover { color: var(--green-dark); background: #f0f7f4; }
.guide-body { padding: 24px 30px 34px; }
.guide-section { display: grid; grid-template-columns: 34px minmax(0,1fr); gap: 10px; padding-bottom: 28px; margin-bottom: 26px; border-bottom: 1px solid #edf0ee; scroll-margin-top: 18px; }
.guide-section:last-child { margin-bottom: 0; border-bottom: 0; }
.guide-index { color: var(--green); font: 700 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.guide-section h3 { margin: 0 0 8px; font-size: 16px; }
.guide-section p { margin: 0 0 14px; color: #596560; font-size: 12px; line-height: 1.7; }
.guide-steps { margin: 0; padding-left: 20px; color: #596560; font-size: 12px; line-height: 1.7; }
.guide-steps li { padding-left: 5px; margin: 6px 0; }
.guide-steps b { display: inline-block; min-width: 76px; color: var(--ink); }
.guide-steps span { color: #596560; }
.guide-section code { padding: 2px 4px; color: var(--green-dark); background: #edf5f1; font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.guide-code-block { margin: 12px 0; border: 1px solid #d4dcd8; background: #f4f7f5; }
.guide-code-title { height: 36px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #d4dcd8; color: #3e4945; font-size: 11px; font-weight: 700; }
.guide-copy { border: 0; color: var(--green-dark); background: transparent; font-size: 11px; font-weight: 700; }
.guide-code-block pre { margin: 0; padding: 13px; overflow: auto; color: #31413b; white-space: pre-wrap; word-break: break-word; font: 11px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.guide-note { color: var(--muted) !important; font-size: 11px !important; }
.guide-list { margin: 0; padding-left: 18px; color: #596560; font-size: 12px; line-height: 1.8; }
.guide-footer { min-height: 56px; padding: 0 30px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.guide-sheet { font-size: 12px; }
.guide-header h2 { font-size: 20px !important; }
.guide-header p { font-size: 11px; }
.guide-nav { display: block !important; min-width: 0; }
.guide-nav a { width: 100%; white-space: nowrap; }
.guide-section { background: transparent; border: 0; border-bottom: 1px solid #edf0ee; border-radius: 0; box-shadow: none; }
.guide-section h3 { font-size: 15px !important; }
.guide-close { font-size: 11px; }
.result-meta { min-height: 38px; padding: 11px 16px; border-top: 1px solid #2a3732; color: #8da098; font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; }

footer { max-width: 1180px; margin: 0 auto; padding: 0 24px 30px; display: flex; justify-content: space-between; color: #8a938f; font-size: 10px; text-transform: uppercase; }
.spin { display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .topbar { height: 64px; padding: 0 16px; }
  .privacy { font-size: 0; }
  .topbar-actions { gap: 10px; }
  .guide-button { height: 32px; }
  main { padding: 24px 14px 40px; }
  .connection, .test-area { padding: 20px; }
  .connection-grid, .test-grid { grid-template-columns: 1fr; }
  .image-options { grid-template-columns: 1fr; }
  .test-grid { gap: 22px; }
  .result-panel { min-height: 320px; }
  .primary-button { width: 100%; justify-content: space-between; }
  footer { padding: 0 16px 24px; gap: 12px; }
  footer span:last-child { text-align: right; }
  .image-lightbox { padding: 10px; }
  .lightbox-content { height: min(760px, calc(100vh - 20px)); }
  #lightbox-image { padding: 14px 12px 24px; }
  .guide-modal { padding: 10px; }
  .guide-sheet { max-height: calc(100vh - 20px); }
  .guide-header { padding: 20px; }
  .guide-layout { display: block; }
  .guide-nav { display: flex; gap: 3px; padding: 8px 12px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .guide-nav a { flex: 0 0 auto; white-space: nowrap; }
  .guide-body { padding: 20px; }
.guide-footer { padding: 0 20px; }
}

/* Enterprise portal theme: Pico supplies accessible primitives; these tokens keep the product branded. */
body { background: #eef3f1; color: #17231f; }
h1, h2, h3, .section-heading h1, .section-heading h2 { color: var(--ink) !important; }
.topbar { height: 82px; background: #12211d; border-bottom-color: #263b34; color: #eef7f3; }
.brand-mark { width: 40px; height: 40px; border-radius: 8px; background: #2aa879; color: #07130f; }
.brand strong { color: #f4faf7; font-size: 15px; }
.brand div span { color: #a4b9b0; text-transform: none; }
.privacy { color: #b1c4bc; }
.privacy-dot { background: #55d39c; box-shadow: 0 0 0 4px rgba(85,211,156,.14); }
.guide-button { border-color: #4c6b60; color: #d9eee5; background: transparent; }
.guide-button:hover { border-color: #67d3a4; color: white; background: rgba(86,211,157,.12); }
main { max-width: 1240px; padding-top: 42px; }
section { border-color: #d7e2dd; box-shadow: 0 16px 36px rgba(29,55,45,.07); border-radius: 10px; }
.connection, .test-area { padding: 34px; }
.connection { position: relative; overflow: hidden; }
.connection::before { content: "麦谷科技  /  DELIVERY WORKSPACE"; display: block; margin-bottom: 18px; color: #16825c; font: 700 10px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
.section-heading { margin-bottom: 28px; }
h1, h2 { font-size: 22px; letter-spacing: -.01em; }
.step { color: #16825c; }
.status { border-radius: 999px; padding: 7px 11px; }
input, select, textarea { border-radius: 7px; border-color: #c9d7d1; background: #fbfdfc; }
input, select { height: 46px; }
textarea { min-height: 170px; }
.primary-button { height: 46px; border-radius: 7px; background: #17231f; }
.primary-button:hover { background: #264139; }
.segmented { border-radius: 8px; }
.mode, .task-mode { border-radius: 6px; }
.run-button { height: 50px; border-radius: 7px; background: #16825c; }
.run-button:hover:not(:disabled) { background: #0e6849; }
.result-panel { border-radius: 10px; overflow: hidden; }
.guide-sheet { border-radius: 12px; }
.guide-close { padding: 7px 11px; border: 1px solid #c8d4ce; border-radius: 6px; }
.guide-footer { border-radius: 0 0 12px 12px; }
footer { text-transform: none; }
@media (max-width: 760px) {
  .topbar { height: 72px; }
  .connection, .test-area { padding: 22px; }
  .connection::before { margin-bottom: 14px; }
}

/* Direct-first debug workspace */
.test-area { margin-top: 0; }
.test-area > .section-heading { display: none; }
.composer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.composer-head > div { display: flex; align-items: center; gap: 12px; }
.composer-head-meta { display: flex; align-items: center; gap: 14px; }
.composer-head-meta .privacy { font-size: 10px; white-space: nowrap; }
.composer-head h1 { margin: 0; font-size: 22px; }
.composer-intro { margin: 0 0 22px; color: var(--muted); font-size: 12px; }
.platform-tabs { margin: 0 0 18px; padding: 3px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; border: 1px solid #d6e0dc; border-radius: 8px; background: #e9efec; }
.platform-tab { height: 34px; margin: 0; padding: 0 12px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 700; }
.platform-tab.active { color: #fff; background: #17362b; box-shadow: 0 1px 4px rgba(15, 42, 32, .18); }
.inline-credentials { display: grid; gap: 14px; }
.load-models-inline { width: 100%; justify-content: space-between; margin: 0 0 9px; }
.model-fetch-status { display: flex; align-items: center; gap: 7px; margin: 0 0 17px; color: var(--green-dark); font-size: 10px; }
.model-fetch-status > span { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.model-fetch-status small { margin-left: auto; color: var(--muted); font-size: 10px; }
@media (max-width: 760px) { .composer-head { align-items: flex-start; gap: 10px; } .composer-head .status { white-space: nowrap; } }

/* Portal chrome shared by the debug workspace and guide. */
.portal-sidebar { position: fixed; z-index: 5; inset: 0 auto 0 0; width: 228px; padding: 26px 14px; display: flex; flex-direction: column; background: #10231d; color: #b7cbc2; }
.portal-brand { display: flex; gap: 10px; align-items: center; padding: 0 10px 34px; color: #fff; }
.portal-brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; background: #4fd29b; color: #0e291f; font-weight: 800; }
.portal-brand strong { display: block; font-size: 14px; }
.portal-brand small { display: block; color: #7d9b8f; font-size: 10px; }
.portal-nav-label { margin: 0 10px 8px; color: #6b8d7f; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.portal-nav { display: grid; gap: 4px; }
.portal-nav a { display: flex; justify-content: space-between; padding: 10px; color: #a8bcb4; border-radius: 6px; text-decoration: none; font-size: 12px; }
.portal-nav a.active, .portal-nav a:hover { color: #fff; background: #1b3d30; }
.portal-sidebar-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid #29463b; color: #769589; font-size: 10px; }
.topbar { margin-left: 228px; }
main, footer { margin-left: 228px; }
main { max-width: none; }
.test-area { max-width: 1180px; margin-left: auto; margin-right: auto; }
body, button, input, select, textarea { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
input, select, textarea { font-size: 13px !important; }
.field > span, .mode-row > span, .task-row > span { font-size: 11px; }
.field small { font-size: 10px; }
.composer-head h1 { font-size: 20px; }
.composer-intro { font-size: 11px; }
.primary-button, .run-button { font-size: 11px; }
.mode, .task-mode { font-size: 11px; }
@media (max-width: 760px) { .portal-sidebar { display: none; } .topbar, main, footer { margin-left: 0; } .test-area { max-width: none; } .composer-head-meta .privacy { display: none; } }

/* The guide is a page view, not a modal overlay. */
body.guide-open main, body.guide-open > footer { display: none; }
body.guide-open .guide-modal { position: static; inset: auto; display: block; padding: 0; }
body.guide-open .guide-backdrop { display: none; }
body.guide-open .guide-sheet { width: min(1100px, calc(100% - 48px)); max-height: none; min-height: calc(100vh - 48px); margin: 24px auto; overflow: visible; box-shadow: 0 12px 30px rgba(21,36,31,.08); }
body.guide-open .guide-layout { overflow: visible; }
