:root {
    color-scheme: light;
    --surface: #fff;
    --text: #333;
    --accent: #0066cc;
    --axis: #000;
    --axis-muted: #666;
    --panel-border: #ddd;
    --panel-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background-color: #fdfdfd;
}

[hidden] {
    display: none !important;
}

.katex-display {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.15rem 0;
}

.scale-label .katex,
.axis-segment .katex,
.axis-sub-segment .katex,
.branch-axis .katex {
    font-size: 0.98em;
}

#app {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: grab;
    user-select: none;
}

#app:active,
#app.is-dragging {
    cursor: grabbing;
}

#ruler-container {
    position: absolute;
    top: 50%;
    z-index: 10;
    display: flex;
    align-items: center;
    height: 60px;
    overflow: visible;
    transform: translateY(-50%);
}

.axis-segment {
    position: absolute;
    z-index: 12;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 30px;
    padding: 0 5px;
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
    cursor: pointer;
    transition: filter 0.2s, transform 0.2s;
}

.axis-segment:hover {
    z-index: 20;
    filter: brightness(1.1);
}

.axis-segment-upper {
    top: 0;
    z-index: 30;
    font-size: 12px;
}

.axis-segment-center {
    top: 15px;
}

.axis-segment-sub {
    top: 30px;
    z-index: 30;
    height: 30px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 11px;
}

.ellipsis-dot {
    position: absolute;
    top: 50%;
    z-index: 10;
    height: 30px;
    background-color: var(--axis-muted);
    transform: translateY(-50%);
}

.axis-arrow,
.branch-arrow {
    position: absolute;
    z-index: 15;
    width: 0;
    height: 0;
    border-top: 25px solid transparent;
    border-bottom: 25px solid transparent;
    transform: translateY(-50%);
}

.axis-arrow {
    top: 50%;
    border-left: 20px solid var(--axis-muted);
}

.branch-arrow {
    border-left: 20px solid var(--axis);
}

.branch-axis {
    position: absolute;
    z-index: 10;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 30px;
    padding: 0 10px;
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    background: var(--axis);
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    transform: translateY(-50%);
    transition: background-color 0.2s, transform 0.2s;
}

.branch-axis:hover {
    background-color: #333;
    transform: translateY(-50%) scaleX(1.02);
    transform-origin: left;
}

.fork-curve {
    fill: none;
    stroke: var(--axis);
    stroke-width: 30px;
}

#svg-layer {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 4;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.tick {
    position: absolute;
    z-index: 5;
    width: 3px;
    background-color: var(--axis);
    pointer-events: none;
    shape-rendering: crispEdges;
    will-change: left;
}

.tick.tick-short {
    background-color: var(--axis-muted);
}

.scale-item {
    position: absolute;
    top: calc(50% - 40px);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    white-space: nowrap;
    transform: translate(-50%, -100%);
    transition: opacity 0.3s, transform 0.3s;
}

.scale-item.side-bottom {
    top: calc(50% + 40px);
    transform: translate(-50%, 0);
}

.scale-label {
    position: relative;
    max-width: 200px;
    padding: 8px 14px;
    color: #1a1a1a;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
    white-space: normal;
    overflow-wrap: break-word;
    background: rgba(255, 255, 255, 0.95);
    border: 1.5px solid #333;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.scale-label:hover {
    background: var(--surface);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: scale(1.05);
}

.scale-item.zoom-level-0 {
    z-index: 50;
}

.scale-item.zoom-level-0 .scale-label {
    font-size: 20px;
    font-weight: 700;
    border: 3px solid #800;
}

.scale-item.zoom-level-1 {
    z-index: 40;
}

.scale-item.zoom-level-1 .scale-label {
    font-size: 18px;
    font-weight: 700;
    border: 2px solid #00f;
}

.scale-item.zoom-level-2 {
    z-index: 30;
}

.scale-item.zoom-level-2 .scale-label {
    font-size: 16px;
    font-weight: 600;
    border: 1.5px solid #090;
}

.scale-item.zoom-level-3 {
    z-index: 20;
}

.scale-item.zoom-level-3 .scale-label {
    font-size: 12px;
    font-weight: 400;
    border: 1px solid #777;
}

.info-icon,
.code-icon {
    position: absolute;
    right: -6px;
    z-index: 2;
    width: 14px;
    height: 14px;
    background-color: var(--surface);
    background-repeat: no-repeat;
    background-size: contain;
    border-radius: 50%;
}

.info-icon {
    top: -6px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230066cc' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='16' x2='12' y2='12'/%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'/%3E%3C/svg%3E");
}

.code-icon {
    top: 10px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2328a745' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='16 18 22 12 16 6'/%3E%3Cpolyline points='8 6 2 12 8 18'/%3E%3C/svg%3E");
}

.btn-icon {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 6px;
    vertical-align: text-bottom;
    background-repeat: no-repeat;
    background-size: contain;
}

.btn-icon.info {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230066cc' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='16' x2='12' y2='12'/%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'/%3E%3C/svg%3E");
}

.btn-icon.code {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2328a745' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='16 18 22 12 16 6'/%3E%3Cpolyline points='8 6 2 12 8 18'/%3E%3C/svg%3E");
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal-content {
    position: relative;
    width: 800px;
    max-width: 90vw;
    height: 80%;
    padding: 30px;
    margin-right: 40px;
    overflow-y: auto;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.2);
    animation: slide-in 0.3s ease-out;
}

@keyframes slide-in {
    from {
        opacity: 0;
        transform: translateX(50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    color: #666;
    font-size: 24px;
    line-height: 1;
    background: none;
    border: 0;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #000;
}

#modal-body {
    color: var(--text);
    line-height: 1.6;
}

#modal-body h2 {
    padding-bottom: 10px;
    margin-top: 0;
    border-bottom: 2px solid #eee;
}

#modal-body pre,
#modal-body code {
    color: #d4d4d4 !important;
    background: #1e1e1e !important;
}

#modal-body pre {
    padding: 16px;
    margin: 15px 0;
    overflow-x: auto;
    font-family: "Cascadia Code", "Consolas", "Monaco", "Courier New", monospace;
    font-size: 14px;
    line-height: 1.6;
    border: 1px solid #3c3c3c;
    border-radius: 8px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
    tab-size: 4;
}

#modal-body code {
    padding: 2px 4px;
    font-family: "Cascadia Code", "Consolas", "Monaco", "Courier New", monospace;
    border-radius: 4px;
}

#modal-body img {
    max-width: 100%;
    height: auto;
    margin: 10px 0;
    border-radius: 4px;
}

#modal-body a,
.scale-label a {
    color: var(--accent);
    text-decoration: none;
}

#modal-body a:hover,
.scale-label a:hover {
    text-decoration: underline;
}

.scale-label sup,
.scale-label sub {
    position: relative;
    font-size: 0.75em;
    line-height: 0;
    vertical-align: baseline;
}

.scale-label sup {
    top: -0.5em;
}

.scale-label sub {
    bottom: -0.25em;
}

.scale-label sup sup,
.scale-label sup sub,
.scale-label sub sup,
.scale-label sub sub {
    font-size: 0.8em;
}

#ui-overlay {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 100;
    display: flex;
    gap: 14px;
    align-items: center;
    pointer-events: none;
}

h1 {
    margin: 0;
    color: #222;
    font-size: 24px;
    letter-spacing: 1px;
}

#language-control {
    display: flex;
    gap: 6px;
    align-items: center;
    color: #555;
    font-size: 13px;
    pointer-events: auto;
}

#language-select {
    min-width: 88px;
    padding: 4px 24px 4px 8px;
    color: var(--text);
    font: inherit;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #bbb;
    border-radius: 5px;
    cursor: pointer;
}

.scale-label:not(.has-detail) {
    cursor: default;
}

#filter-controls {
    position: fixed;
    top: 60px;
    left: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    box-shadow: var(--panel-shadow);
}

#filter-controls button {
    padding: 6px 12px;
    font-size: 13px;
    text-align: left;
    background: var(--surface);
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

#filter-controls button:hover {
    background: #f0f0f0;
}

#filter-controls button.active {
    color: #fff;
    background: var(--accent);
    border-color: #0055aa;
}

#filter-controls label {
    display: flex;
    gap: 5px;
    align-items: center;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

.filter-separator {
    height: 1px;
    margin: 2px 0;
    background: #eee;
}

.zoom-manual-control {
    padding-top: 8px;
    margin-top: 5px;
    border-top: 1px dashed #eee;
}

.zoom-manual-header {
    margin-bottom: 4px;
    color: #666;
    font-size: 12px;
}

.zoom-slider {
    width: 100%;
}

.zoom-scale-labels {
    display: flex;
    justify-content: space-between;
    color: #999;
    font-size: 10px;
}

#controls {
    position: fixed;
    right: 30px;
    bottom: 30px;
    z-index: 100;
    padding: 15px;
    background: var(--surface);
    border: 1px solid #eee;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.zoom-info {
    margin-bottom: 5px;
    font-size: 14px;
    font-weight: 500;
}

.hint {
    color: #999;
    font-size: 12px;
}

.controls-hint {
    margin-bottom: 10px;
}

.control-buttons {
    display: flex;
    gap: 5px;
}

.control-button {
    padding: 5px 10px;
    background: var(--surface);
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
}

.control-button-reset {
    flex: 1;
    padding: 5px;
}

.ide-window {
    margin: 20px 0;
    overflow: hidden;
    font-family: "Cascadia Code", "Consolas", monospace;
    text-align: left;
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.ide-header {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background: #2d2d2d;
    border-bottom: 1px solid #1e1e1e;
}

.ide-controls {
    display: flex;
    gap: 8px;
    margin-right: 15px;
}

.ide-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.ide-dot.red {
    background: #ff5f56;
}

.ide-dot.yellow {
    background: #ffbd2e;
}

.ide-dot.green {
    background: #27c93f;
}

.ide-title {
    flex: 1;
    margin-right: 55px;
    color: #999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
}

.ide-content {
    padding: 20px !important;
    margin: 0 !important;
    overflow-x: auto;
    color: #d4d4d4;
    font-family: "Cascadia Code", "Consolas", monospace !important;
    font-size: 14px;
    line-height: 1.6;
    background: #1e1e1e !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

.ide-content code {
    padding: 0 !important;
    color: inherit !important;
    font-family: inherit !important;
    white-space: pre;
    background: transparent !important;
    border-radius: 0 !important;
}
