/* ============================================================
 * 数学工具箱 · 几何画板
 * 主页与工作台共用一套变量与样式。
 * ============================================================ */

:root {
    --ink: #0f172a;
    --ink-2: #48526d;
    --ink-3: #8d95a8;
    --line: #e4e7f0;
    --line-soft: #eef0f6;
    --bg: #f7f8fc;
    --card: #ffffff;
    --accent: #4f46e5;
    --accent-deep: #4338ca;
    --accent-soft: #eef0ff;
    --danger: #d92d4b;
    --teal: #0f766e;
    --radius: 16px;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
            "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    /* 数字字体：不用带斜杠零的等宽字体，避免 0 显示成 Ø */
    --num: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
           "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.6;
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
code { font-family: var(--num); font-size: 0.94em; }
.grow { flex: 1; }

.ico {
    width: 15px; height: 15px;
    fill: none; stroke: currentColor;
    stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
    flex: none;
}

/* ---------------- 顶栏（主页） ---------------- */
.wrap {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 36px 42px;
}

.nav {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 66px;
    border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 9px; }
.brand-mark {
    width: 27px; height: 27px;
    display: grid; place-items: center;
    background: var(--ink); color: #fff;
    border-radius: 8px; font-size: 14px; font-weight: 600;
}
.brand-name { font-weight: 650; font-size: 14.5px; letter-spacing: 0.2px; }
.nav-sep { color: #ccd2e0; }
.nav-here, .nav-now { color: var(--ink-3); font-size: 13px; }
a.nav-here:hover { color: var(--accent); }
.nav-now { color: var(--ink-2); }
.nav-link {
    font-size: 13px; color: var(--ink-2);
    padding: 6px 10px; border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: #fff; color: var(--accent); }

/* ---------------- 通用按钮 ---------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    border: 1px solid transparent; border-radius: 10px;
    font-size: 13.5px; font-weight: 600;
    padding: 9px 16px; cursor: pointer; white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, transform 0.08s, box-shadow 0.15s;
}
.btn.lg { padding: 12px 20px; font-size: 14px; border-radius: 11px; }
.btn.sm { padding: 6px 12px; font-size: 12.5px; border-radius: 9px; }
.btn.primary {
    background: var(--accent); color: #fff;
    box-shadow: 0 10px 22px -14px rgba(79, 70, 229, 0.9);
}
.btn.primary:hover { background: var(--accent-deep); }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn.ghost:hover { border-color: #cdd3e6; color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

kbd {
    font-family: var(--num); font-size: 10px;
    background: #fff; border: 1px solid var(--line); border-bottom-width: 2px;
    border-radius: 4px; padding: 0 4px; color: #6b748c;
}

/* ============================================================
   主页
   ============================================================ */
.home-hero {
    display: grid;
    grid-template-columns: 1.02fr 0.98fr;
    gap: 52px;
    align-items: center;
    padding: 56px 0 50px;
}
.eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 12px; color: var(--ink-3); letter-spacing: 0.3px;
}
.eyebrow .dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}
.home-hero h1 {
    font-size: clamp(34px, 4.1vw, 50px);
    line-height: 1.24;
    letter-spacing: -1.6px;
    font-weight: 700;
    margin: 16px 0 18px;
}
.home-hero h1 em {
    font-style: normal;
    background: linear-gradient(100deg, #4f46e5 0%, #0f766e 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
}
.lede {
    font-size: 14.5px; color: var(--ink-2);
    max-width: 490px; line-height: 1.85;
    text-wrap: pretty;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.hero-facts {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px; margin-top: 34px; padding-top: 22px;
    border-top: 1px solid var(--line);
}
.fact { display: flex; flex-direction: column; gap: 3px; }
.fact-k { font-size: 11.5px; color: var(--ink-3); }
.fact-v { font-size: 16px; font-weight: 650; letter-spacing: -0.2px; }

.hero-art { position: relative; }
.art-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 12px;
    box-shadow: 0 26px 50px -38px rgba(16, 23, 40, 0.55);
}
.art-svg { display: block; width: 100%; height: auto; border-radius: 12px; background: #fff; }
.art-legend {
    display: flex; flex-wrap: wrap; gap: 14px;
    padding: 11px 8px 2px;
    font-size: 11.5px; color: var(--ink-3);
}
.lg-item { display: inline-flex; align-items: center; gap: 6px; }
.lg-item i { width: 14px; height: 2px; border-radius: 2px; display: inline-block; }
.lg-item i.is-dash { height: 0; border-top: 2px dashed #94a3b8; }
.art-note { margin-top: 12px; font-size: 11.5px; color: #a4abbe; text-align: center; }

.how { padding: 8px 0 4px; }
.how h2 { font-size: 19px; letter-spacing: -0.3px; margin-bottom: 18px; }
.steps { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.steps li {
    background: var(--card); border: 1px solid var(--line);
    border-radius: 16px; padding: 18px 20px 20px;
}
.step-no {
    font-family: var(--num); font-size: 11.5px; color: var(--accent);
    background: var(--accent-soft); border-radius: 6px; padding: 2px 7px;
}
.steps h3 { font-size: 14.5px; margin: 12px 0 6px; }
.steps p { font-size: 12.5px; color: var(--ink-2); line-height: 1.8; }
.steps code { background: #f5f6fb; border-radius: 4px; padding: 1px 5px; color: #5a6480; }

.features {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px; margin-top: 42px;
}
.feature {
    background: var(--card); border: 1px solid var(--line);
    border-radius: 16px; padding: 20px 22px 22px;
}
.f-ico {
    width: 32px; height: 32px; border-radius: 9px;
    display: grid; place-items: center;
    background: #f2f7f6; color: var(--teal);
}
.f-ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.feature h3 { font-size: 14px; margin: 12px 0 6px; }
.feature p { font-size: 12.5px; color: var(--ink-2); line-height: 1.8; }

.home-demos { margin-top: 44px; }
.section-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 16px; }
.section-head h2 { font-size: 18px; letter-spacing: -0.3px; }
.section-head p { font-size: 12px; color: var(--ink-3); }
.demo-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.demo {
    background: var(--card); border: 1px solid var(--line); border-radius: 13px;
    padding: 14px 16px; display: flex; flex-direction: column; gap: 5px;
    transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
}
.demo:hover {
    border-color: #c9cdf7; transform: translateY(-2px);
    box-shadow: 0 14px 26px -20px rgba(79, 70, 229, 0.8);
}
.demo-name { font-size: 12.5px; font-weight: 650; }
.demo-eq { font-size: 11.5px; color: var(--ink-2); }
.demo-hint { font-size: 10.5px; color: #a4abbe; }

.home-notes {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px; margin-top: 42px; padding-top: 24px;
    border-top: 1px solid var(--line);
}
.home-note h3 { font-size: 13px; font-weight: 650; margin-bottom: 6px; }
.home-note p { font-size: 12px; color: var(--ink-3); line-height: 1.8; }

.foot {
    display: flex; align-items: center; gap: 8px;
    margin-top: 36px; padding-top: 18px;
    border-top: 1px solid var(--line);
    font-size: 12px; color: var(--ink-3);
}
.foot a { color: var(--ink-2); }
.foot a:hover { color: var(--accent); }
.foot a + a { margin-left: 16px; }
.foot-dot { color: #ccd2e0; }

/* ============================================================
   工作台
   ============================================================ */
.app { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }

.topbar {
    height: 54px; flex: none;
    display: flex; align-items: center; gap: 9px;
    padding: 0 18px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    position: relative; z-index: 10;
}
.crumb { color: #c5cad8; font-size: 13px; }
.crumb-now { color: var(--ink-3); font-size: 12.5px; }

.icon-btn {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border: 1px solid var(--line); border-radius: 9px;
    background: #fff; color: var(--ink-2); cursor: pointer;
    transition: background 0.14s, color 0.14s, border-color 0.14s;
}
.icon-btn:hover { background: #f8f9fd; color: var(--accent); border-color: #cdd3e6; }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; background: #fff; color: var(--ink-2); border-color: var(--line); }
.icon-btn .ico { width: 15px; height: 15px; }

.workspace {
    flex: 1; min-height: 0;
    display: grid;
    grid-template-columns: 306px minmax(0, 1fr);
    gap: 14px;
    padding: 14px 16px 16px;
}

.sidebar {
    min-height: 0; overflow-y: auto;
    display: flex; flex-direction: column; gap: 10px;
    padding-right: 4px;
    scrollbar-width: thin;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #d7dbe8; border-radius: 99px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 13px;
    flex: none;
}
.panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.panel-head h2 { font-size: 12px; font-weight: 650; color: var(--ink-2); letter-spacing: 0.5px; }
.panel-note { font-size: 10.5px; color: var(--ink-3); margin-left: auto; }
.count {
    font-size: 10.5px; color: var(--ink-3);
    background: #f3f4fa; border-radius: 99px; padding: 1px 7px;
}
.link {
    background: none; border: none; padding: 2px 6px; border-radius: 6px;
    color: var(--ink-3); font-size: 11px; cursor: pointer; transition: 0.14s;
    margin-left: auto;
}
.link:hover { color: var(--accent); background: #f5f6fb; }
.link.is-danger { color: #fff; background: var(--danger); }
.link.is-danger:hover { background: #b91c3c; color: #fff; }

/* 工具箱 */
.tools-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tool-group + .tool-group { margin-top: 12px; }
.tool-group-title {
    font-size: 10.5px; color: var(--ink-3); letter-spacing: 0.4px;
    margin: 0 2px 7px;
}
.tbtn {
    display: flex; align-items: center; gap: 7px;
    height: 36px; padding: 0 9px;
    border: 1px solid var(--line); border-radius: 9px;
    background: #fff; color: var(--ink-2);
    font-size: 12.5px; cursor: pointer;
    transition: border-color 0.14s, color 0.14s, background 0.14s;
    -webkit-tap-highlight-color: transparent;
}
.tbtn:hover { border-color: #c9cdf7; color: var(--accent); background: #fbfbff; }
.tbtn.is-on {
    background: var(--accent-soft);
    border-color: #dcdcfb;
    color: var(--accent);
    font-weight: 650;
}
.tbtn .tico {
    width: 15px; height: 15px; flex: none;
    fill: none; stroke: currentColor;
    stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.tbtn span { flex: 1; text-align: left; white-space: nowrap; }
.tbtn kbd {
    font-size: 9px; padding: 0 3px; border-bottom-width: 1px;
    color: #b3bacb; background: transparent; border-color: transparent;
}
.tbtn.is-on kbd { color: #8f93c9; }

/* 视图面板 */
.opt-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 5px 2px; font-size: 12.5px; color: var(--ink-2);
}
.opt-row input[type="checkbox"] {
    width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer;
}
.view-meta {
    display: flex; align-items: center; gap: 8px;
    margin-top: 9px; padding-top: 9px;
    border-top: 1px dashed var(--line);
    font-size: 11.5px; color: var(--ink-3);
}
.view-meta b { color: var(--ink-2); font-weight: 650; }
.view-meta .link { margin-left: auto; }

.sel-text { font-size: 11.5px; color: var(--ink-3); line-height: 1.7; }
.obj-actions { display: flex; gap: 6px; margin-top: 9px; }
.obj-actions .btn { flex: 1; padding: 7px 8px; font-size: 12px; }

.demo-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    border: 1px solid var(--line); background: #fff;
    font-size: 11.5px; color: var(--ink-2);
    border-radius: 20px; padding: 4px 11px; cursor: pointer;
    transition: border-color 0.14s, color 0.14s, background 0.14s;
}
.chip:hover { border-color: #c9cdf7; color: var(--accent); background: #fafaff; }

.keys-list { display: grid; grid-template-columns: auto 1fr; gap: 5px 10px; font-size: 11.5px; color: var(--ink-3); }
.keys-list kbd { justify-self: start; }

/* 画布区 */
.stage { display: flex; flex-direction: column; gap: 9px; min-width: 0; min-height: 0; }
.canvas-shell {
    position: relative;
    flex: 1; min-height: 0;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 18px 40px -34px rgba(16, 23, 40, 0.55);
}
#board { display: block; touch-action: none; }
#board.is-grabbing { cursor: grabbing !important; }

.stage-tool { display: flex; align-items: center; gap: 7px; min-width: 0; flex: 1 1 auto; }
.stage-tool b { color: var(--ink-2); font-weight: 650; flex: none; }
.stage-tool span {
    color: #7d869c;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.foot-sep { color: #ccd2e0; }

.canvas-tools {
    position: absolute; right: 12px; top: 12px;
    display: flex; flex-direction: column; gap: 3px;
    background: #fff; border: 1px solid var(--line);
    border-radius: 11px; padding: 4px;
    box-shadow: 0 12px 26px -22px rgba(16, 23, 40, 0.7);
}
.canvas-tools button {
    width: 29px; height: 29px;
    display: grid; place-items: center;
    border: 0; border-radius: 7px; background: none;
    color: var(--ink-2); font-size: 16px; line-height: 1; cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.canvas-tools button:hover { background: #f2f4fa; color: var(--accent); }
.canvas-tools .ico { width: 15px; height: 15px; }

.cursor-readout {
    position: absolute; right: 12px; bottom: 12px;
    padding: 3px 9px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    font-size: 11px; color: var(--ink-3);
    pointer-events: none;
}

.toast {
    position: absolute; left: 50%; bottom: 18px;
    transform: translate(-50%, 8px);
    background: #111827; color: #fff;
    font-size: 12px; padding: 7px 15px; border-radius: 999px;
    opacity: 0; transition: opacity 0.18s, transform 0.18s;
    pointer-events: none; white-space: nowrap;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.board-empty {
    position: absolute; inset: 0;
    display: grid; place-items: center;
    pointer-events: none;
}
.empty-card {
    text-align: center;
    padding: 24px 28px;
    border: 1px dashed #d9ddec;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.8);
}
.empty-card p { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.empty-card span { display: block; margin-top: 4px; font-size: 11.5px; color: var(--ink-3); }

.stage-foot {
    display: flex; align-items: center; gap: 12px;
    padding: 0 4px;
    font-size: 11.5px; color: var(--ink-3);
}
.stage-copy { margin-left: auto; color: #b3bacb; flex: none; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1040px) {
    .home-hero { grid-template-columns: 1fr; gap: 30px; padding: 40px 0 38px; }
    .hero-art { max-width: 560px; }
    .demo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .app { height: auto; overflow: visible; }
    .workspace { grid-template-columns: 1fr; }
    .workspace > * { min-width: 0; }
    .sidebar { overflow: visible; padding-right: 0; }
    .stage { order: -1; }
    .canvas-shell { height: 54vh; min-height: 340px; flex: none; }
}

@media (max-width: 760px) {
    .wrap { padding: 0 20px 32px; }
    .nav-link { display: none; }
    .steps { grid-template-columns: 1fr; gap: 12px; }
    .features { grid-template-columns: 1fr; gap: 12px; }
    .home-notes { grid-template-columns: 1fr; gap: 14px; }
    .hero-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
    .foot { flex-wrap: wrap; }
    .topbar { padding: 0 12px; gap: 6px; }
    .topbar .btn.ghost { display: none; }
    .crumb, .crumb-now { display: none; }
    .stage-tool span { display: none; }
    .stage-copy { font-size: 10.5px; }
    .canvas-shell { height: 48vh; min-height: 300px; }
    .tools-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .tbtn { padding: 0 7px; font-size: 11.5px; }
    .tbtn kbd { display: none; }
}

@media (max-width: 560px) {
    .demo-grid { grid-template-columns: 1fr; }
    .tools-grid { gap: 5px; }
    .tbtn { font-size: 12px; padding: 0 7px; height: 34px; }
    .tbtn kbd { display: none; }
    .home-hero h1 { font-size: 31px; }
    .app .btn.sm span { display: none; }
}

/* ---------- 顶栏里的登录状态 ---------- */
.sso-who {
    display: inline-flex; align-items: baseline; gap: 7px;
    font-size: 12px; color: #8d95a8; white-space: nowrap;
}
.sso-who b { font-weight: 600; color: #5b6480; }
.sso-who a { color: #a4abbe; text-decoration: none; }
.sso-who a:hover { color: #4f46e5; }

.sso-login {
    display: inline-flex; align-items: center; height: 28px; padding: 0 13px;
    border: 1px solid #d8dcf5; border-radius: 8px; background: #fff;
    font-size: 12px; color: #4f46e5; text-decoration: none; white-space: nowrap;
    transition: border-color .15s, background .15s;
}
.sso-login:hover { border-color: #b6b9f0; background: #f4f4ff; }

@media (max-width: 760px) {
    .sso-who b { display: none; }
}

/* ---------- 存档弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-mask { position: absolute; inset: 0; background: rgba(16, 23, 40, .44); backdrop-filter: blur(3px); }

.modal-card {
    position: relative;
    width: min(440px, 100%);
    max-height: 88vh; overflow-y: auto;
    background: #fff; border-radius: 14px;
    padding: 20px;
    box-shadow: 0 30px 70px -24px rgba(16, 23, 40, .55);
    animation: bdpop .18s cubic-bezier(.2, .9, .3, 1);
}
@keyframes bdpop { from { opacity: 0; transform: translateY(10px) scale(.985); } }

.modal-card h3 { font-size: 15px; font-weight: 650; }
.modal-card .muted { font-size: 11.5px; color: var(--ink-3); line-height: 1.65; margin: 6px 0 15px; }

.save-row { display: flex; gap: 8px; margin-bottom: 4px; }
.save-row input {
    flex: 1; min-width: 0;
    font-family: inherit; font-size: 13px; height: 34px; padding: 0 10px;
    border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: #fff;
}
.save-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, .15); }

.modal-error { font-size: 11.5px; color: var(--danger); margin-top: 10px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.scheme-list { list-style: none; display: flex; flex-direction: column; gap: 5px; max-height: 280px; overflow-y: auto; margin-top: 12px; }
.scheme-list::-webkit-scrollbar { width: 6px; }
.scheme-list::-webkit-scrollbar-thumb { background: #d7dbe8; border-radius: 99px; }
.scheme-list::-webkit-scrollbar-track { background: transparent; }

.scheme-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 11px;
    border: 1px solid var(--line); border-radius: 10px;
    transition: .14s;
}
.scheme-item:hover { border-color: #cdd3e6; background: #fbfbfe; }
.scheme-main { flex: 1; min-width: 0; }
.scheme-name { display: block; font-size: 12.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scheme-meta { font-size: 10.5px; color: var(--ink-3); font-family: var(--num); }
.scheme-empty { font-size: 12px; color: var(--ink-3); text-align: center; padding: 18px 0; }
