:root {
    color-scheme: light dark;
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    background-color: #0f172a;
    color: #e2e8f0;
}

* {
    box-sizing: border-box;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at top, rgba(30, 64, 175, 0.3), transparent 55%), #0f172a;
}

.app-header,
.app-footer {
    padding: 1.5rem 1.25rem 0;
    text-align: center;
}

.app-header h1 {
    margin: 0;
    font-size: clamp(1.5rem, 5vw, 2.2rem);
    letter-spacing: 0.04em;
}

.app-header p {
    margin: 0.35rem 0 1.25rem;
    font-size: 0.95rem;
    color: #94a3b8;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0 1.25rem 1.5rem;
}

.controls {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.select-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field-label {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
}

select {
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.85rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background-color: rgba(15, 23, 42, 0.55);
    color: inherit;
    font-size: 1rem;
    appearance: none;
    backdrop-filter: blur(12px);
}

select:focus-visible {
    border-color: #38bdf8;
    outline: none;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25);
}

input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.85rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background-color: rgba(15, 23, 42, 0.55);
    color: inherit;
    font-size: 1rem;
    backdrop-filter: blur(12px);
}

input[type="text"]:focus-visible {
    border-color: #38bdf8;
    outline: none;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25);
}

.card {
    background: linear-gradient(160deg, rgba(30, 64, 175, 0.35), rgba(14, 165, 233, 0.15));
    border-radius: 1.25rem;
    padding: 1.25rem;
    box-shadow: 0 16px 45px rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.card h2 {
    margin: 0 0 0.75rem;
    font-size: 1.35rem;
    letter-spacing: 0.03em;
}

.keyboard {
    position: relative;
    display: flex;
    gap: 0.2rem;
    padding: 0.75rem 0.5rem 0.6rem;
    border-radius: 1rem;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.25);
    margin-bottom: 1rem;
    isolation: isolate;
}

.key {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    font-weight: 600;
    transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    pointer-events: none;
}

.white-key {
    flex: 1 1 calc(100% / 7);
    height: clamp(6rem, 28vw, 9.5rem);
    min-width: 0;
    border-radius: 0.5rem 0.5rem 0.75rem 0.75rem;
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.06);
    color: #1f2937;
}

.black-key {
    position: absolute;
    top: -0.6rem;
    left: 100%;
    transform: translateX(-50%);
    width: 60%;
    height: 60%;
    border-radius: 0.45rem 0.45rem 0.6rem 0.6rem;
    background: linear-gradient(180deg, #0f172a, #111827);
    border: 1px solid rgba(30, 41, 59, 0.9);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 6px 14px rgba(15, 23, 42, 0.7);
    color: #e2e8f0;
    pointer-events: none;
    z-index: 2;
    padding-bottom: 0.35rem;
}

.key-label {
    display: block;
    width: 100%;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    text-align: center;
}

.black-key .key-label {
    font-size: 0.65rem;
    letter-spacing: 0.05em;
}

.key.is-active {
    background: linear-gradient(135deg, #facc15, #f97316);
    color: #0f172a;
    box-shadow: 0 10px 25px rgba(249, 115, 22, 0.35);
}

.black-key.is-active {
    background: linear-gradient(135deg, #facc15, #f97316);
    border-color: rgba(15, 23, 42, 0.85);
    color: #0f172a;
}

.white-key.is-active .key-label {
    color: #0f172a;
}

.black-key.is-active .key-label {
    color: #0f172a;
}

.inversions {
    display: grid;
    gap: 0.75rem;
}

.inversion {
    padding: 0.75rem;
    border-radius: 0.85rem;
    background: rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.inversion h3 {
    margin: 0 0 0.45rem;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.inversion-notes {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    font-weight: 600;
}

.inversion-note {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.18);
    border: 1px solid rgba(148, 163, 184, 0.32);
    font-size: 0.85rem;
}

.hint {
    margin: 1rem 0 0;
    font-size: 0.85rem;
    color: #94a3b8;
}

.progression-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.progression-fields {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.progression-submit {
    align-self: flex-start;
    padding: 0.65rem 1.25rem;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, #38bdf8, #6366f1);
    color: #0f172a;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.progression-submit:focus-visible {
    outline: 2px solid #facc15;
    outline-offset: 3px;
}

.progression-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(99, 102, 241, 0.25);
}

.progression-message {
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
    color: #94a3b8;
}

.progression-message.is-error {
    color: #fca5a5;
}

.progression-list {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0;
    display: grid;
    gap: 0.75rem;
}

.progression-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.85rem;
    background: rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(56, 189, 248, 0.22);
}

.progression-numeral {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    padding: 0.35rem 0.6rem;
    border-radius: 0.75rem;
    background: rgba(56, 189, 248, 0.2);
    border: 1px solid rgba(56, 189, 248, 0.35);
    font-weight: 700;
    letter-spacing: 0.05em;
}

.progression-details {
    display: grid;
    gap: 0.2rem;
    align-content: center;
}

.progression-chord-name {
    font-weight: 600;
}

.progression-chord-quality {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #cbd5f5;
}

.progression-chord-notes {
    font-size: 0.85rem;
    color: #94a3b8;
}

.app-footer {
    padding-bottom: 1.5rem;
    color: #64748b;
}

@media (min-width: 768px) {
    body {
        align-items: center;
    }

    .app-main {
        width: 100%;
        max-width: 520px;
    }

    .white-key {
        height: 9.5rem;
    }
}