/* Improved Color Scheme */

/* --- Global & Base Styles --- */
* {
    box-sizing: border-box;
}
body {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    background-color: #F0F2F5; /* Light, soft background */
    margin: 0;
    padding: 20px; /* Default padding */
    color: #333333; /* Dark gray for main text */
    line-height: 1.6;
}

/* --- Typography & Links --- */
h1, h2 {
    margin: 0 0 15px 0;
    color: #2C3E50; /* Dark blue-gray for main headings */
}
h1.section-title {
    font-size: 2em;
    color: #2C3E50;
    margin: 20px 0;
    text-align: center;
}
h2 {
    font-size: 1.5em;
    color: #333333; /* Dark gray for sub-headings */
}
a {
    color: #4A90E2; /* Primary blue for links */
    text-decoration: none;
    transition: color 0.3s ease;
}
a:hover {
    text-decoration: underline;
    color: #357ABD; /* Darker blue on hover */
}
.tag-links a {
    margin-right: 10px;
    font-weight: bold;
}
.meta {
    color: #666666 !important; /* Medium gray for meta info */
    font-size: 14px !important;
    margin: 0 !important;
}
.description {
    text-align: center;
    color: #333333; /* Ensure description text is dark */
}

/* --- Layout & Containers --- */
.container {
    max-width: calc(1000px - 20px);
    margin: 0 auto;
    padding-left: 10px;
    padding-right: 10px;
}
main {
    max-width: 1000px;
    margin: 20px auto;
    background: #FFFFFF; /* Clean white background for main content */
    padding: 30px; /* Default padding */
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); /* Subtle shadow */
}
.two-column-container {
    display: flex;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
}
.column {
    flex: 1;
    min-width: 0;
}
.recently-added-column { order: 1; }
.top-rated-column { order: 2; }

/* --- Header & Navigation --- */
.logo-container {
    background-color: #F0F2F5; /* Match body background */
    padding: 15px 20px 0 20px;
    text-align: center;
    margin: 0 auto;
}
.logo {
    max-width: 360px;
    max-height: 240px;
    height: auto;
    display: inline-block;
    width: 100%; /* Ensure logo scales down */
}
.navbar {
    display: flex;
    align-items: center;
    padding: 15px 30px;
    position: relative;
    background-color: #2C3E50; /* Dark blue-gray for navbar */
    border-radius: 5px;
}
.navbar ul {
    list-style: none;
    display: flex;
    flex-grow: 1;
    justify-content: center;
    gap: 20px;
    margin: 0;
    padding: 0;
    background-color: #2C3E50; /* Match navbar background */
}
.navbar a {
    text-decoration: none;
    padding: 10px 14px;
    color: #fff;
    transition: background 0.3s ease;
}
.navbar a:hover {
    background-color: rgba(255, 255, 255, 0.15); /* Slightly more subtle hover */
    border-radius: 4px;
    text-decoration: none;
}

/* --- Content Blocks --- */
.detail-item {
    margin-bottom: 15px;
}
.detail-item strong {
    font-weight: 600;
}
.content {
    font-size: 1.2em;
    font-weight: 400;
    line-height: 1.8;
    background-color: #F0F2F5; /* Light background for content blocks */
    padding: 20px;
    border-radius: 8px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.03); /* Softer inset shadow */
    text-align: center;
    color: #333333; /* Darker text */
}
.tab-item {
    width: 100%;
    display: block;
    clear: both;
    margin-bottom: 20px;
    padding: 15px;
    border: 1px solid #E0E0E0; /* Lighter, softer border */
    border-radius: 5px;
    background-color: #FFFFFF; /* White background for individual items */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05); /* Subtle shadow */
    box-sizing: border-box;
}
.tab-content {
    white-space: pre-wrap;
    word-wrap: break-word;
    tab-size: 4;
    margin: 0;
    display: block;
    text-align: left;
    padding: 10px;
    background: #F0F0F0; /* Lighter background for code/tab content */
    border-radius: 5px;
    max-height: 150px;
    overflow: hidden;
    transition: max-height 0.5s ease;
    color: #333333; /* Ensure text is readable */
}
.tab-content.expanded {
    max-height: none;
}
/* This class is added by JS to disable transitions during print preparation */
.tab-content.print-ready {
    transition: none !important;
}

.intro-text {
    background: #EBF5FB; /* Lighter, softer blue background */
    border: 1px solid #A9CCE3; /* Softer blue border */
    padding: 20px;
    margin: 20px auto;
    max-width: 800px;
    border-radius: 8px;
    font-family: "Helvetica Neue", Arial, sans-serif;
    color: #333333; /* Darker text */
    line-height: 1.6;
}
.intro-text h1 {
    margin-top: 0;
    color: #2C3E50; /* Dark blue-gray for heading */
    text-align: center;
}

/* --- Buttons --- */
.expand-button,
.print-button {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 16px;
    background-color: #4A90E2; /* Primary blue */
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}
.expand-button:hover,
.print-button:hover {
    background-color: #357ABD; /* Darker blue on hover */
}
.print-button.no-print.btn:hover {
    text-decoration: none;
}
.more-tabs .more-tabs-btn {
    background-color: #4A90E2; /* Primary blue */
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-weight: bold;
    font-size: 16px;
    transition: background-color 0.3s ease;
    text-decoration: none;
    margin-top: 10px;
    display: inline-block;
}
.more-tabs .more-tabs-btn:hover {
    background-color: #357ABD; /* Darker blue shade on hover */
    text-decoration: none;
}
.more-tabs .more-tabs-btn:focus {
    outline: 2px solid #FFD700; /* Golden outline when focused */
    outline-offset: 2px;
}
.filter button {
    background: #4A90E2; /* Primary blue */
    color: #fff;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
.filter button:hover {
    background: #357ABD; /* Darker blue on hover */
}

/* --- Rating & Stars --- */
.stars {
    white-space: nowrap;
    color: #FFD700; /* Gold for filled stars */
    font-size: 24px !important; /* Larger stars */
    letter-spacing: 2px;
}
.rating-stars .star {
    cursor: pointer;
    color: #BDC3C7; /* Default light gray for unrated stars */
    transition: color 0.2s ease;
}
.rating-stars .star.filled {
    color: #FFD700; /* Gold for filled stars */
}
.average-rating.stars .empty-star {
    color: #BDC3C7; /* Light gray for empty stars in average rating */
}

/* --- Share Buttons --- */
.share-container {
    border-top: 1px solid #E0E0E0; /* Lighter border */
    border-bottom: 1px solid #E0E0E0; /* Lighter border */
    margin-bottom:20px;
    padding-bottom:20px;
    margin-top: 20px;
    padding-top: 20px;
    text-align: center;
}
.share-container h2 {
    margin-bottom: 15px;
    color: #333333;
}
.share-buttons {
    list-style: none;
    padding: 0;
    display: inline-flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}
.share-buttons li {
    display: inline-block;
}
.share-btn {
    display: inline-block;
    text-decoration: none;
    padding: 10px 15px;
    border-radius: 5px;
    transition: background-color 0.3s, color 0.3s;
    font-size: 14px;
    font-weight: bold;
}
/* Social media brand colors (kept as is for recognition) */
.share-btn.facebook { background: #3b5998; color: #fff; }
.share-btn.facebook:hover { background: #2d4373; text-decoration: none; }
.share-btn.twitter { background: #1da1f2; color: #fff; }
.share-btn.twitter:hover { background: #0d95e8; text-decoration: none; }
.share-btn.email { background: #7f8c8d; color: #fff; } /* Neutral gray for email */
.share-btn.email:hover { background: #667071; text-decoration: none; }
.share-btn.linkedin { background: #0077b5; color: #fff; }
.share-btn.linkedin:hover { background: #005983; text-decoration: none; }
.share-btn.bookmark { background: #e67e22; color: #fff; }
.share-btn.bookmark:hover { background: #d35400; text-decoration:none; }

/* --- Filters & Search --- */
.filter {
    background: #FFFFFF; /* White background */
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}
.filter h2 {
    margin-top: 0;
    color: #333333;
}
.filter label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555555; /* Slightly lighter label text */
}
.filter input[type="text"] {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #D0D0D0; /* Lighter border */
    border-radius: 4px;
}

/* --- Piano & Controls --- */
.piano-container {
    margin-top: 40px;
    margin-bottom: 20px;
    text-align: center;
    overflow-x: auto; /* Allow horizontal scrolling for piano */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    padding-bottom: 10px; /* Space for scrollbar */
}
#keyboard {
    position: relative;
    width: 100%;
    max-width: 900px;
    height: 200px;
    margin: 20px auto;
    user-select: none;
    font-size: 0;
    margin-bottom: 0;
    padding-bottom: 0;
    /* Removed max-height and overflow: hidden here, relying on parent overflow-x */
}
.white-key {
    display: inline-block;
    width: 60px;
    height: 200px;
    background: #FFFFFF; /* Pure white */
    border: 1px solid #333333; /* Darker border for definition */
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    font-size: 16px;
    border-top: 1px solid #333333 !important;
    border-bottom: 1px solid #333333 !important;
}
.white-key:first-child {
    border-left: 2px solid #333333 !important;
}
.white-key.last-white-key {
    border-right: 2px solid #333333 !important;
}
.white-key .key-label {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 1.2em;
    color: #333333; /* Dark text */
}
.black-key {
    position: absolute;
    width: 40px;
    height: 120px;
    background: #1A1A1A !important; /* Slightly softer black */
    top: 0;
    z-index: 2;
    border-radius: 0 0 5px 5px;
    line-height: 120px;
    font-size: 0.9em;
    text-align: center;
    color: #FFF !important; /* White text for black keys */
    transform: translateX(-50%);
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: bold !important;
}
.black-key .key-label {
    position: absolute;
    top: 5px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.9em;
    color: #FFF !important;
    line-height: normal;
}
/* Black key positioning (no color changes) */
.black-key.key-csharp { left: 60px; }
.black-key.key-dsharp { left: 120px; }
.black-key.key-fsharp { left: 240px; }
.black-key.key-gsharp { left: 300px; }
.black-key.key-asharp { left: 360px; }
.black-key.key-csharp2 { left: 480px; }
.black-key.key-dsharp2 { left: 540px; }
.black-key.key-fsharp2 { left: 660px; }
.black-key.key-gsharp2 { left: 720px; }
.black-key.key-asharp2 { left: 780px; }

.active-piano {
    background: #FFD700; /* Gold for active piano */
}
.white-key.active {
    background: #FFD700 !important; /* Gold for active white key */
}
.black-key.active {
    background: #FFEB80 !important; /* Lighter gold for active black key */
}

/* --- Media Controls (Reverted to original text visibility) --- */
#control-buttons {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    background-color: #2c3e50 !important;
    border-radius: 10px !important;
    padding: 12px 20px !important;
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.1) !important;
    margin-top: 20px !important;
    border: 1px solid #ddd !important;
    flex-wrap: wrap !important;
}

/* General Button Styling for Media Controls */
#play-btn, #pause-btn, #repeat-btn, #mute-btn, #control-buttons .speed-controls button {
    width: 50px !important;
    height: 50px !important;
    margin: 5px !important;
    border: none !important;
    border-radius: 50% !important;
    background-color: #7f8c8d !important;  /* Default gray background */
    cursor: pointer !important;
    position: relative !important;
    outline: none !important;
    transition: background-color 0.3s ease !important;
    padding: 0 !important;
    color: transparent !important; /* Text is transparent, icons/labels use ::before */
    text-shadow: none !important;
    aspect-ratio: 1 !important;
    font-size: 14px !important; /* Consistent font size for all button content */
}

/* Hover State for All Buttons */
#play-btn:hover, #pause-btn:hover, #repeat-btn:hover, #mute-btn:hover, #control-buttons .speed-controls button:hover {
    background-color: #95a5a6 !important;  /* Lighter gray for hover */
}

/* Active States */
#play-btn.active, #pause-btn.active {
    background-color: #2ecc71 !important; /* Green active state for play and pause */
}

#repeat-btn.active {
    background-color: #9b59b6 !important;  /* Purple active state for repeat */
}

#mute-btn.active {
    background-color: #c0392b !important;  /* Red active state for mute */
}

#control-buttons .speed-controls button.active {
    background-color: #2ecc71 !important; /* Green active state for speed controls */
}

/* Play Button Icon */
#play-btn::before {
    content: "\25B6" !important;
    color: #fff !important;
    font-size: 24px !important; /* Icon size adjusted for consistency */
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
}

/* Pause Button Icon */
#pause-btn::before, #pause-btn::after {
    content: "" !important;
    background-color: #fff !important;
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 6px !important;
    height: 24px !important; /* Icon size adjusted for consistency */
    border-radius: 2px !important;
}
#pause-btn::before {
    left: calc(50% - 9px) !important;
}
#pause-btn::after {
    left: calc(50% + 3px) !important;
}

/* Repeat Button Icon */
#repeat-btn::before {
    content: "" !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M7 7h9l-3.5-3.5L14 2l5 5-5 5-1.5-1.5L16 7H7c-2.21 0-4 1.79-4 4s1.79 4 4 4h1v-2H7c-1.1 0-2-.9-2-2s.9-2 2-2z'/%3E%3Cpath fill='white' d='M17 17H8l3.5 3.5L10 22l-5-5 5-5 1.5 1.5L8 17h9c2.21 0 4-1.79 4-4s-1.79-4-4-4h-1v2h1c1.1 0 2 .9 2 2s-.9 2-2 2z'/%3E%3C/svg%3E") !important;
    background-size: 24px 24px !important;
    width: 24px !important;
    height: 24px !important; /* Icon size adjusted for consistency */
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
}

/* Mute Button Icon */
#mute-btn::before {
    content: "" !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M5 9v6h4l5 5V4l-5 5H5z'/%3E%3Cline x1='19' y1='5' x2='5' y2='19' stroke='white' stroke-width='2'/%3E%3C/svg%3E") !important;
    background-size: 24px 24px !important;
    width: 24px !important;
    height: 24px !important; /* Icon size adjusted for consistency */
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
}

/* When Mute Button is Active */
#mute-btn.active::before {
    content: "" !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M5 9v6h4l5 5V4l-5 5H5z'/%3E%3Cline x1='19' y1='5' x2='5' y2='19' stroke='white' stroke-width='2'/%3E%3C/svg%3E") !important;
    background-size: 24px 24px !important;
}

/* Speed Controls Styling */
#control-buttons .speed-controls {
    display: flex !important;
    align-items: center !important;
    margin: 0 !important;
    flex-wrap: wrap !important;
}

#control-buttons .speed-controls button {
    width: 50px !important;
    height: 50px !important;
    background-color: #7f8c8d !important; /* Default gray background */
    color: transparent !important; /* Text is transparent, label uses ::before */
    border-radius: 50% !important;
    cursor: pointer !important;
    position: relative !important;
    outline: none !important;
    transition: background-color 0.3s ease !important;
    padding: 0 !important;
    font-size: 14px !important; /* Consistent font size for speed controls */
}

/* Speed Control Text (Dynamic Text for Different Speeds) */
#control-buttons .speed-controls button::before {
    content: attr(data-speed) "x" !important;
    color: #fff !important;
    font-size: 14px !important;  /* Ensuring consistency in text size */
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
}

/* Speed Control Button Hover */
#control-buttons .speed-controls button:hover {
    background-color: #95a5a6 !important;  /* Lighter gray for hover */
}

/* Speed Control Active Button State */
#control-buttons .speed-controls button.active {
    background-color: #2ecc71 !important; /* Consistent Green for Active Button */
}

/* Specific Speed Labels */
#control-buttons .speed-controls button[data-speed="0.25"]::before { content: "0.25x" !important; }
#control-buttons .speed-controls button[data-speed="0.67"]::before { content: "0.67x" !important; }
#control-buttons .speed-controls button[data-speed="1"]::before { content: "1x" !important; }
#control-buttons .speed-controls button[data-speed="1.33"]::before { content: "1.33x" !important; }


/* --- Utility & Overrides --- */
.section-block h2 {
    text-align: center;
    color: #333333;
}
.rating-section, .related-tabs {
    text-align: center;
}
.related-tabs ul {
    display: inline-block;
    text-align: left;
    margin: 0 auto;
    padding: 0;
    list-style-position: inside;
    font-size: 16px; /* Increased font size for related tabs links */
}
.related-tabs ul li {
    margin-bottom: 5px; /* Add a little space between list items */
}

/* Styles for detail.php's title block */
.title-block {
    display: flex;
    flex-direction: column; /* Stack children vertically */
    align-items: flex-start; /* Align children to the left by default */
    margin-bottom: 20px; /* Spacing below the entire block */
    width: 100%; /* Ensure it takes full width */
}

.title-container { /* Contains H1 and Print Button */
    display: flex;
    justify-content: space-between; /* Pushes H1 left, button right */
    align-items: center;
    width: 100%; /* Crucial: make it span full width of parent */
    margin-bottom: 5px; /* Minimal spacing below title/button row */
}

.title-container h1 {
    margin-bottom: 0; /* Remove default h1 margin */
    flex-grow: 1; /* Allow title to take available space */
    text-align: left; /* Ensure title is left-aligned */
}

.print-button {
    margin-left: 15px; /* Space between title and button */
    margin-top: 0; /* Reset margin-top from general button rules */
}

/* The div containing the average-rating stars (second direct child div of .title-block) */
.title-block > div:nth-of-type(2) {
    text-align: left; /* Align stars to the left */
    margin-bottom: 5px; /* Minimal spacing between stars and meta */
    width: 100%; /* Ensure it takes full width for text-align to work */
}

/* The meta div (third direct child of .title-block) */
.meta {
    text-align: left; /* Align meta to the left */
    margin-top: 0; /* Remove any conflicting margin */
}

/* Specific styles for top-rated.php's tab items */
.tab-item .title-rating {
    display: flex;
    justify-content: space-between; /* Title left, stars right */
    align-items: center;
    margin-bottom: 4px; /* Original spacing */
}

.tab-item .tab-title {
    flex: 1;
    margin-right: 10px;
    white-space: nowrap;
    overflow: hidden;
    font-size: 1.3em; /* Make tab titles larger */
}

.tab-item .stars {
    white-space: nowrap;
    color: gold;
    font-size: 1rem; /* Original size for stars in tab-item, or adjust if needed */
}

.tab-item .meta {
    font-size: 14px; /* Keep meta info size consistent */
}

.tab-item .meta .genre-links a {
    font-size: 1.1em; /* Make genre links larger */
}


.more-tabs {
    text-align: center;
    margin-top: 20px;
    padding: 15px;
    background-color: #FFFFFF;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.center {
    text-align: center;
}
#error-display {
    background-color: #FADBD8; /* Light red */
    border: 1px solid #E74C3C; /* Red border */
    color: #C0392B; /* Darker red text */
    padding: 10px;
    margin: 10px 0;
    /* PHP display logic removed as this is pure CSS */
}
.grid-container {
    width: 800px !important;
    margin: 0 auto !important;
    padding-left: 0px !important;
    padding-right: 0px !important;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}
.category {
    flex: 1 1 500px;
    max-width: 600px;
    box-sizing: border-box;
}

/* --- Footer Styles --- */
.site-footer {
    background-color: #2C3E50; /* Dark blue-gray, matching navbar */
    color: #ecf0f1; /* Light text for contrast */
    padding: 60px 0 30px 0; /* More padding above links and general footer content */
    margin-top: 80px; /* Good separation from main content */
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1); /* Subtle shadow matching existing style */
    text-align: center; /* Center content by default */
}

.footer-content {
    max-width: 1000px; /* Match main content width */
    margin: 0 auto;
    padding: 0 20px; /* Consistent horizontal padding */
}

.footer-brand h3 {
    font-size: 2.2em;
    margin-bottom: 10px;
    color: #4A90E2; /* Primary blue for brand name, matching links */
    font-weight: 600;
    letter-spacing: 1px;
}

.footer-brand p {
    font-size: 1.1em;
    margin-bottom: 40px; /* Generous space below tagline */
    color: #bdc3c7; /* Light gray for descriptive text */
    font-style: italic;
}

.footer-links {
    margin-bottom: 40px; /* Space below links */
    padding-top: 20px; /* Additional padding above links for "more padding above links" */
}

.footer-link {
    display: inline-block;
    color: #ecf0f1; /* Light text for links */
    text-decoration: none;
    margin: 0 20px; /* Slightly reduced horizontal margin for links */
    padding: 12px 24px;
    border: 2px solid #4A90E2; /* Primary blue border */
    border-radius: 5px; /* Consistent with other elements like navbar */
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 1em;
}

.footer-link:hover {
    background-color: #4A90E2; /* Primary blue on hover */
    color: #ffffff;
    transform: translateY(-2px); /* Subtle lift effect */
    box-shadow: 0 5px 15px rgba(74, 144, 226, 0.3); /* Shadow matching primary blue */
    text-decoration: none; /* Remove underline on hover */
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1); /* Subtle white border for separation */
    padding-top: 25px;
    margin-top: 30px;
}

.footer-bottom p {
    margin: 0;
    color: #a0aec0; /* Light gray for copyright text */
    font-size: 0.9em;
}

/* --- Print Styles --- */
@media print {
    /* Hide elements that should never print */
    .no-print,
    header, /* Hide the main header */
    footer { /* Hide the main footer */
        display: none !important;
    }

    /* Specific rules for "print chords only" mode */
    body.print-only-chords {
        /* Reset body styles for print */
        margin: 0;
        padding: 0;
        background: white;
        color: black;
        font-family: sans-serif;
        -webkit-print-color-adjust: exact; /* Ensure colors print as they appear */
        print-color-adjust: exact;
    }

    body.print-only-chords main {
        /* Make main visible and take full print width */
        display: block !important;
        width: 100%;
        margin: 0 auto;
        padding: 20mm; /* Add some print margin */
        box-sizing: border-box;
    }

    /* Hide all direct children of main by default, except the ones we want */
    body.print-only-chords main > *:not(.title-block):not(.detail-item) {
        display: none !important;
    }

    /* Ensure the specific detail-items are visible */
    body.print-only-chords .detail-item {
        display: block !important; /* Override any default hiding */
        visibility: visible !important; /* Override any default hiding */
        page-break-inside: avoid; /* Prevent breaking content across pages */
        margin-bottom: 1em;
    }

    /* Hide specific elements within the visible sections */
    body.print-only-chords .average-rating, /* Hide stars in title block */
    body.print-only-chords .description-paragraph { /* Hide the song description */
        display: none !important;
    }

    /* Ensure the tab-content is fully expanded and visible - CRITICAL FIX */
    body.print-only-chords .tab-content,
    body.print-only-chords .tab-content.expanded,
    body.print-only-chords .tab-content.print-ready {
        max-height: none !important; /* Force full expansion */
        height: auto !important; /* Ensure natural height */
        overflow: visible !important; /* Show all content */
        transition: none !important; /* Remove any transitions */
        white-space: pre-wrap !important;
        word-wrap: break-word !important;
        font-size: 12pt !important;
        line-height: 1.4 !important;
        background: none !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* General styling for the visible content */
    body.print-only-chords h1 {
        font-size: 20pt;
        margin-bottom: 0.5em;
        page-break-after: avoid;
    }
    body.print-only-chords h2 {
        font-size: 14pt;
        margin-top: 1.5em;
        margin-bottom: 0.5em;
        page-break-after: avoid;
    }
    body.print-only-chords .meta {
        font-size: 10pt;
        margin-bottom: 1em;
    }
    body.print-only-chords .detail-item ul {
        margin-left: 20px;
        font-size: 10pt;
    }
    body.print-only-chords .meta a {
        color: black;
        text-decoration: none;
    }
    body.print-only-chords .meta a:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
}

/* --- Mobile Media Queries --- */
@media (max-width: 768px) {
    body { padding: 0 10px; }
    main { padding: 15px; margin: 10px auto; } /* Reduced padding for main content */

    /* Ensure .container also matches body background and padding on mobile */
    .container {
        background-color: #F0F2F5 !important; /* Explicitly set to body background color */
        padding-left: 10px !important; /* Match body padding */
        padding-right: 10px !important; /* Match body padding */
        max-width: 100% !important; /* Ensure it takes full width */
        margin: 0 auto !important; /* Ensure it's centered */
    }

    /* Make logo container background explicitly match body background and remove its padding */
    .logo-container {
        background-color: #F0F2F5 !important; /* Explicitly set to body background color */
        background-image: none !important; /* Ensure no background image is interfering */
        padding: 0 !important; /* Remove all padding from the container */
        margin: 0 auto !important; /* Ensure it's centered if needed */
    }

    /* Add vertical spacing directly to the logo image if needed */
    .logo {
        margin-top: 15px !important; /* Example: add back the 15px top padding to the logo image */
        margin-bottom: 15px !important; /* Example: add some space below the logo */
    }

    .navbar { padding: 10px 15px; } /* Smaller navbar padding */
    .navbar a { font-size: 12px; padding: 8px 10px; } /* Smaller nav links */
    .navbar ul { gap: 5px; flex-wrap: wrap; justify-content: space-around; } /* Allow nav items to wrap, add small gap */

    /* Two-column layout becomes single column */
    .two-column-container {
        flex-direction: column;
        gap: 1rem; /* Reduce gap for mobile */
    }

    /* Adjust .title-block for mobile stacking and centering */
    .title-block {
        align-items: center; /* Center all children in the column */
    }

    .title-container { /* Contains H1 and Print Button */
        flex-direction: column; /* Stack H1 and Print Button */
        align-items: center; /* Center H1 and Print Button */
        margin-bottom: 10px; /* Space below title/button group */
        width: 100%; /* Ensure it takes full width */
    }
    .title-container h1 {
        font-size: 1.75em;
        margin-bottom: 10px;
        text-align: center;
        width: 100%;
    }
    .print-button {
        width: 100%; /* Full width button */
        text-align: center;
        font-size: 16px;
        margin-bottom: 15px; /* Space below button */
        margin-left: 0; /* Remove left margin */
        margin-top: 0; /* Reset margin-top from desktop rule */
    }

    /* The div containing stars */
    .title-block > div:nth-of-type(2) {
        text-align: center; /* Center stars on mobile */
        margin-bottom: 10px; /* Add space below stars */
    }

    /* The meta div */
    .meta {
        text-align: center; /* Center meta on mobile */
    }

    .content, .tab-content {
        font-size: 1em;
        margin: 0 auto;
        padding: 0 5px;
    }
    .speed-controls button {
        display: block;
        width: 100%;
        margin: 5px 0;
    }
    .expand-button { margin-bottom: 10px; }
    .piano-container {
        margin-top: 20px !important;
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
        /* Removed overflow: hidden from here, now handled by overflow-x: auto */
    }
    #keyboard {
        margin: 10px auto 0 auto !important;
        /* Removed max-height and overflow: hidden from here */
    }
    .share-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    .share-buttons li {
        flex: 1 0 48%;
        margin-bottom: 10px;
    }
    .grid-container {
        width: 100% !important; /* Ensure grid container is full width */
        padding: 0 10px !important; /* Add some padding */
    }
    .category {
        flex: 1 1 100%; /* Stack categories */
        max-width: 100%;
    }

    /* --- Footer Media Queries --- */
    .site-footer {
        padding: 40px 0 20px 0;
        margin-top: 60px;
    }
    
    .footer-brand h3 {
        font-size: 1.8em;
    }
    
    .footer-link {
        display: block; /* Stack links vertically */
        margin: 10px auto; /* Center stacked links */
        max-width: 250px; /* Limit width for stacked links */
    }
    
    .footer-content {
        padding: 0 15px; /* Adjust padding for smaller screens */
    }
}

@media (max-width: 768px) and (orientation: landscape) {
    #keyboard {
        /* Re-evaluate scaling for landscape. If overflow-x: auto is used, scaling might not be necessary or could be less aggressive. */
        transform: scale(0.8) !important;
        transform-origin: top left !important;
        width: 100% !important;
        /* overflow: hidden !important; -- Removed, handled by parent overflow-x */
    }
}

@media (max-width: 900px) {
    #keyboard { width: 100%; }
    .white-key { width: calc(100% / 15); height: 150px; font-size: 16px; }
    .black-key { width: calc((100% / 15) * 0.6); height: 90px; line-height: 90px; }
    .black-key.key-csharp { left: calc((100% / 15) * 1); }
    .black-key.key-dsharp { left: calc((100% / 15) * 2); }
    .black-key.key-fsharp { left: calc((100% / 15) * 4); }
    .black-key.key-gsharp { left: calc((100% / 15) * 5); }
    .black-key.key-asharp { left: calc((100% / 15) * 6); }
    .black-key.key-csharp2 { left: calc((100% / 15) * 8); }
    .black-key.key-dsharp2 { left: calc((100% / 15) * 9); }
    .black-key.key-fsharp2 { left: calc((100% / 15) * 11); }
    .black-key.key-gsharp2 { left: calc((100% / 15) * 12); }
    .black-key.key-asharp2 { left: calc((100% / 15) * 13); }
}

@media (max-width: 600px) {
    #keyboard { display: flex; justify-content: center; position: relative; }
    .white-key { width: calc(100% / 15); height: 120px; font-size: 12px; border: 1px solid #333333; background: #FFFFFF; }
    .black-key { width: calc((100% / 15) * 0.6); height: 80px; position: absolute; background: #1A1A1A; z-index: 2; border-radius: 0 0 5px 5px; transform: translateX(-50%); line-height: 80px; }
    .black-key.key-csharp { left: calc((100% / 15) * 1); }
    .black-key.key-dsharp { left: calc((100% / 15) * 2); }
    .black-key.key-fsharp { left: calc((100% / 15) * 4); }
    .black-key.key-gsharp { left: calc((100% / 15) * 5); }
    .black-key.key-asharp { left: calc((100% / 15) * 6); }
    .black-key.key-csharp2 { left: calc((100% / 15) * 8); }
    .black-key.key-dsharp2 { left: calc((100% / 15) * 9); }
    .black-key.key-fsharp2 { left: calc((100% / 15) * 11); }
    .black-key.key-gsharp2 { left: calc((100% / 15) * 12); }
    .black-key.key-asharp2 { left: calc((100% / 15) * 13); }
    .black-key .key-label { font-size: 0.8em; }

    /* --- Footer Media Queries for 600px --- */
    .site-footer {
        padding: 30px 0 15px 0;
        margin-top: 40px;
    }
    .footer-brand h3 {
        font-size: 1.6em;
    }
    .footer-brand p {
        font-size: 1em;
        margin-bottom: 30px;
    }
    .footer-links {
        margin-bottom: 30px;
        padding-top: 15px;
    }
    .footer-link {
        padding: 10px 20px;
        font-size: 0.9em;
    }
    .footer-bottom {
        padding-top: 20px;
        margin-top: 20px;
    }
}

@media only screen and (max-device-width: 812px) and (orientation: landscape) {
    #keyboard { height: 150px; }
    .white-key { height: 150px; }
    .black-key { height: 80px; line-height: 80px; }
}

@media (max-width: 480px) {
    .title-container h1 { font-size: 1.5em; }
    .expand-button, .print-button { padding: 10px; font-size: 14px; }
    .black-key { width: 20px !important; height: 70px !important; font-size: 11px !important; }
    .white-key .key-label { position: absolute; bottom: 5px; width: 100%; text-align: center; font-size: 14px; }
}

@media (max-width: 400px) {
    .title-container h1 { font-size: 1.3em; }
    .expand-button, .print-button { padding: 8px; font-size: 13px; }
    .piano-container { padding: 0 5px; }
}