/* ─── palette ─── */
:root {
    --bg: #1a1b1e;
    --surface: #25262b;
    --surface2: #2c2e33;
    --text: #c1c2c5;
    --text-dim: #909296;
    --border: #373a40;
    --accent: #339af0;
    --green: #51cf66;
    --red: #ff6b6b;
    --orange: #ffa94d;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

/* ─── layout ─── */
.v4-layout {
    display: grid;
    grid-template-rows: 44px 1fr 35vh;
    height: 100vh;
    width: 100vw;
}

/* ─── calendar strip ─── */
.cal-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    overflow: hidden;
}

.cal-title {
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    color: var(--accent);
    white-space: nowrap;
}

.cal-scroll {
    flex: 1;
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 4px 0;
}
.cal-scroll::-webkit-scrollbar { display: none; }

.cal-day {
    flex: 0 0 auto;
    width: 42px;
    height: 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    background: transparent;
    border: 1px solid transparent;
    transition: all 0.15s;
}
.cal-day:hover { background: var(--surface2); }

.cal-day.active {
    background: var(--accent);
    color: #fff;
}
.cal-day.active .cal-wk,
.cal-day.active .cal-num { color: #fff; }

.cal-day.critical-window { border-color: rgba(255,107,107,0.4); }
.cal-day.critical-window.active {
    background: var(--red);
    border-color: var(--red);
}

.cal-day.disabled-day {
    opacity: 0.25;
    pointer-events: none;
}

.cal-wk {
    font-size: 0.5rem;
    text-transform: uppercase;
    color: var(--text-dim);
    font-weight: 600;
    line-height: 1;
}
.cal-num {
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
}

.week-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    align-self: center;
    margin: 0 2px;
    flex-shrink: 0;
}

.cal-tools {
    display: flex;
    gap: 6px;
}

.tool-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tool-btn:hover { background: var(--surface2); }

/* ─── map ─── */
.map-section {
    position: relative;
    overflow: hidden;
}
#map {
    width: 100%;
    height: 100%;
    background: #111;
}

/* map controls overlay */
.map-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
}

.mc-toggle {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
}
.mc-toggle:hover { background: var(--surface2); }

.mc-body {
    display: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    margin-top: 6px;
    width: 180px;
    max-height: 60vh;
    overflow-y: auto;
}
.mc-body.open { display: block; }

.mc-group {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.mc-group:last-child { border-bottom: none; margin-bottom: 0; }

.mc-group h4 {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.mc-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    color: var(--text);
    cursor: pointer;
    padding: 2px 0;
}

.preset-btn {
    display: block;
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    cursor: pointer;
    text-align: left;
    margin-bottom: 3px;
}
.preset-btn:hover { border-color: var(--accent); }

/* headlines overlay */
.headlines-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 220px;
    max-height: 50%;
    background: rgba(26,27,30,0.92);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    overflow-y: auto;
    z-index: 1000;
    font-size: 0.7rem;
}
.headlines-overlay h4 {
    font-size: 0.7rem;
    color: var(--text);
    margin-bottom: 6px;
}
.headlines-overlay h4 span {
    background: var(--accent);
    color: #fff;
    font-size: 0.6rem;
    padding: 1px 5px;
    border-radius: 8px;
    margin-left: 4px;
}
.headlines-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.headline-item {
    font-size: 0.65rem;
    color: var(--text-dim);
    padding: 3px 6px;
    background: var(--surface2);
    border-radius: 3px;
    border-left: 2px solid var(--accent);
}

/* ─── card section ─── */
.card-section {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-top: 1px solid var(--border);
    overflow: hidden;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.card-header h2 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.card-total {
    font-size: 0.7rem;
    color: var(--text-dim);
    font-family: 'JetBrains Mono', monospace;
}

.card-deck {
    display: flex;
    gap: 12px;
    padding: 10px 16px;
    overflow-x: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.card-zone {
    flex: 0 0 260px;
    background: var(--surface2);
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.zone-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}
.zone-header h3 {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.zone-count {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
    background: rgba(51,154,240,0.15);
    padding: 1px 6px;
    border-radius: 8px;
}

.zone-cards {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.zone-cards::-webkit-scrollbar { width: 3px; }
.zone-cards::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.data-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    cursor: pointer;
    transition: border-color 0.15s;
}
.data-card:hover { border-color: var(--accent); }

.data-card.sentiment-good { border-left: 3px solid var(--green); }
.data-card.sentiment-bad  { border-left: 3px solid var(--red); }

.card-suit {
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    margin-bottom: 3px;
}
.data-card.sentiment-good .card-suit { color: var(--green); }
.data-card.sentiment-bad  .card-suit { color: var(--red); }

.card-title {
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--text);
}

/* scrollbar global */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── V5 Layout ─── */
.v5-layout {
    display: grid;
    grid-template-rows: auto 1fr 30vh;
    height: 100vh;
    width: 100vw;
    background: var(--bg);
}

/* ─── Top Timeline ─── */
.top-timeline {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.sliders-container {
    display: flex;
    justify-content: space-around;
    padding: 8px 16px;
    background: var(--surface2);
    border-top: 1px solid var(--border);
}

.slider-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 45%;
}

.slider-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text);
}

.slider-group input[type="range"] {
    width: 100%;
}

/* ─── Main Map Area ─── */
.main-map-area {
    display: flex;
    position: relative;
    overflow: hidden;
}

#map {
    flex: 1;
    height: 100%;
}

.control-panel {
    width: 280px;
    background: rgba(37, 38, 43, 0.95);
    backdrop-filter: blur(10px);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 16px;
    gap: 16px;
}

.panel-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
}

.viewport-dropdown {
    width: 100%;
    padding: 6px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.8rem;
}

.radio-list, .checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.radio-list label, .checkbox-list label {
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.panel-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
}

.action-btn {
    flex: 1;
    padding: 8px;
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}
.action-btn:hover { background: var(--accent); color: #fff; }

/* ─── Gameboard Area ─── */
.gameboard-area {
    background: #1e1f23;
    border-top: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.gb-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.gb-header h2 {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text);
}

.gb-stats {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
}

.gb-zones {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.gb-zone {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    padding: 8px;
    background: var(--bg);
}
.gb-zone:last-child { border-right: none; }

.gb-zone h3 {
    font-size: 0.75rem;
    text-align: center;
    color: var(--text-dim);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.gb-zone .card-deck {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
}

/* Additional CSS for 3 Sliders */
.slider-group label input[type="checkbox"] {
    margin-right: 6px;
    vertical-align: middle;
}
.slider-group {
    width: 32%;
}
