:root {
  --paper: #f5f1e8;
  --paper-deep: #ebe4d7;
  --ink: #21231f;
  --muted: #77776f;
  --line: rgba(33, 35, 31, .14);
  --sage: #7e9b89;
  --sage-deep: #466453;
  --coral: #de765d;
  --cream: #fffdf8;
  --shadow: 0 18px 50px rgba(48, 50, 42, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--paper); color: var(--ink); }
body { font-family: "Manrope", "PingFang SC", sans-serif; }
button, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; background: radial-gradient(circle at 78% 0%, rgba(208, 223, 204, .6), transparent 34%), var(--paper); }
.topbar { height: 76px; padding: 0 4.5vw; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand-mark { display: flex; gap: 9px; align-items: center; font-family: "Noto Serif SC", serif; font-size: 21px; font-weight: 700; letter-spacing: .02em; }
.brand-mark small { margin-left: 4px; color: var(--muted); font: 500 9px "DM Mono", monospace; letter-spacing: .14em; }
.brand-dot { display: inline-block; width: 13px; height: 13px; border-radius: 50%; background: var(--coral); box-shadow: 5px -3px 0 var(--sage); }
.topbar-meta { display: flex; align-items: center; gap: 9px; color: var(--muted); font: 500 11px "DM Mono", monospace; letter-spacing: .06em; text-transform: uppercase; }
.live-dot, .status-pill i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: var(--sage-deep); box-shadow: 0 0 0 4px rgba(70, 100, 83, .12); }
.divider { width: 1px; height: 14px; background: var(--line); margin: 0 5px; }
.clear-button { border: 0; background: transparent; color: var(--ink); font-weight: 700; font-size: 12px; padding: 10px 0 10px 14px; }
.clear-button span { margin-left: 5px; color: var(--coral); font-size: 17px; }

.workspace { flex: 1; width: min(1400px, 91vw); margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1.42fr) minmax(330px, .58fr); gap: 5vw; padding: 6.5vh 0 4vh; }
.conversation-panel { min-height: 650px; display: flex; flex-direction: column; }
.intro-block { max-width: 700px; }
.eyebrow { margin: 0 0 15px; color: var(--sage-deep); font: 500 10px "DM Mono", monospace; letter-spacing: .18em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 21px; font: 600 clamp(42px, 5.1vw, 75px)/.99 "Noto Serif SC", serif; letter-spacing: -.045em; }
h1 em { color: var(--coral); font-style: normal; position: relative; }
h1 em::after { content: ""; position: absolute; left: 0; right: 0; bottom: -5px; height: 6px; background: rgba(126, 155, 137, .35); transform: rotate(-1.5deg); z-index: -1; }
.intro-copy { max-width: 580px; color: #5f625b; font-size: 14px; line-height: 1.85; }
.intro-rules { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.intro-rules span { padding: 7px 10px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font: 11px "DM Mono", monospace; }

.chat-list { flex: 1; padding: 44px 0 22px; display: flex; flex-direction: column; gap: 19px; }
.welcome-message { max-width: 580px; padding: 20px 22px; background: rgba(255, 253, 248, .72); border: 1px solid rgba(126, 155, 137, .24); border-left: 3px solid var(--sage); box-shadow: var(--shadow); }
.welcome-kicker { margin-bottom: 8px; color: var(--sage-deep); font: 500 10px "DM Mono", monospace; letter-spacing: .13em; text-transform: uppercase; }
.message-row { display: flex; gap: 13px; align-items: flex-start; animation: rise .35s ease both; }
.message-row.user { justify-content: flex-end; }
.avatar { flex: 0 0 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--sage-deep); color: white; font: 700 11px "DM Mono", monospace; }
.message-row.user .avatar { order: 2; background: var(--coral); }
.bubble { max-width: min(650px, 82%); padding: 14px 17px; border-radius: 2px 14px 14px 14px; background: rgba(255, 253, 248, .8); border: 1px solid var(--line); font-size: 14px; line-height: 1.75; white-space: pre-wrap; }
.message-row.user .bubble { border-radius: 14px 2px 14px 14px; background: var(--ink); color: #fbf8ef; border-color: var(--ink); }
.message-meta { margin: 5px 3px 0; color: var(--muted); font: 10px "DM Mono", monospace; }
.pending-content { min-width: min(100%, 420px); }
.progress-chain { display: flex; flex-wrap: wrap; gap: 6px 10px; margin: 8px 3px 0; }
.progress-step { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font: 10px "DM Mono", monospace; }
.progress-step i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.progress-step.active, .progress-step.streaming { color: var(--sage-deep); }
.progress-step.active i, .progress-step.streaming i { background: var(--coral); animation: pulse 1s ease-in-out infinite; }
.progress-step.done i { background: var(--sage-deep); }
.progress-step.fallback { color: #876f33; }
.progress-step.fallback i { background: #c49c42; }
.welcome-title { margin-bottom: 8px; font-weight: 800; }
.welcome-message > p { margin-bottom: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.welcome-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 17px; }
.welcome-choice { min-width: 0; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 9px; align-items: center; padding: 11px 12px; border: 1px solid rgba(70, 100, 83, .24); background: rgba(255, 253, 248, .72); color: var(--ink); text-align: left; transition: transform .2s ease, border-color .2s ease, background .2s ease; }
.welcome-choice:hover, .welcome-choice:focus-visible { border-color: var(--sage-deep); background: #e7eee8; transform: translateY(-2px); outline: 0; }
.welcome-choice span { grid-row: 1 / span 2; color: var(--coral); font: 500 10px "DM Mono", monospace; }
.welcome-choice strong { font-size: 12px; }
.welcome-choice small { color: var(--muted); font-size: 10px; line-height: 1.4; }

.result-stack { margin: 2px 0 4px 41px; max-width: 730px; display: flex; flex-direction: column; gap: 11px; animation: rise .45s ease both; }
.recommendation-card { padding: 17px; border: 1px solid var(--line); background: rgba(255, 253, 248, .72); }
.recommendation-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.sku { color: var(--sage-deep); font: 500 10px "DM Mono", monospace; letter-spacing: .08em; }
.recommendation-card h3 { margin: 4px 0 4px; font: 700 16px "Noto Serif SC", serif; }
.recommendation-card .size { color: var(--muted); font-size: 11px; }
.price { color: var(--coral); font: 700 22px "DM Mono", monospace; white-space: nowrap; }
.feature-line { margin: 12px 0 0; color: #555950; font-size: 12px; line-height: 1.65; }
.reason-line { margin: 10px 0 0; padding-top: 10px; border-top: 1px dashed var(--line); color: var(--sage-deep); font-size: 12px; line-height: 1.65; }
.tradeoff-line { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.combo-total { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: var(--sage-deep); color: white; }
.combo-total small { opacity: .7; font: 10px "DM Mono", monospace; letter-spacing: .12em; }
.combo-total strong { font: 700 18px "DM Mono", monospace; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 5px 7px; background: var(--paper-deep); color: var(--muted); font: 10px "DM Mono", monospace; }
.tag.safety { background: #fae2db; color: #a44937; }
.tag.budget { background: #e6eee7; color: #47634f; }
.tag.confirm { background: #f2e9cf; color: #876f33; }
.handoff-card { display: grid; gap: 4px; padding: 13px 15px; border-left: 3px solid var(--coral); background: #fae2db; color: #7f3d2f; }
.handoff-card strong { font-size: 13px; }
.handoff-card span, .handoff-card small { font-size: 11px; line-height: 1.45; }
.handoff-card small { opacity: .8; }

.composer-wrap { margin-top: auto; padding-top: 12px; }
.quick-prompts { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.quick-prompts button { border: 1px solid var(--line); background: rgba(255, 253, 248, .45); color: #555950; border-radius: 99px; padding: 8px 11px; font-size: 11px; transition: .2s ease; }
.quick-prompts button:hover { border-color: var(--sage); background: #e7eee8; color: var(--sage-deep); }
.composer { display: flex; align-items: flex-end; gap: 10px; padding: 10px; border: 1px solid var(--ink); background: var(--cream); box-shadow: 8px 8px 0 rgba(126, 155, 137, .2); }
textarea { width: 100%; min-height: 28px; max-height: 130px; resize: none; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 14px; line-height: 1.55; padding: 6px 5px; }
.send-button { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 11px 13px; border: 0; background: var(--coral); color: white; font-weight: 800; font-size: 12px; }
.send-button b { font-size: 17px; line-height: 1; }
.send-button:disabled { cursor: wait; opacity: .55; }
.retry-button { margin-top: 9px; padding: 6px 9px; border: 1px solid var(--line); background: var(--cream); color: var(--sage-deep); font-size: 11px; }
.composer-note { display: flex; justify-content: space-between; margin-top: 10px; color: var(--muted); font: 10px "DM Mono", monospace; }
.model-switcher { display: flex; align-items: center; gap: 8px; margin-top: 9px; color: var(--muted); font: 10px "DM Mono", monospace; }
.model-switcher select { max-width: 240px; border: 1px solid var(--line); background: var(--cream); color: var(--ink); padding: 5px 8px; font: inherit; }
.model-switcher span { color: var(--sage-deep); }
.live-dot.offline { background: var(--coral); box-shadow: 0 0 0 4px rgba(222, 118, 93, .12); }

.insight-panel { padding-top: 16px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; padding-bottom: 23px; border-bottom: 1px solid var(--line); }
h2 { margin: 0; font: 600 25px "Noto Serif SC", serif; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 7px 9px; border: 1px solid var(--line); color: var(--sage-deep); font: 10px "DM Mono", monospace; }
.state-card, .trace-card, .source-card { border-bottom: 1px solid var(--line); padding: 20px 0; }
.state-card-top, .card-title { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 11px; }
.mono, .source-count { font: 10px "DM Mono", monospace; letter-spacing: .08em; }
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 15px; }
.profile-item { min-height: 47px; padding: 9px; background: rgba(235, 228, 215, .64); }
.profile-item label { display: block; margin-bottom: 4px; color: var(--muted); font: 9px "DM Mono", monospace; text-transform: uppercase; }
.profile-item strong { font-size: 12px; }
.muted { color: var(--muted); font-size: 12px; }
.trace-list { margin-top: 15px; display: flex; flex-direction: column; gap: 11px; }
.trace-item { display: grid; grid-template-columns: 17px 1fr auto; gap: 9px; align-items: center; font-size: 11px; }
.trace-icon { width: 15px; height: 15px; display: grid; place-items: center; border: 1px solid var(--sage); border-radius: 50%; color: var(--sage-deep); font: 9px "DM Mono", monospace; }
.trace-item.waiting .trace-icon { border-color: var(--line); color: var(--muted); }
.trace-detail { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.trace-status { color: var(--sage-deep); font: 9px "DM Mono", monospace; }
.trace-item.waiting .trace-status { color: var(--muted); }
.source-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.source-item { padding: 9px 10px; border-left: 2px solid var(--sage); background: rgba(255, 253, 248, .5); color: #5b6059; font-size: 11px; line-height: 1.5; }
.guardrail-card { display: flex; gap: 11px; margin-top: 22px; padding: 14px; background: #e7eee8; }
.guardrail-icon { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--sage-deep); color: white; font-weight: 800; }
.guardrail-card strong { font-size: 12px; }
.guardrail-card p { margin: 4px 0 0; color: #5a6d5e; font-size: 11px; line-height: 1.55; }
.footer { width: min(1400px, 91vw); margin: 0 auto; padding: 20px 0 27px; display: flex; justify-content: space-between; color: var(--muted); font: 10px "DM Mono", monospace; border-top: 1px solid var(--line); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 50% { opacity: .35; transform: scale(.75); } }
@media (max-width: 900px) {
  .topbar { padding: 0 6vw; }
  .topbar-meta { display: none; }
  .workspace { width: 88vw; grid-template-columns: 1fr; gap: 30px; padding-top: 6vh; }
  .insight-panel { padding-top: 0; }
  .conversation-panel { min-height: 0; }
  .chat-list { min-height: 180px; }
  .footer { width: 88vw; gap: 16px; flex-direction: column; }
}
@media (max-width: 520px) {
  .brand-mark small { display: none; }
  h1 { font-size: 45px; }
  .workspace { width: 90vw; }
  .result-stack { margin-left: 0; }
  .message-row .avatar { display: none; }
  .bubble { max-width: 100%; }
  .recommendation-top { flex-direction: column; gap: 4px; }
  .welcome-options { grid-template-columns: 1fr; }
  .quick-prompts { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .quick-prompts button { white-space: nowrap; }
}
