* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --bg: #f5f0eb;
    --bg-card: #faf7f4;
    --bg-alt: #f0ebe4;
    --bg-input: #ede8e1;
    --accent: #8b9e8b;
    --accent-dim: #8b9e8b20;
    --blue: #7b8caa;
    --blue-dim: #7b8caa20;
    --green: #7a9e7a;
    --red: #c47a7a;
    --orange: #c4a46a;
    --purple: #9a8baa;
    --text: #3d3529;
    --text2: #5a4e42;
    --text3: #99897a;
    --border: #ddd5cb;
    --border2: #ccc3b8;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(61,53,41,0.06);
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', sans-serif;
    background: var(--bg); color: var(--text); min-height: 100vh; line-height: 1.7;
}

/* ===== HEADER ===== */
.header {
    background: linear-gradient(135deg, #e8e0d6, #f0ebe4);
    border-bottom: 1px solid var(--border); padding: 16px 0;
    position: sticky; top: 0; z-index: 100;
    backdrop-filter: blur(10px);
}
.header-inner {
    max-width: 1100px; margin: 0 auto; padding: 0 24px;
    display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 700; color: var(--text); }
.logo-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--accent), var(--blue));
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-size: 18px; color: #fff;
}
.badge {
    font-size: 11px; background: var(--accent-dim); color: var(--accent);
    padding: 4px 12px; border-radius: 20px; font-weight: 600;
}

/* ===== CONTAINER & CARD ===== */
.container { max-width: 1100px; margin: 0 auto; padding: 28px 24px; }
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px; margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.card-title {
    font-size: 15px; font-weight: 700; margin-bottom: 18px;
    display: flex; align-items: center; gap: 8px; color: var(--text);
}

/* ===== QUESTION ===== */
.q-badge {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--accent); font-weight: 600;
    background: var(--accent-dim); padding: 5px 14px; border-radius: 20px; margin-bottom: 16px;
}
.lang-toggle {
    display: flex; gap: 3px; background: var(--bg-input);
    border-radius: 8px; padding: 3px; margin-bottom: 18px; width: fit-content;
}
.lang-btn {
    padding: 5px 14px; border: none; background: transparent;
    color: var(--text3); cursor: pointer; border-radius: 6px;
    font-size: 12px; font-weight: 500; transition: all 0.2s;
}
.lang-btn.active { background: var(--blue); color: white; }
.q-en { font-size: 14px; line-height: 1.8; margin-bottom: 14px; white-space: pre-wrap; }
.q-cn {
    font-size: 14px; line-height: 1.8; color: var(--text2);
    border-left: 3px solid var(--blue-dim); padding-left: 14px; white-space: pre-wrap;
}

/* ===== OPTIONS ===== */
.options { display: flex; flex-direction: column; gap: 10px; }
.opt {
    border: 1px solid var(--border); border-radius: 10px;
    padding: 14px 18px; cursor: pointer; transition: all 0.2s;
    display: flex; gap: 14px; align-items: flex-start; background: var(--bg-card);
}
.opt:hover { border-color: var(--blue); background: var(--blue-dim); }
.opt.selected { border-color: var(--accent); background: var(--accent-dim); }
.opt-letter {
    min-width: 34px; height: 34px; border-radius: 8px; background: var(--bg-input);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; color: var(--text3); transition: all 0.2s; flex-shrink: 0;
}
.opt.selected .opt-letter { background: var(--accent); color: #fff; }
.opt-body { flex: 1; }
.opt-en { font-size: 13px; line-height: 1.7; }
.opt-cn { font-size: 12px; color: var(--text2); margin-top: 6px; line-height: 1.7; }

/* ===== MINDMAP ===== */
.mm-templates {
    display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap;
}
.mm-tpl-label { font-size: 12px; color: var(--text3); font-weight: 600; }
.mm-tpl-btn {
    padding: 5px 12px; border: 1px solid var(--border); border-radius: 6px;
    background: var(--bg-card); color: var(--text2); font-size: 12px; font-weight: 500;
    cursor: pointer; transition: all 0.2s;
}
.mm-tpl-btn:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-dim); }
.mm-workspace { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 768px) { .mm-workspace { grid-template-columns: 1fr; } }
.mm-panel {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 10px; overflow: hidden; display: flex; flex-direction: column;
}
.mm-panel-head {
    padding: 8px 14px; background: var(--bg-alt); border-bottom: 1px solid var(--border);
    font-size: 11px; font-weight: 600; color: var(--text3);
    text-transform: uppercase; letter-spacing: 1px;
}
.mm-editor {
    width: 100%; min-height: 260px; padding: 14px; background: var(--bg-input);
    border: none; color: var(--text); font-family: 'SF Mono','Fira Code','Consolas',monospace;
    font-size: 13px; line-height: 1.8; resize: vertical; outline: none; tab-size: 4;
}
.mm-editor::placeholder { color: var(--text3); }
.mm-preview { padding: 14px; overflow: auto; min-height: 260px; max-height: 400px; }
.mm-preview .empty { color: var(--text3); font-size: 12px; text-align: center; padding: 60px 20px; }

/* ===== TREE ===== */
.tree ul { list-style: none; padding-left: 22px; position: relative; }
.tree > ul { padding-left: 0; }
.tree ul::before {
    content: ''; position: absolute; left: 7px; top: 0; bottom: 10px;
    width: 1px; background: var(--border2);
}
.tree > ul::before { display: none; }
.tree li { position: relative; padding: 2px 0; }
.tree ul > li::before {
    content: ''; position: absolute; left: -15px; top: 13px;
    width: 13px; height: 1px; background: var(--border2);
}
.tree .node {
    display: inline-block; background: var(--bg-alt); border: 1px solid var(--border);
    border-radius: 6px; padding: 2px 10px; font-size: 12px; max-width: 100%; word-wrap: break-word;
}
.tree .node.l0 {
    background: linear-gradient(135deg, var(--blue), #6a7b99);
    border-color: var(--blue); color: #fff; font-weight: 600;
}
.tree .node.l1 { border-color: var(--accent); background: var(--accent-dim); }
.tree .node.l2 { border-color: var(--orange); background: #c4a46a15; }

/* Auto-color by keyword */
.tree .node.kw-service { border-color: #7b8caa; background: #7b8caa18; }
.tree .node.kw-service::before { content: '☁️ '; }
.tree .node.kw-pro { border-color: var(--green); background: #7a9e7a15; }
.tree .node.kw-pro::before { content: '✅ '; }
.tree .node.kw-con { border-color: var(--red); background: #c47a7a12; }
.tree .node.kw-con::before { content: '⚠️ '; }
.tree .node.kw-cost { border-color: var(--orange); background: #c4a46a12; }
.tree .node.kw-cost::before { content: '💰 '; }
.tree .node.kw-security { border-color: var(--purple); background: #9a8baa15; }
.tree .node.kw-security::before { content: '🔒 '; }
.tree .node.kw-perf { border-color: #e06060; background: #e0606010; }
.tree .node.kw-perf::before { content: '⚡ '; }
.tree .node.kw-ha { border-color: #5b9bd5; background: #5b9bd512; }
.tree .node.kw-ha::before { content: '🔄 '; }

/* ===== BUTTONS ===== */
.btn-row { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; padding: 12px 0; }
.submit-btn {
    padding: 13px 36px; font-size: 15px; font-weight: 700; border: none; border-radius: 10px;
    cursor: pointer; background: linear-gradient(135deg, var(--accent), #7a9e7a);
    color: #fff; transition: all 0.3s;
}
.submit-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(139,158,139,0.3); }
.submit-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.zero-study-btn {
    padding: 13px 36px; font-size: 15px; font-weight: 700; border: 2px solid var(--orange);
    border-radius: 10px; cursor: pointer; background: transparent;
    color: var(--orange); transition: all 0.3s;
}
.zero-study-btn:hover { background: var(--orange); color: #fff; transform: translateY(-2px); }

/* ===== STREAMING ===== */
.stream-section { display: none; }
.stream-section.show { display: block; }
.stream-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.stream-status { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }
.stream-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.3; } }
.stream-timer { font-size: 20px; font-weight: 700; color: var(--accent); font-family: monospace; }
.stream-phase { font-size: 12px; color: var(--text3); margin-bottom: 10px; }
.thinking-box {
    background: #f9f5f0; border: 1px solid var(--border); border-radius: 8px;
    padding: 16px; font-family: 'SF Mono','Fira Code','Consolas',monospace;
    font-size: 12px; line-height: 1.7; color: var(--purple);
    max-height: 300px; overflow-y: auto; white-space: pre-wrap; word-wrap: break-word;
    margin-bottom: 12px;
}
.output-box {
    background: #f9f5f0; border: 1px solid var(--border); border-radius: 8px;
    padding: 16px; font-family: 'SF Mono','Fira Code','Consolas',monospace;
    font-size: 12px; line-height: 1.7; color: var(--accent);
    max-height: 200px; overflow-y: auto; white-space: pre-wrap; word-wrap: break-word;
}

/* ===== RESULTS ===== */
.results { display: none; animation: fadeUp 0.5s ease; }
.results.show { display: block; }
@keyframes fadeUp { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }
.res-header { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 20px; }
.answer-badge {
    display: flex; align-items: center; gap: 8px; padding: 10px 20px;
    border-radius: 10px; font-size: 16px; font-weight: 700;
}
.answer-badge.correct { background: #7a9e7a18; color: var(--green); border: 1px solid #7a9e7a30; }
.answer-badge.wrong { background: #c47a7a18; color: var(--red); border: 1px solid #c47a7a30; }
.score-ring { position: relative; width: 90px; height: 90px; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring circle { fill: none; stroke-width: 5; }
.score-bg { stroke: var(--border); }
.score-fill { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 1s ease; }
.score-text { position: absolute; top:50%; left:50%; transform: translate(-50%,-50%); text-align: center; }
.score-num { font-size: 22px; font-weight: 800; color: var(--accent); }
.score-lbl { font-size: 9px; color: var(--text3); text-transform: uppercase; }
.res-block {
    margin-bottom: 16px; padding: 18px; background: var(--bg-alt);
    border-radius: 10px; border: 1px solid var(--border);
}
.res-block-title {
    font-size: 13px; font-weight: 700; margin-bottom: 10px;
    display: flex; align-items: center; gap: 6px; color: var(--accent);
}
.res-block p, .res-block li { font-size: 13px; line-height: 1.8; color: var(--text2); }
.res-block ul { padding-left: 18px; }
.res-block li { margin-bottom: 4px; }
.tag-good { display:inline-block; background:#7a9e7a18; color:var(--green); padding:1px 7px; border-radius:4px; font-size:10px; font-weight:600; margin-right:4px; }
.tag-bad { display:inline-block; background:#c47a7a18; color:var(--red); padding:1px 7px; border-radius:4px; font-size:10px; font-weight:600; margin-right:4px; }
.tag-tip { display:inline-block; background:#c4a46a18; color:var(--orange); padding:1px 7px; border-radius:4px; font-size:10px; font-weight:600; margin-right:4px; }
.perfect-mm {
    background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px;
    padding: 14px; min-height: 60px; max-height: 400px; overflow: auto;
}
.import-mm-btn {
    margin-top: 12px; padding: 10px 20px; border: 2px dashed var(--purple);
    border-radius: 8px; background: transparent; color: var(--purple);
    font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s; width: 100%;
}
.import-mm-btn:hover { background: var(--purple); color: #fff; border-style: solid; }
.thinking-toggle {
    display: none; align-items: center; gap: 6px;
    font-size: 12px; color: var(--text3); cursor: pointer;
    padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border);
    background: transparent; transition: all 0.2s; margin-bottom: 16px;
}
.thinking-toggle:hover { border-color: var(--blue); color: var(--text2); }
.thinking-saved {
    display: none; background: #f9f5f0; border: 1px solid var(--border); border-radius: 8px;
    padding: 14px; font-family: monospace; font-size: 11px; line-height: 1.6;
    color: var(--purple); max-height: 300px; overflow-y: auto; white-space: pre-wrap;
    word-wrap: break-word; margin-bottom: 16px;
}
.thinking-saved.show { display: block; }
.error-box {
    display: none; background: #c47a7a18; border: 1px solid #c47a7a30;
    border-radius: 10px; padding: 16px 20px; color: var(--red); font-size: 13px; margin-bottom: 16px;
}
.error-box.show { display: block; }

/* ===== ZERO STUDY ===== */
.zero-study-section { display: none; }
.zero-study-section.show { display: block; }
.zero-step {
    border-left: 3px solid var(--border2); padding: 16px 20px; margin-bottom: 16px;
    background: var(--bg-card); border-radius: 0 10px 10px 0;
    box-shadow: var(--shadow); transition: border-color 0.3s;
}
.zero-step-header {
    display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.zero-step-num {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--blue); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.zero-step-title { font-size: 14px; font-weight: 700; color: var(--text); }
.zero-step-loading { font-size: 13px; color: var(--text3); }
.zero-user-question {
    background: var(--accent-dim); border: 1px solid var(--accent);
    border-radius: 8px; padding: 10px 14px; margin-bottom: 12px;
    font-size: 13px; color: var(--accent); font-weight: 500; line-height: 1.6;
}
.zero-step-content { margin-bottom: 12px; }
.zero-step-text { font-size: 13px; line-height: 1.8; color: var(--text2); }
.zero-content { font-size: 13px; line-height: 1.8; color: var(--text2); }
.zero-thinking {
    background: #f9f5f0; border: 1px solid var(--border); border-radius: 8px;
    padding: 12px; font-family: monospace; font-size: 11px; line-height: 1.6;
    color: var(--purple); max-height: 200px; overflow-y: auto; white-space: pre-wrap;
    word-wrap: break-word; margin-bottom: 10px;
}
.zero-step-actions {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.zero-btn {
    padding: 7px 16px; border-radius: 8px; font-size: 12px; font-weight: 600;
    cursor: pointer; transition: all 0.2s; border: 1px solid var(--border);
}
.zero-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.zero-btn-ok { background: var(--green); color: #fff; border-color: var(--green); }
.zero-btn-ok:hover { opacity: 0.85; }
.zero-btn-topic { background: var(--bg-card); color: var(--blue); border-color: var(--blue); }
.zero-btn-topic:hover { background: var(--blue); color: #fff; }
.zero-btn-ask { background: var(--orange); color: #fff; border-color: var(--orange); }
.zero-btn-ask:hover { opacity: 0.85; }
.zero-input-wrap {
    display: flex; gap: 8px; width: 100%; margin-top: 8px;
}
.zero-input {
    flex: 1; padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 13px; background: var(--bg-input); color: var(--text); outline: none;
    transition: border-color 0.2s;
}
.zero-input:focus { border-color: var(--blue); }
.zero-input::placeholder { color: var(--text3); }

/* ===== MARKDOWN RENDERED CONTENT ===== */
.md-h { color: var(--text); margin: 12px 0 6px 0; }
h2.md-h { font-size: 16px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
h3.md-h { font-size: 14px; }
h4.md-h { font-size: 13px; }
.md-p { font-size: 13px; line-height: 1.8; color: var(--text2); margin: 4px 0; }
.md-list { padding-left: 20px; margin: 6px 0; }
.md-list li { font-size: 13px; line-height: 1.8; color: var(--text2); margin-bottom: 2px; }
.md-inline-code {
    background: var(--bg-input); border: 1px solid var(--border); border-radius: 4px;
    padding: 1px 5px; font-family: 'SF Mono','Fira Code','Consolas',monospace;
    font-size: 12px; color: var(--accent);
}
.md-code-block {
    background: #2d2a24; border-radius: 8px; padding: 14px; margin: 8px 0;
    overflow-x: auto;
}
.md-code-block code {
    color: #e8dfd6; font-family: 'SF Mono','Fira Code','Consolas',monospace;
    font-size: 12px; line-height: 1.6;
}
.md-rendered strong { color: var(--text); font-weight: 700; }
.md-rendered em { color: var(--accent); font-style: italic; }

/* ===== STEP BY STEP ===== */
.step-study-btn {
    padding: 13px 36px; font-size: 15px; font-weight: 700; border: 2px solid var(--purple);
    border-radius: 10px; cursor: pointer; background: transparent;
    color: var(--purple); transition: all 0.3s;
}
.step-study-btn:hover { background: var(--purple); color: #fff; transform: translateY(-2px); }
.step-section { display: none; }
.step-section.show { display: block; animation: fadeUp 0.5s ease; }
.step-workspace { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 768px) { .step-workspace { grid-template-columns: 1fr; } }
.step-left { display: flex; flex-direction: column; }
.step-right {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 10px; overflow: hidden; display: flex; flex-direction: column;
}
.step-mm-preview { padding: 16px; overflow: auto; min-height: 300px; max-height: 500px; }
.step-card-active {
    background: var(--bg-alt); border: 1px solid var(--border);
    border-radius: 10px; padding: 20px; position: relative; overflow: hidden;
}
.step-progress {
    position: absolute; top: 0; left: 0; height: 3px;
    background: linear-gradient(90deg, var(--purple), var(--blue));
    transition: width 0.6s ease; width: 0%;
}
.step-title {
    font-size: 16px; font-weight: 700; color: var(--text);
    margin-bottom: 14px; display: flex; align-items: center; gap: 8px;
}
.step-guide { font-size: 13px; line-height: 1.8; color: var(--text2); margin-bottom: 18px; }
.step-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.step-nav-btn {
    padding: 8px 20px; border-radius: 8px; font-size: 13px; font-weight: 600;
    cursor: pointer; border: 1px solid var(--border); background: var(--bg-card);
    color: var(--text2); transition: all 0.2s;
}
.step-nav-btn:hover:not(:disabled) { border-color: var(--purple); color: var(--purple); }
.step-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.step-nav-next { background: var(--purple); color: #fff; border-color: var(--purple); }
.step-nav-next:hover:not(:disabled) { opacity: 0.85; color: #fff; }
.step-counter { font-size: 13px; color: var(--text3); font-weight: 600; }
.step-loading {
    padding: 20px 0;
}
.step-loading-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.step-loading-status {
    display: flex; align-items: center; gap: 10px;
    font-size: 14px; font-weight: 600; color: var(--text);
}
.step-loading-timer {
    font-size: 20px; font-weight: 700; color: var(--purple);
    font-family: monospace;
}
.step-loading-phases {
    display: flex; gap: 8px; margin-bottom: 20px;
}
.step-phase {
    flex: 1; background: var(--bg-alt); border: 1px solid var(--border);
    border-radius: 10px; padding: 14px 12px; text-align: center;
    opacity: 0.4; transition: all 0.5s ease;
}
.step-phase.active {
    opacity: 1; border-color: var(--purple);
    box-shadow: 0 0 12px rgba(154,139,170,0.2);
}
.step-phase.done {
    opacity: 1; border-color: var(--green);
    background: #7a9e7a08;
}
.step-phase-icon {
    font-size: 24px; margin-bottom: 6px;
}
.step-phase-text {
    font-size: 11px; font-weight: 600; color: var(--text2);
    white-space: nowrap;
}
.step-phase-bar {
    height: 3px; background: var(--border); border-radius: 2px;
    margin-top: 8px; overflow: hidden;
}
.step-phase-fill {
    height: 100%; width: 0%; border-radius: 2px;
    background: linear-gradient(90deg, var(--purple), var(--blue));
    transition: width 0.3s ease;
}
.step-phase.active .step-phase-fill {
    animation: phaseProgress 3s ease-in-out forwards;
}
.step-phase.done .step-phase-fill {
    width: 100% !important; background: var(--green);
    animation: none;
}
.step-phase.done .step-phase-icon::after {
    content: ' ✓'; font-size: 12px; color: var(--green);
}
@keyframes phaseProgress {
    0% { width: 0%; }
    80% { width: 85%; }
    100% { width: 92%; }
}
.step-thinking-box {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 10px; overflow: hidden;
    animation: fadeUp 0.3s ease;
}
.step-thinking-head {
    padding: 10px 16px; background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
    font-size: 12px; font-weight: 600; color: var(--purple);
}
.step-thinking-content {
    padding: 14px 16px; max-height: 200px; overflow-y: auto;
    font-family: 'SF Mono','Fira Code','Consolas',monospace;
    font-size: 12px; line-height: 1.7; color: var(--text2);
    white-space: pre-wrap; word-wrap: break-word;
}
@media (max-width: 768px) {
    .step-loading-phases { flex-wrap: wrap; }
    .step-phase { flex: 1 1 45%; }
}
/* Step mindmap node animation */
.step-mm-preview .tree .node { animation: nodeGrow 0.4s ease; }
@keyframes nodeGrow { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }
.step-mm-preview .node.new-node { animation: nodePulse 1s ease 2; }
@keyframes nodePulse {
    0%,100% { box-shadow: none; }
    50% { box-shadow: 0 0 12px rgba(154,139,170,0.4); }
}
/* New node highlight in Step by Step */
.tree .node.new-node {
    animation: nodeGlow 1.5s ease 2;
    border-style: dashed;
}
@keyframes nodeGlow {
    0%,100% { box-shadow: none; }
    50% { box-shadow: 0 0 14px rgba(139,92,246,0.45); }
}
