/* === RESET & BASE === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --gold: #d4a843;
    --gold-light: #f0d68a;
    --purple-deep: #1a0a2e;
    --purple-dark: #2d1b4e;
    --purple-mid: #4a2d6e;
    --purple-light: #7b5ea7;
    --text-light: #e8dff5;
    --text-muted: #a89bc2;
    --card-width: 140px;
    --card-height: 240px;
    --bg-gradient: linear-gradient(135deg, #0d0618 0%, #1a0a2e 30%, #2d1450 70%, #1a0a2e 100%);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Cormorant Garamond', Georgia, serif;
    background: var(--bg-gradient);
    color: var(--text-light);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

#stars-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

#app {
    position: relative;
    z-index: 1;
    min-height: 100vh;
}

/* === SCREENS === */
.screen {
    display: none;
    padding: 2rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.screen.active {
    display: block;
    animation: fadeIn 0.6s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === HOME SCREEN === */
.home-content {
    text-align: center;
}

.logo-container {
    margin: 2rem 0 3rem;
}

.moon-icon {
    font-size: 4rem;
    color: var(--gold);
    text-shadow: 0 0 30px rgba(212, 168, 67, 0.5);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

h1 {
    font-family: 'Cinzel', serif;
    font-size: clamp(2rem, 6vw, 3.5rem);
    color: var(--gold);
    letter-spacing: 0.1em;
    text-shadow: 0 0 40px rgba(212, 168, 67, 0.3);
    margin: 0.5rem 0;
}

.subtitle {
    font-size: 1.3rem;
    color: var(--text-muted);
    font-style: italic;
}

/* === SPREAD SELECTION === */
.spread-selection h2 {
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    color: var(--gold-light);
    margin-bottom: 1.5rem;
}

#section-training h2 {
    color: #8eca8e;
}

.spread-grid, .spread-grid-training {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.2rem;
    max-width: 960px;
    margin: 0 auto 2rem;
}

.spread-card {
    background: linear-gradient(145deg, rgba(74, 45, 110, 0.4), rgba(26, 10, 46, 0.6));
    border: 1px solid rgba(212, 168, 67, 0.2);
    border-radius: 16px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-light);
    font-family: inherit;
    text-align: center;
}

.spread-card:hover {
    border-color: var(--gold);
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(212, 168, 67, 0.15);
    background: linear-gradient(145deg, rgba(74, 45, 110, 0.6), rgba(45, 27, 78, 0.8));
}

.spread-card.selected {
    border-color: var(--gold);
    box-shadow: 0 0 20px rgba(212, 168, 67, 0.25);
    background: linear-gradient(145deg, rgba(74, 45, 110, 0.7), rgba(45, 27, 78, 0.9));
}

.spread-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    letter-spacing: 0.2em;
}

.spread-card h3 {
    font-family: 'Cinzel', serif;
    font-size: 1.15rem;
    color: var(--gold);
    margin-bottom: 0.3rem;
}

.spread-card p {
    font-size: 0.95rem;
    color: var(--text-muted);
}

/* === QUESTION SECTION === */
.question-section {
    margin-top: 2rem;
    animation: fadeIn 0.4s ease;
}

.question-section h2 {
    font-family: 'Cinzel', serif;
    color: var(--gold);
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
}

.question-hint {
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 1rem;
}

#user-question {
    width: 100%;
    max-width: 500px;
    padding: 0.9rem 1.2rem;
    background: rgba(74, 45, 110, 0.3);
    border: 1px solid rgba(212, 168, 67, 0.3);
    border-radius: 12px;
    color: var(--text-light);
    font-family: inherit;
    font-size: 1.05rem;
    outline: none;
    transition: border-color 0.3s;
}

#user-question:focus {
    border-color: var(--gold);
}

#user-question::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

/* === BUTTONS === */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding: 1rem 2.5rem;
    background: linear-gradient(135deg, var(--gold), #b8922e);
    color: var(--purple-deep);
    border: none;
    border-radius: 50px;
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 0.05em;
}

.btn-primary:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(212, 168, 67, 0.4);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding: 0.8rem 2rem;
    background: transparent;
    color: var(--gold);
    border: 1px solid var(--gold);
    border-radius: 50px;
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: rgba(212, 168, 67, 0.1);
}

.btn-back {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: color 0.3s;
}

.btn-back:hover {
    color: var(--gold);
}

/* === READING SCREEN === */
.reading-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.reading-header h2 {
    font-family: 'Cinzel', serif;
    color: var(--gold);
    font-size: 1.6rem;
}

.question-display {
    text-align: center;
    font-style: italic;
    color: var(--text-muted);
    font-size: 1.15rem;
    margin-bottom: 2rem;
    padding: 0.8rem;
    border-left: 3px solid var(--gold);
    background: rgba(74, 45, 110, 0.2);
    border-radius: 0 8px 8px 0;
}

/* === CARD LAYOUTS === */
.cards-layout {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 2rem 1.5rem;
    margin: 2rem auto;
    min-height: 280px;
    position: relative;
    padding-bottom: 2rem;
}

/* Cross layout */
.cards-layout.layout-cross {
    display: grid;
    grid-template-columns: repeat(3, calc(var(--card-width) + 1rem));
    grid-template-rows: repeat(3, calc(var(--card-height) + 2.5rem));
    gap: 0.5rem;
    justify-content: center;
    justify-items: center;
    align-items: start;
    max-width: 600px;
    margin: 2rem auto;
    padding-bottom: 1rem;
}

.cards-layout.layout-cross .tarot-card:nth-child(1) { grid-column: 2; grid-row: 1; }
.cards-layout.layout-cross .tarot-card:nth-child(2) { grid-column: 1; grid-row: 2; }
.cards-layout.layout-cross .tarot-card:nth-child(3) { grid-column: 2; grid-row: 2; }
.cards-layout.layout-cross .tarot-card:nth-child(4) { grid-column: 3; grid-row: 2; }
.cards-layout.layout-cross .tarot-card:nth-child(5) { grid-column: 2; grid-row: 3; }

/* Medicine Wheel layout — Nord top, Est left, Sud bottom, Ouest right
   Grid: 8 cols with gaps between binômes, 5 rows with spacing */
.cards-layout.layout-medicine {
    --mw-card: min(calc(var(--card-width) + 0.2rem), calc((100vw - 6rem) / 8));
    --mw-gap: clamp(0.5rem, 2vw, 1.8rem);
    display: grid;
    grid-template-columns:
        var(--mw-card) var(--mw-card)
        var(--mw-gap)
        var(--mw-card) var(--mw-card)
        var(--mw-gap)
        var(--mw-card) var(--mw-card);
    grid-template-rows:
        calc(var(--card-height) + 2.5rem)
        1.5rem
        calc(var(--card-height) + 2.5rem)
        1.5rem
        calc(var(--card-height) + 2.5rem);
    gap: 0;
    justify-content: center;
    justify-items: center;
    align-items: start;
    max-width: 1100px;
    margin: 2rem auto;
    padding-bottom: 1rem;
}

/* Row 1: Nord ❄ (top centre) — cartes 1,2 */
.cards-layout.layout-medicine .tarot-card:nth-child(1) { grid-column: 4; grid-row: 1; }
.cards-layout.layout-medicine .tarot-card:nth-child(2) { grid-column: 5; grid-row: 1; }
/* Row 3: Ouest 🍂 (left) — cartes 7,8 | Centre ✦ — cartes 9,10 | Est ☀ (right) — cartes 3,4 */
.cards-layout.layout-medicine .tarot-card:nth-child(7) { grid-column: 1; grid-row: 3; }
.cards-layout.layout-medicine .tarot-card:nth-child(8) { grid-column: 2; grid-row: 3; }
.cards-layout.layout-medicine .tarot-card:nth-child(9)  { grid-column: 4; grid-row: 3; }
.cards-layout.layout-medicine .tarot-card:nth-child(10) { grid-column: 5; grid-row: 3; }
.cards-layout.layout-medicine .tarot-card:nth-child(3) { grid-column: 7; grid-row: 3; }
.cards-layout.layout-medicine .tarot-card:nth-child(4) { grid-column: 8; grid-row: 3; }
/* Row 5: Sud 🔥 (bottom centre) — cartes 5,6 */
.cards-layout.layout-medicine .tarot-card:nth-child(5) { grid-column: 4; grid-row: 5; }
.cards-layout.layout-medicine .tarot-card:nth-child(6) { grid-column: 5; grid-row: 5; }

/* Single label per binôme — centered across the pair */
.cards-layout.layout-medicine .tarot-card:nth-child(odd) .position-label {
    left: calc(100% + 0.1rem);
    transform: translateX(-50%);
}
.cards-layout.layout-medicine .tarot-card:nth-child(even) .position-label {
    display: none;
}

/* Horseshoe layout */
.cards-layout.layout-horseshoe {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 2.5rem 1.2rem;
    max-width: 900px;
    margin: 2rem auto;
    padding-bottom: 1rem;
}

/* === TAROT CARD === */
.tarot-card {
    width: var(--card-width);
    height: var(--card-height);
    perspective: 800px;
    cursor: pointer;
    position: relative;
    margin-bottom: 1.8rem;
}

.tarot-card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.tarot-card.flipped .tarot-card-inner {
    transform: rotateY(180deg);
}

.tarot-card.reversed.flipped .tarot-card-inner {
    transform: rotateY(180deg) rotate(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    overflow: hidden;
}

.card-back {
    background: linear-gradient(135deg, var(--purple-dark), var(--purple-mid));
    border: 2px solid var(--gold);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.card-back-pattern {
    width: 80%;
    height: 80%;
    border: 1px solid rgba(212, 168, 67, 0.4);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(212, 168, 67, 0.05) 10px,
        rgba(212, 168, 67, 0.05) 20px
    );
}

.card-back-symbol {
    font-size: 3rem;
    color: var(--gold);
    opacity: 0.6;
}

.card-front {
    transform: rotateY(180deg);
    background: #f5f0e8;
    border: 2px solid var(--gold);
    display: flex;
    flex-direction: column;
    align-items: center;
    border-radius: 12px;
}

.card-front img {
    width: 100%;
    height: 85%;
    object-fit: contain;
    padding: 4px;
}

.card-front .card-name {
    font-family: 'Cinzel', serif;
    font-size: 0.65rem;
    color: #2d1b4e;
    text-align: center;
    padding: 2px 4px;
    line-height: 1.2;
    font-weight: 600;
}

.tarot-card .position-label {
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--gold);
    font-family: 'Cinzel', serif;
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    z-index: 2;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.reversed-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(180, 40, 40, 0.85);
    color: white;
    font-size: 0.55rem;
    padding: 2px 5px;
    border-radius: 4px;
    font-family: 'Cinzel', serif;
    z-index: 3;
    transform: rotateY(180deg);
}

/* Card entrance animation */
.tarot-card {
    opacity: 0;
    transform: translateY(30px) scale(0.9);
    animation: cardAppear 0.5s ease forwards;
    transition: opacity 0.4s ease;
}

.tarot-card:nth-child(1) { animation-delay: 0.1s; }
.tarot-card:nth-child(2) { animation-delay: 0.25s; }
.tarot-card:nth-child(3) { animation-delay: 0.4s; }
.tarot-card:nth-child(4) { animation-delay: 0.55s; }
.tarot-card:nth-child(5) { animation-delay: 0.7s; }
.tarot-card:nth-child(6) { animation-delay: 0.85s; }
.tarot-card:nth-child(7) { animation-delay: 1.0s; }
.tarot-card:nth-child(8) { animation-delay: 1.15s; }
.tarot-card:nth-child(9) { animation-delay: 1.3s; }
.tarot-card:nth-child(10) { animation-delay: 1.45s; }

@keyframes cardAppear {
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Glow on hover before flip */
.tarot-card:not(.flipped):hover .card-back {
    box-shadow: 0 0 20px rgba(212, 168, 67, 0.4);
}

/* Sequential draw: highlight the next card to flip */
.tarot-card.next-to-flip .card-back {
    box-shadow: 0 0 25px rgba(212, 168, 67, 0.6), 0 0 50px rgba(212, 168, 67, 0.25);
    border-color: var(--gold-light);
    animation: pulseGlow 1.8s ease-in-out infinite;
}

#cards-layout .tarot-card:not(.next-to-flip):not(.flipped) {
    opacity: 0.5;
    pointer-events: none;
}

.tarot-card.flipped {
    opacity: 1;
    pointer-events: auto;
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 20px rgba(212, 168, 67, 0.5), 0 0 40px rgba(212, 168, 67, 0.15); }
    50% { box-shadow: 0 0 35px rgba(212, 168, 67, 0.8), 0 0 60px rgba(212, 168, 67, 0.3); }
}

/* === LOADING === */
.loading {
    text-align: center;
    padding: 2rem;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(212, 168, 67, 0.2);
    border-top: 3px solid var(--gold);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === INTERPRETATION === */
.interpretation {
    margin: 2rem 0;
    animation: fadeIn 0.8s ease;
}

/* Desktop: 4 cols + verdict centered below */
.card-details {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card-details .card-detail-item:last-child:nth-child(5) {
    grid-column: 2 / 4;
}

/* Carousel navigation */
.carousel-nav {
    display: none;
}

/* For spreads with fewer cards, adapt columns */
.card-details.details-1 { grid-template-columns: 1fr; max-width: 500px; margin-left: auto; margin-right: auto; }
.card-details.details-2 { grid-template-columns: repeat(2, 1fr); max-width: 700px; margin-left: auto; margin-right: auto; }
.card-details.details-3 { grid-template-columns: repeat(3, 1fr); }
.card-details.details-5 { grid-template-columns: repeat(4, 1fr); }
.card-details.details-7 { grid-template-columns: repeat(4, 1fr); }

.card-detail-item {
    background: linear-gradient(145deg, rgba(74, 45, 110, 0.3), rgba(26, 10, 46, 0.5));
    border: 1px solid rgba(212, 168, 67, 0.15);
    border-radius: 16px;
    padding: 1.5rem;
    transition: border-color 0.3s;
}

.card-detail-item:hover {
    border-color: rgba(212, 168, 67, 0.4);
}

.card-detail-item .detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.mini-card {
    width: 60px;
    height: 100px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid var(--gold);
}

.detail-header .detail-info h3 {
    font-family: 'Cinzel', serif;
    color: var(--gold);
    font-size: 1.05rem;
}

.detail-header .detail-info .position-name {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

.detail-header .detail-info .reversed-tag {
    font-size: 0.75rem;
    color: #e07070;
    font-weight: 600;
}

.card-detail-item .detail-text {
    color: var(--text-light);
    font-size: 1.05rem;
    line-height: 1.7;
}

/* Pair items for Medicine Wheel */
.pair-item .pair-title {
    font-family: 'Cinzel', serif;
    color: var(--gold);
    font-size: 1.15rem;
    margin-bottom: 0.3rem;
}

.pair-item .pair-desc {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.pair-cards {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.pair-card {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: rgba(26, 10, 46, 0.4);
    padding: 0.6rem 1rem;
    border-radius: 10px;
    border: 1px solid rgba(212, 168, 67, 0.1);
}

.pair-card strong {
    color: var(--gold-light);
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
}

.pair-separator {
    color: var(--gold);
    font-size: 1.2rem;
    opacity: 0.6;
}

.global-interpretation {
    background: linear-gradient(145deg, rgba(212, 168, 67, 0.08), rgba(74, 45, 110, 0.3));
    border: 1px solid rgba(212, 168, 67, 0.25);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.global-interpretation h3 {
    font-family: 'Cinzel', serif;
    color: var(--gold);
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

.global-interpretation p {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-light);
}

.conclusion-section {
    background: linear-gradient(145deg, rgba(26, 10, 46, 0.6), rgba(74, 45, 110, 0.2));
    border: 1px solid rgba(212, 168, 67, 0.15);
    border-left: 4px solid var(--gold);
    border-radius: 0 16px 16px 0;
    padding: 1.5rem 2rem;
}

.conclusion-section h3 {
    font-family: 'Cinzel', serif;
    color: var(--gold);
    font-size: 1.2rem;
    margin-bottom: 0.8rem;
}

.conclusion-section p {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text-light);
}

/* === ACTIONS === */
.reading-actions {
    text-align: center;
    margin: 2rem 0;
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* === FOOTER === */
footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid rgba(212, 168, 67, 0.1);
    margin-top: 2rem;
}

footer p {
    margin: 0.3rem 0;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    :root {
        --card-width: 100px;
        --card-height: 172px;
    }

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

    /* Mobile carousel mode */
    .card-details {
        display: flex !important;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        gap: 0;
        padding-bottom: 1rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .card-details::-webkit-scrollbar {
        display: none;
    }

    .card-details .card-detail-item {
        flex: 0 0 85vw;
        scroll-snap-align: center;
        margin: 0 0.5rem;
    }

    .card-details .card-detail-item:first-child {
        margin-left: calc((100vw - 85vw) / 2);
    }

    .card-details .card-detail-item:last-child {
        margin-right: calc((100vw - 85vw) / 2);
    }

    .carousel-nav {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 0.6rem;
        margin-bottom: 1.5rem;
    }

    .carousel-dot {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background: rgba(212, 168, 67, 0.25);
        border: 1px solid rgba(212, 168, 67, 0.4);
        cursor: pointer;
        transition: all 0.3s;
        padding: 0;
    }

    .carousel-dot.active {
        background: var(--gold);
        transform: scale(1.3);
    }

    .carousel-arrow {
        background: none;
        border: 1px solid rgba(212, 168, 67, 0.3);
        color: var(--gold);
        width: 32px;
        height: 32px;
        border-radius: 50%;
        cursor: pointer;
        font-size: 1rem;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s;
    }

    .carousel-arrow:hover {
        border-color: var(--gold);
        background: rgba(212, 168, 67, 0.1);
    }

    .cards-layout.layout-medicine {
        --mw-gap: 0.5rem;
        --mw-card: calc((100vw - 4rem) / 8);
        grid-template-rows:
            calc(var(--mw-card) * 1.72 + 2rem)
            0.5rem
            calc(var(--mw-card) * 1.72 + 2rem)
            0.5rem
            calc(var(--mw-card) * 1.72 + 2rem);
    }

    .cards-layout.layout-medicine .tarot-card {
        width: var(--mw-card);
        height: calc(var(--mw-card) * 1.72);
    }

    .cards-layout.layout-medicine .position-label {
        font-size: 0.55rem;
    }

    .cards-layout.layout-cross {
        grid-template-columns: repeat(3, calc(var(--card-width) + 0.5rem));
        grid-template-rows: repeat(3, calc(var(--card-height) + 2rem));
    }

    .reading-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .card-front .card-name {
        font-size: 0.5rem;
    }
}

@media (max-width: 480px) {
    :root {
        --card-width: 85px;
        --card-height: 146px;
    }

    .cards-layout {
        gap: 0.8rem;
    }

    .cards-layout.layout-cross {
        gap: 0.5rem;
    }
}

/* === CARD LIGHTBOX === */
.card-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    animation: fadeIn 0.3s ease;
    padding: 1rem;
}

.card-lightbox img {
    max-width: 90vw;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 12px;
    border: 2px solid var(--gold);
    box-shadow: 0 0 60px rgba(212, 168, 67, 0.3);
}

.card-lightbox img.lightbox-reversed {
    transform: rotate(180deg);
}

.card-lightbox .lightbox-name {
    font-family: 'Cinzel', serif;
    color: var(--gold);
    font-size: 1.4rem;
    margin-top: 1rem;
    text-align: center;
}

.card-lightbox .lightbox-keywords {
    color: var(--text-muted);
    font-size: 1rem;
    margin-top: 0.4rem;
    text-align: center;
    max-width: 400px;
}

.card-lightbox .lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    color: var(--gold);
    font-size: 2rem;
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
}

/* === TOAST / NOTIFICATION === */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--purple-dark);
    border: 1px solid var(--gold);
    color: var(--text-light);
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-family: inherit;
    z-index: 100;
    transition: transform 0.4s ease;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
}

/* === SETTINGS === */
.btn-settings {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: 1px solid rgba(212, 168, 67, 0.3);
    color: var(--gold);
    font-size: 1.3rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-settings:hover {
    border-color: var(--gold);
    background: rgba(212, 168, 67, 0.1);
}

.logo-container {
    position: relative;
}

/* === MODAL === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: linear-gradient(145deg, var(--purple-dark), var(--purple-deep));
    border: 1px solid rgba(212, 168, 67, 0.3);
    border-radius: 20px;
    padding: 2rem;
    max-width: 450px;
    width: 90%;
    text-align: center;
}

.modal-content h3 {
    font-family: 'Cinzel', serif;
    color: var(--gold);
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.modal-content input {
    width: 100%;
    padding: 0.8rem 1rem;
    background: rgba(74, 45, 110, 0.3);
    border: 1px solid rgba(212, 168, 67, 0.3);
    border-radius: 10px;
    color: var(--text-light);
    font-family: inherit;
    font-size: 1rem;
    margin-top: 1rem;
    outline: none;
}

.modal-content input:focus {
    border-color: var(--gold);
}

.modal-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
}

#key-status, #update-status {
    color: var(--gold-light);
}

.settings-group {
    margin: 1rem 0;
    text-align: left;
}

.settings-group label {
    display: block;
    font-family: 'Cinzel', serif;
    color: var(--gold);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.lang-toggle {
    display: flex;
    gap: 0;
    border: 1px solid rgba(212, 168, 67, 0.3);
    border-radius: 8px;
    overflow: hidden;
}

.lang-btn {
    flex: 1;
    padding: 0.5rem 1rem;
    background: transparent;
    color: var(--text-muted);
    border: none;
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s;
}

.lang-btn.active {
    background: rgba(212, 168, 67, 0.2);
    color: var(--gold);
    font-weight: 600;
}

.lang-btn:not(.active):hover {
    background: rgba(212, 168, 67, 0.08);
    color: var(--text-light);
}

/* === MODE TOGGLE === */
.mode-toggle {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-bottom: 2rem;
    background: rgba(26, 10, 46, 0.6);
    border: 1px solid rgba(212, 168, 67, 0.2);
    border-radius: 50px;
    padding: 4px;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.mode-btn {
    flex: 1;
    padding: 0.6rem 1.5rem;
    border: none;
    border-radius: 50px;
    background: transparent;
    color: var(--text-muted);
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn.active {
    background: linear-gradient(135deg, var(--gold), #b8922e);
    color: var(--purple-deep);
    font-weight: 700;
}

.mode-btn:not(.active):hover {
    color: var(--gold-light);
}

/* === TRAINING INTRO === */
.training-intro {
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 1.5rem;
    font-size: 1.05rem;
}

.spread-card-training {
    background: linear-gradient(145deg, rgba(45, 80, 45, 0.3), rgba(26, 10, 46, 0.6));
    border: 1px solid rgba(100, 180, 100, 0.25);
    border-radius: 16px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-light);
    font-family: inherit;
    text-align: center;
}

.spread-card-training:hover {
    border-color: #8eca8e;
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(100, 180, 100, 0.15);
    background: linear-gradient(145deg, rgba(45, 80, 45, 0.5), rgba(26, 10, 46, 0.8));
}

.spread-card-training .spread-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    letter-spacing: 0.2em;
}

.spread-card-training h3 {
    font-family: 'Cinzel', serif;
    font-size: 1.15rem;
    color: #8eca8e;
    margin-bottom: 0.3rem;
}

.spread-card-training p {
    font-size: 0.95rem;
    color: var(--text-muted);
}

/* === TRAINING WORKSPACE === */
.training-workspace {
    margin: 2rem 0;
    animation: fadeIn 0.6s ease;
}

.training-prompt {
    text-align: center;
    margin-bottom: 1.5rem;
}

.training-prompt h3 {
    font-family: 'Cinzel', serif;
    color: #8eca8e;
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.training-prompt p {
    color: var(--text-muted);
    font-style: italic;
}

#training-input {
    width: 100%;
    min-height: 250px;
    padding: 1.2rem 1.5rem;
    background: rgba(74, 45, 110, 0.2);
    border: 1px solid rgba(100, 180, 100, 0.25);
    border-radius: 16px;
    color: var(--text-light);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.1rem;
    line-height: 1.7;
    outline: none;
    transition: border-color 0.3s;
    resize: vertical;
}

#training-input:focus {
    border-color: #8eca8e;
    box-shadow: 0 0 20px rgba(100, 180, 100, 0.1);
}

#training-input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.training-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.training-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

/* === TRAINING FEEDBACK === */
.training-feedback {
    margin: 2rem 0;
    animation: fadeIn 0.8s ease;
}

.feedback-section {
    background: linear-gradient(145deg, rgba(74, 45, 110, 0.3), rgba(26, 10, 46, 0.5));
    border: 1px solid rgba(100, 180, 100, 0.2);
    border-radius: 16px;
    padding: 1.8rem;
    margin-bottom: 1.5rem;
}

.feedback-section h3 {
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.feedback-section h3 .feedback-icon {
    font-size: 1.4rem;
}

.feedback-section.feedback-good {
    border-left: 4px solid #8eca8e;
}

.feedback-section.feedback-good h3 {
    color: #8eca8e;
}

.feedback-section.feedback-improve {
    border-left: 4px solid #e0c070;
}

.feedback-section.feedback-improve h3 {
    color: #e0c070;
}

.feedback-section.feedback-missed {
    border-left: 4px solid #e07070;
}

.feedback-section.feedback-missed h3 {
    color: #e07070;
}

.feedback-section.feedback-reference {
    border-left: 4px solid var(--gold);
    background: linear-gradient(145deg, rgba(212, 168, 67, 0.08), rgba(74, 45, 110, 0.3));
}

.feedback-section.feedback-reference h3 {
    color: var(--gold);
}

.feedback-section p, .feedback-section li {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text-light);
}

.feedback-section ul {
    list-style: none;
    padding: 0;
}

.feedback-section li {
    padding: 0.4rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.feedback-section li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--gold);
}

.feedback-score {
    text-align: center;
    margin-bottom: 2rem;
}

.feedback-score .score-value {
    font-family: 'Cinzel', serif;
    font-size: 3rem;
    color: var(--gold);
    font-weight: 700;
}

.feedback-score .score-label {
    font-size: 1.1rem;
    color: var(--text-muted);
    display: block;
    margin-top: 0.3rem;
}

.feedback-score .score-bar {
    width: 200px;
    height: 6px;
    background: rgba(212, 168, 67, 0.15);
    border-radius: 3px;
    margin: 0.8rem auto 0;
    overflow: hidden;
}

.feedback-score .score-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #e07070, #e0c070, #8eca8e);
    transition: width 1s ease;
}

/* === CHAT === */
.chat-container {
    margin: 2rem 0;
    animation: fadeIn 0.6s ease;
}

.chat-title {
    font-family: 'Cinzel', serif;
    color: var(--gold);
    font-size: 1.3rem;
    margin-bottom: 1rem;
    text-align: center;
}

.chat-messages {
    max-height: 500px;
    overflow-y: auto;
    padding: 1rem;
    background: rgba(26, 10, 46, 0.4);
    border: 1px solid rgba(212, 168, 67, 0.15);
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(212, 168, 67, 0.3);
    border-radius: 2px;
}

.chat-msg {
    max-width: 85%;
    padding: 0.8rem 1.2rem;
    border-radius: 16px;
    font-size: 1.05rem;
    line-height: 1.6;
}

.chat-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(212, 168, 67, 0.2), rgba(212, 168, 67, 0.1));
    border: 1px solid rgba(212, 168, 67, 0.3);
    color: var(--gold-light);
    border-bottom-right-radius: 4px;
}

.chat-msg.ai {
    align-self: flex-start;
    background: linear-gradient(145deg, rgba(74, 45, 110, 0.4), rgba(26, 10, 46, 0.5));
    border: 1px solid rgba(123, 94, 167, 0.25);
    color: var(--text-light);
    border-bottom-left-radius: 4px;
}

.chat-msg.ai.typing {
    opacity: 0.7;
    font-style: italic;
}

.chat-input-row {
    display: flex;
    gap: 0;
    border: 1px solid rgba(212, 168, 67, 0.25);
    border-top: none;
    border-radius: 0 0 16px 16px;
    overflow: hidden;
    background: rgba(26, 10, 46, 0.5);
}

.chat-input {
    flex: 1;
    padding: 0.9rem 1.2rem;
    background: transparent;
    border: none;
    color: var(--text-light);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.05rem;
    outline: none;
    resize: none;
    line-height: 1.5;
}

.chat-input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.btn-chat-send {
    padding: 0.8rem 1.4rem;
    background: linear-gradient(135deg, var(--gold), #b8922e);
    color: var(--purple-deep);
    border: none;
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    align-self: stretch;
}

.btn-chat-send:hover {
    background: linear-gradient(135deg, var(--gold-light), var(--gold));
}

.btn-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
