:root {
    --bg-primary: #0a0e27;
    --bg-secondary: #151932;
    --bg-tertiary: #1e2742;
    --bg-card: #1a1f3a;
    --bg-hover: #252b4a;
    --bg-border: #2a3458;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --warning: #ffb300;
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
}

body {
    margin: 0;
    padding: 0;
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', 'Roboto', sans-serif;
    transition: filter 0.3s ease;
}

body.night-mode {
    filter: contrast(0.95) brightness(0.98);
}

body.day-mode {
    filter: contrast(1.05) brightness(1.02);
}

header {
    padding: 16px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--bg-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-lg);
    position: relative;
}

h2 {
    font-size: 30px;
    font-weight: 900;
    letter-spacing: -0.03em;
    color: #fff;
    white-space: nowrap;
}

#volumeBox {
    margin-left: 16px;
    font-size: 15px;
    font-weight: bold;
    color: var(--warning);
    padding: 5px 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--bg-border);
    transition: color 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease, filter 0.3s ease;
}

#volumeBox.flash {
    background-color: rgba(255, 179, 0, 0.25);
    box-shadow: 0 0 12px rgba(255, 179, 0, 0.4);
}

#volumeBox.dim {
    color: #cc9000;
}

#volumeBox.stopped {
    color: #888;
    opacity: 0.5;
    filter: grayscale(0.8);
}

#volumeBox.alert {
    animation: borderBlink 0.4s ease infinite;
}

@keyframes borderBlink {
    0%, 100% { border-color: var(--bg-border); }
    50% { border-color: #ff4444; }
}

#volumeSpeed {
    margin-left: 8px;
    font-size: 12px;
    font-weight: normal;
}

#volumeSpeed.up {
    color: #4ade80;
}

#volumeSpeed.down {
    color: #fbbf24;
}

#volumeSpeed.neutral {
    color: #94a3b8;
}

.loading-text {
    font-size: 12px;
    color: rgba(226, 232, 240, 0.5);
}

#wsStatus {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 12px;
}

#wsStatus.connected {
    color: #4ade80;
}

#wsStatus.disconnected {
    color: #f87171;
}

#tensionGauge {
    width: 100px;
    height: 6px;
    background: rgba(42, 52, 88, 0.5);
    border-radius: 3px;
    margin-left: 12px;
    position: relative;
    overflow: hidden;
}

#tensionGaugeBar {
    height: 100%;
    background: linear-gradient(90deg, #4ade80, #fbbf24, #f87171);
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 3px;
}

#sensitivityControl {
    margin-left: 8px;
    display: flex;
    gap: 4px;
}

#sensitivityControl button {
    background: rgba(15, 21, 37, 0.5);
    color: rgba(148, 163, 184, 0.6);
    border: 1px solid rgba(42, 52, 88, 0.5);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#sensitivityControl button.active {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.5);
    color: var(--text-primary);
}

#chart-wrap {
    height: 500px;
    border: 1px solid #293457;
    border-radius: 4px;
    padding: 20px;
    background: var(--bg-secondary);
    position: relative;
    transition: transform 0.1s ease, filter 0.3s ease;
    margin: 40px;
}

#chart-wrap.shake {
    animation: chartShake 0.3s ease;
}

@keyframes chartShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

#chart-wrap.stopped {
    filter: grayscale(0.6) contrast(0.9);
}

#chart-wrap::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at center, rgba(255, 179, 0, 0.02) 0%, transparent 60%);
    pointer-events: none;
    z-index: 2;
}

#chartAlertOverlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 68, 68, 0.08);
    pointer-events: none;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#chartAlertOverlay.active {
    opacity: 1;
}

#chartDenseBand {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 179, 0, 0.03);
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#chartDenseBand.active {
    opacity: 1;
}

#chartHeatZone {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(255, 179, 0, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.5s ease;
    margin: 20px;
}

#chartHeatZone.active {
    opacity: 1;
}

#chartHoverHighlight {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 4;
    opacity: 0;
    transition: opacity 0.2s ease;
}

#chartHoverHighlight.active {
    opacity: 1;
}

#chartCanvas {
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, #040b1b 0%, var(--bg-primary) 100%);
    border-radius: 4px;
    border: 1px solid var(--bg-border);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 1;
    transition: filter 0.3s ease;
    padding: 20px;
}

#sparkContainer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 5;
    margin: 20px;
}

.spark {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #ffb300;
    border-radius: 50%;
    pointer-events: none;
    animation: sparkFade 0.6s ease-out forwards;
}

@keyframes sparkFade {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0) translate(var(--spark-x, 0), var(--spark-y, 0));
    }
}

#toggleEffects {
    background: rgba(15, 21, 37, 0.5);
    color: rgba(148, 163, 184, 0.6);
    border: 1px solid rgba(42, 52, 88, 0.5);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#toggleEffects:hover {
    background: rgba(18, 34, 104, 0.6);
    border-color: rgba(255, 179, 0, 0.4);
}

#toggleEffects.active {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.5);
    color: var(--text-primary);
}

.manual-section {
    margin: 20px 40px;
    background: #1a1f3a;
    border: 1px solid var(--bg-border);
    border-radius: 5px;
    overflow: hidden;
}
.manual-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.18s ease, color 0.18s ease;
}
.manual-header:hover {
    background: #040b1b;
}
.manual-header h3 {
    font-size: 15px;
    color: var(--warning);
    font-weight: 800;
    margin: 0;
    transition: color 0.18s ease;
}
.manual-toggle {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 700;
    transition: color 0.18s ease;
}
.manual-header:hover .manual-toggle {
    color: var(--warning);
}
.manual-content {
    display: none;
    border-top: 1px solid var(--bg-border);
}
.manual-content.open {
    display: block;
}
.manual-body {
    padding: 14px 18px;
}
.manual-item {
    border-bottom: 1px solid rgba(255,255,255,0.06);
    padding: 10px 0;
}
.manual-item:last-child {
    border-bottom: 0;
}
.manual-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 4px;
    transition: background-color 0.18s ease, transform 0.18s ease;
}
.manual-item-header:hover {
    background: rgba(56, 189, 248, 0.10);
    transform: translateX(2px);
}
.manual-item-header h4 {
    font-size: 14px;
    font-weight: 700;
    color: #e2e8f0;
    margin: 0;
    transition: color 0.18s ease;
}
.manual-item-header:hover h4 {
    color: #7dd3fc;
}
.manual-item-header.is-open h4 {
    color: #4ade80;
}
.manual-item-toggle {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    min-width: 14px;
    text-align: right;
    transition: color 0.18s ease;
}
.manual-item-header:hover .manual-item-toggle,
.manual-item-header.is-open .manual-item-toggle {
    color: #7dd3fc;
}
.manual-item-header.is-open .manual-item-toggle {
    color: #4ade80;
}
.manual-item-content {
    display: none;
    margin-top: 10px;
    color: #cbd5e1;
    font-size: 13px;
    line-height: 1.7;
    padding: 0 12px;
}
.manual-item-content.open {
    display: block;
}
.manual-item-content ul {
    padding-left: 18px;
    margin: 6px 0 10px;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
    border: 2px solid var(--bg-secondary);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-hover);
}