/* =========================================================
   TONGUE DRUM — MODE-BASED UI (April 2026 simplification)
   3 mode tabs · contextual settings · welcome · help modal
   ========================================================= */

/* ---- Hide legacy chrome that the redesign replaces ---- */
body.simplified #menu-toggle,
body.simplified #settings-toggle,
body.simplified #light-mode-toggle,
body.simplified #controls,
body.simplified .scale-chips-wrap,
body.simplified #onboarding-new,
body.simplified #onboarding,
body.simplified #scales-overlay,
body.simplified #tips-overlay,
body.simplified #faq-overlay,
body.simplified #about-overlay,
body.simplified #practice-overlay,
body.simplified #learn-panel,
body.simplified #melody-browser {
    display: none !important;
}

/* The hidden settings panel still drives app.js via its inputs */
body.simplified #settings-panel,
body.simplified #sidebar,
body.simplified #backdrop {
    display: none !important;
}

/* Re-center brand without flanking icon buttons */
body.simplified #header {
    justify-content: flex-start;
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
}
body.simplified #header .brand {
    position: static;
    transform: none;
    margin-right: auto;
}

/* New header buttons */
.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.header-pill {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--text-2);
    height: 36px;
    padding: 0 12px;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 500;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.header-pill:hover {
    background: rgba(255,255,255,0.10);
    border-color: rgba(255,255,255,0.20);
    color: var(--text-1);
}
.header-pill svg { flex-shrink: 0; }

[data-theme="studio"] .header-pill {
    background: rgba(31,35,55,0.05);
    border-color: rgba(31,35,55,0.12);
    color: var(--text-2);
}
[data-theme="studio"] .header-pill:hover {
    background: rgba(31,35,55,0.10);
    color: var(--text-1);
}

/* ---- Mode tabs row ---- */
.mode-tabs {
    position: fixed;
    top: calc(52px + env(safe-area-inset-top));
    left: 0;
    right: 0;
    z-index: 95;
    height: 56px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 0 16px;
}
.mode-tab {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-2);
    padding: 9px 22px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.mode-tab:hover {
    color: var(--text-1);
    background: rgba(255,255,255,0.06);
}
.mode-tab.active {
    color: var(--text-1);
    background: rgba(124,111,255,0.16);
    border-color: rgba(124,111,255,0.32);
    box-shadow: 0 0 12px rgba(124,111,255,0.18);
}
[data-theme="studio"] .mode-tab:hover {
    background: rgba(31,35,55,0.06);
}
[data-theme="studio"] .mode-tab.active {
    background: rgba(99,102,241,0.12);
    border-color: rgba(99,102,241,0.40);
    color: #4f46e5;
    box-shadow: 0 0 12px rgba(99,102,241,0.20);
}

.tab-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: linear-gradient(135deg, #7C6FFF, #FD79A8);
    color: #fff;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Push canvas content down so mode tabs don't overlap */
body.simplified main#main {
    padding-top: 56px;
}

/* ---- Top context (melody/scale selector area) ---- */
.top-context {
    position: fixed;
    top: calc(52px + 56px + env(safe-area-inset-top) + 12px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: calc(100vw - 24px);
}
.top-card {
    background: var(--glass-bg);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.32);
}
.top-card .label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-3);
}
.top-card .ambient-hint {
    font-size: 13px;
    color: var(--text-2);
}
.top-card .ambient-glyph {
    font-size: 18px;
    line-height: 1;
}

.select-pill {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.14);
    color: var(--text-1);
    padding: 8px 32px 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    min-width: 200px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='rgba(255,255,255,0.4)' stroke-width='1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: background 0.2s, border-color 0.2s;
}
.select-pill:hover { background-color: rgba(255,255,255,0.10); }
[data-theme="studio"] .select-pill {
    background-color: rgba(31,35,55,0.05);
    border-color: rgba(31,35,55,0.12);
    color: var(--text-1);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='rgba(31,35,55,0.4)' stroke-width='1.5'/%3E%3C/svg%3E");
}

.btn-primary {
    background: linear-gradient(135deg, #7C6FFF, #9C8FFF);
    border: none;
    color: #fff;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.2s, transform 0.15s;
}
.btn-primary:hover { opacity: 0.88; }
.btn-primary:active { transform: scale(0.96); }
[data-theme="studio"] .btn-primary {
    background: linear-gradient(135deg, #6366F1, #8B5CF6);
}

/* ---- Bottom contextual settings ---- */
.contextual-settings {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;
    background: var(--glass-bg);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 14px 22px;
    display: flex;
    gap: 22px;
    align-items: center;
    box-shadow: 0 -4px 30px rgba(0,0,0,0.3), 0 10px 40px rgba(0,0,0,0.4);
    max-width: calc(100vw - 16px);
    flex-wrap: wrap;
    justify-content: center;
}
.contextual-settings::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
    pointer-events: none;
}
.contextual-settings .setting-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border: none;
    padding: 0;
}
.contextual-settings .setting-group + .setting-group {
    border-top: none;
    padding-top: 0;
}
.setting-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-3);
}
.setting-control {
    display: flex;
    gap: 6px;
    align-items: center;
}
.btn-setting {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.14);
    color: var(--text-1);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    font-family: inherit;
}
.btn-setting:hover { background: rgba(255,255,255,0.12); }
.btn-setting.active {
    background: linear-gradient(135deg, rgba(124,111,255,0.32), rgba(124,111,255,0.16));
    border-color: rgba(124,111,255,0.50);
    color: #c5bfff;
}
[data-theme="studio"] .btn-setting {
    background: rgba(31,35,55,0.05);
    border-color: rgba(31,35,55,0.12);
    color: var(--text-1);
}
[data-theme="studio"] .btn-setting:hover { background: rgba(31,35,55,0.09); }
[data-theme="studio"] .btn-setting.active {
    background: linear-gradient(135deg, rgba(99,102,241,0.20), rgba(99,102,241,0.10));
    border-color: rgba(99,102,241,0.45);
    color: #4f46e5;
}

.btn-record {
    background: rgba(255, 85, 119, 0.15);
    border: 1px solid rgba(255, 85, 119, 0.40);
    color: #FF5577;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s, border-color 0.2s;
}
.btn-record:hover { background: rgba(255, 85, 119, 0.25); }
.btn-record.active {
    background: rgba(255, 85, 119, 0.35);
    border-color: rgba(255, 85, 119, 0.60);
}
.btn-record .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #FF5577;
    box-shadow: 0 0 8px #FF5577;
}
.btn-record.active .dot {
    animation: rec-pulse-dot 1s infinite;
}
@keyframes rec-pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.5; transform: scale(0.85); }
}

.slider-mini {
    width: 110px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.10);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}
.slider-mini::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 8px var(--accent-glow);
}
.slider-mini::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    cursor: pointer;
}

.select-mini {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.14);
    color: var(--text-1);
    padding: 6px 26px 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='rgba(255,255,255,0.4)' stroke-width='1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}
[data-theme="studio"] .select-mini {
    background-color: rgba(31,35,55,0.05);
    border-color: rgba(31,35,55,0.12);
    color: var(--text-1);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='rgba(31,35,55,0.4)' stroke-width='1.5'/%3E%3C/svg%3E");
}

/* ---- Practice status (in-flight) ---- */
.practice-status-card {
    position: fixed;
    top: calc(52px + 56px + env(safe-area-inset-top) + 80px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 70;
    background: var(--glass-bg);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 14px 22px;
    text-align: center;
    display: none;
    pointer-events: none;
    min-width: 220px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
.practice-status-card.active { display: block; }
.practice-status-card h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-1);
}
.practice-status-card p {
    font-size: 12px;
    color: var(--text-2);
}
.practice-status-card.error p { color: #FF5577; }
.practice-status-card.complete p { color: #48D58E; }
.practice-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.10);
    border-radius: 2px;
    margin-top: 10px;
    overflow: hidden;
}
.practice-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #FD79A8);
    transition: width 0.3s;
    width: 0%;
}

/* ---- Welcome tooltip (first visit) ---- */
.welcome-tooltip {
    position: fixed;
    inset: 0;
    z-index: 350;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 20px;
}
.welcome-tooltip.active { display: flex; }
.welcome-card {
    background: var(--glass-bg);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 28px 32px;
    text-align: center;
    max-width: 460px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
[data-theme="studio"] .welcome-card {
    background: rgba(255,255,255,0.97);
    border-color: rgba(31,35,55,0.10);
}
.welcome-card h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #7C6FFF, #FD79A8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
[data-theme="studio"] .welcome-card h2 {
    background: linear-gradient(135deg, #6366F1, #EC4899);
    -webkit-background-clip: text;
    background-clip: text;
}
.mode-list {
    text-align: left;
    margin: 16px 0 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.mode-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px;
    background: rgba(255,255,255,0.04);
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
}
[data-theme="studio"] .mode-item {
    background: rgba(31,35,55,0.04);
    border-color: rgba(31,35,55,0.10);
}
.mode-item .icon { font-size: 22px; flex-shrink: 0; line-height: 1; }
.mode-item strong {
    display: block;
    font-size: 14px;
    margin-bottom: 2px;
    color: var(--text-1);
}
.mode-item span {
    font-size: 12.5px;
    color: var(--text-2);
    line-height: 1.5;
}
.btn-got-it {
    background: linear-gradient(135deg, #7C6FFF, #9C8FFF);
    border: none;
    color: #fff;
    padding: 12px 28px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.2s, transform 0.15s;
}
.btn-got-it:hover { opacity: 0.88; }
.btn-got-it:active { transform: scale(0.97); }
[data-theme="studio"] .btn-got-it {
    background: linear-gradient(135deg, #6366F1, #8B5CF6);
}

/* ---- Help overlay (4-tab modal) ---- */
.help-overlay {
    position: fixed;
    inset: 0;
    z-index: 320;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.help-overlay.active { display: flex; }
.help-modal {
    position: relative;
    background: rgba(14,18,40,0.95);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 28px 30px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0,0,0,0.5);
}
[data-theme="studio"] .help-modal {
    background: rgba(255,255,255,0.97);
    border-color: rgba(31,35,55,0.10);
    color: var(--text-1);
}
.help-modal h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
    background: linear-gradient(135deg, #fff, var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
[data-theme="studio"] .help-modal h2 {
    background: linear-gradient(135deg, #1f2337, #6366f1);
    -webkit-background-clip: text;
    background-clip: text;
}
.help-modal .help-subtitle {
    font-size: 13px;
    color: var(--text-3);
    margin-bottom: 20px;
}
.help-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--glass-border);
    flex-wrap: wrap;
}
.help-tab {
    background: transparent;
    border: none;
    color: var(--text-2);
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.2s, border-color 0.2s;
}
.help-tab:hover { color: var(--text-1); }
.help-tab.active {
    color: var(--text-1);
    border-bottom-color: var(--accent);
}
[data-theme="studio"] .help-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.help-content { padding-bottom: 6px; }
.help-content h3 {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--accent);
    margin: 18px 0 8px;
}
.help-content h3:first-child { margin-top: 0; }
.help-content p {
    font-size: 13px;
    color: var(--text-2);
    line-height: 1.65;
    margin-bottom: 8px;
}
.help-content ul {
    font-size: 13px;
    color: var(--text-2);
    line-height: 1.7;
    padding-left: 18px;
    list-style: disc;
}
.help-content kbd {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 5px;
    padding: 2px 7px;
    font-family: inherit;
    font-size: 12px;
    color: var(--text-1);
    min-width: 22px;
    text-align: center;
    display: inline-block;
}
[data-theme="studio"] .help-content kbd {
    background: rgba(31,35,55,0.06);
    border-color: rgba(31,35,55,0.18);
}
.help-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255,255,255,0.08);
    border: none;
    color: var(--text-1);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}
.help-close:hover { background: rgba(255,255,255,0.14); }
[data-theme="studio"] .help-close {
    background: rgba(31,35,55,0.06);
    color: var(--text-1);
}
[data-theme="studio"] .help-close:hover { background: rgba(31,35,55,0.10); }

/* ---- Responsive tweaks ---- */
@media (max-width: 640px) {
    .mode-tabs { height: 50px; gap: 2px; padding: 0 10px; }
    .mode-tab { padding: 8px 14px; font-size: 12.5px; }
    body.simplified main#main { padding-top: 50px; }
    .top-context { top: calc(52px + 50px + env(safe-area-inset-top) + 8px); }
    .top-card { padding: 10px 12px; gap: 10px; }
    .select-pill { min-width: 150px; font-size: 12px; }
    .contextual-settings {
        gap: 14px;
        padding: 12px 16px;
        border-radius: 14px;
    }
    .slider-mini { width: 80px; }
    .practice-status-card { top: calc(52px + 50px + env(safe-area-inset-top) + 60px); }
}
@media (max-width: 480px) {
    .mode-tab { padding: 8px 10px; font-size: 12px; gap: 4px; }
    .tab-badge { font-size: 8px; padding: 1px 4px; }
    .top-card { flex-wrap: wrap; }
    .select-pill { min-width: 130px; }
    .contextual-settings {
        gap: 10px;
        padding: 10px 12px;
        bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }
    .header-pill .header-pill-label { display: none; }
    .header-pill { padding: 0 10px; }
}

@media (prefers-reduced-motion: reduce) {
    .btn-record.active .dot { animation: none; }
}
