/* Theme Variables */
:root {
    /* Regular Theme (Default) */
    --bg-color: #f0f0f0;
    --panel-bg: #ffffff;
    --border-color: #333333;
    --button-bg: #e0e0e0;
    --button-hover: #d0d0d0;
    --accent-1: #4a90e2;
    --accent-2: #5da8ff;
    --accent-3: #50c878;
    --delete-color: #e24a4a;
    --text-color: #000000;
    --input-bg: #ffffff;
    --input-text: #000000;
    --list-even: #f8f8f8;
    --tab-inactive-bg: #e0e0e0;
    --tab-active-bg: #4a90e2;
    --tab-hover-bg: #c0c0c0;
    --scrollbar-track: #333333;
    --scrollbar-thumb: #4a90e2;
    --scrollbar-thumb-hover: #5da8ff;
    --info-bg: #ffffff;
    --info-title-bg: #4a90e2;
    --info-title-text: #ffffff;
    --result-bg: #fafafa;
    --result-border: #e0e0e0;
    --success-color: #28a745;
}

.theme-high-contrast {
    --bg-color: #ffffff;
    --panel-bg: #ffffff;
    --border-color: #000000;
    --button-bg: #ffffff;
    --button-hover: #000000;
    --accent-1: #000000;
    --accent-2: #333333;
    --accent-3: #000000;
    --delete-color: #000000;
    --text-color: #000000;
    --input-bg: #ffffff;
    --input-text: #000000;
    --list-even: #f0f0f0;
    --tab-inactive-bg: #d0d0d0;
    --tab-active-bg: #000000;
    --tab-hover-bg: #aaaaaa;
    --scrollbar-track: #ffffff;
    --scrollbar-thumb: #000000;
    --scrollbar-thumb-hover: #333333;
    --info-bg: #ffffff;
    --info-title-bg: #000000;
    --info-title-text: #ffffff;
    --result-bg: #ffffff;
    --result-border: #000000;
    --success-color: #000000;
}

.theme-dark {
    --bg-color: #1a1a1a;
    --panel-bg: #2d2d2d;
    --border-color: #404040;
    --button-bg: #404040;
    --button-hover: #505050;
    --accent-1: #4a90e2;
    --accent-2: #5da8ff;
    --accent-3: #50c878;
    --delete-color: #ff6b6b;
    --text-color: #ffffff;
    --input-bg: #404040;
    --input-text: #ffffff;
    --list-even: #363636;
    --tab-inactive-bg: #404040;
    --tab-active-bg: #4a90e2;
    --tab-hover-bg: #505050;
    --scrollbar-track: #404040;
    --scrollbar-thumb: #4a90e2;
    --scrollbar-thumb-hover: #5da8ff;
    --info-bg: #2d2d2d;
    --info-title-bg: #4a90e2;
    --info-title-text: #ffffff;
    --result-bg: #383838;
    --result-border: #505050;
    --success-color: #50c878;
}

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

body {
    font-family: 'Times New Roman', Times, serif;
    background-color: var(--bg-color);
    padding: 20px;
    color: var(--text-color);
    transition: all 0.3s ease;
    min-height: 100vh;
    position: relative;
}

/* Corner Buttons */
.corner-btn {
    position: absolute;
    padding: 8px 16px;
    background-color: var(--accent-1);
    color: white;
    text-decoration: none;
    border: 2px solid var(--border-color);
    font-family: 'Times New Roman', Times, serif;
    font-size: 14px;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.2s ease;
    border-radius: 0;
}

.corner-btn:hover {
    background-color: var(--accent-2);
}

.return-btn {
    top: 20px;
    left: 20px;
}

.theme-btn {
    top: 20px;
    right: 20px;
}

/* Main Container */
.main-container {
    max-width: 1200px;
    margin: 55px auto 20px;
    background-color: var(--panel-bg);
    border: 2px solid var(--border-color);
    border-radius: 0;
    display: flex;
    flex-direction: column;
}

.title-bar {
    background-color: var(--accent-1);
    color: white;
    padding: 12px 20px;
    font-weight: bold;
    font-size: 18px;
    border-bottom: 2px solid var(--border-color);
    text-align: left;
    flex-shrink: 0;
}

/* Template Content Styles */
.template-content {
    padding: 30px;
    min-height: 500px;
    flex-grow: 1;
}

.template-content h2 {
    color: var(--accent-1);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent-1);
}

.template-content p {
    margin-bottom: 15px;
    line-height: 1.6;
}

.template-features {
    margin-top: 25px;
    padding: 15px;
    background-color: var(--list-even);
    border-left: 4px solid var(--accent-1);
}

.template-features h3 {
    margin-bottom: 10px;
    color: var(--accent-2);
}

.template-features ul {
    padding-left: 20px;
    margin-bottom: 15px;
}

.template-features li {
    margin-bottom: 8px;
    line-height: 1.5;
}

/* Info Section */
.info-section {
    width: 900px;
    height: 350px;
    margin: 20px auto 20px;
    border: 2px solid var(--border-color);
    background-color: var(--info-bg);
    border-radius: 0;
    display: flex;
    flex-direction: column;
}

.info-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    background-color: var(--list-even);
    flex-shrink: 0;
}

.info-tab-btn {
    flex: 1;
    padding: 12px 20px;
    background-color: var(--tab-inactive-bg);
    border: none;
    cursor: pointer;
    font-family: 'Times New Roman', Times, serif;
    font-size: 15px;
    font-weight: bold;
    color: var(--text-color);
    transition: all 0.2s ease;
    border-right: 1px solid var(--border-color);
    border-radius: 0;
}

.info-tab-btn:last-child {
    border-right: none;
}

.info-tab-btn:hover {
    background-color: var(--tab-hover-bg);
}

.info-tab-btn.active {
    background-color: var(--tab-active-bg);
    color: white;
}

.info-tab-content {
    display: none;
    padding: 20px;
    flex: 1;
    overflow: hidden;
}

.info-tab-content.active {
    display: block;
}

.info-content-scroll {
    height: 100%;
    overflow-y: auto;
    padding-right: 10px;
}

/* Scrollbar styling */
.info-content-scroll::-webkit-scrollbar {
    width: 8px;
}

.info-content-scroll::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    opacity: 0.3;
}

.info-content-scroll::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border: 1px solid var(--border-color);
}

.info-content-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

.info-content-scroll {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.info-content-scroll h4 {
    margin: 16px 0 8px 0;
    padding-bottom: 4px;
    border-bottom: 2px solid var(--border-color);
    color: var(--accent-1);
    font-size: 16px;
}

.info-content-scroll h4:first-of-type {
    margin-top: 0;
}

.info-content-scroll p {
    margin-bottom: 12px;
    line-height: 1.5;
    font-size: 13px;
    color: var(--text-color);
}

.info-content-scroll ul {
    margin: 8px 0 12px 25px;
    line-height: 1.5;
    font-size: 13px;
    color: var(--text-color);
}

.info-content-scroll li {
    margin-bottom: 4px;
}

.info-content-scroll strong {
    color: var(--accent-1);
}

.info-content-scroll a {
    color: var(--accent-1);
    text-decoration: none;
    font-size: 13px;
}

.info-content-scroll a:hover {
    text-decoration: underline;
}

/* Footer */
.footer-container {
    max-width: 1200px;
    margin: 20px auto 0;
    text-align: center;
    padding: 12px;
}

.copyright-footer {
    margin-bottom: 8px;
    color: var(--text-color);
    opacity: 0.7;
    font-size: 14px;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.footer-links a {
    color: var(--accent-1);
    text-decoration: none;
    font-size: 13px;
}

.footer-links a:hover {
    text-decoration: underline;
}

/* Button Styles */
button {
    padding: 8px 12px;
    background: var(--button-bg);
    border: 2px solid var(--border-color);
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-color);
    transition: all 0.2s ease;
    border-radius: 0;
}

button:hover {
    background: var(--button-hover);
}

button:active {
    transform: translate(1px, 1px);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-container {
        max-width: 95%;
    }
    
    .info-section {
        width: 95%;
        max-width: 900px;
        height: 300px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .corner-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .return-btn {
        top: 10px;
        left: 10px;
    }
    
    .theme-btn {
        top: 10px;
        right: 10px;
    }
    
    .main-container {
        margin-top: 50px;
        max-width: 100%;
    }
    
    .template-content {
        padding: 15px;
        min-height: 350px;
    }
    
    .info-section {
        width: 100%;
        height: 350px;
        max-width: 100%;
    }
    
    .info-tabs {
        flex-direction: column;
    }
    
    .info-tab-btn {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .info-tab-btn:last-child {
        border-bottom: none;
    }
}

@media (max-width: 480px) {
    .title-bar {
        font-size: 16px;
        padding: 10px;
    }
    
    .template-content {
        padding: 15px;
        min-height: 300px;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 8px;
    }
    
    .info-tab-btn {
        padding: 10px;
        font-size: 13px;
    }
    
    .info-section {
        height: 400px;
    }
}

/* Metronome */
.metro-content { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 24px; padding: 24px; }
.metro-stage { border: 2px solid var(--border-color); background: var(--result-bg); padding: 10px; }
#metroSvg { display: block; width: 100%; max-width: 300px; height: auto; margin: 0 auto; }
.m-body { fill: var(--panel-bg); stroke: var(--border-color); stroke-width: 3; }
.m-rod { stroke: var(--text-color); stroke-width: 5; }
.m-weight { fill: var(--accent-1); stroke: var(--border-color); stroke-width: 2; }
.m-pivot { fill: var(--border-color); }

.beat-row { display: flex; align-items: flex-end; gap: 6px; margin-top: 14px; min-height: 80px; }
.beat-cell { flex: 1; max-width: 48px; padding: 0; border: none; background: none; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; font-size: 13px; }
.beat-cell:hover { background: none; }
.beat-cell .bar { width: 100%; border: 2px solid var(--border-color); }
.beat-cell[data-level="2"] .bar { height: 46px; background: var(--accent-1); }
.beat-cell[data-level="1"] .bar { height: 26px; background: var(--accent-3); }
.beat-cell[data-level="0"] .bar { height: 10px; background: transparent; border-style: dashed; }
.beat-cell.active .bar { outline: 3px solid var(--text-color); outline-offset: 2px; }
.hint, .keys { font-size: 13px; opacity: 0.75; margin-top: 8px; }

.bpm-panel { text-align: center; border: 2px solid var(--border-color); padding: 14px; margin-bottom: 14px; }
#bpmInput { width: 5.5ch; font-size: 64px; font-weight: bold; text-align: center; border: none; background: transparent; color: var(--accent-1); font-family: inherit; -moz-appearance: textfield; appearance: textfield; padding: 0; }
#bpmInput::-webkit-outer-spin-button, #bpmInput::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.bpm-unit { font-size: 18px; margin-left: 6px; }
.tempo-name { font-style: italic; font-size: 22px; margin-bottom: 10px; }
#bpmSlider, #volume { width: 100%; accent-color: var(--accent-1); }
.nudge-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 10px; }

.start-btn { width: 100%; padding: 14px; font-size: 20px; font-weight: bold; background: var(--accent-3); color: #fff; margin-bottom: 14px; }
.start-btn:hover { background: var(--accent-3); filter: brightness(0.9); }
.start-btn.running, .start-btn.running:hover { background: var(--delete-color); }

.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.settings label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.metro-content select, .metro-content input[type="number"] { padding: 6px; border: 2px solid var(--border-color); background: var(--input-bg); color: var(--input-text); font-family: inherit; font-size: 15px; border-radius: 0; }
.trainer { border: 2px solid var(--border-color); padding: 10px 12px; margin-top: 14px; font-size: 14px; }
.trainer legend { padding: 0 6px; font-weight: bold; }
.trainer .row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.trainer input[type="number"] { width: 70px; }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }

@media (max-width: 768px) {
    .metro-content { grid-template-columns: 1fr; padding: 14px; }
    #bpmInput { font-size: 52px; }
}
