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

body {
    background: #f2f2f2;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    display: flex;
    height: 100vh;
    overflow: hidden;
    color: #2d2d2d;
}

/* ── Sidebar ── */
#toolbar {
    width: 400px;
    background: #ffffff;
    border-right: 1px solid #d4d4d8;
    display: flex;
    flex-direction: column;
    padding: 18px 16px;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.03);
    z-index: 20;
    overflow-y: auto;
    gap: 14px;
    flex-shrink: 0;
}

#toolbar h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #18181b;
    letter-spacing: -0.3px;
}

.section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    font-weight: 700;
    color: #7c7c8a;
    margin: 6px 0 0;
}

textarea {
    width: 100%;
    height: 110px;
    resize: vertical;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 10px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 10px;
    background: #fafafa;
    outline: none;
    line-height: 1.5;
}

textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.smaps-textarea {
    height: 100px;
}

button {
    background: #1e293b;
    border: none;
    color: white;
    font-weight: 600;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s;
    letter-spacing: -0.2px;
}

button.primary {
    background: #2563eb;
}

button.primary:hover {
    background: #1d4ed8;
}

button:hover {
    background: #334155;
}

.row-btns {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.row-btns button {
    flex: 1;
    background: #f4f4f5;
    color: #3f3f46;
    border: 1px solid #e4e4e7;
    font-weight: 500;
    font-size: 0.78rem;
    padding: 8px 4px;
}

.row-btns button.active {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}

.filter-input {
    width: 100%;
    padding: 9px 12px;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    font-size: 0.85rem;
    background: #fafafa;
    outline: none;
}

.legend-box {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.68rem;
    background: #f9f9f9;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
}

.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
}

#details-box {
    background: #fafafa;
    border-radius: 12px;
    padding: 12px;
    font-size: 0.72rem;
    border: 1px solid #e5e7eb;
    color: #3f3f46;
    line-height: 1.6;
    max-height: 260px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── Viewport ── */
#viewport {
    flex: 1;
    overflow: auto;
    background: #ffffff;
    position: relative;
}

#canvas {
    position: relative;
    width: max-content;
    min-width: 100%;
    min-height: 100%;
    padding: 20px 30px 40px 30px;
}

.vcolumn {
    position: absolute;
    width: 5px;
    background: #cbd5e1;
    border-radius: 10px;
    top: 30px;
}

.addr-top-label {
    position: absolute;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: #475569;
    font-weight: 600;
    white-space: nowrap;
    transform: translateX(-50%);
}

.segment-block {
    position: absolute;
    left: -42px;
    width: 88px;
    border-radius: 8px;
    border: 3px solid;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    transition: all 0.15s;
    cursor: default;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    z-index: 10;
    color: #1e293b;
}

.segment-block:hover {
    z-index: 30;
    transform: scale(1.03);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
}

.rss-overlay-bar {
    position: absolute;
    background: #10b981;
    opacity: 0.5;
    border-radius: 3px;
    pointer-events: none;
    z-index: 5;
}

.boundary-hline {
    position: absolute;
    left: 10px;
    right: 10px;
    height: 1px;
    border-top: 2px dashed #d4d4d8;
    opacity: 0.7;
    pointer-events: none;
}

.boundary-text-right {
    position: absolute;
    right: 14px;
    font-size: 10px;
    font-weight: 700;
    color: #71717a;
    background: white;
    padding: 0 6px;
    font-family: 'JetBrains Mono', monospace;
}

.group-dso-label {
    position: absolute;
    left: 16px;
    font-weight: 700;
    font-size: 13px;
    color: #18181b;
    background: rgba(255, 255, 255, 0.85);
    padding: 2px 12px;
    border-radius: 8px;
    white-space: nowrap;
}

.tooltip-popup {
    position: fixed;
    background: #0f172a;
    color: #f1f5f9;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 12px;
    pointer-events: none;
    z-index: 2000;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.4);
    max-width: 340px;
    line-height: 1.5;
}

.vmflag-chip {
    display: inline-block;
    background: #334155;
    color: #e2e8f0;
    padding: 2px 7px;
    border-radius: 5px;
    margin: 1px;
    font-size: 10px;
    font-family: 'JetBrains Mono', monospace;
}