* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --cell: 19px;
    --grid-line: 1px;
    --tile: calc(var(--cell) + var(--grid-line));
    --tile-2: calc(var(--tile) * 2 + var(--grid-line));
    --half-gap: 9px;
    --type-button-width: calc(var(--tile-2) + var(--half-gap) + var(--grid-line));
    --variant-button-width: calc(var(--tile) * 5 + var(--grid-line));
    --paper: #fffdf8;
    --paper-line: rgba(72, 61, 48, 0.12);
    --ink: #2f2b26;
    --soft-ink: #70675c;
    --accent: #b99018;
    --accent-dark: #7a5b00;
    --accent-soft: #ead08a;
    --line: rgba(72, 61, 48, 0.22);
    --grid-x: calc((100vw - min(1000px, calc(100vw - var(--tile) * 2))) / 2);
    --grid-y: var(--tile);
}

body {
    min-height: 100vh;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    color: var(--ink);
    font-family: "Nunito", "Segoe UI", Arial, sans-serif;
    background:
        radial-gradient(circle, var(--paper-line) 1.2px, transparent 1.3px),
        radial-gradient(circle at top, rgba(255, 255, 255, 0.3), transparent 34rem),
        linear-gradient(135deg, #907ee0, #6f9ec9);
    background-position: var(--grid-x) var(--grid-y), 0 0, 0 0;
    background-size: var(--tile) var(--tile), auto, auto;
}

.container {
    width: min(calc(1000px + var(--tile) * 7), calc(100% - var(--tile)));
    min-height: calc(100vh - var(--tile) * 2);
    margin: var(--tile) auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 19px;
    box-shadow: 0 22px 52px rgba(44, 38, 76, 0.24);
}

.ad-rail {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 8;
    width: 8vw;
    background: var(--accent-soft);
}

.container {
    background-color: var(--paper);
    background-image: radial-gradient(circle, var(--paper-line) 1.2px, transparent 1.3px);
    background-position: 50% 0;
    background-size: var(--tile) var(--tile);
}

.tabs,
.main-content,
.grid-panel,
.fretboard {
    background: transparent;
}

.header {
    background: var(--paper);
    height: calc(var(--tile) * 9);
    padding: calc(var(--tile) * 2) var(--tile) var(--tile);
    text-align: center;
    border-bottom: 1px solid var(--line);
}

.main-title {
    margin-bottom: calc(var(--tile) / 2);
    color: var(--ink);
    font-size: clamp(2rem, 6vw, 3.6rem);
    font-weight: 900;
    line-height: calc(var(--tile) * 3);
}

.tagline {
    color: var(--soft-ink);
    font-size: 1.08rem;
    font-weight: 700;
    line-height: var(--tile);
}

.tabs {
    display: flex;
    justify-content: center;
    gap: var(--tile);
    height: calc(var(--tile) * 3);
    padding: calc(var(--tile) / 2) var(--tile);
    border-bottom: 1px solid var(--line);
}

.tab-btn,
.panel-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: calc(var(--tile) / 2);
    height: var(--tile-2);
    min-height: var(--tile-2);
    padding: 0 var(--half-gap);
    border: 1px solid var(--line);
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    font-size: 0.98rem;
    font-weight: 900;
}

.tab-btn {
    transform: none;
}

.tab-btn.active,
.panel-btn {
    border-color: var(--accent-dark);
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.tab-btn.coming-soon {
    cursor: not-allowed;
    opacity: 0.68;
}

.tab-icon {
    font-size: 1.2rem;
}

.soon-label {
    color: var(--soft-ink);
    font-size: 0.72rem;
    font-weight: 800;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: var(--tile);
}

.chord-section {
    display: grid;
    gap: var(--tile);
}

.grid-panel {
    outline: 1px solid var(--line);
    outline-offset: -1px;
    border-radius: 0;
}

.chord-controls {
    position: relative;
    height: calc(var(--tile) * 9);
    padding: 0 var(--tile) var(--tile);
    border-radius: 19px;
    overflow: hidden;
}

.selector-row {
    position: absolute;
    left: var(--tile);
    right: var(--tile);
    display: grid;
    grid-template-columns: calc(var(--tile) * 4) 1fr;
    min-height: calc(var(--tile) * 4);
    border-bottom: 0;
}

.selector-row::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(var(--tile) * 0.5);
    height: 1px;
    background: var(--line);
    transform: translateY(50%);
}

.variant-row::after {
    display: none;
}

.note-row {
    top: calc(var(--tile) * -0.5);
}

.type-row {
    top: calc(var(--tile) * 2.5);
}

.variant-row {
    top: calc(var(--tile) * 5.5);
}

.selector-row:last-child {
    border-bottom: 0;
}

.selector-label {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(var(--tile) * 4);
    color: var(--soft-ink);
    font-size: 0.82rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.selector-options {
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    gap: var(--half-gap);
    min-height: calc(var(--tile) * 4);
}

.note-row,
.note-row .selector-label,
.note-row .selector-options {
    min-height: calc(var(--tile) * 4);
}

.choice-btn {
    width: var(--tile-2);
    height: var(--tile-2);
    border: 1px solid var(--line);
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    font-size: 1rem;
    font-weight: 900;
}

.type-row .choice-btn,
.variant-row .choice-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--type-button-width);
    height: var(--tile-2);
    padding: 0 calc(var(--tile) / 2);
    font-size: 0.86rem;
    text-align: center;
}

.variant-row .choice-btn {
    width: var(--variant-button-width);
    color: var(--soft-ink);
}

.choice-btn:hover,
.choice-btn:focus-visible {
    border-color: var(--accent-dark);
    outline: 2px solid var(--accent-soft);
    outline-offset: -2px;
}

.choice-btn.active {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.choice-btn.unavailable {
    color: rgba(112, 103, 92, 0.42);
    cursor: default;
}

.selector-row.keyboard-row .selector-label {
    color: var(--accent-dark);
}

.chord-display {
    display: grid;
    gap: 0;
    padding: var(--tile);
    border-radius: 19px;
    padding-bottom: var(--tile);
    min-width: 0;
}

.chord-name {
    min-height: calc(var(--tile) * 2);
    color: var(--ink);
    font-size: clamp(1.45rem, 3vw, 2rem);
    font-weight: 900;
    line-height: calc(var(--tile) * 2);
    text-align: center;
    transform: translateY(calc(var(--tile) * -0.5));
}

.fretboard-layout {
    display: grid;
    grid-template-columns: calc(var(--tile) * 4) 1fr;
    gap: 0;
    align-items: start;
    min-width: 0;
    transform: translateY(calc(var(--tile) * -2.5));
    margin-bottom: calc(var(--tile) * -3);
}

.fret-notation {
    position: relative;
    display: grid;
    grid-auto-rows: calc(var(--tile) * 2);
    align-items: center;
    justify-items: center;
    height: calc(var(--tile) * 15);
    padding-top: calc(var(--tile) * 2);
    outline: 0;
    border: 0;
    border-right: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--accent-dark);
    font-size: 1.15rem;
    font-weight: 900;
    transform: translate(calc(var(--tile) * -1), calc(var(--tile) * 0.5));
}

.fret-notation::before {
    content: "";
    position: absolute;
    top: calc(var(--tile) * 2.2);
    bottom: calc(var(--tile) * 1.2);
    left: 50%;
    width: 30px;
    border-radius: 999px;
    background: rgb(234, 208, 138);
    transform: translateX(-50%);
}

.fretboard-scroll {
    max-width: 100%;
    min-width: 0;
    overflow: visible;
    display: flex;
    justify-content: flex-start;
    height: calc(var(--tile) * 16);
    padding-left: calc(var(--tile) * 2);
    padding-top: var(--tile);
    padding-right: calc(var(--tile) * 3);
    transform: translate(calc(var(--tile) * -2), calc(var(--tile) * -0.5));
}

.fretboard {
    position: relative;
    width: calc(var(--tile) * var(--fretboard-tiles, 44));
    flex: 0 0 auto;
    height: calc(var(--tile) * 15);
    outline: 0;
    border: 0;
    border-radius: 0;
    overflow: visible;
    background: transparent;
    transform: translateX(calc(var(--tile) * -1));
}

.string-line,
.fret-line,
.string-label,
.open-marker,
.mute-marker,
.finger-dot,
.fret-number {
    position: absolute;
}

.string-line {
    left: calc(var(--tile) * 1);
    width: calc(var(--tile) * 42);
    height: 1px;
    transform: translateY(-50%);
    background: rgba(47, 43, 38, 0.72);
}

.fret-line {
    top: calc(var(--tile) * 3);
    height: calc(var(--tile) * 10);
    width: 1px;
    transform: translateX(-50%);
    background: rgba(72, 61, 48, 0.44);
}

.fret-line.nut {
    width: 1px;
    background: var(--ink);
}

.string-label,
.fret-number {
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translate(-50%, -50%);
    font-weight: 900;
}

.string-label {
    width: var(--tile-2);
    height: var(--tile-2);
    color: var(--ink);
    font-size: 1.18rem;
    overflow: visible;
}

.tab-dot,
.open-marker,
.mute-marker,
.finger-dot,
.scale-dot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 999px;
    background: rgb(234, 208, 138);
    color: var(--accent-dark);
    font-size: 1rem;
    font-weight: 900;
}

.open-marker,
.mute-marker,
.finger-dot,
.scale-dot {
    transform: translate(-50%, -50%);
}

.tab-dot {
    position: relative;
    z-index: 1;
}

.tab-dot.muted,
.mute-marker {
    border-color: var(--soft-ink);
    background: rgb(234, 208, 138);
    color: var(--soft-ink);
    z-index: 6;
}

.fret-number,
.comb-marker {
    width: var(--tile-2);
    height: var(--tile-2);
    color: var(--ink);
    font-size: 0.9rem;
    z-index: 1;
}

.fret-number.capo-number,
.comb-marker {
    width: var(--tile);
    height: var(--tile);
    border-radius: 999px;
    background: var(--ink);
    color: var(--paper);
    font-size: 0.72rem;
    z-index: 6;
}

.capo-line {
    position: absolute;
    top: calc(var(--tile) * 3);
    height: calc(var(--tile) * 11);
    width: 3px;
    border-radius: 999px;
    background: var(--ink);
    cursor: grab;
    touch-action: none;
    transform: translateX(-50%);
    z-index: 5;
}

.capo-line::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: calc(var(--tile) * -1);
    left: calc(var(--tile) * -1.5);
    width: calc(var(--tile) * 3);
    cursor: grab;
}

.scale-dot {
    position: absolute;
    z-index: 6;
    opacity: 1;
}

.scale-dot.root {
    background: var(--accent-dark);
    color: var(--paper);
    font-size: 0.72rem;
}

.capo-line::before {
    display: none;
}

.end-line {
    position: absolute;
    top: calc(var(--tile) * 1.5);
    height: calc(var(--tile) * 11.5);
    width: 3px;
    border-radius: 999px;
    background: #4f321f;
    cursor: grab;
    touch-action: none;
    transform: translateX(-50%);
    z-index: 4;
}

.end-line::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: calc(var(--tile) * -1);
    left: calc(var(--tile) * -0.5);
    width: calc(var(--tile) * 2);
    cursor: grab;
}

.comb-marker {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    transform: translate(-50%, -50%);
}

.scale-tools {
    position: fixed;
    top: var(--tile);
    left: var(--tile);
    z-index: 10;
    width: calc(var(--tile) * 10);
    padding: var(--tile);
    border-radius: 19px;
    background: var(--paper);
    box-shadow: 0 14px 38px rgba(44, 38, 76, 0.18);
}

.scale-toggle {
    display: inline-flex;
    align-items: center;
    gap: calc(var(--tile) / 2);
    min-height: var(--tile-2);
    color: var(--ink);
    font-size: 0.95rem;
    font-weight: 900;
    text-transform: none;
}

.scale-toggle input {
    width: var(--tile);
    height: var(--tile);
    accent-color: var(--accent-dark);
}

.request-frame {
    position: fixed;
    top: var(--tile);
    right: var(--tile);
    z-index: 10;
    width: calc(var(--tile) * 15);
    max-height: calc(100vh - var(--tile) * 2);
    height: min(calc(var(--tile) * 28), calc(100vh - var(--tile) * 2));
    border: 0;
    border-radius: 19px;
    box-shadow: 0 14px 38px rgba(44, 38, 76, 0.18);
}

.site-footer {
    margin-top: auto;
    padding: var(--tile) 0 0;
    text-align: center;
}

.site-credit,
.visitor-count {
    color: var(--soft-ink);
    font-size: 0.95rem;
    font-weight: 800;
}

.visitor-count {
    margin-top: calc(var(--tile) / 2);
    color: var(--accent-dark);
}

@media (max-width: 1660px) {
    .scale-tools {
        position: static;
        width: min(calc(1000px + var(--tile) * 7), calc(100% - var(--tile)));
        margin: 0 auto var(--tile);
        display: block;
    }

    .request-frame {
        position: static;
        width: min(calc(1000px + var(--tile) * 5), calc(100% - var(--tile)));
        height: 620px;
        margin: var(--tile) auto 0;
        margin-bottom: var(--tile);
        display: block;
    }
}

@media (max-width: 760px) {
    .main-content {
        padding: var(--tile);
    }

    .selector-row,
    .fretboard-layout {
        grid-template-columns: 1fr;
    }

    .selector-label {
        min-height: calc(var(--tile) * 2);
    }

    .fret-notation {
        grid-auto-flow: column;
        grid-auto-columns: calc(var(--tile) * 2);
        grid-auto-rows: calc(var(--tile) * 2);
        min-height: calc(var(--tile) * 2);
        overflow: hidden;
    }
}

@media (max-width: 480px) {
    body {
        padding: 0;
    }

    .container {
        width: calc(100% - var(--tile));
        border-radius: 19px;
    }

    .tabs {
        flex-wrap: wrap;
    }
}
