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

:root {
    --paper: #f8f5ee;
    --paper-deep: #eee8dd;
    --ink: #090909;
    --muted: #34465d;
    --line: rgba(9, 9, 9, 0.32);
    --soft-line: rgba(9, 9, 9, 0.12);
    --sage: #667764;
    --sepia: #877247;
    --wine: #88403f;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    color: var(--ink);
    font-family: "Cormorant Garamond", Georgia, serif;
    background:
        repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.018) 0 1px, transparent 1px 12px),
        radial-gradient(circle at 18% 8%, rgba(135, 114, 71, 0.12), transparent 28%),
        var(--paper);
}

button,
input {
    font: inherit;
}

.piano-page {
    width: min(1680px, calc(100% - 56px));
    min-height: 100vh;
    margin: 0 auto;
    padding: 42px 0 34px;
    position: relative;
}

.back-btn {
    position: absolute;
    left: 0;
    top: 24px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid var(--ink);
    background: var(--soft);
    color: var(--ink);
    text-decoration: none;
    font-family: "Cinzel", serif;
    font-size: 0.82rem;
    font-weight: 800;
    box-shadow: 4px 4px 0 rgba(17, 16, 15, 0.16);
}


.paper-header {
    max-width: 1100px;
    margin: 0 auto 14px;
    text-align: center;
}

.paper-header h1{
    line-height:58px;
}

.kicker {
    width: fit-content;
    margin: 0 auto 18px;
    padding: 4px 34px;
    color: rgba(9, 9, 9, 0.68);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 800;
    font-size: 1.05rem;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

h1 {
    font-family: "Playfair Display", Didot, Georgia, serif;
    font-size: clamp(4rem, 3.4vw, 12.4rem);
    font-weight: 900;
    line-height: 0.78;
    letter-spacing: 0;
    text-transform: uppercase;
}

.i-star {
    position: relative;
    display: inline-block;
}

.i-star::after {
    content: "*";
    position: absolute;
    left: 50%;
    top: -0.56em;
    transform: translateX(-50%);
    font-family: Georgia, serif;
    font-size: 0.52em;
    line-height: 1;
}

.rule-star {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 24px;
    width: min(900px, 80%);
    margin: 4px auto 2px;
}

.rule-star span {
    height: 1px;
    background: var(--ink);
}

.rule-star i {
    font-style: normal;
    font-size: 1.7rem;
}

.subtitle {
    font-style: italic;
    font-weight: 600;
   font-size: clamp(1.35rem, 2.4vw, 1rem);
}

.paper-grid {
    display: grid;
    grid-template-columns: minmax(230px, 0.9fr) minmax(520px, 1.9fr) minmax(300px, 1fr);
    gap: 28px;
    border-top: 4px double var(--ink);
    border-bottom: 4px double var(--ink);
    padding: 32px 0;
}

.editorial-card,
.recordings-section,
.rhythm-generator {
    min-width: 0;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    padding: 24px 24px 28px;
    background: rgba(255, 255, 255, 0.22);
}

.section-label {
    margin-bottom: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-weight: 800;
    font-size: 1rem;
}

.drop-intro {
    font-size: 1.55rem;
    font-weight: 700;
    line-height: 1.18;
}

.drop-intro span {
    float: left;
    padding: 8px 9px 0 0;
    font-family: "Playfair Display", Georgia, serif;
    font-size: 5.1rem;
    line-height: 0.72;
}

.editorial-card p:not(.section-label) {
    margin-bottom: 18px;
    font-size: 1.35rem;
    line-height: 1.34;
}

.piano-keys {
    height: 400px;
    margin-top: 28px;
    border: 1px solid var(--ink);
    background-image:
        linear-gradient(rgba(248, 245, 238, 0.04), rgba(248, 245, 238, 0.04)),
        url("../images/pianoPaper.png");
    background-size: cover;
    background-position: center left;
    background-repeat: no-repeat;
    overflow: hidden;
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.section-heading h2 {
    font-family: "Playfair Display", Georgia, serif;
    font-size: clamp(2rem, 3vw, 3.5rem);
    line-height: 1;
    text-transform: uppercase;
}

.tabs-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.tab-btn {
    min-height: 36px;
    padding: 6px 16px;
    color: var(--ink);
    cursor: pointer;
    background: transparent;
    border: 1px solid var(--line);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 800;
}

.tab-btn.active,
.tab-btn:hover {
    color: var(--paper);
    background: var(--ink);
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    min-height: 396px;
}

.book-card {
    position: relative;
    display: block;
    min-height: 122px;
    padding: 18px 18px 16px 72px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.72);
    border: 2px solid rgba(9, 9, 9, 0.32);
    box-shadow: 4px 4px 0 rgba(9, 9, 9, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.book-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 42px;
    background: var(--sage);
    border-right: 2px solid rgba(9, 9, 9, 0.2);
}

.book-card:nth-child(3n + 2)::before {
    background: var(--sepia);
}

.book-card:nth-child(3n)::before {
    background: #58488a;
}

.book-card:nth-child(4n)::before {
    background: var(--wine);
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: 7px 7px 0 rgba(9, 9, 9, 0.11);
}

.card-number {
    color: var(--muted);
    font-weight: 900;
    font-size: 1.25rem;
}

.book-title {
    margin: 8px 0 5px;
    font-family: "Playfair Display", Georgia, serif;
    font-size: clamp(1.4rem, 1.8vw, 2rem);
    line-height: 0.96;
}

.book-author {
    color: rgba(9, 9, 9, 0.64);
    font-style: italic;
    font-weight: 600;
    font-size: 1.18rem;
}

.note-container {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 12px;
    color: var(--muted);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.book-note {
    font-size: 0.86rem;
}

.pagination-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
    font-weight: 900;
}

.pagination-btn {
    width: 42px;
    height: 38px;
    cursor: pointer;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--line);
}

.pagination-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.rhythm-generator {
    position: relative;
    padding-top: 78px;
}

.rhythm-sticker {
    position: absolute;
    top: -38px;
    right: 18px;
    width: 108px;
    height: auto;
    object-fit: contain;
}

.rhythm-generator h2 {
    font-family: "Playfair Display", Georgia, serif;
    font-size: clamp(2.1rem, 2.6vw, 3.3rem);
    line-height: 0.95;
    margin-bottom: 12px;
}

.rhythm-copy {
    margin-bottom: 18px;
    font-size: 1.2rem;
    line-height: 1.25;
}

.search-container {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    margin-bottom: 14px;
}

#rhythmInput {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
    outline: none;
}

#rhythmInput:focus {
    border-color: var(--ink);
}

#playBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 18px;
    color: var(--paper);
    cursor: pointer;
    background: var(--ink);
    border: 1px solid var(--ink);
    font-weight: 800;
}

#nameDetail,
#algoDetails {
    color: rgba(9, 9, 9, 0.7);
    font-family: "Cormorant Garamond", Georgia, serif;
    font-size: 1.05rem;
    line-height: 1.35;
}

#musicSheet {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 156px;
    margin: 16px 0;
    padding: 30px 20px 30px 82px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.62);
    border: 2px solid var(--ink);
}

.clef {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 5rem;
    line-height: 1;
}

.staff-lines {
    position: absolute;
    left: 76px;
    right: 18px;
    top: 50%;
    display: flex;
    height: 68px;
    transform: translateY(-50%);
    flex-direction: column;
    justify-content: space-between;
}

.staff-lines span {
    border-top: 1px solid var(--ink);
}

#notesContainer {
    position: relative;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

#videoModal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.86);
}

#modalContainer {
    width: min(420px, 100%);
    padding: 10px;
    background: #050505;
    border: 2px solid var(--paper);
}

#modalVideo {
    display: block;
    width: 100%;
    max-height: 78vh;
    background: #000;
}

.close-btn {
    display: block;
    width: 34px;
    height: 34px;
    margin: 0 0 8px auto;
    color: var(--paper);
    cursor: pointer;
    background: transparent;
    border: 1px solid var(--paper);
    font-size: 1.5rem;
    line-height: 1;
}

.site-footer {
    width: 98vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding: 30px 28px 0;
    text-align: center;
}

.footer-keys {
    width: 100%;
    margin: 0 auto 24px;
    height: clamp(110px, 12vw, 178px);
    background-position: center 18%;
}

.social-footer {
    display: flex;
    justify-content: center;
    gap: 26px;
    margin-bottom: 18px;
}

.social-link {
    color: var(--muted);
    font-size: 1.65rem;
    transition: color 0.2s ease, transform 0.2s ease;
}

.social-link:hover {
    color: var(--ink);
    transform: translateY(-2px);
}

.copyright {
    color: rgba(9, 9, 9, 0.58);
    font-size: 1rem;
}

@media (max-width: 1180px) {
    .piano-page {
        width: min(100% - 32px, 920px);
        padding-top: 88px;
    }

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

    .editorial-card,
    .recordings-section,
    .rhythm-generator {
        border: 1px solid var(--line);
    }

    .books-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    .piano-page {
        width: min(100% - 22px, 440px);
        padding-top: 78px;
    }

    .back-btn {
        top: 12px;
        min-height: 38px;
        padding: 6px 14px;
        font-size: 0.95rem;
    }

    .kicker {
        max-width: 260px;
        padding: 4px 10px;
        font-size: 0.78rem;
    }

    h1 {
        font-size: clamp(2.45rem, 12vw, 5.8rem);
    }

    .subtitle {
        font-size: 2rem;
        line-height: 1.05;
    }

    .rule-star {
        width: 92%;
        gap: 12px;
        margin: 8px auto 5px;
    }

    .paper-grid {
        gap: 20px;
        padding: 22px 0;
    }

    .editorial-card,
    .recordings-section,
    .rhythm-generator {
        padding: 20px 16px 22px;
    }

    .section-heading {
        display: block;
    }

    .section-heading h2 {
        font-size: 2.2rem;
        margin-bottom: 12px;
    }

    .books-grid {
        grid-template-columns: 1fr;
        min-height: 792px;
    }

    .book-card {
        min-height: 112px;
        padding: 16px 14px 14px 62px;
    }

    .book-card::before {
        width: 34px;
    }

    .book-title {
        font-size: 1.45rem;
    }

    .book-author {
        font-size: 1.05rem;
    }

    .rhythm-generator {
        padding-top: 64px;
    }

    .rhythm-sticker {
        top: -30px;
        right: 8px;
        width: 82px;
    }

    .search-container {
        grid-template-columns: 1fr;
    }

    #playBtn {
        width: 100%;
    }

    #musicSheet {
        min-height: 134px;
        padding-left: 58px;
    }

    .clef {
        left: 10px;
        font-size: 3.8rem;
    }

    .staff-lines {
        left: 58px;
    }

    .social-footer {
        gap: 20px;
    }
}
