:root {
    --bg: #0a192f;
    --bg-2: #112240;
    --bg-3: #172a45;
    --line: rgba(100, 255, 218, 0.12);
    --text: #ccd6f6;
    --muted: #8892b0;
    --white: #e6f1ff;
    --green: #64ffda;
    --orange: #ff7e36;
    --violet: #a359a0;
    --shadow: 0 24px 60px rgba(2, 12, 27, 0.45);
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: dark;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, "Segoe UI", system-ui, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 12% 12%, rgba(255, 126, 54, 0.16), transparent 26%),
        radial-gradient(circle at 82% 18%, rgba(163, 89, 160, 0.16), transparent 24%),
        radial-gradient(circle at 50% 100%, rgba(100, 255, 218, 0.1), transparent 28%),
        linear-gradient(180deg, #081321 0%, #0a192f 50%, #0d2037 100%);
}

.page-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 40px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    margin-bottom: 18px;
}

.back-link,
.back-link:visited {
    color: var(--green);
    text-decoration: none;
    font-weight: 700;
}

.back-link:hover,
.back-link:focus-visible {
    color: var(--orange);
}

.topbar-note {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
    text-align: right;
}

.hero-card,
.controls-card,
.visual-card,
.selector-card,
.play-card,
.compose-card,
.guide-card {
    background: rgba(17, 34, 64, 0.88);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.hero-card {
    padding: 32px;
}

.controls-card,
.visual-card,
.selector-card,
.play-card,
.compose-card,
.guide-card {
    margin-top: 18px;
    padding: 24px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--orange);
    font-size: 0.78rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    font-weight: 700;
}

h1,
h2,
h3 {
    margin: 0;
    color: var(--white);
    line-height: 1.08;
}

h1 {
    font-size: clamp(2.7rem, 6vw, 4.9rem);
    max-width: 12ch;
}

h2 {
    font-size: clamp(1.6rem, 3vw, 2.3rem);
}

h3 {
    font-size: 1.06rem;
}

.hero-text,
.panel-copy {
    margin: 16px 0 0;
    color: var(--muted);
    max-width: 68ch;
    line-height: 1.7;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 26px;
}

.primary-button,
.secondary-button {
    appearance: none;
    border-radius: 14px;
    padding: 14px 20px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.primary-button {
    border: 1px solid rgba(255, 126, 54, 0.45);
    background: linear-gradient(135deg, rgba(255, 126, 54, 0.16), rgba(163, 89, 160, 0.18));
    color: var(--white);
}

.secondary-button {
    border: 1px solid rgba(100, 255, 218, 0.25);
    background: rgba(100, 255, 218, 0.08);
    color: var(--green);
}

.primary-button:hover,
.primary-button:focus-visible,
.secondary-button:hover,
.secondary-button:focus-visible,
.instrument-button:hover,
.instrument-button:focus-visible,
.pad:hover,
.pad:focus-visible {
    transform: translateY(-2px);
}

.secondary-button.is-active {
    background: rgba(100, 255, 218, 0.14);
    border-color: rgba(100, 255, 218, 0.45);
    color: var(--white);
}

.status-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    min-height: 38px;
    border-radius: 999px;
    background: rgba(255, 126, 54, 0.12);
    border: 1px solid rgba(255, 126, 54, 0.18);
    color: var(--white);
    font-size: 0.94rem;
}

.status-pill-soft {
    background: rgba(100, 255, 218, 0.08);
    border-color: rgba(100, 255, 218, 0.16);
    color: var(--text);
}

.panel-heading,
.play-header {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
}

.visual-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.95fr);
    gap: 18px;
    margin-top: 20px;
}

.wave-panel,
.amphi-panel {
    padding: 18px;
    border-radius: 20px;
    background: rgba(10, 25, 47, 0.52);
    border: 1px solid rgba(100, 255, 218, 0.08);
}

.visual-meta {
    display: grid;
    gap: 6px;
    margin-bottom: 14px;
}

.visual-meta strong {
    color: var(--white);
    font-size: 1.02rem;
}

.visual-meta span {
    color: var(--muted);
    line-height: 1.55;
}

.math-canvas {
    width: 100%;
    min-height: 320px;
    display: block;
    border-radius: 18px;
    background:
        radial-gradient(circle at top right, rgba(255, 126, 54, 0.08), transparent 38%),
        linear-gradient(180deg, rgba(17, 34, 64, 0.85), rgba(10, 25, 47, 0.9));
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.equation-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.equation-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1.3;
}

.equation-chip::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--chip-color, var(--orange));
    box-shadow: 0 0 12px var(--chip-color, var(--orange));
}

.amphitheater-scene {
    width: 100%;
    min-height: 360px;
    display: block;
    border-radius: 18px;
    background:
        radial-gradient(circle at 50% 100%, rgba(100, 255, 218, 0.09), transparent 40%),
        linear-gradient(180deg, rgba(17, 34, 64, 0.82), rgba(10, 25, 47, 0.92));
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.scene-tier {
    fill: none;
    stroke: rgba(136, 146, 176, 0.22);
    stroke-width: 2;
}

.scene-stage {
    fill: rgba(255, 126, 54, 0.08);
    stroke: rgba(255, 126, 54, 0.2);
    stroke-width: 2;
}

.scene-stage-line {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 1.5;
    stroke-dasharray: 4 8;
}

.musician-node {
    transform-origin: center;
    transition: transform 140ms ease, opacity 140ms ease;
}

.musician-node circle {
    fill: var(--musician-color, var(--green));
    stroke: rgba(230, 241, 255, 0.22);
    stroke-width: 2;
    opacity: 0.62;
}

.musician-node text {
    fill: var(--text);
    font-size: 13px;
    font-family: Inter, "Segoe UI", system-ui, sans-serif;
    text-anchor: middle;
}

.musician-node .musician-role {
    fill: var(--muted);
    font-size: 11px;
}

.musician-node.is-selected circle {
    opacity: 0.9;
    stroke: rgba(230, 241, 255, 0.44);
}

.musician-node.is-active circle {
    opacity: 1;
    filter: drop-shadow(0 0 14px var(--musician-color, var(--green)));
}

.musician-node.is-active {
    transform: scale(1.08);
}

.scene-pulse {
    fill: none;
    stroke: rgba(255, 255, 255, 0.18);
    stroke-width: 1.5;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.control-block {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    border-radius: 18px;
    background: rgba(10, 25, 47, 0.52);
    border: 1px solid rgba(100, 255, 218, 0.08);
}

.control-label {
    color: var(--white);
    font-weight: 700;
}

.slider-row {
    display: flex;
    gap: 14px;
    align-items: center;
}

select,
input[type="range"] {
    width: 100%;
}

select {
    appearance: none;
    border: 1px solid rgba(255, 126, 54, 0.18);
    background: rgba(17, 34, 64, 0.92);
    color: var(--white);
    border-radius: 12px;
    padding: 12px 14px;
    font: inherit;
}

input[type="range"] {
    accent-color: var(--orange);
}

.value-chip {
    min-width: 84px;
    text-align: center;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(255, 126, 54, 0.08);
    color: var(--white);
    font-weight: 700;
    font-size: 0.92rem;
}

.rhythm-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.meta-card {
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(10, 25, 47, 0.52);
    border: 1px solid rgba(163, 89, 160, 0.12);
}

.meta-label {
    display: block;
    color: var(--muted);
    font-size: 0.84rem;
    margin-bottom: 8px;
}

.meta-card strong {
    color: var(--white);
}

.instrument-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-top: 20px;
}

.instrument-button {
    appearance: none;
    width: 100%;
    padding: 18px;
    text-align: left;
    background: rgba(10, 25, 47, 0.5);
    color: var(--text);
    border: 1px solid rgba(100, 255, 218, 0.08);
    border-radius: 18px;
    cursor: pointer;
    transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.instrument-button.is-active {
    border-color: rgba(255, 126, 54, 0.34);
    background: linear-gradient(135deg, rgba(255, 126, 54, 0.12), rgba(163, 89, 160, 0.14));
}

.instrument-name {
    display: block;
    font-size: 1.05rem;
    color: var(--white);
    font-weight: 700;
}

.instrument-family {
    display: inline-flex;
    margin-top: 12px;
    padding: 6px 10px;
    border-radius: 999px;
    color: var(--green);
    background: rgba(100, 255, 218, 0.08);
    font-size: 0.82rem;
    font-weight: 700;
}

.instrument-button p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.55;
}

.legend-panel {
    display: grid;
    gap: 8px;
    min-width: 260px;
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(10, 25, 47, 0.54);
    border: 1px solid rgba(100, 255, 218, 0.1);
    color: var(--muted);
    line-height: 1.55;
}

.pad-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.pad {
    appearance: none;
    position: relative;
    overflow: hidden;
    min-height: 240px;
    padding: 20px;
    border-radius: 22px;
    text-align: left;
    color: var(--white);
    border: 1px solid var(--pad-border, rgba(255, 255, 255, 0.08));
    background:
        radial-gradient(circle at top right, var(--pad-glow, rgba(255, 126, 54, 0.18)), transparent 46%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01)),
        rgba(10, 25, 47, 0.72);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: transform 110ms ease, border-color 110ms ease, box-shadow 110ms ease;
}

.pad::after {
    content: "";
    position: absolute;
    right: -40px;
    bottom: -34px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: var(--pad-wave, rgba(255, 126, 54, 0.12));
}

.pad.is-playing {
    transform: translateY(4px) scale(0.985);
    box-shadow: 0 18px 34px rgba(0, 0, 0, 0.28);
}

.pad__header,
.pad__keys {
    position: relative;
    z-index: 1;
}

.pad__header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.pad__title {
    font-size: clamp(1.7rem, 3.4vw, 2.5rem);
    font-weight: 800;
    line-height: 1.04;
}

.pad__subtitle {
    margin: 10px 0 0;
    color: var(--text);
    line-height: 1.6;
}

.pad__index {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    font-weight: 700;
}

.pad__keys {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 24px;
}

.compose-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-end;
    margin-top: 20px;
}

.compose-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.ghost-button {
    appearance: none;
    border-radius: 14px;
    padding: 14px 20px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.ghost-button:hover,
.ghost-button:focus-visible {
    transform: translateY(-2px);
    border-color: rgba(255, 126, 54, 0.24);
    background: rgba(255, 126, 54, 0.08);
}

.swing-block {
    min-width: min(360px, 100%);
    padding: 16px;
    border-radius: 18px;
    background: rgba(10, 25, 47, 0.52);
    border: 1px solid rgba(100, 255, 218, 0.08);
}

.sequence-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.sequence-legend span {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--muted);
    font-size: 0.9rem;
}

.sequence-grid {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

.sequence-row {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
}

.sequence-row-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px;
    border-radius: 16px;
    background: rgba(10, 25, 47, 0.52);
    border: 1px solid rgba(163, 89, 160, 0.12);
}

.sequence-row-label strong {
    color: var(--white);
}

.sequence-row-label span {
    color: var(--muted);
    font-size: 0.9rem;
}

.sequence-steps {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 8px;
}

.sequence-cell {
    appearance: none;
    min-height: 44px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform 110ms ease, border-color 110ms ease, background 110ms ease;
}

.sequence-cell:hover,
.sequence-cell:focus-visible {
    transform: translateY(-1px);
    border-color: rgba(255, 126, 54, 0.24);
}

.sequence-cell.is-on {
    background: rgba(100, 255, 218, 0.14);
    border-color: rgba(100, 255, 218, 0.34);
    color: var(--white);
}

.sequence-cell.is-accent {
    background: rgba(255, 126, 54, 0.18);
    border-color: rgba(255, 126, 54, 0.34);
    color: var(--white);
}

.sequence-cell.is-current {
    box-shadow: 0 0 0 2px rgba(255, 126, 54, 0.34);
}

.key-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 54px;
    min-height: 34px;
    padding: 6px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--white);
    font-weight: 700;
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.guide-block {
    margin: 0;
    padding: 18px;
    border-radius: 18px;
    background: rgba(10, 25, 47, 0.52);
    border: 1px solid rgba(163, 89, 160, 0.12);
}

.guide-block p {
    margin: 10px 0 0;
    color: var(--muted);
    line-height: 1.6;
}

.tone-gold {
    --pad-border: rgba(255, 188, 94, 0.32);
    --pad-glow: rgba(255, 188, 94, 0.18);
    --pad-wave: rgba(255, 188, 94, 0.12);
}

.tone-violet {
    --pad-border: rgba(163, 89, 160, 0.32);
    --pad-glow: rgba(163, 89, 160, 0.2);
    --pad-wave: rgba(163, 89, 160, 0.12);
}

.tone-green {
    --pad-border: rgba(100, 255, 218, 0.28);
    --pad-glow: rgba(100, 255, 218, 0.18);
    --pad-wave: rgba(100, 255, 218, 0.11);
}

.tone-orange {
    --pad-border: rgba(255, 126, 54, 0.32);
    --pad-glow: rgba(255, 126, 54, 0.18);
    --pad-wave: rgba(255, 126, 54, 0.12);
}

.tone-slate {
    --pad-border: rgba(136, 146, 176, 0.26);
    --pad-glow: rgba(136, 146, 176, 0.14);
    --pad-wave: rgba(136, 146, 176, 0.1);
}

@media (max-width: 920px) {
    .panel-heading,
    .play-header,
    .topbar {
        flex-direction: column;
    }

    .topbar-note {
        text-align: left;
    }

    .controls-grid,
    .visual-layout,
    .rhythm-meta,
    .guide-grid {
        grid-template-columns: 1fr;
    }

    .compose-toolbar,
    .sequence-row {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    .legend-panel {
        min-width: 0;
        width: 100%;
    }

    .pad-grid {
        grid-template-columns: 1fr;
    }

    .sequence-steps {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .pad {
        min-height: 190px;
    }
}

@media (max-width: 640px) {
    .page-shell {
        width: min(100% - 20px, 1180px);
        padding-top: 18px;
        padding-bottom: 24px;
    }

    .hero-card,
    .controls-card,
    .visual-card,
    .selector-card,
    .play-card,
    .compose-card,
    .guide-card {
        padding: 20px;
        border-radius: 18px;
    }

    h1 {
        max-width: none;
    }

    .hero-actions {
        flex-direction: column;
    }

    .primary-button,
    .secondary-button {
        width: 100%;
    }
}
