/* ============================================
   MODE CALCULATOR - COMPACT DESIGN
   ============================================ */

.mode-app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
    min-height: 100vh;
    background: var(--bg);
}

/* Compact Header */
.mode-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}

.mode-header h1 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    color: var(--text);
}

/* Controls Panel */
.controls-panel {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
}

.selectors-row {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.selector-group {
    flex: 1;
    min-width: 0;
}

.selector-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

/* Root Note Grid - 15 keys */
.root-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}

.root-btn {
    padding: 8px 2px;
    font-size: 13px;
    font-weight: 700;
    border: 2px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    transition: all 0.12s;
    text-align: center;
}

.root-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.root-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(20, 184, 166, 0.4);
}

/* Mode Grid */
.mode-grid {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border: 2px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    cursor: pointer;
    transition: all 0.12s;
    white-space: nowrap;
}

.mode-btn:hover {
    transform: translateY(-1px);
}

.mode-num {
    font-size: 10px;
    font-weight: 700;
    color: white;
    background: var(--text-light);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mode-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
}

/* Mode colors - Default state */
.mode-btn.ionian { border-color: #ef4444; }
.mode-btn.ionian .mode-num { background: #ef4444; }
.mode-btn.ionian .mode-name { color: #dc2626; }

.mode-btn.dorian { border-color: #06b6d4; }
.mode-btn.dorian .mode-num { background: #06b6d4; }
.mode-btn.dorian .mode-name { color: #0891b2; }

.mode-btn.phrygian { border-color: #f59e0b; }
.mode-btn.phrygian .mode-num { background: #f59e0b; }
.mode-btn.phrygian .mode-name { color: #d97706; }

.mode-btn.lydian { border-color: #3b82f6; }
.mode-btn.lydian .mode-num { background: #3b82f6; }
.mode-btn.lydian .mode-name { color: #2563eb; }

.mode-btn.mixolydian { border-color: #22c55e; }
.mode-btn.mixolydian .mode-num { background: #22c55e; }
.mode-btn.mixolydian .mode-name { color: #16a34a; }

.mode-btn.aeolian { border-color: #6b7280; }
.mode-btn.aeolian .mode-num { background: #6b7280; }
.mode-btn.aeolian .mode-name { color: #4b5563; }

.mode-btn.locrian { border-color: #8b5cf6; }
.mode-btn.locrian .mode-num { background: #8b5cf6; }
.mode-btn.locrian .mode-name { color: #7c3aed; }

/* Mode colors - Hover */
.mode-btn.ionian:hover { background: #fef2f2; }
.mode-btn.dorian:hover { background: #ecfeff; }
.mode-btn.phrygian:hover { background: #fffbeb; }
.mode-btn.lydian:hover { background: #eff6ff; }
.mode-btn.mixolydian:hover { background: #f0fdf4; }
.mode-btn.aeolian:hover { background: #f9fafb; }
.mode-btn.locrian:hover { background: #f5f3ff; }

/* Mode colors - Active (stronger emphasis) */
.mode-btn.ionian.active {
    background: #ef4444;
    border-color: #ef4444;
    box-shadow: 0 2px 10px rgba(239, 68, 68, 0.4);
}
.mode-btn.ionian.active .mode-num { background: white; color: #ef4444; }
.mode-btn.ionian.active .mode-name { color: white; }

.mode-btn.dorian.active {
    background: #06b6d4;
    border-color: #06b6d4;
    box-shadow: 0 2px 10px rgba(6, 182, 212, 0.4);
}
.mode-btn.dorian.active .mode-num { background: white; color: #06b6d4; }
.mode-btn.dorian.active .mode-name { color: white; }

.mode-btn.phrygian.active {
    background: #f59e0b;
    border-color: #f59e0b;
    box-shadow: 0 2px 10px rgba(245, 158, 11, 0.4);
}
.mode-btn.phrygian.active .mode-num { background: white; color: #f59e0b; }
.mode-btn.phrygian.active .mode-name { color: white; }

.mode-btn.lydian.active {
    background: #3b82f6;
    border-color: #3b82f6;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.4);
}
.mode-btn.lydian.active .mode-num { background: white; color: #3b82f6; }
.mode-btn.lydian.active .mode-name { color: white; }

.mode-btn.mixolydian.active {
    background: #22c55e;
    border-color: #22c55e;
    box-shadow: 0 2px 10px rgba(34, 197, 94, 0.4);
}
.mode-btn.mixolydian.active .mode-num { background: white; color: #22c55e; }
.mode-btn.mixolydian.active .mode-name { color: white; }

.mode-btn.aeolian.active {
    background: #6b7280;
    border-color: #6b7280;
    box-shadow: 0 2px 10px rgba(107, 114, 128, 0.4);
}
.mode-btn.aeolian.active .mode-num { background: white; color: #6b7280; }
.mode-btn.aeolian.active .mode-name { color: white; }

.mode-btn.locrian.active {
    background: #8b5cf6;
    border-color: #8b5cf6;
    box-shadow: 0 2px 10px rgba(139, 92, 246, 0.4);
}
.mode-btn.locrian.active .mode-num { background: white; color: #8b5cf6; }
.mode-btn.locrian.active .mode-name { color: white; }

/* Dark mode - mode button text */
body.dark-mode .mode-btn.locrian .mode-name { color: #a78bfa; }
body.dark-mode .mode-btn.aeolian .mode-name { color: #9ca3af; }

/* Main Body */
.mode-body {
    padding: 16px;
}

/* Placeholder */
.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.placeholder p {
    font-size: 14px;
    color: var(--text-light);
    margin: 0;
}

/* Results */
.results {
    max-width: 100%;
}

/* Selected Mode Card */
.selected-mode-card {
    background: var(--card);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 24px;
}

.card-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.card-header.ionian { background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%); }
.card-header.dorian { background: linear-gradient(135deg, #ecfeff 0%, #cffafe 100%); }
.card-header.phrygian { background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%); }
.card-header.lydian { background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%); }
.card-header.mixolydian { background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%); }
.card-header.aeolian { background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%); }
.card-header.locrian { background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%); }

body.dark-mode .card-header.ionian { background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, rgba(239, 68, 68, 0.08) 100%); }
body.dark-mode .card-header.dorian { background: linear-gradient(135deg, rgba(6, 182, 212, 0.15) 0%, rgba(6, 182, 212, 0.08) 100%); }
body.dark-mode .card-header.phrygian { background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(245, 158, 11, 0.08) 100%); }
body.dark-mode .card-header.lydian { background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(59, 130, 246, 0.08) 100%); }
body.dark-mode .card-header.mixolydian { background: linear-gradient(135deg, rgba(34, 197, 94, 0.15) 0%, rgba(34, 197, 94, 0.08) 100%); }
body.dark-mode .card-header.aeolian { background: linear-gradient(135deg, rgba(107, 114, 128, 0.15) 0%, rgba(107, 114, 128, 0.08) 100%); }
body.dark-mode .card-header.locrian { background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(139, 92, 246, 0.08) 100%); }

.card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.card-mode-name {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
}

.card-alterations {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    padding: 3px 8px;
    background: rgba(255,255,255,0.5);
    border-radius: 4px;
}

body.dark-mode .card-alterations {
    background: rgba(0,0,0,0.2);
}

.card-body {
    padding: 0;
}

/* Parent Key Banner - Subtle inline style */
.card-key-banner {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}

.key-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-light);
}

.key-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.card-section {
    padding: 14px 16px;
}

.card-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    text-align: center;
}

.notes-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.note-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 44px;
    padding: 10px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.note-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.note-degree {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-light);
    margin-top: 3px;
}

/* Tables Container - Side by side on larger screens */
.tables-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Modes Section */
.modes-section {
    margin-bottom: 0;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.section-label {
    font-size: 15px;
    font-weight: 800;
    color: var(--text);
    margin: 0;
}

.section-badge {
    font-size: 10px;
    font-weight: 700;
    color: var(--primary);
    background: rgba(20, 184, 166, 0.1);
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.section-desc {
    font-size: 12px;
    color: var(--text-light);
    margin: 0 0 10px;
}

/* Modes Table */
.table-wrapper {
    overflow-x: auto;
    background: var(--card);
    border-radius: 10px;
    border: 1px solid var(--border);
}

.modes-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.modes-table th,
.modes-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.modes-table th {
    background: var(--bg);
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
}

.modes-table tbody tr:last-child td {
    border-bottom: none;
}

.modes-table tbody tr {
    cursor: pointer;
    transition: background 0.1s;
}

.modes-table tbody tr:hover {
    background: var(--bg);
}

.modes-table .col-degree {
    width: 36px;
    text-align: center;
}

.modes-table .col-mode {
    width: 130px;
}

.modes-table .col-alter {
    width: 130px;
}

/* Table row colors */
.modes-table tr.row-ionian { border-left: 4px solid #ef4444; }
.modes-table tr.row-dorian { border-left: 4px solid #06b6d4; }
.modes-table tr.row-phrygian { border-left: 4px solid #f59e0b; }
.modes-table tr.row-lydian { border-left: 4px solid #3b82f6; }
.modes-table tr.row-mixolydian { border-left: 4px solid #22c55e; }
.modes-table tr.row-aeolian { border-left: 4px solid #6b7280; }
.modes-table tr.row-locrian { border-left: 4px solid #8b5cf6; }

.modes-table tr.selected {
    background: var(--bg);
}

.modes-table tr.selected.row-ionian { background: rgba(239, 68, 68, 0.1); }
.modes-table tr.selected.row-dorian { background: rgba(6, 182, 212, 0.1); }
.modes-table tr.selected.row-phrygian { background: rgba(245, 158, 11, 0.1); }
.modes-table tr.selected.row-lydian { background: rgba(59, 130, 246, 0.1); }
.modes-table tr.selected.row-mixolydian { background: rgba(34, 197, 94, 0.1); }
.modes-table tr.selected.row-aeolian { background: rgba(107, 114, 128, 0.1); }
.modes-table tr.selected.row-locrian { background: rgba(139, 92, 246, 0.1); }

.degree-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    color: white;
    background: var(--text-light);
}

.row-ionian .degree-badge { background: #ef4444; }
.row-dorian .degree-badge { background: #06b6d4; }
.row-phrygian .degree-badge { background: #f59e0b; }
.row-lydian .degree-badge { background: #3b82f6; }
.row-mixolydian .degree-badge { background: #22c55e; }
.row-aeolian .degree-badge { background: #6b7280; }
.row-locrian .degree-badge { background: #8b5cf6; }

.mode-cell {
    font-weight: 700;
    color: var(--text);
}

.row-ionian .mode-cell { color: #dc2626; }
.row-dorian .mode-cell { color: #0891b2; }
.row-phrygian .mode-cell { color: #d97706; }
.row-lydian .mode-cell { color: #2563eb; }
.row-mixolydian .mode-cell { color: #16a34a; }
.row-aeolian .mode-cell { color: #4b5563; }
.row-locrian .mode-cell { color: #7c3aed; }

body.dark-mode .row-aeolian .mode-cell { color: #9ca3af; }
body.dark-mode .row-locrian .mode-cell { color: #a78bfa; }

.alter-cell {
    font-size: 12px;
    color: var(--text-light);
}

.notes-cell {
    font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
    font-size: 12px;
    letter-spacing: 0.5px;
    color: var(--text);
}

/* Responsive - Tablet and below: stack tables */
@media (max-width: 900px) {
    .tables-container {
        grid-template-columns: 1fr;
    }

    .modes-section {
        margin-bottom: 20px;
    }
}

/* Responsive - Mobile */
@media (max-width: 600px) {
    .controls-panel {
        padding: 10px 12px;
    }

    .selectors-row {
        flex-direction: row;
        gap: 12px;
    }

    .selector-group {
        flex: 1;
    }

    .root-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 3px;
    }

    .root-btn {
        padding: 6px 2px;
        font-size: 12px;
    }

    .mode-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 3px;
    }

    .mode-btn {
        padding: 5px 4px;
        justify-content: center;
        flex-direction: column;
        gap: 2px;
    }

    .mode-name {
        font-size: 8px;
    }

    .mode-num {
        width: 16px;
        height: 16px;
        font-size: 10px;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .modes-table {
        font-size: 12px;
    }

    .modes-table th,
    .modes-table td {
        padding: 8px 10px;
    }

    .notes-cell {
        font-size: 11px;
    }

    .note-item {
        min-width: 38px;
        padding: 8px 6px;
    }

    .note-value {
        font-size: 16px;
    }

    .section-header {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .selectors-row {
        flex-direction: row;
        gap: 10px;
    }

    .root-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .root-btn {
        padding: 5px 1px;
        font-size: 11px;
    }

    .mode-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .mode-btn .mode-name {
        display: none;
    }

    .mode-btn {
        padding: 6px;
    }

    .mode-num {
        width: 18px;
        height: 18px;
        font-size: 10px;
    }

    .col-alter {
        display: none;
    }

    .note-item {
        min-width: 34px;
        padding: 6px 4px;
    }

    .note-value {
        font-size: 14px;
    }

    .note-degree {
        font-size: 10px;
    }
}
