* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    height: 100%; width: 100%;
    background: #0f0f12;
    color: #e6e6ee;
    font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
    overflow: hidden;
}
#toolbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 44px;
    background: rgba(20, 20, 26, 0.92);
    border-bottom: 1px solid #2a2a34;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 14px;
    font-size: 13px;
    z-index: 10;
}
.title { font-weight: 600; letter-spacing: 0.2px; }

.icon-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid #3a3a48;
    background: #1a1a24;
    color: #b0b0c0;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.icon-btn:hover {
    background: #24242e;
    color: #e6e6ee;
    border-color: #5a5a6a;
}

#modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
#modal-overlay.hidden {
    display: none;
}
#modal {
    position: relative;
    background: #17171f;
    border: 1px solid #2a2a34;
    border-radius: 12px;
    max-width: 640px;
    width: 100%;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
#modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #8a8aa0;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}
#modal-close:hover {
    background: #2a2a34;
    color: #e6e6ee;
}
.modal-content {
    padding: 28px 32px 24px;
    color: #d8d8e2;
    font-size: 14px;
    line-height: 1.55;
}
.modal-content h2 {
    font-size: 15px;
    margin: 18px 0 8px;
    color: #e6e6ee;
    letter-spacing: 0.2px;
}
.modal-content h2:first-of-type { margin-top: 6px; }
.modal-content p { margin: 0 0 10px; }
.modal-content ul { margin: 0; padding-left: 20px; }
.modal-content li { margin: 4px 0; }
.modal-content code {
    background: #24242e;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12.5px;
    color: #e6e6ee;
}
.modal-content a { color: #7ec8bd; }
.modal-content a:hover { color: #a4e4d8; }
.modal-content .placeholder-note {
    background: rgba(255, 200, 80, 0.12);
    border: 1px solid rgba(255, 200, 80, 0.35);
    color: #e8c878;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    margin-bottom: 16px;
}
.file-btn {
    background: #2b2b38;
    border: 1px solid #3a3a48;
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    user-select: none;
}
.file-btn:hover { background: #34344a; }
.file-btn input { display: none; }
.toggle {
    display: flex;
    background: #1a1a24;
    border: 1px solid #3a3a48;
    border-radius: 4px;
    overflow: hidden;
}
.toggle button {
    background: transparent;
    color: #b0b0c0;
    border: none;
    padding: 6px 12px;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
}
.toggle button.active {
    background: #3a3a48;
    color: #e6e6ee;
}
.toggle button:hover:not(.active) {
    background: #24242e;
}
.toggle button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.ext-links {
    display: flex;
    gap: 6px;
    align-items: center;
}
.ext-links a {
    display: flex;
    flex-direction: column;
    gap: 1px;
    text-decoration: none;
    padding: 4px 10px;
    border: 1px solid #3a3a48;
    border-radius: 4px;
    background: #1a1a24;
    white-space: nowrap;
    line-height: 1.15;
}
.ext-links a .main {
    color: #b0b0c0;
    font-size: 12px;
}
.ext-links a .sub {
    color: #6a6a80;
    font-size: 10px;
}
.ext-links a:hover {
    background: #24242e;
}
.ext-links a:hover .main { color: #e6e6ee; }
.ext-links a:hover .sub { color: #9a9ab0; }
button#reset-view {
    background: #2b2b38;
    color: #e6e6ee;
    border: 1px solid #3a3a48;
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    font: inherit;
}
button#reset-view:hover { background: #34344a; }
.slider-group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    font-size: 11px;
    min-width: 140px;
}
.slider-group label {
    color: #b0b0c0;
    user-select: none;
}
.slider-group label span {
    color: #e6e6ee;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.slider-group input[type=range] {
    width: 100%;
    accent-color: #5ecfc4;
}
#status {
    margin-left: auto;
    color: #b0b0c0;
    font-size: 12px;
}
canvas {
    position: fixed;
    top: 44px; left: 0;
    width: 100vw;
    height: calc(100vh - 44px);
    display: block;
    cursor: grab;
}
canvas.dragging { cursor: grabbing; }
#hud {
    position: fixed;
    left: 12px; bottom: 12px;
    background: rgba(15, 15, 22, 0.82);
    border: 1px solid #2a2a34;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    pointer-events: none;
    line-height: 1.5;
}
#hud .k { color: #8a8aa0; }

#legend {
    position: fixed;
    right: 12px; bottom: 12px;
    background: rgba(15, 15, 22, 0.82);
    border: 1px solid #2a2a34;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 11px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    width: 200px;
    pointer-events: none;
}
#legend .label { color: #8a8aa0; margin-bottom: 4px; }
#legend .bar {
    height: 10px;
    border-radius: 2px;
    background: linear-gradient(
        to right,
        rgb(55, 90, 135) 0%,
        rgb(58, 170, 140) 50%,
        rgb(255, 220, 60) 100%
    );
}
#legend .ticks {
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
    color: #c8c8d6;
}
