:root {
    --cream: #FDF6EC;
    --warm-bg: #FAF0E4;
    --dark: #2C1810;
    --brown: #5C3D2E;
    --accent: #C4713B;
    --accent-hover: #D4854F;
    --gold: #D4A853;
    --sage: #8B9E7E;
    --muted: #9C8B7A;
    --card-bg: rgba(255, 255, 255, 0.6);
    --shadow: 0 8px 32px rgba(44, 24, 16, 0.08);
    --shadow-hover: 0 12px 48px rgba(44, 24, 16, 0.14);
}

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

body {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 20px;
    background: var(--cream);
    color: var(--dark);
    overflow-x: hidden;
    min-height: 100vh;
}

/* Subtle grain texture */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 9999;
}

/* Header */
header {
    padding: 24px 48px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 10;
    animation: fadeDown 0.8s ease;
}

.logo {
    font-family: 'Playfair Display', serif;
    font-size: 36px;
    font-weight: 700;
    color: var(--dark);
    text-decoration: none;
    letter-spacing: -0.5px;
}

.logo span { color: var(--accent); }

nav {
    display: flex;
    gap: 32px;
    align-items: center;
}

nav a {
    text-decoration: none;
    color: var(--brown);
    font-size: 19px;
    font-weight: 400;
    transition: color 0.3s;
    position: relative;
}

nav a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 1.5px;
    background: var(--accent);
    transition: width 0.3s ease;
}

nav a:hover { color: var(--accent); }
nav a:hover::after { width: 100%; }


/* Hero */
.hero {
    max-width: 1200px;
    margin: 0 auto;
    padding: 60px 48px 40px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 80px;
    align-items: center;
    min-height: 70vh;
}

.hero-text { animation: fadeUp 1s ease 0.2s both; }

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(196, 113, 59, 0.1);
    border: 1px solid rgba(196, 113, 59, 0.2);
    border-radius: 100px;
    padding: 6px 16px;
    font-size: 15px;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 24px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.hero-badge::before {
    content: '✦';
    font-size: 10px;
}

h1 {
    font-family: 'Playfair Display', serif;
    font-size: 72px;
    line-height: 1.1;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 24px;
    letter-spacing: -1px;
}

h1 em {
    font-style: italic;
    color: var(--accent);
}

.hero-sub {
    font-size: 24px;
    line-height: 1.7;
    color: var(--muted);
    font-weight: 300;
    margin-bottom: 40px;
    max-width: 440px;
}

/* CTA */
.cta-group {
    display: flex;
    gap: 16px;
    align-items: center;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    padding: 16px 36px;
    font-size: 16px;
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(196, 113, 59, 0.3);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(196, 113, 59, 0.4);
}

.btn-secondary {
    background: transparent;
    color: var(--brown);
    border: 1.5px solid rgba(92, 61, 46, 0.25);
    padding: 15px 32px;
    font-size: 16px;
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

/* Book cards */
.hero-visual {
    position: relative;
    height: 520px;
    animation: fadeUp 1s ease 0.5s both;
}

.book-stack {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.book-card {
    position: absolute;
    width: 200px;
    height: 280px;
    border-radius: 12px;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    box-shadow: var(--shadow);
    transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
    cursor: pointer;
    overflow: hidden;
}

.book-card::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.06;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000' fill-opacity='1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.book-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-hover);
}

.book-card-1 {
    background: linear-gradient(135deg, #2C3E50 0%, #1a252f 100%);
    color: white;
    top: 20px;
    left: -40px;
    transform: rotate(-8deg);
    z-index: 1;
}
.book-card-1:hover { transform: rotate(-8deg) translateY(-8px) scale(1.02); }

.book-card-2 {
    background: linear-gradient(135deg, #C4713B 0%, #a85d2e 100%);
    color: white;
    top: 40px;
    left: 80px;
    transform: rotate(3deg);
    z-index: 3;
}
.book-card-2:hover { transform: rotate(3deg) translateY(-8px) scale(1.02); }

.book-card-3 {
    background: linear-gradient(135deg, #8B9E7E 0%, #6d7f63 100%);
    color: white;
    top: 160px;
    left: -20px;
    transform: rotate(5deg);
    z-index: 2;
}
.book-card-3:hover { transform: rotate(5deg) translateY(-8px) scale(1.02); }

.book-card-4 {
    background: linear-gradient(135deg, #D4A853 0%, #b8903d 100%);
    color: white;
    top: 180px;
    left: 120px;
    transform: rotate(-4deg);
    z-index: 4;
}
.book-card-4:hover { transform: rotate(-4deg) translateY(-8px) scale(1.02); }

.book-genre {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.7;
    margin-bottom: 8px;
    position: relative;
}

.book-title {
    font-family: 'Playfair Display', serif;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
    position: relative;
}

.book-author {
    font-size: 14px;
    opacity: 0.7;
    margin-top: 6px;
    position: relative;
}

.ai-match {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 600;
}

/* How it works */
.how-it-works {
    max-width: 1200px;
    margin: 0 auto;
    padding: 80px 48px;
    animation: fadeUp 1s ease 0.8s both;
}

.section-label {
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 16px;
}

h2 {
    font-family: 'Playfair Display', serif;
    font-size: 52px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 56px;
    letter-spacing: -0.5px;
}

.steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
}

.step {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(92, 61, 46, 0.08);
    border-radius: 20px;
    padding: 40px 32px;
    transition: all 0.4s ease;
    position: relative;
    overflow: hidden;
}

.step::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--gold));
    opacity: 0;
    transition: opacity 0.4s;
}

.step:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.step:hover::before { opacity: 1; }

.step-number {
    font-family: 'Playfair Display', serif;
    font-size: 48px;
    font-weight: 700;
    color: var(--accent);
    opacity: 0.2;
    line-height: 1;
    margin-bottom: 20px;
}

.step-icon {
    font-size: 32px;
    margin-bottom: 20px;
    display: block;
}

.step h3 {
    font-family: 'Playfair Display', serif;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--dark);
}

.step p {
    font-size: 19px;
    line-height: 1.7;
    color: var(--muted);
    font-weight: 300;
}

/* Demo section */
.demo-section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 48px 100px;
}

.demo-card {
    background: white;
    border-radius: 24px;
    padding: 56px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(92, 61, 46, 0.06);
    position: relative;
    overflow: hidden;
}

.demo-card::after {
    content: '';
    position: absolute;
    top: -100px;
    right: -100px;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(196, 113, 59, 0.06) 0%, transparent 70%);
    pointer-events: none;
}

.demo-header {
    text-align: center;
    margin-bottom: 48px;
}

.demo-header h2 { margin-bottom: 12px; }

.demo-header p {
    color: var(--muted);
    font-size: 22px;
    font-weight: 300;
}

.demo-form {
    max-width: 640px;
    margin: 0 auto;
}

.form-group { margin-bottom: 28px; }

.form-group label {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: var(--brown);
    margin-bottom: 10px;
    letter-spacing: 0.3px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 16px 20px;
    border: 1.5px solid rgba(92, 61, 46, 0.12);
    border-radius: 12px;
    font-size: 16px;
    font-family: 'Source Sans 3', sans-serif;
    color: var(--dark);
    background: var(--warm-bg);
    transition: all 0.3s;
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(196, 113, 59, 0.08);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--muted);
    font-weight: 300;
}

/* Tags */
.genre-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.genre-tag {
    padding: 10px 20px;
    border: 1.5px solid rgba(92, 61, 46, 0.12);
    border-radius: 100px;
    font-size: 16px;
    font-family: 'Source Sans 3', sans-serif;
    color: var(--brown);
    background: var(--warm-bg);
    cursor: pointer;
    transition: all 0.3s;
    user-select: none;
}

.genre-tag:hover { border-color: var(--accent); color: var(--accent); }

.genre-tag.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.demo-submit {
    text-align: center;
    margin-top: 40px;
}

.btn-large {
    padding: 18px 56px;
    font-size: 19px;
    border-radius: 14px;
}

/* Results */
.results-area {
    max-width: 640px;
    margin: 40px auto 0;
    display: none;
}

.results-area.visible { display: block; }

.result-book {
    display: flex;
    gap: 20px;
    padding: 24px;
    background: var(--warm-bg);
    border-radius: 16px;
    margin-bottom: 16px;
    border: 1px solid rgba(92, 61, 46, 0.06);
    transition: all 0.3s;
    animation: fadeUp 0.5s ease both;
}

.result-book:nth-child(2) { animation-delay: 0.1s; }
.result-book:nth-child(3) { animation-delay: 0.2s; }

.result-book:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow);
}

.result-cover {
    width: 72px;
    height: 104px;
    border-radius: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2C3E50, #1a252f);
    overflow: hidden;
}
.cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.result-cover span {
    font-family: 'Playfair Display', serif;
    font-size: 24px;
    font-weight: 700;
    color: white;
}

.result-info { flex: 1; }

.result-info h4 {
    font-family: 'Playfair Display', serif;
    font-size: 23px;
    font-weight: 700;
    margin-bottom: 4px;
}

.result-info .result-author {
    font-size: 17px;
    color: var(--muted);
    margin-bottom: 8px;
}

.result-info .result-why {
    font-size: 18px;
    line-height: 1.6;
    color: var(--brown);
    font-weight: 300;
}

.result-match {
    font-size: 14px;
    font-weight: 600;
    color: var(--sage);
    background: rgba(139, 158, 126, 0.12);
    padding: 4px 10px;
    border-radius: 6px;
    align-self: flex-start;
    white-space: nowrap;
}

.result-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.result-link {
    font-size: 14px;
    padding: 6px 14px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
}

.link-litres   { background: #FFF0E6; color: #D4632A; }
.link-mif      { background: #F5F4F2; color: #5C5550; }
.link-chitay   { background: #E6F3FA; color: #2A7BAD; }
.link-alpina   { background: #EAF4EC; color: #2E7D40; }
.link-bookvoed { background: #F0EBF8; color: #6B3FA0; }
.result-link:hover { transform: translateY(-1px); opacity: 0.85; }

/* Footer */
footer {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 48px;
    border-top: 1px solid rgba(92, 61, 46, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-text {
    font-size: 16px;
    color: var(--muted);
    font-weight: 300;
}

.footer-links { display: flex; gap: 24px; }

.footer-links a {
    font-size: 16px;
    color: var(--muted);
    text-decoration: none;
    transition: color 0.3s;
}

.footer-links a:hover { color: var(--accent); }

.nav-disabled {
    opacity: 0.4;
    pointer-events: none;
    cursor: default;
}

/* Loader */
.loader {
    display: none;
    text-align: center;
    padding: 40px;
}

.loader.visible { display: block; }

.loader-dots { display: inline-flex; gap: 8px; }

.loader-dot {
    width: 10px;
    height: 10px;
    background: var(--accent);
    border-radius: 50%;
    animation: bounce 1.4s ease infinite;
}

.loader-dot:nth-child(2) { animation-delay: 0.16s; }
.loader-dot:nth-child(3) { animation-delay: 0.32s; }

.loader-text {
    margin-top: 16px;
    font-size: 17px;
    color: var(--muted);
    font-weight: 300;
    font-style: italic;
}

/* Animations */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Responsive */
@media (max-width: 768px) {
    header { padding: 20px 24px; flex-direction: column; align-items: flex-start; gap: 10px; }
    .logo { font-size: 28px; }
    nav { gap: 20px; flex-wrap: wrap; }
    nav a { font-size: 15px; }
    .hero {
        grid-template-columns: 1fr;
        padding: 40px 24px;
        gap: 40px;
        min-height: auto;
    }
    h1 { font-size: 48px; }
    .hero-visual { height: 360px; overflow: hidden; }
    .book-card { width: 160px; height: 220px; }
    .steps { grid-template-columns: 1fr; }
    .how-it-works { padding: 60px 24px; }
    .demo-section { padding: 20px 24px 60px; }
    .demo-card { padding: 32px 24px; }
    h2 { font-size: 40px; }
    footer { flex-direction: column; gap: 16px; padding: 32px 24px; }
    .cookie-banner { flex-direction: column; gap: 12px; padding: 16px 24px; }
}

@media (max-width: 480px) {
    header { padding: 16px 20px; flex-direction: column; align-items: flex-start; gap: 8px; }
    .logo { font-size: 24px; }
    nav { gap: 16px; flex-wrap: wrap; }
    nav a { font-size: 14px; }

    .hero {
        padding: 28px 20px 20px;
        gap: 32px;
    }
    h1 { font-size: 36px; letter-spacing: -0.5px; }
    .hero-sub { font-size: 18px; margin-bottom: 28px; }
    .cta-group { flex-direction: column; align-items: stretch; }
    .btn-primary, .btn-secondary { text-align: center; }

    .hero-visual { display: none; }

    h2 { font-size: 30px; margin-bottom: 32px; }
    .how-it-works { padding: 48px 20px; }
    .step { padding: 28px 24px; }
    .step h3 { font-size: 22px; }

    .demo-section { padding: 16px 20px 60px; }
    .demo-card { padding: 28px 20px; border-radius: 16px; }
    .demo-header p { font-size: 17px; }
    .genre-tags { gap: 8px; }
    .genre-tag { padding: 7px 14px; font-size: 14px; }
    .btn-large { padding: 16px 32px; font-size: 17px; width: 100%; }

    .result-book { gap: 14px; padding: 16px; }
    .result-cover { width: 56px; height: 80px; }
    .result-cover span { font-size: 20px; }
    .result-info h4 { font-size: 19px; }
    .result-info .result-why { font-size: 15px; }
    .result-match { display: none; }

    footer { text-align: center; }
    .footer-links { flex-wrap: wrap; justify-content: center; gap: 16px; }

    .cookie-banner p { font-size: 14px; }
    .cookie-actions { width: 100%; }
    .cookie-actions .btn-primary,
    .cookie-actions .btn-secondary { flex: 1; text-align: center; }
}

/* Results footer */
.results-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-top: 24px;
}

.share-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.share-label {
    font-size: 15px;
    color: var(--muted);
    font-weight: 400;
}

.share-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, opacity 0.2s ease;
    padding: 0;
    flex-shrink: 0;
}

.share-btn:hover { transform: translateY(-2px); opacity: 0.88; }

.share-tg   { background: #2AABEE; color: white; }
.share-vk   { background: #4680C2; color: white; }
.share-wa   { background: #25D366; color: white; }
.share-copy { background: rgba(92, 61, 46, 0.08); color: var(--brown); }
.share-copy.copied { background: var(--sage); color: white; }

/* Cookie banner */
.cookie-banner {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--dark);
    color: var(--cream);
    padding: 16px 40px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    z-index: 1000;
    box-shadow: 0 -4px 24px rgba(44, 24, 16, 0.2);
}
.cookie-banner.visible { display: flex; }
.cookie-banner p { font-size: 16px; line-height: 1.5; margin: 0; }
.cookie-banner a { color: var(--gold); text-decoration: underline; }
.cookie-actions { display: flex; gap: 12px; flex-shrink: 0; }
.cookie-actions .btn-primary  { padding: 8px 20px; font-size: 14px; }
.cookie-actions .btn-secondary { padding: 8px 20px; font-size: 14px; }

/* Privacy page */
.privacy-page {
    max-width: 800px;
    margin: 80px auto 80px;
    padding: 0 24px;
}
.privacy-container h1 {
    font-family: 'Playfair Display', serif;
    font-size: 48px;
    color: var(--dark);
    margin-bottom: 8px;
}
.privacy-date {
    color: var(--muted);
    font-size: 16px;
    margin-bottom: 48px;
}
.privacy-container h2 {
    font-family: 'Playfair Display', serif;
    font-size: 26px;
    color: var(--brown);
    margin: 36px 0 12px;
}
.privacy-container p, .privacy-container li {
    font-size: 18px;
    line-height: 1.8;
    color: var(--dark);
    margin-bottom: 8px;
}
.privacy-container ul {
    padding-left: 24px;
    margin-bottom: 8px;
}
.privacy-container a { color: var(--accent); }

/* ── Error page ─────────────────────────────────────────────────────────── */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 80px 24px 120px;
    min-height: calc(100vh - 160px);
    animation: fadeUp 0.7s ease;
}

.error-visual {
    width: 220px;
    height: 180px;
    margin-bottom: 40px;
    animation: errorFloat 4s ease-in-out infinite;
}

.error-visual svg {
    width: 100%;
    height: 100%;
    drop-shadow: 0 8px 24px rgba(196, 113, 59, 0.15);
}

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

.error-status {
    font-family: 'Playfair Display', serif;
    font-size: 96px;
    font-weight: 700;
    line-height: 1;
    color: var(--accent);
    opacity: 0.18;
    margin-bottom: -24px;
    letter-spacing: -4px;
    user-select: none;
}

.error-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(28px, 5vw, 42px);
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 16px;
}

.error-desc {
    font-size: 18px;
    color: var(--muted);
    line-height: 1.7;
    max-width: 460px;
    margin-bottom: 40px;
}

.error-cta {
    text-decoration: none;
    display: inline-block;
}

/* ── Error fragment (inline HTMX result) ──────────────────────────────── */
.error-message {
    padding: 20px 28px;
    background: rgba(196, 113, 59, 0.08);
    border: 1px solid rgba(196, 113, 59, 0.25);
    border-radius: 12px;
    color: var(--brown);
    font-size: 16px;
    text-align: center;
    margin-top: 16px;
}
