:root {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #1b2923;
  background: #f2f4ef;
  font-size: 15px;
  font-synthesis: none;
  --muted: #5d6c63;
  --border: #dce3da;
  --green: #205940;
  --green-soft: #e7f1e8;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input { font: inherit; }
button { touch-action: manipulation; }
button:focus-visible, summary:focus-visible, a:focus-visible { outline: 2px solid #2f6f50; outline-offset: 4px; }

.shell { width: min(100% - 72px, 1120px); margin: 0 auto; padding: 52px 0 36px; }
.masthead { display: flex; gap: 17px; align-items: center; margin-bottom: 30px; }
.brand-icon { display: grid; place-items: center; width: 55px; aspect-ratio: 1; flex-shrink: 0; border-radius: 17px; background: #24553d; color: #f9fcf5; }
.brand-icon svg { width: 30px; height: 30px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(27px, 4vw, 39px); font-weight: 710; line-height: 1.2; letter-spacing: -.05em; }
h2 { font-size: 18px; font-weight: 700; line-height: 1.35; }
.masthead p { margin-top: 8px; color: var(--muted); line-height: 1.55; }

.workspace { display: grid; grid-template-columns: minmax(275px, .8fr) minmax(0, 1.65fr); gap: 20px; align-items: stretch; }
.panel { border: 1px solid var(--border); border-radius: 19px; background: #fdfefb; min-width: 0; }
.setup { padding: 24px; }
fieldset { display: grid; gap: 10px; min-width: 0; margin: 18px 0 0; padding: 0; border: 0; }
.mode-card { position: relative; display: block; cursor: pointer; }
.mode-card input { position: absolute; margin: 0; opacity: 0; }
.mode-card input:disabled + .mode-content { cursor: default; }
.mode-card input:focus-visible + .mode-content { outline: 2px solid #2f6f50; outline-offset: 3px; }
.mode-content { display: flex; flex-direction: column; min-width: 0; padding: 13px 14px; border: 1px solid var(--border); border-radius: 12px; background: #fbfcf9; transition: border-color .15s, background .15s; }
.mode-card:hover .mode-content { border-color: #96ae9c; }
.mode-card input:checked + .mode-content { border-color: #6c997d; background: var(--green-soft); }
.mode-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 680; }
.radio-mark { display: grid; place-items: center; width: 17px; height: 17px; flex: 0 0 17px; border-radius: 50%; border: 1px solid #a0aea3; background: #fff; }
.mode-card input:checked + .mode-content .radio-mark { border-color: #31684b; }
.mode-card input:checked + .mode-content .radio-mark::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #31684b; }
.model-name { margin-top: 5px; color: #336148; font-size: 12px; font-weight: 650; line-height: 1.45; overflow-wrap: anywhere; }
.mode-description { margin-top: 5px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.call-controls { margin-top: 17px; }
.button { display: inline-flex; gap: 8px; align-items: center; justify-content: center; min-height: 41px; border: 1px solid transparent; border-radius: 9px; padding: 8px 14px; cursor: pointer; white-space: nowrap; font-size: 13px; font-weight: 680; }
.button svg { width: 17px; aspect-ratio: 1; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.button:disabled { opacity: .57; cursor: default; }
.button.primary, .button.stop { width: 100%; min-height: 48px; font-size: 15px; }
.button.primary { background: var(--green); color: #fff; }
.button.primary:hover:not(:disabled) { background: #173f2f; }
.button.stop { background: #f6eeea; border-color: #ecd5ca; color: #8c3e28; }
.button.stop:hover:not(:disabled) { background: #f3e2da; }
.button.secondary { border-color: var(--border); color: #345744; background: #f8faf6; }
.button.secondary:hover:not(:disabled) { border-color: #94ac9a; }
.notice { min-height: 20px; margin-top: 9px; color: var(--muted); font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; }
.notice[data-error="true"] { color: #8c3e28; }
.prompts { margin-top: 16px; padding-top: 14px; border-top: 1px solid #e4e9e1; font-size: 13px; }
.prompts summary { cursor: pointer; color: #345744; font-weight: 680; }
.prompts ol { margin: 8px 0 0; padding-left: 20px; color: var(--muted); line-height: 1.6; }
.prompts li + li { margin-top: 4px; }

.conversation { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; height: 100%; min-height: 440px; }
.panel-header { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; padding: 21px 24px; }
.panel-header p { color: var(--muted); margin-top: 5px; font-size: 13px; line-height: 1.5; }
.conversation .panel-header { border-bottom: 1px solid #e7ebe4; }
.call-indicator { display: inline-flex; gap: 7px; align-items: center; flex: 0 0 auto; border-radius: 30px; padding: 6px 10px; color: #516359; background: #eef2ec; font-size: 12px; white-space: nowrap; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #8c9c92; }
.call-indicator[data-state="active"] { color: #205940; background: #e4f2e6; }
.call-indicator[data-state="active"] .status-dot { background: #397950; box-shadow: 0 0 0 3px #cfe6d3; }
.call-indicator[data-state="error"] { color: #8c3e28; background: #f6ede7; }
.call-indicator[data-state="error"] .status-dot { background: #a85f45; }
.transcript { height: 365px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px 24px; scrollbar-width: thin; }
.empty-transcript { min-height: 100%; display: grid; align-content: center; justify-items: center; gap: 8px; color: var(--muted); text-align: center; font-size: 14px; }
.empty-transcript svg { width: 38px; height: 38px; color: #71917b; }
.turn { max-width: min(92%, 530px); margin: 0 0 13px; width: fit-content; }
.turn[data-role="user"] { margin-left: auto; text-align: right; }
.speaker { display: block; margin: 0 4px 4px; color: var(--muted); font-size: 11px; }
.bubble { display: inline-block; padding: 9px 12px; border-radius: 5px 14px 14px; background: #edf1eb; line-height: 1.6; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; }
.turn[data-role="user"] .bubble { border-radius: 14px 5px 14px 14px; background: #e5f0e7; }
.turn[data-final="false"] .bubble { color: #4f6259; }
.turn[data-interrupted="true"] .speaker::after { content: " · 已打断"; }
.chat-transcript-images { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.bubble:not([hidden]) + .chat-transcript-images { margin-top: 5px; }
.chat-transcript-images img { display: block; width: 76px; height: 76px; object-fit: cover; border: 1px solid var(--border); border-radius: 9px; background: #edf1eb; }
.chat-composer { padding: 10px 24px 13px; border-top: 1px solid #e7ebe4; }
.chat-composer-row { display: flex; gap: 9px; align-items: end; }
.chat-composer textarea { display: block; flex: 1; min-width: 0; width: 100%; max-height: 140px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: #fbfcf9; color: inherit; font: inherit; font-size: 14px; line-height: 1.4; resize: vertical; }
.chat-composer textarea:focus-visible { outline: 2px solid #2f6f50; outline-offset: 2px; }
.chat-composer textarea:disabled { color: var(--muted); background: #f1f5ef; }
.chat-composer .notice { min-height: 0; margin-top: 6px; }
.button.chat-send { background: var(--green); color: #fff; min-width: 67px; }
.button.chat-send:hover:not(:disabled) { background: #173f2f; }
.button.chat-attach { position: relative; flex-shrink: 0; width: 44px; min-height: 44px; padding: 0; }
.chat-attach input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.chat-attach input::file-selector-button { width: 100%; height: 100%; cursor: inherit; }
.chat-attach:has(input:disabled) { opacity: .57; cursor: default; }
.chat-attach input:disabled { cursor: default; }
.chat-attach:focus-within { outline: 2px solid #2f6f50; outline-offset: 2px; }
.chat-attachments { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 8px; padding: 0; list-style: none; }
.chat-attachments li { position: relative; }
.chat-attachments img { display: block; width: 52px; height: 52px; object-fit: cover; border: 1px solid var(--border); border-radius: 8px; background: #edf1eb; }
.chat-attachment-remove { position: absolute; top: 2px; right: 2px; width: 26px; height: 26px; padding: 0; border: 1px solid #fffe; border-radius: 50%; background: #22342bdb; color: white; line-height: 1; cursor: pointer; }
.chat-attachment-remove:disabled { opacity: .55; cursor: default; }
.conversation-footer { display: flex; gap: 9px; align-items: center; min-height: 49px; padding: 0 24px; color: var(--muted); background: #f8faf6; border-top: 1px solid #e7ebe4; border-radius: 0 0 19px 19px; font-size: 12px; }
.level { position: relative; width: 46px; height: 5px; overflow: hidden; border-radius: 4px; background: #dee7dd; }
.level span { position: absolute; inset: 0; transform: scaleX(0); transform-origin: left; background: #519168; border-radius: 4px; transition: transform 60ms linear; }
.elapsed { margin-left: auto; font-variant-numeric: tabular-nums; color: #355544; }

.memories { margin-top: 20px; }
.memories .panel-header { align-items: center; }
.memory-body { padding: 0 24px 20px; }
.memory-search, .memory-actions { display: flex; gap: 8px; }
.memory-search input, .memory-editor textarea { min-width: 0; width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: #fbfcf9; color: inherit; font: inherit; font-size: 14px; }
.memory-search input:focus-visible, .memory-editor textarea:focus-visible { outline: 2px solid #2f6f50; outline-offset: 2px; }
.memory-editor { margin-bottom: 14px; padding: 13px; border: 1px solid var(--border); border-radius: 11px; background: #f8faf6; }
.memory-editor label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 680; }
.memory-editor textarea { display: block; resize: vertical; }
.memory-type { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 12px; padding: 0; border: 0; }
.memory-type legend { margin-bottom: 6px; font-size: 13px; font-weight: 680; }
.memory-type label { position: relative; margin: 0; cursor: pointer; }
.memory-type input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: inherit; }
.memory-type span { display: block; padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fbfcf9; font-weight: 560; }
.memory-type input:checked + span { border-color: #88a995; background: #e9f2e9; color: #204733; }
.memory-type input:focus-visible + span { outline: 2px solid #2f6f50; outline-offset: 2px; }
.memory-type:disabled label { cursor: default; opacity: .75; }
.memory-attachment, .memory-drawing { margin-top: 12px; }
.memory-attachment-controls, .memory-canvas-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.memory-attachment input { max-width: 100%; font: inherit; font-size: 13px; }
.memory-attachment input::file-selector-button { margin-right: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 7px; background: #eef4ec; color: #204733; cursor: pointer; font: inherit; }
.memory-board { display: block; width: min(100%, 720px); height: auto; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
#memory-canvas { touch-action: none; cursor: crosshair; }
.memory-canvas-tools { margin-top: 8px; }
.memory-editor .memory-canvas-analysis { display: flex; align-items: start; gap: 6px; margin: 8px 0 0; font-weight: 500; }
.memory-canvas-analysis input { margin: 2px 0 0; accent-color: var(--green); }
#memory-media-status { margin: 8px 0 0; }
.memory-actions { margin-top: 9px; }
.button.memory-save { background: var(--green); color: #fff; }
.button.memory-save:hover:not(:disabled) { background: #173f2f; }
.memory-action-status { margin: 0 0 10px; }
.memory-list { display: grid; gap: 0; margin: 12px 0 0; padding: 0; list-style: none; }
.memory-item { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--border); }
.memory-item > div { min-width: 0; }
.memory-item p { color: #273b30; font-size: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.memory-item small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.memory-item .button { min-height: 34px; padding: 6px 10px; }
.memory-item-controls { display: flex; flex-wrap: wrap; flex-shrink: 0; gap: 6px; }
.memory-item[data-asset-type] { align-items: flex-start; }
.memory-asset { display: grid; justify-items: start; gap: 6px; margin-top: 8px; }
.memory-asset img, #memory-file-preview img { display: block; max-width: 100%; max-height: 160px; border-radius: 8px; object-fit: contain; }
.memory-asset audio, #memory-file-preview audio { display: block; width: 280px; max-width: 100%; }
#memory-file-preview small { display: block; margin: 7px 0 4px; color: var(--muted); overflow-wrap: anywhere; }
.memory-asset details { max-width: 100%; }
.memory-asset details > summary { cursor: pointer; font-size: 13px; color: #2a5742; }
.memory-asset details > p, .memory-board-preview { margin-top: 4px; }
.memory-board-preview { width: min(100%, 300px); }
.button.memory-delete { border-color: #ecd5ca; background: #fbf6f3; color: #8c3e28; }
.button.memory-delete:hover:not(:disabled) { border-color: #c79783; background: #f6e9e3; }

.results { margin-top: 20px; }
.results .panel-header { align-items: center; }
.results a { color: #255c44; text-underline-offset: 3px; }
.comparison { margin: 0 24px 14px; padding: 11px 13px; border-radius: 10px; background: #eaf3e9; color: #315842; line-height: 1.6; font-size: 13px; }
.runs-status { margin: 0 24px 15px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.table-scroll { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 650px; text-align: left; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 11px 13px; border-top: 1px solid #e7ebe4; vertical-align: top; }
th:first-child, td:first-child { padding-left: 24px; }
th:last-child, td:last-child { padding-right: 24px; }
th { background: #f7f9f5; color: #506258; font-size: 12px; font-weight: 650; white-space: nowrap; }
td small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.run-mode { font-weight: 690; }
.cost-detail { margin-top: 4px; color: var(--muted); font-size: 11px; min-width: 140px; }
.cost-detail summary { cursor: pointer; width: fit-content; }
.cost-detail ul { margin: 4px 0; padding-left: 14px; line-height: 1.5; }
.usage-json { max-height: 180px; max-width: 210px; overflow: auto; padding: 7px; border-radius: 5px; background: #edf1ec; font-size: 10px; }
.metric-note { padding: 11px 24px 19px; color: var(--muted); font-size: 12px; line-height: 1.5; }

@media (max-width: 760px) {
  .shell { width: min(100% - 32px, 540px); padding-top: 26px; }
  .masthead { gap: 12px; margin-bottom: 21px; }
  .brand-icon { width: 46px; border-radius: 13px; }
  .workspace { grid-template-columns: 1fr; gap: 14px; }
  .setup, .panel-header { padding: 18px; }
  .transcript { height: 310px; padding: 14px 18px; }
  .conversation { min-height: auto; }
  .chat-composer { padding-right: 18px; padding-left: 18px; }
  .conversation-footer { padding: 0 18px; }
  .memories { margin-top: 14px; }
  .memory-body { padding-right: 18px; padding-left: 18px; }
  .memory-item[data-asset-type] { flex-direction: column; gap: 8px; }
  .memory-item[data-asset-type] > div { max-width: 100%; }
  .results { margin-top: 14px; }
  .results .panel-header { align-items: flex-start; }
  .comparison, .runs-status { margin-left: 18px; margin-right: 18px; }
  .metric-note { padding-left: 18px; padding-right: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
