/* ============================================================
   ToyAgent 样式系统 v3 · 纸面编辑部
   暖米纸面 + 墨色文字 + 赭石点缀，衬线标题
   没有渐变、没有光晕、没有深夜蓝 —— 像一本被认真排版的手册
   ============================================================ */

:root {
    --bg: #f6f4ef;
    --panel: #fffefb;
    --sidebar: #efece4;
    --ink: #1f1b16;
    --ink-2: #3d372f;
    --muted: #837a6d;
    --line: #e0dbcf;
    --line-soft: #e9e5da;
    --accent: #9a4a1e;          /* 赭石 */
    --accent-hover: #7f3c17;
    --accent-soft: #f6ede3;
    --accent-border: #ddc4ab;
    --code-bg: #2a251f;
    --code-ink: #ece7dc;
    --green: #3d6b4f;
    --green-soft: #edf3ec;
    --green-border: #cfe0cf;
    --amber: #8a6116;
    --amber-soft: #f7f0de;
    --amber-border: #e6d6ab;
    --red: #a03028;
    --red-soft: #f8ece8;
    --teal: #2f6b66;
    --teal-soft: #e9f1ee;
    --teal-border: #c8ddd6;
    --radius: 10px;
    --radius-sm: 7px;
    --article-w: 420px;
    --shadow: 0 1px 2px rgba(50, 42, 30, .05);
    --shadow-lg: 0 14px 44px rgba(50, 42, 30, .18);
    --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --serif: "Noto Serif SC", "Songti SC", "STSong", Georgia, serif;
    --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.65;
    overflow: hidden;
}

::selection { background: #e8d5bd; }

/* ==================== 三栏布局 ==================== */

.layout {
    display: grid;
    grid-template-columns: 264px 1fr var(--article-w);
    height: 100vh;
}

/* ==================== 左侧导航 ==================== */

.sidebar {
    background: var(--sidebar);
    border-right: 1px solid var(--line);
    color: var(--ink-2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 20px 18px 14px;
    cursor: pointer;
    border-radius: 10px;
    transition: background .15s;
}

.brand:hover { background: var(--line-soft); }

.brand-logo {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.brand-text h1 {
    font-family: var(--serif);
    font-size: 17px;
    letter-spacing: .3px;
    color: var(--ink);
}

.brand-text p {
    font-size: 11px;
    color: var(--muted);
    margin-top: 1px;
}

/* 模型徽标（可点击） */

.model-badge {
    margin: 0 16px 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--panel);
    border: 1px solid var(--line);
    font-size: 11.5px;
    color: var(--ink-2);
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: border-color .15s, background .15s;
    width: calc(100% - 32px);
}

.model-badge:hover { border-color: var(--accent-border); background: var(--accent-soft); }

.model-badge .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    flex-shrink: 0;
}

.model-badge.mock .dot { background: var(--amber); }

.model-badge #modelText {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-badge .gear { opacity: .55; font-size: 13px; }

.nav {
    flex: 1;
    overflow-y: auto;
    padding: 2px 12px 12px;
}

.nav::-webkit-scrollbar { width: 5px; }
.nav::-webkit-scrollbar-thumb { background: #d4cec0; border-radius: 3px; }

.nav-group {
    font-size: 10.5px;
    color: var(--muted);
    letter-spacing: 2px;
    padding: 16px 4px 6px;
    font-weight: 600;
    border-bottom: 1px solid var(--line-soft);
    margin-bottom: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--ink-2);
    transition: background .13s, color .13s;
    text-decoration: none;
    position: relative;
}

.nav-item:hover { background: rgba(31, 27, 22, .05); color: var(--ink); }

.nav-item.active {
    background: var(--ink);
    color: #f6f4ef;
}

.nav-num {
    width: 30px;
    height: 20px;
    border-radius: 5px;
    border: 1px solid #cfc8b8;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: var(--mono);
    transition: all .13s;
}

.nav-item:hover .nav-num { border-color: var(--accent-border); color: var(--accent); }

.nav-item.active .nav-num {
    background: var(--accent);
    color: #fff;
    border-color: transparent;
}

.nav-name {
    font-size: 12.8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-foot {
    padding: 13px 18px;
    border-top: 1px solid var(--line);
    font-size: 11px;
    color: var(--muted);
    line-height: 1.7;
}

.sidebar-foot b { color: var(--ink-2); }

.sidebar-foot p { margin: 0; }

.sidebar-foot p + p { margin-top: 4px; }

.sidebar-foot .guide-link {
    color: var(--ink-2);
    text-decoration: none;
    border-bottom: 1px dashed var(--muted);
    padding-bottom: 1px;
}

.sidebar-foot .guide-link:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.sidebar-foot .guide-link b { color: inherit; }

.foot-author { margin-top: 6px; padding-top: 6px; }

.foot-author a { color: var(--accent); text-decoration: none; }
.foot-author a:hover { text-decoration: underline; }

/* ==================== 中间对话区 ==================== */

.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;   /* 允许 flex/grid 子项收缩，chat-area 才能内部滚动 */
    overflow: hidden;
}

.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    height: 64px;
    padding: 0 24px;
    flex-shrink: 0;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}

.icon-btn {
    font-size: 16px;
    line-height: 1;
    padding: 6px 10px;
}

.scenario-title {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.step-chip {
    background: transparent;
    color: var(--accent);
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 6px;
    border: 1px solid var(--accent-border);
    flex-shrink: 0;
}

.scenario-title h2 {
    font-family: var(--serif);
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--ink);
}

.scenario-title p {
    font-size: 11.5px;
    color: var(--muted);
}

.header-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }

.src-link {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 31px;
    padding: 0 13px;
    border-radius: 8px;
    border: 1px solid #3f3f3f;
    background: #3f3f3f;
    color: #f6f4ef;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, border-color .15s;
}

.src-emoji { font-size: 11px; line-height: 1; }

/* ---- 代码块五语言切换标签（编辑器风格：标签栏与代码块同一连续表面） ---- */

.codetabs { margin: 14px 0; }

.article-body .codetabs pre {
    margin: 0;
    border-radius: 0 0 10px 10px;
}

.codetab-bar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 8px;
    background: var(--code-bg);
    border-radius: 10px 10px 0 0;
    border-bottom: 1px solid rgba(255, 255, 255, .09);
}

.codetab {
    appearance: none;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, .42);
    font: inherit;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .3px;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    position: relative;
    transition: color .15s, background .15s;
}

.codetab:hover {
    color: rgba(255, 255, 255, .78);
    background: rgba(255, 255, 255, .045);
}

.codetab.active {
    color: #f6f4ef;
    background: rgba(255, 255, 255, .07);
}

/* 激活标签底部短下划线：用主题强调色提亮，与标签栏底线重叠 */
.codetab.active::after {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: -1px;
    height: 2px;
    border-radius: 2px 2px 0 0;
    background: #d98e5f;
    background: color-mix(in srgb, var(--accent) 55%, #fff);
}

/* 标签栏右侧的复制按钮：常显、幽灵样式 */
.codetab-bar .copy-btn {
    position: static;
    margin-left: auto;
    opacity: .55;
    background: transparent;
    border: none;
    padding: 3px 8px;
}

.codetab-bar .copy-btn:hover {
    opacity: 1;
    color: #f6f4ef;
    background: rgba(255, 255, 255, .06);
}

.src-link:hover {
    background: #262626;
    border-color: #262626;
    color: #f6f4ef;
}

/* ---- 五语言源码链接组（右侧文章面板头部） ---- */

.src-links {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.src-link.src-lang {
    height: 26px;
    padding: 0 8px;
    border-radius: 7px;
    border: 1px solid #3f3f3f;
    background: #3f3f3f;
    color: #f6f4ef;
    font-size: 11px;
    font-weight: 600;
    gap: 4px;
}

.src-link.src-lang .src-emoji { font-size: 10px; }

.src-link.src-lang:hover {
    background: #262626;
    border-color: #262626;
    color: #f6f4ef;
}

.btn {
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    border-radius: 8px;
    padding: 8px 16px;
    transition: all .15s;
}

.btn.primary {
    background: var(--ink);
    color: #f6f4ef;
    font-weight: 600;
    padding: 9px 22px;
}

.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:active { transform: translateY(1px); }
.btn.primary:disabled { opacity: .5; cursor: not-allowed; }

.btn.ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
    font-size: 12px;
    padding: 6px 13px;
}

.btn.ghost:hover { color: var(--accent); border-color: var(--accent-border); background: var(--accent-soft); }

/* 聊天消息 */

.chat-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 26px 28px 10px;
    scroll-behavior: smooth;
}

.chat-area::-webkit-scrollbar { width: 8px; }
.chat-area::-webkit-scrollbar-thumb { background: #d8d2c4; border-radius: 4px; }
.chat-area::-webkit-scrollbar-thumb:hover { background: #c4bca9; }

.msg {
    max-width: 820px;
    margin: 0 auto 20px;
    display: flex;
    gap: 12px;
    animation: rise .3s ease both;
}

@keyframes rise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    margin-top: 2px;
}

.msg.user { flex-direction: row-reverse; }

.msg.user .avatar {
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent-border);
}

.msg.agent .avatar {
    background: transparent;
    overflow: hidden;
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.bubble {
    padding: 12px 16px;
    border-radius: var(--radius);
    max-width: 85%;
    word-break: break-word;
    font-size: 13.8px;
}

.msg.user .bubble {
    background: var(--ink);
    color: #f3f0e9;
    border-top-right-radius: 4px;
    white-space: pre-wrap;
}

.msg.agent .bubble {
    background: var(--panel);
    border: 1px solid var(--line);
    border-top-left-radius: 4px;
    color: var(--ink-2);
}

.bubble.error { background: var(--red-soft); border-color: #e4c4bd; color: var(--red); }

/* 气泡内 Markdown 渲染样式 */

.bubble.md > :first-child { margin-top: 0; }
.bubble.md > :last-child { margin-bottom: 0; }

.bubble.md p { margin: 8px 0; }

.bubble.md h1, .bubble.md h2, .bubble.md h3, .bubble.md h4 {
    margin: 14px 0 8px;
    color: var(--ink);
    line-height: 1.4;
}

.bubble.md h1 { font-family: var(--serif); font-size: 17px; }
.bubble.md h2 { font-family: var(--serif); font-size: 15.5px; padding-left: 9px; border-left: 2.5px solid var(--accent); }
.bubble.md h3 { font-size: 14px; }

.bubble.md ul, .bubble.md ol { padding-left: 20px; margin: 8px 0; }
.bubble.md li { margin: 4px 0; }
.bubble.md li::marker { color: var(--accent); }

.bubble.md strong { color: var(--ink); font-weight: 700; }

.bubble.md code {
    font-family: var(--mono);
    font-size: 12.2px;
    background: var(--accent-soft);
    color: var(--accent-hover);
    padding: 1.5px 6px;
    border-radius: 5px;
}

.bubble.md pre {
    background: var(--code-bg);
    color: var(--code-ink);
    border-radius: 8px;
    padding: 12px 14px;
    overflow-x: auto;
    margin: 10px 0;
    font-size: 12.2px;
    line-height: 1.6;
}

.bubble.md pre code { background: transparent; color: inherit; padding: 0; font-size: inherit; }

.bubble.md blockquote {
    border-left: 2.5px solid var(--accent-border);
    background: var(--accent-soft);
    border-radius: 0 8px 8px 0;
    padding: 6px 12px;
    margin: 8px 0;
    color: var(--accent-hover);
}

.bubble.md hr { border: none; border-top: 1px dashed var(--line); margin: 12px 0; }

.bubble.md table { border-collapse: collapse; margin: 10px 0; font-size: 12.5px; width: 100%; }
.bubble.md th, .bubble.md td { border: 1px solid var(--line); padding: 5px 10px; text-align: left; }
.bubble.md th { background: var(--bg); color: var(--ink); }

.bubble.md a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

.typing { display: inline-flex; gap: 5px; padding: 4px 2px; }
.typing i {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--accent);
    animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }

@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* 执行轨迹时间线 */

.trace {
    max-width: 820px;
    margin: 0 auto 20px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    animation: rise .3s ease both;
}

.trace-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    font-weight: 600;
}

.trace-head .chev { transition: transform .2s; }
.trace.collapsed .chev { transform: rotate(-90deg); }
.trace.collapsed .trace-steps { display: none; }

.trace-steps { padding: 14px 16px 16px; }

/* mermaid 流程图卡片 */

.trace.diag .trace-head { font-weight: 600; }

.diag-box {
    padding: 16px;
    overflow-x: auto;
    display: flex;
    justify-content: center;
    background: var(--panel);
}

.diag-box svg { max-width: 100%; height: auto; }

.diag-box .nodeLabel, .diag-box .edgeLabel, .diag-box .messageText { font-size: 12.5px; }

.diag-loading, .diag-fail {
    font-size: 12.5px;
    color: var(--muted);
    padding: 14px 4px;
    text-align: center;
    width: 100%;
}

.diag-fail { color: var(--amber); }

.trace.collapsed .diag-box { display: none; }

.tstep {
    position: relative;
    padding: 0 0 16px 28px;
    font-size: 12.8px;
}

.tstep:last-child { padding-bottom: 2px; }

.tstep::before {
    content: "";
    position: absolute;
    left: 6px;
    top: 6px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--tc, var(--accent));
}

.tstep::after {
    content: "";
    position: absolute;
    left: 10px;
    top: 19px;
    bottom: 0;
    width: 1.5px;
    background: var(--line-soft);
}

.tstep:last-child::after { display: none; }

.tstep .tlabel {
    font-weight: 700;
    color: var(--tc, var(--accent));
    font-size: 12px;
    letter-spacing: .2px;
}

.tstep .tdetail {
    color: var(--ink-2);
    margin-top: 2px;
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--bg);
    border-radius: 7px;
    padding: 5px 10px;
    display: inline-block;
    max-width: 100%;
}

/* 轨迹配色：泥土系（赤/褐/苔/靛） */
.tstep.t-thought   { --tc: #7c5cb0; }
.tstep.t-action    { --tc: #4a6b8a; }
.tstep.t-observation { --tc: var(--teal); }
.tstep.t-tool      { --tc: var(--amber); }
.tstep.t-intent    { --tc: #a04f6e; }
.tstep.t-memory    { --tc: #7c5cb0; }
.tstep.t-compress  { --tc: var(--amber); }
.tstep.t-mcp       { --tc: var(--teal); }
.tstep.t-skill     { --tc: #a04f6e; }
.tstep.t-retrieve  { --tc: var(--teal); }
.tstep.t-agent     { --tc: var(--accent); }
.tstep.t-guard     { --tc: var(--red); }
.tstep.t-warn      { --tc: var(--amber); }
.tstep.t-node      { --tc: var(--accent); }
.tstep.t-edge      { --tc: var(--muted); }
.tstep.t-prompt    { --tc: #7c5cb0; }
.tstep.t-final     { --tc: var(--green); }

/* ==================== 总览页（home） ==================== */

.overview {
    max-width: 860px;
    margin: 0 auto;
    padding-bottom: 20px;
}

.hero {
    text-align: center;
    padding: 30px 10px 22px;
    animation: rise .35s ease both;
}

.hero .logo-big {
    width: 58px;
    height: 58px;
    margin: 0 auto 14px;
    border-radius: 14px;
    object-fit: cover;
    display: block;
}

.hero h3 {
    font-family: var(--serif);
    font-size: 24px;
    letter-spacing: .5px;
    color: var(--ink);
}

.hero p { color: var(--muted); font-size: 13.5px; margin-top: 7px; }

.hero .soul {
    display: inline-block;
    margin-top: 14px;
    font-family: var(--mono);
    font-size: 12.5px;
    color: var(--accent-hover);
    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
    padding: 8px 16px;
    border-radius: 8px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 18px 0 22px;
    animation: rise .4s ease both;
}

.stat {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 8px;
    text-align: center;
}

.stat b {
    display: block;
    font-family: var(--serif);
    font-size: 21px;
    color: var(--accent);
}

.stat span { font-size: 11.5px; color: var(--muted); }

.sec-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0 12px;
    font-family: var(--serif);
    font-size: 15px;
    color: var(--ink);
}

.sec-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    animation: rise .45s ease both;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, transform .15s;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--accent);
    opacity: 0;
    transition: opacity .15s;
}

.card:hover {
    border-color: var(--accent-border);
    box-shadow: 0 6px 18px rgba(50, 42, 30, .09);
    transform: translateY(-1px);
}

.card:hover::before { opacity: 1; }

.card .card-top { display: flex; align-items: center; gap: 9px; }

.card .card-num {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
    border-radius: 6px;
    padding: 2px 8px;
}

.card h4 { font-family: var(--serif); font-size: 14px; color: var(--ink); }

.card p { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.55; }

.card .card-chapters { margin-top: 8px; }

.card .card-chapters .chip { font-size: 10.3px; padding: 2px 9px; }

/* 进阶实战卡片 */

.adv-sub {
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-2);
    letter-spacing: .5px;
    margin: 16px 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px dashed var(--line);
}

.card.adv { cursor: default; }
.card.adv:hover { border-color: var(--line); box-shadow: var(--shadow); transform: none; }
.card.adv::before { display: none; }
.card.adv .card-num { color: var(--green); background: var(--green-soft); border-color: var(--green-border); }

/* 教程实战篇章卡片（可点击跳转在线教程） */

.card.adv.guide { cursor: pointer; }
.card.adv.guide:hover {
    border-color: var(--accent-border);
    box-shadow: 0 6px 18px rgba(50, 42, 30, .09);
    transform: translateY(-1px);
}
.card.adv.guide:hover::before { display: block; opacity: 1; }
.card.adv.guide .card-num { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-border); }

.mono-chip { font-family: var(--mono); font-size: 10.5px; }

.adv-lede {
    font-size: 12.8px;
    color: var(--muted);
    margin: -4px 0 12px;
    line-height: 1.7;
}

/* 作者卡片 */

.author-card {
    margin: 22px 0 8px;
    padding: 18px 20px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
    border-radius: var(--radius);
    animation: rise .5s ease both;
}

.author-card .author-line b {
    font-family: var(--serif);
    font-size: 14.5px;
    color: var(--ink);
}

.author-card p { font-size: 12.8px; color: var(--ink-2); margin: 8px 0; line-height: 1.7; }

.author-card .author-links { display: flex; flex-wrap: wrap; gap: 8px; }

.author-card .author-links a {
    font-size: 12px;
    color: var(--accent-hover);
    background: var(--panel);
    border: 1px solid var(--accent-border);
    border-radius: 999px;
    padding: 5px 13px;
    text-decoration: none;
    transition: background .15s, color .15s;
}

.author-card .author-links a:hover { background: var(--accent); color: #fff; }

.author-card .author-license { font-size: 11px; color: var(--muted); margin-bottom: 0; }

.author-card .author-license a { color: var(--accent); text-decoration: none; font-weight: 600; }
.author-card .author-license a:hover { text-decoration: underline; }

/* NEW 徽标 */
.new-badge {
    display: inline-block;
    font-family: var(--sans);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .5px;
    color: #fff;
    background: var(--accent);
    border-radius: 4px;
    padding: 1px 5px;
    vertical-align: 2px;
    margin-left: 4px;
}

/* 底部备案信息栏 */
.beian-bar {
    margin-top: 18px;
    padding: 14px 18px;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    text-align: center;
    font-size: 11px;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px 10px;
}

.beian-bar a {
    color: var(--muted);
    text-decoration: none;
    border-bottom: 1px dotted var(--line);
}

.beian-bar a:hover { color: var(--accent); border-bottom-color: var(--accent); }

.hint-bar {
    margin-top: 20px;
    text-align: center;
    color: var(--muted);
    font-size: 12.5px;
    animation: rise .5s ease both;
}

.hint-bar .kbd {
    font-family: var(--mono);
    font-size: 11px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: 5px;
    padding: 2px 7px;
    color: var(--ink-2);
}

/* 欢迎占位（场景内初始状态） */

.welcome {
    max-width: 780px;
    margin: 46px auto;
    text-align: center;
    color: var(--muted);
    animation: rise .35s ease both;
}

.welcome .big-emoji {
    width: 60px;
    height: 60px;
    margin: 0 auto 14px;
    border-radius: 14px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
}

.welcome h3 { font-family: var(--serif); color: var(--ink); font-size: 19px; margin-bottom: 8px; }

.welcome p { font-size: 13px; max-width: 470px; margin: 0 auto; }

/* 示例问题 */

.samples {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0 28px 12px;
    max-width: 876px;
    margin: 0 auto;
    width: 100%;
}

.samples:empty { display: none; }

.sample-chip {
    font-size: 12px;
    color: var(--ink-2);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 14px;
    cursor: pointer;
    transition: all .15s;
}

.sample-chip:hover {
    background: var(--accent-soft);
    border-color: var(--accent-border);
    color: var(--accent-hover);
}

/* 输入区 */

.composer {
    padding: 14px 28px 20px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0), var(--bg) 60%);
}

.composer-inner {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
    align-items: flex-end;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 8px 8px 8px 6px;
    box-shadow: var(--shadow);
    transition: border-color .15s, box-shadow .15s;
}

.composer-inner:focus-within {
    border-color: #b09a7c;
    box-shadow: 0 0 0 3px rgba(154, 74, 30, .08);
}

.composer textarea {
    flex: 1;
    resize: none;
    border: none;
    padding: 9px 12px;
    font-family: inherit;
    font-size: 13.8px;
    line-height: 1.5;
    outline: none;
    max-height: 140px;
    background: transparent;
    color: var(--ink);
}

.composer textarea::placeholder { color: #a89e8e; }

/* ==================== 右侧文章面板 ==================== */

.article-panel {
    background: var(--panel);
    border-left: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 320px;
}

.article-head-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.article-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding: 8px 18px;
    flex-shrink: 0;
    flex-wrap: wrap;
    row-gap: 6px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
}

.article-tag {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: .5px;
    white-space: nowrap;
}

.article-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 24px 48px;
}

.article-body::-webkit-scrollbar { width: 7px; }
.article-body::-webkit-scrollbar-thumb { background: #d8d2c4; border-radius: 4px; }

/* 文章排版 */

.article-body .chapters { margin-bottom: 18px; }

.article-body h1 {
    font-family: var(--serif);
    font-size: 21px;
    line-height: 1.4;
    margin-bottom: 6px;
    color: var(--ink);
}

.article-body .lede {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px dashed var(--line);
}

.article-body h2 {
    font-family: var(--serif);
    font-size: 16.5px;
    margin: 28px 0 10px;
    padding-left: 11px;
    border-left: 3px solid var(--accent);
    color: var(--ink);
}

.article-body h3 {
    font-family: var(--serif);
    font-size: 14.5px;
    margin: 20px 0 8px;
    color: var(--ink-2);
}

.article-body p { margin: 9px 0; color: var(--ink-2); font-size: 13.4px; }

.article-body ul, .article-body ol { padding-left: 20px; margin: 9px 0; }

.article-body li { margin: 5px 0; color: var(--ink-2); font-size: 13.4px; }

.article-body li::marker { color: var(--accent); }

.article-body strong { color: var(--ink); }

.article-body code {
    font-family: var(--mono);
    font-size: 12.3px;
    background: var(--accent-soft);
    color: var(--accent-hover);
    padding: 2px 6px;
    border-radius: 5px;
}

.article-body pre {
    background: var(--code-bg);
    color: var(--code-ink);
    border-radius: 9px;
    padding: 15px 17px;
    overflow-x: auto;
    margin: 13px 0;
    position: relative;
    font-size: 12.3px;
    line-height: 1.65;
}

.article-body pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    font-size: inherit;
}

.article-body pre::-webkit-scrollbar { height: 6px; }
.article-body pre::-webkit-scrollbar-thumb { background: #57503f; border-radius: 3px; }

/* 代码高亮 token（暖纸底色上的柔和色） */
.tok-kw { color: #a8c4e8; font-weight: 600; }
.tok-str { color: #a8cf9e; }
.tok-com { color: #8a8171; font-style: italic; }
.tok-ann { color: #e0c184; }
.tok-num { color: #d3aede; }
.tok-type { color: #8ec9c0; }

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 10.5px;
    color: #a89e8c;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .15);
    border-radius: 5px;
    padding: 3px 9px;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s;
    font-family: var(--font);
}

.article-body pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: #ece7dc; }

/* 提示框 */

.callout {
    border-radius: 9px;
    padding: 13px 16px;
    margin: 13px 0;
    font-size: 13px;
    border: 1px solid;
}

.callout .co-title {
    font-weight: 700;
    font-size: 12.5px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.callout.tip { background: var(--green-soft); border-color: var(--green-border); color: #2c4f39; }
.callout.tip .co-title { color: var(--green); }

.callout.warn { background: var(--amber-soft); border-color: var(--amber-border); color: #5c420f; }
.callout.warn .co-title { color: var(--amber); }

.callout.core { background: var(--accent-soft); border-color: var(--accent-border); color: #6e3514; }
.callout.core .co-title { color: var(--accent); }

/* 表格 */

.article-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 13px 0;
    font-size: 12.6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.article-body th {
    background: var(--bg);
    text-align: left;
    padding: 8px 12px;
    color: var(--ink);
    font-size: 12.2px;
    border-bottom: 1px solid var(--line);
}

.article-body td {
    padding: 7.5px 12px;
    border-bottom: 1px solid var(--line-soft);
    color: var(--ink-2);
}

.article-body tr:last-child td { border-bottom: none; }

/* 章节对照 chips */

.chip {
    display: inline-block;
    font-size: 11.3px;
    color: var(--teal);
    background: var(--teal-soft);
    border: 1px solid var(--teal-border);
    border-radius: 999px;
    padding: 3px 11px;
    margin: 2px 4px 2px 0;
}

/* 演进流程 */

.flow {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin: 13px 0;
}

.flow .fnode {
    background: var(--panel);
    border: 1.5px solid var(--accent-border);
    color: var(--accent-hover);
    border-radius: 7px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
}

.flow .fnode.dim { border-color: var(--line); color: var(--muted); }

.flow .farrow { color: #a89e8e; font-size: 12px; }

/* ==================== 模型设置弹窗 ==================== */

.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(46, 38, 27, .4);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn .18s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-mask[hidden] { display: none; }

.toast[hidden] { display: none; }

.modal {
    width: min(480px, 92vw);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 22px 24px;
    box-shadow: var(--shadow-lg);
    animation: pop .2s ease both;
}

@keyframes pop {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.modal-head h3 { font-family: var(--serif); font-size: 16px; }

.modal-tip {
    font-size: 12px;
    color: #6e3514;
    line-height: 1.6;
    margin-bottom: 12px;
    padding: 9px 12px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
    border-radius: 8px;
}

.field { display: block; margin-bottom: 13px; }

.field span {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 5px;
}

.field input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 12px;
    font-family: var(--mono);
    font-size: 12.5px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    background: var(--bg);
    color: var(--ink);
}

.field input:focus {
    border-color: #b09a7c;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(154, 74, 30, .08);
}

.modal-status {
    min-height: 20px;
    font-size: 12px;
    margin: 4px 0 10px;
    color: var(--muted);
    white-space: pre-wrap;
    word-break: break-all;
}

.modal-status.ok { color: var(--green); }
.modal-status.err { color: var(--red); }

.modal-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.flex-space { flex: 1; }

/* ==================== Toast ==================== */

.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: #f3f0e9;
    font-size: 13px;
    padding: 10px 20px;
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    z-index: 120;
    animation: toastIn .25s ease both;
    max-width: 80vw;
}

.toast.ok { background: var(--green); color: #f2f7f0; }
.toast.err { background: var(--red); color: #faf0ee; }

@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, 12px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* ==================== 主题 ==================== */

html[data-theme="mist"] {
    --bg: #f2f5f1;
    --panel: #fcfdfb;
    --sidebar: #e6ece5;
    --ink: #1c2620;
    --ink-2: #37423b;
    --muted: #7c8680;
    --line: #d7dfd6;
    --line-soft: #e3e9e1;
    --accent: #2e6e5c;
    --accent-hover: #24574a;
    --accent-soft: #e2efe8;
    --accent-border: #b9d4c6;
    --code-bg: #21302a;
    --code-ink: #dde8e0;
}

html[data-theme="ink"] {
    --bg: #f4f4f2;
    --panel: #fdfdfc;
    --sidebar: #eaeae7;
    --ink: #191919;
    --ink-2: #353532;
    --muted: #7f7f7b;
    --line: #dcdcda;
    --line-soft: #e8e8e5;
    --accent: #262626;
    --accent-hover: #0e0e0e;
    --accent-soft: #efefec;
    --accent-border: #c8c8c3;
    --code-bg: #1e1e1e;
    --code-ink: #e4e4df;
}

html[data-theme="dusk"] {
    --bg: #f1f3f7;
    --panel: #fcfdff;
    --sidebar: #e4e9f1;
    --ink: #1b2331;
    --ink-2: #364053;
    --muted: #75808f;
    --line: #d6dce6;
    --line-soft: #e2e7ef;
    --accent: #33528a;
    --accent-hover: #284170;
    --accent-soft: #e6ecf7;
    --accent-border: #bfcee3;
    --code-bg: #222b3b;
    --code-ink: #dfe5ef;
}

html[data-theme="snow"] {
    --bg: #ffffff;
    --panel: #ffffff;
    --sidebar: #f6f6f8;
    --ink: #16181d;
    --ink-2: #35383e;
    --muted: #83868d;
    --line: #e7e8ec;
    --line-soft: #f1f1f4;
    --accent: #1c1e24;
    --accent-hover: #000000;
    --accent-soft: #f2f3f6;
    --accent-border: #d6d9e0;
    --code-bg: #1b1d23;
    --code-ink: #e8e9ed;
}

html[data-theme="latte"] {
    --bg: #f5efe6;
    --panel: #fffcf7;
    --sidebar: #ece2d2;
    --ink: #2b211a;
    --ink-2: #4a3b2e;
    --muted: #8a7a67;
    --line: #e0d3c0;
    --line-soft: #eae0d0;
    --accent: #8c5a2e;
    --accent-hover: #724826;
    --accent-soft: #f3e7d6;
    --accent-border: #d9c1a0;
    --code-bg: #2b2119;
    --code-ink: #efe5d6;
}

html[data-theme="sakura"] {
    --bg: #faf3f5;
    --panel: #fffdfe;
    --sidebar: #f4e5e9;
    --ink: #2a1f24;
    --ink-2: #4d3a42;
    --muted: #907680;
    --line: #ecd8de;
    --line-soft: #f3e5ea;
    --accent: #b04a68;
    --accent-hover: #933956;
    --accent-soft: #f9e7ed;
    --accent-border: #e4bac9;
    --code-bg: #2e2128;
    --code-ink: #f0e3ea;
}

/* 主题选择器（侧栏底部色点） */

.theme-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
}

.theme-row .theme-label {
    font-size: 10.5px;
    color: var(--muted);
    letter-spacing: 1px;
}

.theme-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid transparent;
    background: var(--dot);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: transform .15s, box-shadow .15s, border-color .15s;
}

.theme-dot:hover { transform: scale(1.18); }

.theme-dot.active {
    border-color: var(--ink);
    box-shadow: inset 0 0 0 2px var(--sidebar);
}

/* ==================== 右侧面板拖拽调宽 ==================== */

.article-panel {
    position: relative;
}

.panel-resizer {
    position: absolute;
    left: -3px;
    top: 0;
    bottom: 0;
    width: 7px;
    cursor: col-resize;
    z-index: 10;
}

.panel-resizer::after {
    content: "";
    position: absolute;
    left: 3px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: transparent;
    transition: background .15s;
}

.article-panel:hover .panel-resizer::after,
.panel-resizer.active::after { background: var(--accent-border); }

.panel-resizer .grip {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 7px;
    height: 42px;
    border-radius: 4px;
    background: var(--line);
    opacity: 0;
    transition: opacity .15s, background .15s;
    pointer-events: none;
}

.panel-resizer:hover .grip,
.panel-resizer.active .grip { opacity: 1; background: var(--accent-border); }

body.resizing {
    cursor: col-resize;
    user-select: none;
}

body.resizing iframe, body.resizing textarea { pointer-events: none; }

/* ==================== 响应式 ==================== */

.only-mobile { display: none; }

@media (max-width: 1280px) {
    .layout { grid-template-columns: 240px 1fr var(--article-w); }
}

@media (max-width: 1024px) {
    .layout { grid-template-columns: 1fr; grid-template-rows: 1fr; }

    .sidebar {
        position: fixed;
        z-index: 50;
        left: 0; top: 0; bottom: 0;
        width: 264px;
        transform: translateX(-100%);
        transition: transform .25s;
        box-shadow: 8px 0 30px rgba(50, 42, 30, .15);
    }

    .sidebar.open { transform: none; }

    .article-panel {
        position: fixed;
        z-index: 40;
        right: 0; top: 0; bottom: 0;
        width: min(430px, 92vw);
        transform: translateX(100%);
        transition: transform .25s;
        box-shadow: -8px 0 30px rgba(50, 42, 30, .15);
    }

    .panel-resizer { display: none; }

    .article-panel.open { transform: none; }

    .only-mobile { display: inline-block; }

    .card-grid { grid-template-columns: 1fr; }
    .stats { grid-template-columns: repeat(2, 1fr); }
}

/* ================= Toy 桌面 · 3D 场景学习地图 ================= */
.slogan {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
  margin-top: 10px;
}
.slogan small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0;
  margin-top: 4px;
}

.map-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.map-btn {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-2);
  cursor: pointer;
  transition: all .15s;
}
.map-btn:hover { border-color: var(--accent-border); }
.map-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.map-hint { font-size: 11px; color: var(--muted); margin-left: 4px; }

.desk-map {
  user-select: none;
  -webkit-user-select: none;
  padding: 4px 0 6px;
}
.desk-scene {
  --rz: -34deg;
  --rx: 52deg;
  --s: 1;
  perspective: 1500px;
  perspective-origin: 50% 16%;
  height: calc(780px * var(--s));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  cursor: grab;
}
.desk-scene.dragging { cursor: grabbing; }

.desk {
  flex: none;
  position: relative;
  width: 930px;
  height: 480px;
  transform-style: preserve-3d;
  transform: scale(var(--s)) rotateX(var(--rx)) rotateZ(var(--rz));
  transition: transform .45s cubic-bezier(.2, .7, .25, 1);
}
.desk-scene.dragging .desk { transition: none; }
.desk::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .05) 0 2px, transparent 2px 96px),
    linear-gradient(135deg, #cda475, #bd8f60 45%, #a97b4e);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, .22),
    inset 0 0 70px rgba(88, 48, 18, .3),
    0 34px 70px rgba(50, 35, 18, .35);
}
.desk::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 14px;
  border: 1.5px solid rgba(255, 255, 255, .25);
  transform: translateZ(1px);
  pointer-events: none;
}

/* ---- 分区（桌面上的纸卡）---- */
.zone {
  position: absolute;
  border: 1.5px dashed color-mix(in srgb, var(--zc) 45%, #fff);
  border-radius: 14px;
  background: color-mix(in srgb, var(--zc) 7%, #fffdf6);
  transform: translateZ(2px);
  transform-style: preserve-3d;
}
.z-sign {
  position: absolute;
  top: -14px;
  left: 10px;
  padding: 4px 12px;
  background: var(--zc);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 1px;
  border-radius: 8px;
  white-space: nowrap;
  transform-origin: 50% 50%;
  transform: translateZ(30px) rotateZ(calc(var(--rz) * -1)) rotateX(calc(var(--rx) * -1));
  box-shadow: 0 6px 12px rgba(40, 24, 8, .3);
}

/* ---- 积木（三面体）---- */
.cube {
  position: absolute;
  width: 62px;
  height: 62px;
  transform-style: preserve-3d;
  cursor: pointer;
  animation: blockIn .45s ease backwards;
}
@keyframes blockIn { from { opacity: 0; } }
.cube::before {
  content: "";
  position: absolute;
  inset: -7px;
  background: radial-gradient(rgba(60, 34, 10, .32), transparent 68%);
  transform: translateZ(.4px);
}
.cube .core {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-style: preserve-3d;
  transform: translateZ(calc(var(--h) / 2));
  transition: transform .18s ease;
}
.cube:hover .core { transform: translateZ(calc(var(--h) / 2 + 16px)); }
.cube .face { position: absolute; left: 0; top: 0; }
.f-top {
  width: 68px;
  height: 68px;
  margin-left: -31px;
  margin-top: -31px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--zc) 24%, #fffef8);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--zc) 38%, #fff);
  transform: translateZ(calc(var(--h) / 2));
}
.f-top::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--zc) 45%, #fff);
  transform: translate(-50%, -50%);
}
.f-front {
  width: 62px;
  height: var(--h);
  margin-left: -31px;
  margin-top: calc(var(--h) / -2);
  border-radius: 5px;
  background: var(--zc);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 18px/1 var(--mono);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
  box-shadow: inset 0 7px 9px -7px rgba(255, 255, 255, .55), inset 0 -6px 8px -6px rgba(0, 0, 0, .4);
  transform: rotateX(-90deg) translateZ(31px);
  transition: filter .18s;
}
.f-side {
  width: var(--h);
  height: 62px;
  margin-left: calc(var(--h) / -2);
  margin-top: -31px;
  background: color-mix(in srgb, var(--zc) 68%, #241505);
  border-radius: 5px;
  transform: rotateY(90deg) translateZ(31px);
}
.cube:hover .f-front { filter: brightness(1.12); }

/* ---- 悬停提示牌（面向屏幕的告示牌）---- */
.cube .tip {
  position: absolute;
  left: 50%;
  top: 50%;
  width: max-content;
  max-width: 230px;
  padding: 8px 11px;
  border-radius: 9px;
  background: rgba(31, 27, 22, .94);
  color: #f3ede2;
  font-size: 11.5px;
  line-height: 1.5;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 5;
  transform: translate(-50%, -50%) translateZ(calc(var(--h) + 64px)) rotateZ(calc(var(--rz) * -1)) rotateX(calc(var(--rx) * -1));
}
.cube .tip b {
  display: block;
  font-size: 12px;
  color: #f2c896;
  margin-bottom: 2px;
}
.cube:hover .tip { opacity: 1; }

/* ---- 起点标牌与桌面小装饰 ---- */
.start-pin {
  position: absolute;
  left: 46px;
  top: 412px;
  padding: 7px 14px;
  background: var(--accent);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transform: translateZ(34px) rotateZ(calc(var(--rz) * -1)) rotateX(calc(var(--rx) * -1));
  box-shadow: 0 8px 14px rgba(40, 24, 8, .35);
  transition: filter .15s;
}
.start-pin:hover { filter: brightness(1.12); }
.decor {
  position: absolute;
  font-size: 26px;
  opacity: .85;
  transform: translateZ(3px) rotate(-14deg);
  pointer-events: none;
}
.decor.d1 { left: 850px; top: 410px; }
.decor.d2 { left: 130px; top: 418px; transform: translateZ(3px) rotate(10deg); }

/* ---- 桌两端的大王（致敬《打，打个大西瓜》：两位大王隔着地图对坐）---- */
.king {
  position: absolute;
  width: 78px;
  height: 122px;
  transform-origin: 50% 100%;
  transform: translateZ(8px) rotateZ(calc(var(--rz) * -1)) rotateX(calc(var(--rx) * -1));
  pointer-events: auto;
  cursor: pointer;
  z-index: 3;
}
.king.k-west { --kc: #a03028; --kg: #d29a2e; }
.king.k-east { --kc: #3e5c76; --kg: #c9932f; }

.king .k-fig {
  position: absolute;
  inset: 0;
  animation: kBob 3.6s ease-in-out infinite;
}
.king.k-east .k-fig { animation-delay: -1.8s; }
@keyframes kBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.king .k-shadow {
  position: absolute;
  left: 4px;
  bottom: -5px;
  width: 70px;
  height: 15px;
  background: radial-gradient(rgba(50, 30, 10, .32), transparent 70%);
}

/* 王座 */
.king .k-chair {
  position: absolute;
  left: 8px;
  bottom: 0;
  width: 62px;
  height: 86px;
  background: linear-gradient(180deg, #8a5a2b, #6f4420);
  border-radius: 14px 14px 4px 4px;
  box-shadow: inset 0 4px 6px rgba(255, 235, 200, .25), inset 0 -8px 10px rgba(40, 20, 5, .35);
}
.king .k-chair::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -13px;
  transform: translateX(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f4d27a, var(--kg));
  box-shadow: 0 2px 4px rgba(40, 24, 8, .4);
}

/* 王袍 + 衣领 + 腰带 */
.king .k-robe {
  position: absolute;
  left: 16px;
  bottom: 6px;
  width: 46px;
  height: 56px;
  background: linear-gradient(180deg, var(--kc) 62%, color-mix(in srgb, var(--kc) 68%, #1a0d05) 62%);
  border-radius: 18px 18px 5px 5px;
  box-shadow: inset 3px 4px 6px rgba(255, 255, 255, .22), inset -4px -6px 8px rgba(0, 0, 0, .28);
}
.king .k-robe::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -2px;
  transform: translateX(-50%);
  width: 18px;
  height: 10px;
  background: #fffdf2;
  border-radius: 0 0 10px 10px;
}
.king .k-robe::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 24px;
  height: 6px;
  background: #e8b64c;
  box-shadow: 0 2px 3px rgba(0, 0, 0, .25);
}

/* 头 + 眼睛 + 八字胡 */
.king .k-head {
  position: absolute;
  left: 26px;
  bottom: 60px;
  width: 27px;
  height: 26px;
  background: radial-gradient(circle at 35% 30%, #f6d3ab, #dfa874);
  border-radius: 50%;
}
.king .k-head::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 9px;
  width: 4px;
  height: 5px;
  border-radius: 50%;
  background: #2c1c0c;
  box-shadow: 13px 0 #2c1c0c;
}
.king .k-head::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 15px;
  transform: translateX(-50%);
  width: 15px;
  height: 7px;
  border-bottom: 2.5px solid #4a2f16;
  border-radius: 0 0 12px 12px;
}

/* 金冠 */
.king .k-crown {
  position: absolute;
  left: 24px;
  bottom: 85px;
  width: 31px;
  height: 14px;
  background: linear-gradient(180deg, #f2cd6e, var(--kg));
  clip-path: polygon(0 100%, 0 35%, 25% 68%, 50% 0, 75% 68%, 100% 35%, 100% 100%);
  filter: drop-shadow(0 2px 2px rgba(40, 24, 8, .35));
}

/* 武器：西大王亮银剑 / 东大王红缨关刀 */
.king .k-weapon { position: absolute; }
.king.k-west .k-weapon {
  left: 57px;
  bottom: 34px;
  width: 10px;
  height: 76px;
  transform: rotate(9deg);
  transform-origin: 50% 100%;
}
.king.k-west .k-weapon::before {
  content: "";
  position: absolute;
  left: 1.5px;
  bottom: 12px;
  width: 7px;
  height: 62px;
  background: linear-gradient(90deg, #eef2f6, #9fb2c2 55%, #dfe7ee);
  clip-path: polygon(50% 0, 100% 9%, 100% 100%, 0 100%, 0 9%);
}
.king.k-west .k-weapon::after {
  content: "";
  position: absolute;
  left: -5px;
  bottom: 5px;
  width: 20px;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(180deg, #f2cd6e, #c08a24);
  box-shadow: 0 11px 0 -3px #6b4423;
}
.king.k-east .k-weapon {
  left: 56px;
  bottom: 30px;
  width: 6px;
  height: 94px;
  transform: rotate(-12deg);
  transform-origin: 50% 100%;
}
.king.k-east .k-weapon::before {
  content: "";
  position: absolute;
  left: 1px;
  top: -9px;
  width: 18px;
  height: 22px;
  background: linear-gradient(135deg, #eef2f6, #9fb2c2);
  border-radius: 4px 100% 60% 8px;
}
.king.k-east .k-weapon::after {
  content: "";
  position: absolute;
  left: -1px;
  top: 14px;
  width: 10px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #e86a48, #b03018);
}

/* 悬停对白气泡 */
.king .k-say {
  position: absolute;
  left: 50%;
  bottom: 132px;
  transform: translateX(-50%);
  width: max-content;
  max-width: 200px;
  padding: 7px 11px;
  border-radius: 9px;
  background: rgba(31, 27, 22, .94);
  color: #f3ede2;
  font-size: 11.5px;
  line-height: 1.5;
  opacity: 0;
  transition: opacity .15s;
  pointer-events: none;
  z-index: 6;
}
.king .k-say::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(31, 27, 22, .94);
  border-bottom: 0;
}
.king:hover .k-say { opacity: 1; }
.king:hover .k-fig { filter: brightness(1.06); }

@media (max-width: 760px) {
  .map-hint { display: none; }
  .desk-scene { perspective-origin: 50% 30%; }
}
@media (prefers-reduced-motion: reduce) {
  .cube { animation: none; }
  .desk, .cube .core { transition: none; }
  .king .k-fig { animation: none; }
}
