/**
 * dis.css — 离散数学可视化页面共享外壳样式
 * 由 dis.css 派生：仅替换类名前缀 dis- → app-，布局与交互保持一致。
 */
/* ============================================================
   SimLabs · 应用数学系列（app1~app4）公共外壳样式
   与 fn/ 下其它数学可视化页保持同一套视觉语言
   ============================================================ */

:root {
    --app-primary: #4f46e5;
    --app-primary-soft: #eef2ff;
    --app-ink: #1f2937;
    --app-muted: #6b7280;
    --app-border: #dbe1ea;
    --app-stage-1: #ffffff;
    --app-stage-2: #e7eef8;
    --app-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

* {
    box-sizing: border-box;
}

body.app-page {
    margin: 0;
    min-height: 100vh;
    background: #f3f6fb;
    color: var(--app-ink);
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    display: flex;
    flex-direction: column;
}

/* ---------- 主框架 ---------- */
.app-main {
    position: relative;
    flex: 1 1 auto;
    display: flex;
    align-items: stretch;
    width: 100%;
    min-width: 0;
    height: calc(100vh - 70px);
    min-height: 540px;
    overflow: hidden;
}

.app-body {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ---------- 顶栏标题 ---------- */
.app-hero {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 22px;
    color: #fff;
    background: linear-gradient(100deg, var(--app-primary) 0%, var(--app-primary-2, #7c3aed) 100%);
    box-shadow: 0 10px 28px rgba(79, 70, 229, 0.22);
}

.app-hero-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.app-hero-icon {
    font-size: 26px;
    line-height: 1;
}

.app-hero h2 {
    margin: 0 0 3px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.app-hero p {
    margin: 0;
    font-size: 12.5px;
    opacity: 0.9;
}

.app-hero-tag {
    flex-shrink: 0;
    padding: 7px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.28);
    font-size: 12px;
    white-space: nowrap;
    backdrop-filter: blur(6px);
}

/* ---------- 内容区 ---------- */
.app-shell {
    flex: 1 1 0;
    display: flex;
    min-height: 0;
    overflow: hidden;
}

.app-panel {
    flex: 0 0 372px;
    width: 372px;
    max-width: 400px;
    min-height: 0;
    padding: 18px 18px 30px;
    background: #fff;
    border-right: 1px solid var(--app-border);
    box-shadow: 8px 0 28px rgba(15, 23, 42, 0.05);
    overflow-y: auto;
    overflow-x: hidden;
}

.app-stage {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 480px;
    overflow: hidden;
    background:
        radial-gradient(120% 100% at 22% 8%, #ffffff 0%, var(--app-stage-2) 72%),
        #eef2f8;
}

.app-stage canvas {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: grab;
}

.app-stage.is-dragging canvas {
    cursor: grabbing;
}

/* ---------- 面板内的排版 ---------- */
.app-label {
    display: block;
    margin: 0 0 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #64748b;
}

.app-card {
    margin-bottom: 14px;
    padding: 16px;
    border: 1px solid var(--app-border);
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--app-shadow);
}

.app-card.tint {
    background: linear-gradient(135deg, #f8fafc, #eef2ff);
}

.app-card.dark {
    border-color: #111827;
    background: linear-gradient(140deg, #111827, #1f2937);
    color: #fff;
}

.app-card.dark .app-label {
    color: #94a3b8;
}

.app-card-title {
    margin: 0 0 12px;
    padding-bottom: 9px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: #64748b;
}

.app-card.dark .app-card-title {
    border-bottom-color: rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
}

.app-desc {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.75;
    color: #64748b;
}

.app-desc strong {
    color: #334155;
}

.app-desc code,
.app-mono {
    font-family: "Cascadia Code", Consolas, "SFMono-Regular", monospace;
}

/* 键值读数 */
.app-kv {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px dashed #e6ebf2;
    font-size: 13px;
    color: #52607a;
}

.app-kv:last-child {
    border-bottom: 0;
}

.app-kv i {
    font-style: normal;
    font-family: Cambria, "Times New Roman", serif;
    font-size: 14px;
    color: #334155;
}

.app-kv b {
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
}

.app-kv b.hi {
    color: var(--app-primary);
}

.app-kv b.warn {
    color: #dc2626;
}

.app-card.dark .app-kv {
    border-bottom-color: rgba(255, 255, 255, 0.09);
    color: #a8b6cc;
}

.app-card.dark .app-kv i {
    color: #dbeafe;
}

.app-card.dark .app-kv b {
    color: #fff;
}

.app-card.dark .app-kv b.hi {
    color: #a5b4fc;
}

/* 大数值 */
.app-big {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 0 10px;
}

.app-big span {
    font-size: 12px;
    color: #94a3b8;
}

.app-big strong {
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: 26px;
    font-weight: 700;
    color: #a5b4fc;
    line-height: 1.1;
}

/* ---------- 开关 chip ---------- */
.app-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    flex: 0 0 auto;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 12px;
    border: 1px solid var(--app-border);
    border-radius: 999px;
    background: #f8fafc;
    color: #3f4a5f;
    font-size: 12.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    user-select: none;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.chip:hover {
    background: var(--app-primary-soft);
    border-color: #c7d2fe;
    color: var(--app-primary);
}

.chip .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.9;
    flex-shrink: 0;
}

.chip.on {
    background: var(--app-primary);
    border-color: var(--app-primary);
    color: #fff;
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.28);
}

.app-card.dark .chip {
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.06);
    color: #cbd5e1;
}

.app-card.dark .chip.on {
    background: #818cf8;
    border-color: #818cf8;
    color: #0b1020;
}

/* ---------- 分段按钮 ---------- */
.segmented {
    display: flex;
    gap: 6px;
    padding: 6px;
    border-radius: 14px;
    background: #f1f5f9;
}

.segmented button {
    flex: 1 1 0;
    padding: 9px 8px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #64748b;
    font-size: 12.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.segmented button:hover {
    color: var(--app-primary);
}

.segmented button.on {
    background: #fff;
    color: var(--app-primary);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
}

/* ---------- 按钮 ---------- */
.app-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.app-btn {
    flex: 1 1 0;
    min-width: 92px;
    padding: 10px 12px;
    border: 1px solid var(--app-border);
    border-radius: 12px;
    background: #f8fafc;
    color: #334155;
    font-size: 12.5px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.15s ease;
}

.app-btn:hover {
    background: var(--app-primary-soft);
    border-color: #c7d2fe;
    color: var(--app-primary);
    transform: translateY(-1px);
}

.app-btn.primary {
    background: var(--app-primary);
    border-color: var(--app-primary);
    color: #fff;
}

.app-btn.primary:hover {
    color: #fff;
    filter: brightness(1.07);
}

.app-card.dark .app-btn {
    border-color: rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.07);
    color: #e2e8f0;
}

.app-card.dark .app-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

/* ---------- 滑块 ---------- */
.app-slider {
    margin-top: 4px;
}

.app-slider-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12.5px;
    color: #52607a;
}

.app-slider-head b {
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: 14px;
    color: var(--app-primary);
}

.app-panel input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 22px;
    background: transparent;
    cursor: pointer;
    margin: 0;
}

.app-panel input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(90deg, #c7d2fe, #818cf8 60%, #c084fc);
}

.app-panel input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    margin-top: -6px;
    border: 3px solid #fff;
    border-radius: 50%;
    background: var(--app-primary);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
}

.app-panel input[type="range"]::-moz-range-track {
    height: 6px;
    border-radius: 999px;
    background: #c7d2fe;
}

.app-panel input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border: 3px solid #fff;
    border-radius: 50%;
    background: var(--app-primary);
}

.app-card.dark input[type="range"]::-webkit-slider-runnable-track {
    background: linear-gradient(90deg, #4f46e5, #818cf8);
}

.app-card.dark input[type="range"]::-webkit-slider-thumb {
    border-color: #1f2937;
    background: #c7d2fe;
}

.app-range-scale {
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
    font-size: 11px;
    color: #94a3b8;
}

/* ---------- 舞台浮层 ---------- */
.app-legend {
    position: absolute;
    left: 16px;
    bottom: 16px;
    max-width: min(90%, 430px);
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.1);
    font-size: 12px;
    line-height: 1.95;
    color: #475569;
    backdrop-filter: blur(6px);
    pointer-events: none;
}

.app-legend .sw {
    display: inline-block;
    width: 16px;
    height: 3px;
    border-radius: 2px;
    vertical-align: middle;
    margin-right: 7px;
}

.app-legend .swd {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 7px;
}

.app-legend em {
    color: #64748b;
    font-style: normal;
}

.app-badge {
    position: absolute;
    top: 14px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.1);
    font-size: 12px;
    color: #475569;
    pointer-events: none;
    backdrop-filter: blur(6px);
}

.app-badge b {
    font-family: "Cascadia Code", Consolas, monospace;
    color: var(--app-primary);
    font-size: 13px;
}

.app-note {
    margin: 12px 0 0;
    padding: 10px 12px;
    border-left: 3px solid #c7d2fe;
    border-radius: 0 10px 10px 0;
    background: #f8fafc;
    font-size: 12px;
    line-height: 1.7;
    color: #64748b;
}

.app-card.dark .app-note {
    border-left-color: #4f46e5;
    background: rgba(255, 255, 255, 0.05);
    color: #a8b6cc;
}

/* 色标 */
.app-colorbar {
    height: 10px;
    margin: 10px 0 4px;
    border-radius: 999px;
    border: 1px solid #e2e8f0;
}

.app-colorbar-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #94a3b8;
}

/* ---------- 数学公式块 ---------- */
.app-formula {
    margin: 10px 0 0;
    padding: 10px 12px;
    border: 1px dashed #dbe1ea;
    border-radius: 12px;
    background: #fbfcfe;
    font-family: Cambria, "Times New Roman", serif;
    font-size: 14px;
    color: #334155;
    line-height: 1.9;
    overflow-x: auto;
}

.app-formula sub,
.app-formula sup {
    font-size: 10.5px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1180px) {
    .app-panel {
        flex: 0 0 330px;
        width: 330px;
    }
}

@media (max-width: 980px) {
    .app-main {
        overflow: visible;
        min-height: auto;
    }

    .app-body {
        overflow: visible;
    }

    .app-shell {
        flex-direction: column;
        overflow: visible;
    }

    .app-panel {
        flex: 0 0 auto;
        width: 100%;
        max-width: none;
        border-right: 0;
        border-bottom: 1px solid var(--app-border);
        overflow: visible;
    }

    .app-stage {
        min-height: 62vh;
    }

    .app-hero {
        flex-wrap: wrap;
        padding: 12px 16px;
    }

    .app-hero h2 {
        font-size: 17px;
    }

    .app-hero p {
        font-size: 11.5px;
    }

    .app-legend {
        left: 10px;
        bottom: 10px;
        font-size: 11px;
        padding: 8px 11px;
    }

    .app-badge {
        top: 10px;
        right: 10px;
        font-size: 11px;
    }
}
