* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif; color: #1a1a2e; background: #f5f7fa; }

/* Header - CATL blue style */
header { background: #fff; border-bottom: 3px solid #1a5fb4; padding: 0; }
.hero { max-width: 1240px; margin: 0 auto; padding: 28px clamp(18px, 4vw, 54px) 24px; display: grid; grid-template-columns: 1.4fr .6fr; gap: 24px; align-items: start; }
.hero-main { padding: 0; }
.eyebrow { color: #1a5fb4; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; }
h1 { margin: 8px 0 12px; font-size: clamp(26px, 3.8vw, 46px); color: #0d1b3e; font-weight: 800; line-height: 1.25; }
.lead { margin: 0; color: #5a6578; font-size: 15px; line-height: 1.7; }
.hero-side { background: #f8fafd; border: 1px solid #e2e8f0; border-radius: 12px; padding: 20px; }
.formula { background: #0d1b3e; color: #e8edf5; border-radius: 10px; padding: 16px; font-family: "SF Mono", Consolas, "PingFang SC", monospace; font-size: 12px; line-height: 1.7; }
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.tag { padding: 5px 12px; border-radius: 6px; background: #e8f0fe; color: #1a5fb4; font-size: 12px; font-weight: 700; border: 1px solid #d0ddf9; }

/* Main layout */
main { max-width: 1240px; margin: 0 auto; padding: 20px clamp(18px, 4vw, 54px) 40px; display: grid; gap: 16px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.tab-btn { border: 0; border-radius: 8px; padding: 10px 16px; font-weight: 700; cursor: pointer; background: transparent; color: #4a5568; font-size: 14px; transition: all .15s; }
.tab-btn:hover { background: #f0f4ff; color: #1a5fb4; }
.tab-btn.active { background: #1a5fb4; color: #fff; box-shadow: 0 1px 4px rgba(26,95,180,.25); }

/* Scene panels */
.scene { display: none; gap: 16px; }
.scene.active { display: grid; }
.grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }
section { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.03); min-width: 0; }
h2 { margin: 0 0 12px; font-size: 18px; color: #0d1b3e; font-weight: 800; }
label { display: block; font-size: 12px; font-weight: 700; color: #4a5568; margin: 10px 0 6px; text-transform: uppercase; letter-spacing: .5px; }
textarea, input, select { width: 100%; border: 1px solid #dce3eb; border-radius: 8px; padding: 10px 12px; font: 14px/1.5 Inter, sans-serif; color: #1a1a2e; background: #fff; transition: border-color .15s; }
textarea:focus, input:focus, select:focus { outline: none; border-color: #1a5fb4; box-shadow: 0 0 0 3px rgba(26,95,180,.08); }
textarea { min-height: 140px; resize: vertical; font-family: "SF Mono", Consolas, "PingFang SC", monospace; font-size: 13px; }
.inputs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.inputs.two { grid-template-columns: repeat(2, 1fr); }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
button { border: 0; border-radius: 8px; padding: 10px 16px; font-weight: 700; cursor: pointer; background: #1a5fb4; color: #fff; font-size: 13px; transition: all .15s; }
button:hover { background: #144a94; box-shadow: 0 2px 8px rgba(26,95,180,.2); }
button.secondary { background: #f0f4ff; color: #1a5fb4; border: 1px solid #d0ddf9; }
button.secondary:hover { background: #e0e8fb; }
button.warn { background: #c45c2c; }
button.warn:hover { background: #a3481f; }

/* Results */
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.metric { background: #f8fafd; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px; min-height: 80px; }
.metric b { display: block; font-size: 11px; color: #718096; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.metric strong { font-size: 20px; color: #0d1b3e; word-break: break-word; }
.metric small { display: block; margin-top: 4px; color: #718096; font-size: 11px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; }
th, td { border-bottom: 1px solid #e8ecf1; padding: 8px 6px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: #1a5fb4; background: #f5f8fd; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.note { background: #f0f6ff; border: 1px solid #c5d5f5; border-radius: 8px; padding: 10px 12px; color: #1a3a6e; font-size: 12px; line-height: 1.6; margin-bottom: 12px; }
.note.blue { background: #f0f6ff; border-color: #c5d5f5; color: #1a3a6e; }
.error { color: #c53030; background: #fff5f5; border: 1px solid #feb2b2; border-radius: 8px; padding: 10px 12px; display: none; font-size: 13px; }
footer { color: #718096; font-size: 11px; padding: 20px 0 30px; }

/* Plot */
.plot { width: 100% !important; height: 340px; overflow: hidden !important; }
.plot .js-plotly-plot,
.plot .plotly,
.plot .svg-container { width: 100% !important; }

/* Sidebar chat → floating widget */
.app-layout { display: block; min-height: 100vh; }
.app-main { }

/* FAB toggle button */
#ma-fab { position: fixed; bottom: 24px; right: 24px; z-index: 1000;
  width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer;
  background: #1a5fb4; color: #fff; box-shadow: 0 4px 16px rgba(26,95,180,.35);
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s, box-shadow .2s; }
#ma-fab:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(26,95,180,.5); }
#ma-fab svg { width: 22px; height: 22px; }
#ma-fab.hidden { display: none; }

/* Floating chat panel */
#ma-sidebar { position: fixed; bottom: 88px; right: 24px; z-index: 999;
  width: 380px; max-height: 520px; background: #fff; border: 1px solid #e2e8f0;
  border-radius: 14px; box-shadow: 0 8px 32px rgba(0,0,0,.12);
  display: flex; flex-direction: column; overflow: hidden;
  transition: opacity .2s, transform .2s; }
#ma-sidebar.collapsed { opacity: 0; transform: translateY(12px) scale(.96); pointer-events: none; }
#ma-head { background: linear-gradient(135deg, #1a5fb4 0%, #0d3a7a 100%); color: #fff; padding: 14px 16px; flex-shrink: 0; display: flex; justify-content: space-between; align-items: flex-start; }
#ma-head-text strong { font-size: 14px; font-weight: 800; display: block; }
#ma-head-text small { font-size: 11px; opacity: .75; margin-top: 2px; display: block; }
#ma-close { border: 0; background: rgba(255,255,255,.18); color: #fff; border-radius: 6px; width: 28px; height: 28px; cursor: pointer; font-size: 16px; line-height: 1; padding: 0; flex-shrink: 0; margin-left: 8px; }
#ma-close:hover { background: rgba(255,255,255,.3); }
#ma-msgs { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; font-size: 13px; line-height: 1.6; }
.ma-msg { border-radius: 10px; padding: 10px 13px; white-space: normal; word-break: break-word; }
.ma-msg p { margin: 0 0 6px; }
.ma-msg p:last-child { margin-bottom: 0; }
.ma-msg ul, .ma-msg ol { margin: 4px 0; padding-left: 18px; }
.ma-msg li { margin: 2px 0; }
.ma-msg table { border-collapse: collapse; margin: 6px 0; font-size: 12px; width: 100%; }
.ma-msg th, .ma-msg td { border: 1px solid #c5cdd8; padding: 4px 8px; text-align: left; }
.ma-msg th { background: #e8edf5; font-weight: 600; }
.ma-msg code { background: rgba(0,0,0,.07); padding: 1px 4px; border-radius: 3px; font-size: 12px; }
.ma-msg pre { background: #1e293b; color: #e2e8f0; padding: 8px 12px; border-radius: 6px; overflow-x: auto; font-size: 12px; margin: 6px 0; }
.ma-msg pre code { background: none; padding: 0; }
.ma-msg strong { font-weight: 600; }
.ma-msg hr { border: none; border-top: 1px solid #dce3f0; margin: 8px 0; }
.ma-bot { background: #f0f4ff; color: #1a2744; border: 1px solid #dce3f0; }
.ma-user { background: #1a5fb4; color: #fff; align-self: flex-end; }
.ma-typing { color: #718096; font-style: italic; font-size: 12px; }
.ma-recommend { background: #fff9f0; border: 1px solid #f5e0b8; cursor: pointer; }
.ma-reasoning { color: #8896a8; font-size: 11px; line-height: 1.55; background: #fafbfc; border: 1px dashed #dce3eb; }
.ma-reasoning summary { cursor: pointer; color: #5a6578; font-weight: 600; font-size: 11px; user-select: none; }
.ma-reasoning[open] summary { margin-bottom: 8px; }
#ma-input-row { padding: 10px 14px; border-top: 1px solid #e2e8f0; display: flex; gap: 8px; flex-shrink: 0; background: #fff; }
#ma-input { flex: 1; border: 1px solid #dce3eb; border-radius: 999px; padding: 9px 14px; font-size: 13px; outline: none; }
#ma-input:focus { border-color: #1a5fb4; }
#ma-send { background: #1a5fb4; color: #fff; border: none; border-radius: 999px; width: 34px; height: 34px; cursor: pointer; flex-shrink: 0; }
#ma-send:hover { background: #144a94; }

/* ========== View routing ========== */
.view { }
.view:not(.active) { display: none !important; }

/* ========== Landing Page ========== */
.landing-hero { text-align: center; padding: 48px 18px 36px; }
.landing-hero h1 { font-size: clamp(28px, 4vw, 48px); margin-bottom: 14px; }
.landing-hero .lead { font-size: 16px; max-width: 640px; margin: 0 auto; }
.landing-main { max-width: 900px; margin: 0 auto; padding: 0 clamp(18px, 4vw, 54px) 40px; display: grid; gap: 28px; }

.landing-goal { background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 24px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.landing-goal h2 { font-size: 20px; text-align: center; margin-bottom: 16px; }
.landing-goal-input { text-align: left; }
.landing-goal-input textarea { width: 100%; border: 1px solid #dce3eb; border-radius: 10px; padding: 12px 14px; font-size: 14px; resize: vertical; min-height: 80px; }

.landing-quick-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: center; font-size: 12px; color: #718096; }
.tag-btn { background: #f0f4ff; color: #1a5fb4; border: 1px solid #d0ddf9; border-radius: 20px; padding: 6px 14px; font-size: 12px; font-weight: 600; cursor: pointer; transition: all .15s; }
.tag-btn:hover { background: #dce6f9; }

.landing-optional { margin-top: 14px; }
.opt-label { font-size: 12px; font-weight: 600; color: #718096; text-transform: none; letter-spacing: 0; display: block; }
.opt-row { display: flex; gap: 8px; margin-top: 6px; }
.opt-row input, .opt-row select { width: auto; font-size: 13px; padding: 8px 10px; }

.landing-cta { display: inline-block; padding: 14px 36px; font-size: 16px; font-weight: 800; margin-top: 16px; border-radius: 12px; background: linear-gradient(135deg, #1a5fb4 0%, #0d3a7a 100%); color: #fff; border: 0; cursor: pointer; transition: all .2s; box-shadow: 0 4px 16px rgba(26,95,180,.3); }
.landing-cta:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(26,95,180,.4); }

.landing-entries { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.landing-card { background: #fff; border: 2px solid #e2e8f0; border-radius: 14px; padding: 24px; cursor: pointer; transition: all .2s; text-align: center; }
.landing-card:hover { border-color: #1a5fb4; box-shadow: 0 4px 16px rgba(26,95,180,.12); transform: translateY(-2px); }
.landing-card-primary { border-color: #1a5fb4; background: #f8faff; }
.landing-card-icon { font-size: 36px; margin-bottom: 10px; }
.landing-card h3 { margin: 0 0 10px; font-size: 17px; color: #0d1b3e; }
.landing-card p { margin: 0 0 12px; font-size: 13px; color: #5a6578; line-height: 1.7; }
.landing-card-cta { font-weight: 700; color: #1a5fb4; font-size: 13px; }

.landing-cases { text-align: center; }
.landing-cases h2 { text-align: center; margin-bottom: 16px; }
.landing-case-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.landing-case-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 18px 14px; cursor: pointer; transition: all .2s; text-align: center; }
.landing-case-card:hover { border-color: #1a5fb4; box-shadow: 0 2px 12px rgba(26,95,180,.1); }
.landing-case-card.demo-entry { border-style: dashed; border-color: #c5d5f5; background: #fafbff; }
.case-icon { font-size: 28px; margin-bottom: 8px; }
.landing-case-card h4 { margin: 0 0 8px; font-size: 14px; color: #0d1b3e; }
.landing-case-card p { margin: 0 0 10px; font-size: 12px; color: #5a6578; line-height: 1.6; }
.case-link { font-size: 12px; font-weight: 700; color: #1a5fb4; }

/* ========== Guided Workflow ========== */
.guide-header { background: #fff; border-bottom: 1px solid #e2e8f0; padding: 0; }
.guide-header-row { max-width: 900px; margin: 0 auto; padding: 14px clamp(18px, 4vw, 36px); display: flex; align-items: center; justify-content: space-between; }
.guide-header-row h2 { margin: 0; font-size: 18px; }
.guide-back, .demo-back { border: 0; background: transparent; color: #1a5fb4; font-weight: 700; cursor: pointer; font-size: 13px; padding: 6px 10px; border-radius: 6px; }
.guide-back:hover, .demo-back:hover { background: #f0f4ff; }
.guide-steps { max-width: 900px; margin: 0 auto; padding: 0 clamp(18px, 4vw, 36px) 12px; display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: #a0aec0; }
.guide-step { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; transition: all .2s; }
.guide-step.active { color: #1a5fb4; background: #f0f4ff; }
.guide-step.done { color: #38a169; }
.step-num { font-weight: 800; }
.guide-step-arrow { color: #cbd5e0; }

.guide-main { max-width: 900px; margin: 0 auto; padding: 20px clamp(18px, 4vw, 36px) 40px; }
.guide-panel { }
.guide-model-badge { display: inline-block; background: #1a5fb4; color: #fff; padding: 6px 16px; border-radius: 20px; font-size: 12px; font-weight: 700; margin-bottom: 16px; }
.guide-chat { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px; min-height: 200px; max-height: 400px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; font-size: 14px; line-height: 1.7; }
.guide-chat .ma-msg { font-size: 14px; }
.guide-chat-input { display: flex; gap: 10px; margin-top: 12px; }
.guide-chat-input textarea { flex: 1; min-height: 52px; resize: vertical; border-radius: 10px; }
.guide-chat-input button { flex-shrink: 0; align-self: flex-end; }
.guide-step-actions { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; }
.guide-data-attrs { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 10px; }
.guide-data-attrs label { margin: 0; }
.guide-data-attrs select, .guide-data-attrs input { font-size: 13px; }
.guide-report { background: #fff9f0; border: 1px solid #f5e0b8; border-radius: 12px; padding: 20px; margin-top: 16px; }
.guide-report h3 { margin-top: 0; }
.guide-report table { background: #fff; border-radius: 8px; overflow: hidden; }
.report-table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; font-size: 14px; }
.report-table th, .report-table td { padding: 8px 12px; border-bottom: 1px solid #eee; text-align: left; }
.report-table th { background: #f8f8f8; font-weight: 600; color: #555; }
.report-table .row-recommended { background: #e8f5e9; font-weight: 600; }
.report-table .row-current { background: #e3f2fd; }
.report-table .row-recommended td:first-child::before { content: '⭐ '; }

/* ========== Auto Demo ========== */
.demo-header { background: #0d1b3e; color: #fff; padding: 0; }
.demo-header > .demo-back { color: rgba(255,255,255,.8); }
.demo-header > .demo-back:hover { background: rgba(255,255,255,.1); color: #fff; }
.demo-header h2 { color: #fff; margin: 0; font-size: 17px; }
.demo-header { display: flex; align-items: center; gap: 16px; padding: 12px clamp(18px, 4vw, 36px); }
.demo-controls-top { margin-left: auto; display: flex; gap: 8px; }
.demo-controls-top button { font-size: 12px; padding: 6px 12px; }

.demo-main { max-width: 900px; margin: 0 auto; padding: 20px clamp(18px, 4vw, 36px) 40px; }
.demo-progress { height: 4px; background: #e2e8f0; border-radius: 2px; margin-bottom: 16px; overflow: hidden; }
.demo-progress-bar { height: 100%; background: linear-gradient(90deg, #1a5fb4, #38a169); border-radius: 2px; transition: width .5s; width: 0; }
.demo-step-indicator { text-align: center; font-size: 13px; color: #718096; margin-bottom: 16px; font-weight: 600; }
.demo-content { background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 24px; min-height: 300px; box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.demo-content .ma-msg { font-size: 14px; max-width: 80%; }
.demo-content .ma-bot { margin-right: auto; }
.demo-content .ma-user { margin-left: auto; text-align: right; }
.demo-content .demo-done { text-align: center; padding: 40px 0; }
.demo-content .demo-done h3 { font-size: 22px; margin-bottom: 10px; }

/* ========== LLM API Settings ========== */
#llm-settings-btn {
  position: fixed; top: 12px; right: 12px; z-index: 9999;
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid #dce3eb;
  background: #fff; color: #4a5568; font-size: 20px; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.08); display: flex;
  align-items: center; justify-content: center; transition: all .15s;
}
#llm-settings-btn:hover { background: #f0f4ff; color: #1a5fb4; border-color: #1a5fb4; }

#llm-settings-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 10000;
  background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center;
}
.llm-settings-modal {
  background: #fff; border-radius: 14px; box-shadow: 0 8px 40px rgba(0,0,0,.15);
  width: 400px; max-width: calc(100vw - 32px); overflow: hidden;
}
.llm-settings-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid #e2e8f0;
}
.llm-settings-head h3 { margin: 0; font-size: 16px; color: #0d1b3e; }
#llm-settings-close {
  border: 0; background: transparent; font-size: 22px; color: #718096;
  cursor: pointer; padding: 0 4px; line-height: 1;
}
#llm-settings-close:hover { color: #1a1a2e; }
.llm-settings-body { padding: 20px; display: grid; gap: 14px; }
.llm-settings-body label { margin: 0; }
.llm-settings-body input { font-size: 14px; }
.llm-settings-actions {
  display: flex; gap: 10px; padding: 14px 20px; border-top: 1px solid #e2e8f0;
  justify-content: flex-end;
}
@media (max-width: 920px) {
  .hero, .grid { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .inputs { grid-template-columns: 1fr; }
  #ma-sidebar { width: calc(100vw - 32px); right: 16px; max-height: 60vh; }
  .landing-entries, .landing-case-grid { grid-template-columns: 1fr 1fr; }
  .landing-case-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .landing-entries, .landing-case-grid { grid-template-columns: 1fr; }
}