:root {
  --ink: #14211b;
  --muted: #637169;
  --paper: #f2f0e9;
  --surface: #fffefa;
  --line: #d9ddd7;
  --green: #176b4d;
  --green-dark: #0e4935;
  --sun: #f2c14e;
  --error: #a33a2b;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--paper); color: var(--ink); font-family: "Segoe UI", "Microsoft YaHei", sans-serif; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(255,254,250,.92); }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; background: var(--green); color: white; font: 700 15px Georgia, serif; }
.brand strong, .brand small { display: block; }
.brand strong { font: 700 16px Georgia, "Times New Roman", serif; letter-spacing: .02em; }
.brand small { color: var(--muted); margin-top: 2px; font-size: 11px; }
.status { color: var(--muted); font-size: 13px; }
.status span { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #4ca975; box-shadow: 0 0 0 4px #ddefe5; }
.workspace { display: grid; grid-template-columns: minmax(340px, 42%) 1fr; height: calc(100vh - 72px); }
.chat-panel { display: grid; grid-template-rows: auto minmax(120px, 1fr) auto; min-width: 0; padding: 38px 38px 24px; border-right: 1px solid var(--line); background: var(--surface); }
.panel-heading { max-width: 580px; }
.eyebrow { margin: 0 0 10px !important; color: var(--green) !important; font-weight: 700; text-transform: uppercase; letter-spacing: .18em; font-size: 11px !important; }
.panel-heading h1 { margin: 0; font: 500 clamp(32px, 4vw, 56px)/1.02 Georgia, "STSong", serif; letter-spacing: -.035em; }
.panel-heading > p { margin: 16px 0 18px; max-width: 500px; color: var(--muted); font-size: 14px; line-height: 1.75; }
.messages { overflow-y: auto; padding: 8px 4px 14px 0; scrollbar-width: thin; }
.message { display: grid; grid-template-columns: 34px 1fr; gap: 10px; max-width: 94%; margin: 12px 0; }
.message > span { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--line); color: var(--green); font-weight: 700; font-size: 11px; }
.message p { margin: 0; padding: 11px 14px; background: #edf4ef; line-height: 1.65; font-size: 14px; white-space: pre-wrap; }
.message.user { margin-left: auto; grid-template-columns: 1fr 34px; }
.message.user span { order: 2; color: var(--ink); }
.message.user p { background: var(--ink); color: white; }
.composer { padding-top: 16px; border-top: 1px solid var(--line); }
.composer label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12px; font-weight: 600; }
.composer textarea { width: 100%; resize: none; border: 1px solid #b9c2bb; background: white; padding: 13px 14px; color: var(--ink); font: inherit; line-height: 1.5; outline: none; }
.composer textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,107,77,.1); }
.composer-row { min-height: 45px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
#form-feedback { margin: 0; color: var(--error); font-size: 13px; }
.composer button { border: 0; padding: 12px 18px; background: var(--green); color: white; font: 600 13px inherit; cursor: pointer; }
.composer button:hover { background: var(--green-dark); }
.composer button:disabled { opacity: .65; cursor: wait; }
.composer button span { margin-left: 15px; }
.content-panel { min-width: 0; display: grid; grid-template-rows: 62px 1fr; padding: 16px; background: #e7e8e2; }
.content-bar { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 0 4px; }
.content-bar span, .content-bar strong { display: block; }
.content-bar span { color: var(--muted); font-size: 10px; letter-spacing: .15em; text-transform: uppercase; }
.content-bar strong { margin-top: 3px; font: 600 15px Georgia, serif; }
.content-bar a { color: var(--green); font-size: 12px; text-decoration: none; }
.content-panel iframe { width: 100%; height: 100%; border: 1px solid #cbd1ca; background: white; }
.debug-panel { position: fixed; right: 26px; bottom: 24px; z-index: 10; width: min(470px, calc(100vw - 52px)); background: #101b16; color: #d7eee2; box-shadow: 0 16px 48px rgba(0,0,0,.24); font: 12px Consolas, monospace; }
.debug-panel[hidden] { display: none; }
.debug-panel header { display: flex; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid #2d4639; }
.debug-panel header strong { color: var(--sun); letter-spacing: .12em; }
.debug-panel header span { color: #789486; }
.debug-panel dl { display: grid; grid-template-columns: 1fr 1fr; margin: 0; padding: 8px 14px 13px; gap: 0 18px; }
.debug-panel dl > div { display: grid; grid-template-columns: 95px 1fr; padding: 6px 0; border-bottom: 1px solid #21382d; overflow: hidden; }
.debug-panel .usage-row { grid-column: 1 / -1; }
.debug-panel dt { color: #79998a; }
.debug-panel dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 850px) {
  .workspace { grid-template-columns: 1fr; height: auto; }
  .chat-panel { min-height: calc(100vh - 72px); padding: 28px 22px 20px; border-right: 0; }
  .content-panel { height: 75vh; }
  .status { display: none; }
}
