* { box-sizing: border-box; }
body { 
    font-family: 'Montserrat', sans-serif; 
    background: var(--surface-ground);
    color: var(--ink); 
    text-align: center; 
    margin: 0; 
    padding: 15px; 
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: 
        linear-gradient(135deg, var(--wash-teal) 0%, transparent 40%), linear-gradient(225deg, var(--wash-coral) 0%, transparent 40%);
    pointer-events: none;
    z-index: 0;
}

/* Header: the horizontal lockup (logo + OCTOPUS) and the tagline */
h1.brand {
    display: flex; align-items: center; justify-content: center; gap: 14px;
    margin: 10px 0 4px; line-height: 1;
}
.brand-logo { width: 118px; height: 64px; flex: none; }
.brand-word {
    font-family: 'Oswald', sans-serif; font-weight: 700; font-size: 44px;
    letter-spacing: -0.5px; text-transform: uppercase; color: var(--brand-wordmark);
}
.logo-fret { stroke: var(--logo-fret); }
.logo-string-high { stroke: var(--logo-string-high); }
p.subtitle {
    font-family: 'Oswald', sans-serif; font-size: 13px; font-weight: 500;
    margin: 0 0 22px; color: var(--tagline);
    text-transform: uppercase; letter-spacing: 4px;
}

.app-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    max-width: 1350px;
    margin: 0 auto;
    position: relative;
    z-index: 10;
}

@media (min-width: 1250px) {
    .app-layout {
        flex-direction: row;
        align-items: flex-start;
        justify-content: center;
    }
    
    .controls-sidebar {
        flex: 0 0 340px;
        position: sticky;
        top: 15px;
        max-height: calc(100vh - 30px);
        overflow-y: auto;
    }

    .main-content {
        flex: 1;
        min-width: 0;
    }
}

/* ---- Header: brand · modes · help / settings ---- */
.app-header {
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px;
    max-width: 1350px; margin: 0 auto 16px; position: relative; z-index: 20;
}
.brand-block { justify-self: start; text-align: left; }
.app-header h1.brand { justify-content: flex-start; margin: 0; gap: 10px; }
.app-header .brand-logo { width: 84px; height: 46px; }
.app-header .brand-word { font-size: 30px; }
.app-header p.subtitle { margin: 4px 0 0; font-size: 9.5px; letter-spacing: 3px; text-align: left; }
.modes { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-3); overflow: hidden; }
.modes button {
    border: none; border-radius: 0; border-right: 1px solid var(--line-strong);
    padding: 9px 16px; font-size: 12px; font-weight: 700; background: var(--surface-panel); color: var(--control-ink);
}
.modes button:last-child { border-right: none; }
.modes button.on { background: var(--selected); color: var(--on-selected); }
.top-actions { justify-self: end; display: flex; gap: 6px; }
.top-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 11px; font-size: 11px; font-weight: 700;
    background: var(--surface-panel); color: var(--ink-soft);
    border: 1px solid var(--line-strong); border-radius: var(--radius-3);
}
.top-toggle:hover, .top-toggle[aria-expanded="true"] { border-color: var(--action); color: var(--text-strong); background: var(--surface-panel); }
.top-toggle:focus-visible, .modes button:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* ---- Pop-overs: settings, help, rhythm ---- */
.pop {
    position: absolute; z-index: 60; text-align: left;
    background: var(--surface-panel); border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-float); padding: 14px 16px;
}
.pop[hidden] { display: none; }
.pop h4 { margin: 0 0 10px; font-family: 'Oswald', sans-serif; font-weight: 600; font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-strong); }
.settings-pop, .help-pop { right: 15px; top: 74px; width: 320px; }
.help-pop { width: 380px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0; }
.set-row > span { font-size: 11px; font-weight: 700; color: var(--ink-soft); }
.set-row .vb-seg button { padding: 6px 10px; }
.vb-seg button.active { background: var(--selected); color: var(--on-selected); }
.switch { min-width: 56px; padding: 6px 10px; font-size: 11px; font-weight: 800; }
.switch::before { content: 'Off'; }
.switch.active, .switch.on { background: var(--selected); color: var(--on-selected); border-color: var(--selected); box-shadow: none; }
.switch.active::before, .switch.on::before { content: 'On'; }
.help-pop p { font-size: 12px; line-height: 1.5; color: var(--ink-soft); margin: 0 0 10px; }
.help-dots { display: grid; grid-template-columns: repeat(5, auto); justify-content: start; gap: 4px 14px; align-items: center; margin: 4px 0 12px; }
.help-dots i { grid-row: 2; font-style: normal; font-size: 10px; color: var(--ink-muted); text-align: center; }
.help-note { grid-row: 1; justify-self: center; width: 27px; height: 27px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; box-shadow: var(--shadow-note); }
.help-legend { list-style: none; padding: 0; margin: 0 0 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.help-legend li { font-size: 10.5px; color: var(--ink-soft); }
.help-legend b { display: inline-block; min-width: 28px; color: var(--action); font-weight: 800; }
.got-it { display: block; margin: 12px 0 0 auto; padding: 8px 18px; font-size: 12px; font-weight: 800; background: var(--action); color: var(--on-action); border-color: var(--action); }
.got-it:hover { background: var(--action); color: var(--on-action); filter: brightness(1.08); }
.share-toast {
    position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
    background: var(--selected); color: var(--on-selected); padding: 10px 18px; border-radius: var(--radius-3);
    font-size: 12px; font-weight: 800; z-index: 200; transition: opacity 0.2s ease, transform 0.2s ease;
}
.share-toast.on { opacity: 1; transform: translate(-50%, 0); }
