/* ===================================
   MINIMALIST BLACK & WHITE DESIGN
   Color Palette:
   - Background: #FAFAFA (neutral-50)
   - Surface/Cards: #FFFFFF (white)
   - Borders: #E5E5E5 (neutral-200)
   - Primary text: #171717 (neutral-900)
   - Secondary text: #525252 (neutral-600)
   - Muted text: #A3A3A3 (neutral-400)
   - Accent (stats): #0891B2 (cyan-600)
   - Success: #059669 (emerald-600)
   - Warning/Due: #DC2626 (red-600)
   =================================== */

:root {
    --color-bg: #FAFAFA;
    --color-surface: #FFFFFF;
    --color-border: #E5E5E5;
    --color-border-hover: #A3A3A3;
    --color-text-primary: #171717;
    --color-text-secondary: #525252;
    --color-text-muted: #A3A3A3;
    --color-accent: #0891B2;
    --color-success: #059669;
    --color-warning: #DC2626;
}

/* General layout and containers */
body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--color-bg);
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* Headers and text */
.header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.bg-red-100 {
    background-color: #fee2e2;
}

.text-red-800 {
    color: #991b1b;
}

/* Calendar / Grid sections */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1rem;
    /* Improves performance on large grids by deferring off-screen rendering */
    content-visibility: auto;
    contain-intrinsic-size: 0 500px;
}
.calendar-day {
    width: 100%; 
}
@media (max-width: 640px) {
    .calendar-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Headings */
.h1 {
    color: var(--color-text-primary);
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.025em;
}

/* Tooltip */
.tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 10;
    background-color: var(--color-text-primary);
    color: white;
    padding: 8px;
    border-radius: 6px;
    text-align: left;
}
.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: var(--color-text-primary) transparent transparent transparent;
}
.group:hover .tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-5px);
}

/* Progress Bar */
.progress-bar {
    position: relative;
    height: 2rem;
}
.progress-bar .total-progress-indicator {
    position: absolute;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

/* Puzzle Information Section */
.puzzle-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 1.5rem;
}
.solve-button.locked {
    background-color: #e2e8f0;
    color: #718096;
    cursor: not-allowed;
    border: 2px dashed #cbd5e0;
}
.solve-button.locked:hover {
    background-color: #edf2f7;
}
.upgrade-message {
    color: #2b6cb0;
    font-weight: 600;
    margin-top: 5px;
}
.upgrade-message a:hover {
    text-decoration: underline;
}

/* Book / Puzzle Title */
.book-title {
    color: var(--color-text-primary);
    font-weight: 600;
    font-size: 1.125rem;
}
.side-to-move {
    color: var(--color-text-secondary);
    font-size: 1rem;
}
.puzzle-timer {
    font-family: ui-monospace, 'Roboto Mono', monospace;
    font-size: 1rem;
    color: var(--color-text-secondary);
    font-weight: 500;
}

/* Board Container */
.board-container {
    aspect-ratio: 1;
    max-width: 600px;
    margin: 0 auto;
    background: var(--color-surface);
    border-radius: 0.5rem;
    border: 1px solid var(--color-border);
    padding: 0.75rem;
    /* Prevent layout shifts during stats updates */
    contain: layout style;
}

/* Stats Container */
.stats-container {
    max-width: 600px;
    margin: 1.5rem auto;
    background: var(--color-surface);
    border-radius: 0.5rem;
    border: 1px solid var(--color-border);
    padding: 1.25rem;
}
.stats-header {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}
.stat-item {
    text-align: center;
    padding: 1rem;
    background: var(--color-bg);
    border-radius: 0.5rem;
    border: 1px solid var(--color-border);
}
.stat-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 0.25rem;
}
.stat-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Buttons & Controls */
.buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1.5rem;
}
.button {
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 150ms ease;
    cursor: pointer;
}
.hint-button {
    background-color: var(--color-surface);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}
.hint-button:hover {
    border-color: var(--color-border-hover);
}
.next-button {
    background-color: var(--color-text-primary);
    color: white;
    border: 1px solid transparent;
}
.next-button:hover {
    background-color: #262626;
}

/* Move Status and Feedback */
#move-status {
    text-align: center;
    padding: 0.75rem;
    margin: 1rem auto;
    max-width: 600px;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: background-color 150ms ease;
}
#move-status.success {
    background-color: #ecfdf5;
    color: var(--color-success);
}
#move-status.error {
    background-color: #fef2f2;
    color: var(--color-warning);
}

/* Progress Bars & Indicators */
.progress-container {
    width: 100%;
    height: 6px;
    background-color: var(--color-border);
    border-radius: 9999px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background-color: var(--color-text-primary);
    transition: width 300ms ease;
}

/* Book Selection Cards */
.book-card {
    background: var(--color-surface);
    border-radius: 0.5rem;
    border: 1px solid var(--color-border);
    transition: border-color 150ms ease;
    overflow: hidden;
}
.book-card:hover {
    border-color: var(--color-border-hover);
}
.book-thumbnail {
    width: 96px;
    height: 128px;
    border-radius: 0.5rem;
    overflow: hidden;
    transition: transform 150ms ease;
}
.book-thumbnail:hover {
    transform: scale(1.02);
}

/* Loading states & spinners */
.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}
.spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 100;
}
@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}
.board-loading {
    position: relative;
    background: rgba(255, 255, 255, 0.8);
}
.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background-color: rgb(255 255 255 / 0.5);
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .container {
        padding: 0 0.5rem;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .buttons {
        flex-direction: column;
    }
    .button {
        width: 100%;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.fade-in {
    animation: fadeIn 200ms ease-out;
}

@keyframes slideIn {
    from {
        transform: translateY(10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}
.slide-in {
    animation: slideIn 200ms ease-out;
}

/* Flash Messages */
.flash-message {
    margin: 1rem auto;
    padding: 1rem;
    border-radius: 0.5rem;
    max-width: 600px;
    animation: slideIn 200ms ease-out;
}
.flash-message.success {
    background-color: #ecfdf5;
    border: 1px solid #10b981;
    color: #065f46;
}
.flash-message.error {
    background-color: #fef2f2;
    border: 1px solid #ef4444;
    color: #991b1b;
}

/* Nav & Footer */
.nav-link {
    color: var(--color-text-secondary);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: color 150ms ease;
}
.nav-link:hover {
    color: var(--color-text-primary);
}
.nav-link.active {
    color: var(--color-text-primary);
    font-weight: 600;
}
footer {
    margin-top: auto;
    padding: 1.5rem 0;
    background-color: white;
    border-top: 1px solid var(--color-border);
}

/* Highlight animation for updated stats */
.highlight {
    animation: highlight 0.5s ease-out;
}
@keyframes highlight {
    0% {
        background-color: rgba(8, 145, 178, 0.1);
    }
    100% {
        background-color: transparent;
    }
}
.stat-value, .progress-bar {
    transition: all 0.3s ease-out;
}

/* Additional quick transitions for cards */
.cycle-card {
    transform: translateZ(0);
    transition: border-color 0.15s ease;
    border: 1px solid var(--color-border);
}
.cycle-card:hover {
    border-color: var(--color-border-hover);
}

/* Book Banner Styles - Simplified minimalist version */
.book-promo-container {
    position: fixed;
    right: 0;
    top: 33%;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Hide promotion banner on mobile devices */
@media (max-width: 768px) {
    .book-promo-container {
        display: none !important;
        visibility: hidden;
        pointer-events: none;
        opacity: 0;
    }
}

/* Additional rule to prevent banner from interfering with the board */
@media (hover: none) and (pointer: coarse) {
    .book-promo-container {
        display: none !important;
        visibility: hidden;
        pointer-events: none;
        opacity: 0;
    }
}

.book-promo-tab,
.author-link-tab {
    transform: translateX(calc(100% - 10px));
    transition: transform 0.2s ease;
}

.book-promo-tab:hover,
.author-link-tab:hover {
    transform: translateX(0);
}

.book-promo-tab a {
    display: flex;
    width: auto;
    min-width: 200px;
    border: 1px solid var(--color-border);
}

.author-link-tab a {
    display: flex;
    width: auto;
    min-width: 180px;
    border: 1px solid var(--color-border);
    transition: border-color 0.15s ease;
}

.author-link-tab a:hover {
    border-color: var(--color-border-hover);
}

/* Pulsing review badge */
@keyframes pulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.02); }
    100% { transform: scale(1); }
}
.review-badge {
    animation: pulse 2s infinite;
    box-shadow: 0 0 0 2px white, 0 0 0 3px var(--color-warning);
}

/* Smooth transitions for book cards */
.book-card {
    transition: border-color 0.15s ease;
}

/* Success rate chart container */
.success-rate {
    transition: color 0.3s ease-out;
}
#success-rate-chart {
    height: 300px;
    width: 100%;
    position: relative;
}
.chart-tooltip {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    white-space: nowrap;
}

/* Review Stage Label */
.review-stage-label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 4px;
    text-align: center;
    font-weight: 500;
}

/* Puzzle Title */
.puzzle-title {
    font-size: 1.5rem;
    text-align: center;
    margin-top: 0;
    color: var(--color-text-primary);
}

/* Text utility */
.p-text-gray-600 {
    color: rgb(75 85 99);
    font-display: swap;
}

/* ===================================
   PUZZLE PAGE TWO-COLUMN LAYOUT
   =================================== */

.puzzle-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    max-width: 100%;
    margin: 0 auto;
}

/* Prevent board column from resizing during stats updates */
.puzzle-main {
    min-width: 0;
    contain: layout style;
}

@media (min-width: 1024px) {
    .puzzle-layout {
        grid-template-columns: minmax(140px, 160px) minmax(400px, 500px) minmax(280px, 360px);
        max-width: 1100px;
        align-items: start;
    }
}

/* Left promo sidebar */
.promo-sidebar {
    position: sticky;
    top: 1.5rem;
}

.promo-sidebar-card-inner {
    border-left: 3px solid #059669;
}

/* Stats sidebar - sticky on desktop */
.stats-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 1024px) {
    .stats-sidebar {
        position: sticky;
        top: 1.5rem;
        max-height: calc(100vh - 3rem);
        overflow-y: auto;
    }
}

/* Mobile compact stats bar */
.mobile-stats-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    gap: 0.75rem;
}

@media (min-width: 1024px) {
    .mobile-stats-bar {
        display: none;
    }
}

.mobile-stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mobile-stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.mobile-stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

.mobile-stat-value.accent {
    color: var(--color-accent);
}

.mobile-stat-value.warning {
    color: var(--color-warning);
}

/* ===================================
   MINIMALIST BUTTON STYLES
   =================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 150ms ease;
    cursor: pointer;
    border: none;
}

.btn-primary {
    background-color: var(--color-text-primary);
    color: white;
}

.btn-primary:hover {
    background-color: #262626;
}

.btn-primary:disabled {
    background-color: #D4D4D4;
    color: #A3A3A3;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: var(--color-surface);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    border-color: var(--color-border-hover);
}

.btn-ghost {
    background-color: transparent;
    color: var(--color-text-secondary);
}

.btn-ghost:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* ===================================
   MINIMALIST CARD STYLES
   =================================== */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    padding: 1rem;
}

.card-lg {
    padding: 1.5rem;
    border-radius: 0.75rem;
}

/* ===================================
   STATS DISPLAY STYLES
   =================================== */

.stat-label-minimal {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value-minimal {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-primary);
    line-height: 1.2;
}

.stat-value-accent {
    color: var(--color-accent);
}

.stat-value-warning {
    color: var(--color-warning);
}

.stat-value-success {
    color: var(--color-success);
}

/* ===================================
   PROGRESS BAR MINIMALIST STYLES
   =================================== */

.progress-minimal {
    height: 6px;
    background-color: #E5E5E5;
    border-radius: 9999px;
    overflow: hidden;
}

.progress-minimal-bar {
    height: 100%;
    border-radius: 9999px;
    transition: width 300ms ease;
}

.progress-bar-gray {
    background-color: #737373;
}

.progress-bar-accent {
    background-color: var(--color-accent);
}

.progress-bar-success {
    background-color: var(--color-success);
}

.progress-bar-warning {
    background-color: #f59e0b;
}

/* ===================================
   COLLAPSIBLE SECTION FOR MOBILE
   =================================== */

.collapsible-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.collapsible-trigger:hover {
    background: #FAFAFA;
}

.collapsible-content {
    display: none;
    padding-top: 1rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;
}

.collapsible-content.expanded {
    display: block;
    max-height: 2000px; /* Large enough to fit content */
    padding-top: 1rem;
}

/* Style cloned sidebar cards in mobile view */
.collapsible-content .sidebar-stat-card {
    margin-bottom: 1rem;
}

@media (min-width: 1024px) {
    .collapsible-trigger {
        display: none;
    }
    .collapsible-content {
        display: block;
    }
}

/* ===================================
   SIDEBAR STAT CARD
   =================================== */

.sidebar-stat-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
}

.sidebar-stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Hide desktop stats on mobile */
@media (max-width: 1023px) {
    .desktop-stats-sidebar {
        display: none;
    }
}

/* Community Notes */
.note-item {
    padding: 0.75rem;
    background: var(--color-bg);
    border-radius: 0.375rem;
    border: 1px solid var(--color-border);
}

.note-item-content {
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--color-text-primary);
    margin-bottom: 0.5rem;
}

.note-item-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.625rem;
    color: var(--color-text-muted);
}

.note-vote-buttons {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.note-vote-btn {
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: all 0.15s ease;
}

.note-vote-btn:hover {
    background: var(--color-border);
    color: var(--color-text-primary);
}

.note-vote-btn.active-up {
    color: var(--color-success);
}

.note-vote-btn.active-down {
    color: var(--color-warning);
}

.note-vote-count {
    font-weight: 500;
    min-width: 1.25rem;
    text-align: center;
}

/* ===================================
   BOOK COLOR UTILITIES
   =================================== */

/* Book badge - pill-style indicator */
.book-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-weight: 600;
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
}

.book-color-bar {
    width: 4px;
    height: 1.25rem;
    border-radius: 2px;
    flex-shrink: 0;
}

.book-badge-text {
    font-size: 0.875rem;
    color: var(--color-text-primary);
}

.book-badge-level {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

/* Colored book title with accent bar */
.book-title-colored {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.book-title-colored .book-color-indicator {
    width: 4px;
    height: 1.5rem;
    border-radius: 2px;
    flex-shrink: 0;
}

/* Ladder progress indicator */
.ladder-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
}

.ladder-step {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.ladder-step:hover {
    transform: scale(1.2);
}

.ladder-step.current {
    transform: scale(1.3);
    box-shadow: 0 0 0 2px white, 0 0 0 3px currentColor;
}

.ladder-step.completed {
    opacity: 1;
}

.ladder-step.future {
    opacity: 0.3;
}

/* Book progress card with colored border */
.book-progress-card {
    position: relative;
    padding-left: 1rem;
    border-left: 4px solid var(--book-color, var(--color-border));
}

.book-progress-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: var(--book-color, var(--color-border));
    border-radius: 2px 0 0 2px;
}

/* Book header with color accent */
.book-header-colored {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.book-header-colored .book-level-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: white;
}

/* Ladder container styling */
.ladder-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
}

.ladder-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Responsive ladder indicator */
@media (max-width: 640px) {
    .ladder-step {
        width: 10px;
        height: 10px;
    }

    .ladder-indicator {
        gap: 3px;
    }
}

/* ===================================
   BOOK PROMOTION STYLES
   =================================== */

/* Dashboard Banner */
.promo-banner {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    padding: 1rem;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.promo-banner-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.promo-banner-icon {
    flex-shrink: 0;
    padding: 0.5rem;
    background: var(--color-bg);
    border-radius: 0.5rem;
}

.promo-banner-text {
    flex: 1;
    min-width: 0;
}

.promo-banner-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0 0 0.25rem 0;
}

.promo-banner-desc {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    margin: 0;
    line-height: 1.4;
}

.promo-banner-actions {
    flex-shrink: 0;
}

.promo-banner-close {
    flex-shrink: 0;
    padding: 0.5rem;
    background: transparent;
    border: none;
    border-radius: 0.375rem;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

.promo-banner-close:hover {
    color: var(--color-text-secondary);
    background: var(--color-bg);
}

/* Responsive banner */
@media (max-width: 640px) {
    .promo-banner-content {
        flex-wrap: wrap;
    }

    .promo-banner-text {
        flex: 1 1 calc(100% - 4rem);
    }

    .promo-banner-actions {
        flex: 1 1 100%;
        margin-top: 0.5rem;
    }

    .promo-banner-actions .promo-btn {
        width: 100%;
        text-align: center;
    }
}

/* Celebration Card */
.promo-celebration-card {
    position: relative;
    background: linear-gradient(135deg, #ecfdf5 0%, #f0fdfa 100%);
    border: 1px solid #a7f3d0;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.promo-celebration-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 1.75rem;
    height: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid #a7f3d0;
    border-radius: 50%;
    color: #047857;
    cursor: pointer;
    transition: all 0.15s ease;
    z-index: 1;
}

.promo-celebration-close:hover {
    background: white;
    color: #065f46;
}

.promo-celebration-close svg {
    width: 1rem;
    height: 1rem;
}

.promo-celebration-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.promo-celebration-text {
    text-align: center;
}

.promo-celebration-title {
    font-size: 1rem;
    font-weight: 600;
    color: #065f46;
    margin: 0 0 0.25rem 0;
}

.promo-celebration-desc {
    font-size: 0.75rem;
    color: #047857;
    margin: 0;
    line-height: 1.4;
}

.promo-celebration-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

/* Promo Buttons */
.promo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s ease;
    cursor: pointer;
    border: none;
}

.promo-btn-primary {
    background-color: var(--color-text-primary);
    color: white;
}

.promo-btn-primary:hover {
    background-color: #262626;
}

.promo-btn-secondary {
    background-color: transparent;
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}

.promo-btn-secondary:hover {
    background-color: var(--color-bg);
    border-color: var(--color-border-hover);
}

/* Sidebar Support Card */
.promo-sidebar-card-inner {
    border-left: 3px solid #059669;
}

/* Book Cover Images */
.promo-book-cover-link {
    display: block;
    transition: transform 0.15s ease;
}

.promo-book-cover-link:hover {
    transform: scale(1.02);
}

.promo-book-cover {
    width: 100%;
    max-width: 120px;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    margin: 0 auto;
    display: block;
}

/* Banner cover */
.promo-banner-cover-link {
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.promo-banner-cover-link:hover {
    transform: scale(1.03);
}

.promo-banner-cover {
    width: 60px;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Celebration cover */
.promo-celebration-cover-link {
    display: block;
    margin: 0 auto 0.75rem;
    transition: transform 0.15s ease;
}

.promo-celebration-cover-link:hover {
    transform: scale(1.03);
}

.promo-celebration-cover {
    width: 80px;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ===================================
   LANDING PAGE STYLES
   =================================== */

.landing-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 2rem 1.5rem;
    background: white;
    border-radius: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
}

.landing-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.landing-card-icon {
    width: 5rem;
    height: 5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 1rem;
    margin-bottom: 1.25rem;
}

.landing-card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 0.5rem;
}

.landing-card-desc {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
    margin-bottom: 1rem;
    flex-grow: 1;
}

.landing-card-link {
    display: inline-flex;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-accent);
    transition: color 0.15s ease;
}

.landing-card:hover .landing-card-link {
    color: #0e7490; /* cyan-700 */
}

/* ===================================
   MODE SELECTOR MODAL
   =================================== */

.mode-selector-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.mode-selector-modal.hidden {
    display: none;
}

.mode-selector-backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
}

.mode-selector-container {
    position: relative;
    background: var(--color-surface);
    border-radius: 0.75rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mode-selector-header {
    padding: 1.5rem 1.5rem 1rem;
    text-align: center;
}

.mode-selector-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin: 0;
}

.mode-selector-subtitle {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin: 0.25rem 0 0;
}

.mode-selector-options {
    padding: 0 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.mode-option {
    display: block;
    position: relative;
    padding: 1rem;
    border: 2px solid var(--color-border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.mode-option:hover {
    border-color: var(--color-border-hover);
}

.mode-option.selected {
    border-color: var(--color-text-primary);
    background-color: var(--color-bg);
}

.mode-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.mode-option-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.mode-option-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mode-option-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

.mode-option-badge {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.125rem 0.375rem;
    background-color: var(--color-success);
    color: white;
    border-radius: 9999px;
}

.mode-option-desc {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    line-height: 1.4;
    margin: 0;
}

/* Custom Settings Panel */
.custom-settings-panel {
    margin: 1rem 1.5rem;
    padding: 1rem;
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
}

.custom-settings-panel.hidden {
    display: none;
}

.custom-settings-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin: 0 0 0.75rem;
}

.custom-settings-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.custom-setting {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.custom-setting label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-primary);
}

.custom-setting input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    width: 100%;
}

.custom-setting input:focus {
    outline: none;
    border-color: var(--color-text-primary);
    box-shadow: 0 0 0 2px rgba(23, 23, 23, 0.1);
}

.custom-setting-hint {
    font-size: 0.6875rem;
    color: var(--color-text-muted);
}

/* Modal Actions */
.mode-selector-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--color-border);
    margin-top: 1rem;
}

.mode-selector-btn-cancel {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    background: transparent;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: color 0.15s ease;
}

.mode-selector-btn-cancel:hover {
    color: var(--color-text-primary);
}

.mode-selector-btn-confirm {
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: white;
    background-color: var(--color-text-primary);
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.mode-selector-btn-confirm:hover {
    background-color: #262626;
}

.mode-selector-btn-confirm:disabled {
    background-color: #D4D4D4;
    color: #A3A3A3;
    cursor: not-allowed;
}

/* ===================================
   MODE BADGES
   =================================== */

.mode-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    white-space: nowrap;
}

.mode-badge-no_spaced_rep {
    background-color: #dbeafe;
    color: #1d4ed8;
}

.mode-badge-original {
    background-color: #dcfce7;
    color: #15803d;
}

.mode-badge-custom {
    background-color: #fef3c7;
    color: #b45309;
}

/* Mode info in book cards */
.book-mode-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.book-mode-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* Mode reset button in profile */
.mode-reset-btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    color: var(--color-warning);
    background: transparent;
    border: 1px solid currentColor;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.mode-reset-btn:hover {
    background-color: rgba(220, 38, 38, 0.1);
}
