@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,800;1,400;1,600&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@700;900&display=swap');

:root {
    --primary: #4f46e5;
    --paper-bg: #fdfbf7;
    --gold-gradient: linear-gradient(135deg, #bf953f, #fcf6ba, #b38728, #fbf5b7, #aa771c);
}

#rbg-frontend-wrapper {
    font-family: 'Plus Jakarta Sans', sans-serif;
    scroll-behavior: smooth;
    background-color: #fafafa;
    color: #0f172a;
    min-height: 100vh;
    position: relative;
}

.bg-mesh {
    position: fixed;
    inset: 0;
    background-image: 
        radial-gradient(at 0% 0%, hsla(234,100%,98%,1) 0, transparent 50%), 
        radial-gradient(at 100% 100%, hsla(234,100%,98%,1) 0, transparent 50%);
    z-index: -1;
    pointer-events: none;
}

.premium-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(0,0,0,0.04);
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.04);
}

.command-input-container {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 2rem;
    padding: 1rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 48rem;
    margin: 0 auto;
}

.command-input-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 20px 40px -20px rgba(79, 70, 229, 0.15);
    transform: translateY(-2px);
}

.rbg-input-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1rem;
    padding-top: 0.5rem;
}

.rbg-input-label {
    font-size: 0.625rem;
    font-weight: 800;
    color: #1e293b;
    text-transform: uppercase;
    letter-spacing: 0.2em;
}

.rbg-divider {
    height: 1px;
    flex: 1;
    background: #e2e8f0;
}

.rbg-branding {
    font-size: 0.5625rem;
    font-weight: 700;
    color: #64748b;
    background: #f1f5f9;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    text-transform: uppercase;
}

.search-area-wrapper {
    position: relative;
    display: flex;
    align-items: flex-end;
    width: 100%;
}

.search-button-fixed {
    position: absolute;
    right: 0.75rem;
    bottom: 0.75rem;
    z-index: 20;
}

#commandInput {
    width: 100%;
    padding: 1.5rem;
    padding-right: 12rem;
    min-height: 180px;
    background: transparent;
    outline: none;
    resize: none;
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.5;
    color: #0f172a;
    border: none;
}

.btn-gradient {
    background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
    color: white;
    padding: 1rem 2rem;
    border-radius: 0.75rem;
    font-weight: 700;
    font-size: 0.875rem;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-gradient:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.btn-gradient:active {
    transform: scale(0.98);
}

.rbg-spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.rbg-frontend-header {
    text-align: center;
    margin-bottom: 3rem;
    padding-top: 4rem;
}

.rbg-frontend-title {
    font-size: 3rem;
    font-weight: 800;
    font-family: 'Playfair Display', serif;
    color: #0f172a;
}

.rbg-title-accent {
    background: linear-gradient(to right, #64748b, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.rbg-main-content {
    max-width: 80rem;
    margin: 0 auto;
    padding: 0 2rem 10rem;
}

.rbg-command-section {
    margin-bottom: 3rem;
}

.rbg-showcase {
    max-width: 64rem;
    margin: 0 auto;
    padding: 1rem 0;
}

.rbg-showcase-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
}

.rbg-showcase-divider {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
}

.rbg-line {
    height: 1px;
    flex: 1;
    background: #e2e8f0;
}

.rbg-showcase-title {
    font-size: 0.625rem;
    font-weight: 800;
    color: #cbd5e1;
    text-transform: uppercase;
    letter-spacing: 0.5em;
}

.rbg-books-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4rem 6rem;
}

.mini-book-btn {
    perspective: 2500px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    display: block;
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

.mini-book-3d {
    width: 125px;
    height: 185px;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateY(-22deg) rotateX(4deg);
    transition: transform 0.6s ease;
}

.mini-book-btn:hover .mini-book-3d {
    transform: rotateY(-8deg) rotateX(0deg) translateY(-25px);
}

.mini-book-spine {
    position: absolute;
    left: -8px;
    top: 0;
    bottom: 0;
    width: 24px;
    background: #111;
    transform: rotateY(-90deg);
    transform-origin: right;
    border-radius: 12px 0 0 12px;
    box-shadow: inset 10px 0 10px rgba(0,0,0,0.5);
}

.mini-book-depth {
    position: absolute;
    top: 5px;
    right: -12px;
    bottom: 5px;
    width: 28px;
    background: #fff;
    background-image: 
        linear-gradient(to right, #ccc 0%, #fff 15%),
        repeating-linear-gradient(to bottom, transparent 0, transparent 1px, #e5e5e5 1px, #e5e5e5 2px);
    transform: rotateY(90deg);
    transform-origin: left;
    border-radius: 0 4px 4px 0;
}

.mini-book-top, .mini-book-bottom {
    position: absolute;
    left: 12px;
    right: -4px;
    height: 28px;
    background: #f8f8f8;
    background-image: linear-gradient(90deg, #d4af37 0%, #f7e08a 50%, #d4af37 100%);
    opacity: 0.15;
}

.mini-book-top {
    top: 5px;
    transform: rotateX(90deg);
    transform-origin: top;
}

.mini-book-bottom {
    bottom: 5px;
    transform: rotateX(-90deg);
    transform-origin: bottom;
}

.mini-cover-front {
    position: absolute;
    inset: 0;
    background: #1e293b;
    border-radius: 2px 8px 8px 2px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 1rem;
    box-shadow: 
        inset 1px 1px 0 rgba(255,255,255,0.15),
        15px 15px 40px rgba(0,0,0,0.5);
    backface-visibility: hidden;
    overflow: hidden;
}

.mini-cover-front::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("https://www.transparenttextures.com/patterns/black-leather.png");
    opacity: 0.7;
    pointer-events: none;
}

.mini-spine-indent {
    position: absolute;
    top: 0;
    left: 14px;
    bottom: 0;
    width: 3px;
    background: rgba(0,0,0,0.5);
    box-shadow: 1px 0 2px rgba(255,255,255,0.1);
    z-index: 21;
}

.mini-title {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: 13px;
    line-height: 1.3;
    color: #fff;
    position: relative;
    z-index: 22;
    text-shadow: 0 3px 6px rgba(0,0,0,0.8);
    letter-spacing: 0.01em;
}

.theme-astronomy {
    background: linear-gradient(135deg, #020617 0%, #1e1b4b 100%);
}

.theme-ocean {
    background: linear-gradient(135deg, #042f2e 0%, #134e4a 100%);
}

.theme-seo {
    background: linear-gradient(135deg, #111 0%, #000 100%);
}

.theme-seo .mini-title {
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-family: 'Cinzel Decorative';
}

.rbg-placeholder {
    max-width: 48rem;
    margin: 0 auto;
    height: 250px;
    border: 2px dashed #e2e8f0;
    border-radius: 2.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    background: rgba(248, 250, 252, 0.5);
    transition: opacity 0.3s ease;
}

.rbg-placeholder-icon {
    color: #cbd5e1;
    margin-bottom: 1rem;
}

.rbg-placeholder-text {
    color: #94a3b8;
    font-weight: 600;
    font-style: italic;
}

.rbg-loading-state {
    padding: 6rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.rbg-loading-spinner {
    position: relative;
    width: 4rem;
    height: 4rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rbg-spinner-outer {
    position: absolute;
    inset: 0;
    border: 4px solid #e2e8f0;
    border-radius: 50%;
}

.rbg-spinner-inner {
    position: absolute;
    inset: 0;
    border: 4px solid #1e293b;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

.rbg-loading-text {
    text-align: center;
}

.rbg-loading-title {
    color: #1e293b;
    font-weight: 700;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
}

.rbg-loading-subtitle {
    color: #64748b;
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.rbg-result-container {
    max-width: 80rem;
    margin: 0 auto;
    opacity: 0;
    transform: translateY(2rem);
    transition: all 1s ease-out;
}

.rbg-result-container.show {
    opacity: 1;
    transform: translateY(0);
}

.rbg-download-section {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1.5rem;
}

.rbg-download-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 0.75rem;
    font-size: 0.625rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: #1e293b;
    background: white;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.rbg-download-btn:hover {
    color: #0f172a;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.book-container {
    perspective: 3000px;
    position: relative;
    width: 100%;
    height: 850px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-fab {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    z-index: 150;
    transition: all 0.3s ease;
    color: #1e293b;
}

.nav-fab:hover:not(:disabled) {
    background: #f8fafc;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

.nav-fab:disabled {
    opacity: 0;
    pointer-events: none;
}

.nav-fab-left {
    left: -4rem;
}

.nav-fab-right {
    right: -4rem;
}

.book-object {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    background-color: var(--paper-bg);
    border-radius: 2px 12px 12px 2px;
    box-shadow: 
        0 40px 100px -20px rgba(0,0,0,0.35),
        0 20px 40px -20px rgba(0,0,0,0.2);
    overflow: hidden;
}

.book-object::before {
    content: '';
    position: absolute;
    left: 22px;
    top: 0;
    bottom: 0;
    width: 5px;
    background: linear-gradient(to right, rgba(0,0,0,0.1), transparent, rgba(0,0,0,0.05));
    z-index: 60;
}

.book-cover {
    position: absolute;
    inset: 0;
    transform-origin: left center;
    transition: transform 1.3s cubic-bezier(0.645, 0.045, 0.355, 1), opacity 0.7s ease-out;
    backface-visibility: hidden;
    background: radial-gradient(circle at 40% 40%, #1e293b, #020617);
    border-left: 22px solid #000;
    box-shadow: inset 20px 0 40px rgba(0,0,0,0.7), 25px 25px 50px rgba(0,0,0,0.4);
    z-index: 100;
    border-radius: 2px 12px 12px 2px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: white;
    padding: 3rem 5rem;
}

.book-cover::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("https://www.transparenttextures.com/patterns/black-leather.png");
    opacity: 0.5;
    pointer-events: none;
    border-radius: inherit;
}

.book-cover.open {
    transform: rotateY(-120deg);
    opacity: 0;
    pointer-events: none;
}

.cover-pattern {
    position: absolute;
    inset: 0;
    opacity: 0.1;
    pointer-events: none;
    background-image: radial-gradient(circle at 2px 2px, white 1px, transparent 0);
    background-size: 32px 32px;
}

.cover-content {
    margin-top: 6rem;
    text-align: center;
    position: relative;
    z-index: 10;
}

.cover-publisher {
    color: #fbbf24;
    font-weight: 700;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    font-size: 0.625rem;
    margin-bottom: 2.5rem;
    opacity: 0.8;
}

.cover-title {
    font-size: 5rem;
    font-weight: 900;
    font-family: 'Cinzel Decorative';
    line-height: 1.1;
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0px 10px 15px rgba(0,0,0,0.5));
    padding-bottom: 1rem;
}

.cover-divider {
    width: 6rem;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(251, 191, 36, 0.5), transparent);
    margin: 3rem auto 0;
}

.cover-footer {
    text-align: center;
    margin-bottom: 2.5rem;
    position: relative;
    z-index: 10;
}

.cover-author-label {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 0.5rem;
}

.cover-author {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'Playfair Display', serif;
    font-style: italic;
    color: white;
    letter-spacing: 0.2em;
}

.page-view {
    flex: 1;
    overflow-y: auto;
    padding: 3rem 5rem 10rem 8rem;
    z-index: 20;
    position: relative;
    background-image: url("data:image/svg+xml,%3Csvg width='500' height='500' viewBox='0 0 500 500' xmlns='http://www.w3.org/2000/svg'%3E%3Ctext x='50%25' y='50%25' font-size='24' font-weight='900' fill='rgba(0,0,0,0.015)' font-family='sans-serif' text-anchor='middle' transform='rotate(-45 250 250)'%3EAUTHENTIC REORK MANUSCRIPT%3C/text%3E%3C/svg%3E");
    background-repeat: repeat;
}

.page-view::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 140px;
    background: linear-gradient(to right, rgba(0,0,0,0.12) 0%, rgba(0,0,0,0.02) 15%, transparent 100%);
    z-index: 20;
    pointer-events: none;
}

.page-content {
    max-width: 65ch;
    margin: 0 auto;
    position: relative;
    z-index: 10;
    animation: pageFadeIn 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes pageFadeIn {
    from {
        opacity: 0;
        transform: translateX(30px) rotateY(2deg);
    }
    to {
        opacity: 1;
        transform: translateX(0) rotateY(0deg);
    }
}

.book-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, var(--paper-bg), var(--paper-bg), transparent);
    padding-top: 5rem;
    padding-bottom: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 110;
    pointer-events: none;
}

.controls-pill {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(40px);
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    padding: 1.25rem 3rem;
    border-radius: 9999px;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 3rem;
}

.controls-chapter {
    font-size: 0.6875rem;
    font-weight: 800;
    color: #0f172a;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.controls-divider {
    width: 1px;
    height: 1.5rem;
    background: #e2e8f0;
}

.controls-page {
    font-size: 0.625rem;
    font-weight: 800;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.3em;
}

.rbg-toast {
    position: fixed;
    top: 2rem;
    left: 50%;
    transform: translate(-50%, -8rem);
    z-index: 300;
    background: white;
    border: 1px solid #e2e8f0;
    color: #1e293b;
    padding: 0.75rem 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    opacity: 0;
    transition: all 0.5s ease;
}

.rbg-toast.show {
    transform: translate(-50%, 0);
    opacity: 1;
}

.rbg-toast-icon {
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 50%;
    background: #6366f1;
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@media (max-width: 768px) {
    .rbg-frontend-title {
        font-size: 2rem;
    }
    
    #commandInput {
        font-size: 1.25rem;
        padding-right: 8rem;
        min-height: 150px;
    }
    
    .cover-title {
        font-size: 3rem;
    }
    
    .page-view {
        padding: 2rem;
    }
    
    .nav-fab-left {
        left: -1.5rem;
    }
    
    .nav-fab-right {
        right: -1.5rem;
    }
}
