@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,700;1,700&display=swap');

:root {
    --brand-main: #16342C;
    --brand-secondary: #C59982;
    --brand-secondary-bg-dark: #2A4C42;
    --brand-text-light: #F0EFEA;
    --brand-text-hint: #A0B3AD;
    --status-green: #4CAF50;
    --status-yellow: #FFC107;
    --status-red: #F44336;

    --tg-theme-bg-color: #16342C !important;
    --tg-theme-text-color: #F0EFEA !important;
    --tg-theme-hint-color: #A0B3AD !important;
    --tg-theme-link-color: #C59982 !important;
    --tg-theme-button-color: #C59982 !important;
    --tg-theme-button-text-color: #16342C !important;
    --tg-theme-secondary-bg-color: #2A4C42 !important;
}

body {
    margin: 0;
    font-family: 'Cormorant Garamond', serif;
    font-size: 18px;
    background-color: var(--tg-theme-bg-color) !important;
    color: var(--tg-theme-text-color) !important;
    overscroll-behavior-y: none;
    position: relative;
    min-height: 100vh;
}

body::before {
    content: "";
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: -1;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.15'/%3E%3C/svg%3E");
    opacity: 0.6; mix-blend-mode: overlay;
}

#app-container { padding: 15px; max-width: 600px; margin: 0 auto; }

.screen { animation: fadeIn 0.4s ease-out; }
.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

@keyframes float { 0% { transform: translateY(0px); box-shadow: 0 5px 15px rgba(0,0,0,0.3); } 50% { transform: translateY(-8px); box-shadow: 0 15px 25px rgba(0,0,0,0.2); } 100% { transform: translateY(0px); box-shadow: 0 5px 15px rgba(0,0,0,0.3); } }
.floating-cover { animation: float 5s ease-in-out infinite; border-radius: 8px; }
@keyframes slideUpFade { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.animate-item { opacity: 0; animation: slideUpFade 0.5s ease-out forwards; }
.action-button:active, .menu-button:active, .year-button:active, .rate-btn:active, .report-card:active, .archive-card:active { transform: scale(0.96); transition: transform 0.1s; }

h1, h2, h3, h4 { font-weight: 700; }
.screen-header { display: flex; align-items: center; margin-bottom: 20px; position: relative; }
.screen-header h2 { margin: 0 auto 0 0; font-size: 1.8em; flex-grow: 1; text-align: center; padding-right: 40px; }
.back-button { background: none; border: none; color: var(--tg-theme-link-color); font-size: 1.8em; font-weight: bold; cursor: pointer; padding: 0 10px; margin-left: -10px; position: absolute; }
#main-screen header { text-align: center; margin-bottom: 25px; }
#main-screen h1 { font-size: 2.2em; margin: 0 0 5px 0; }
#main-screen .subtitle { color: var(--tg-theme-hint-color); margin: 0; font-size: 1.1em; }
.main-menu { display: flex; flex-direction: column; gap: 10px; }

.book-card, .meeting-card { background-color: var(--tg-theme-secondary-bg-color); border-radius: 12px; padding: 20px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.book-card img { max-width: 100%; max-height: 280px; width: auto; object-fit: contain; margin-bottom: 15px; }
.book-card h3 { margin: 0; font-size: 1.8em; }
.book-card .author { color: var(--tg-theme-hint-color); margin: 5px 0 20px 0; font-size: 1.2em; }
.book-card .rating { margin-bottom: 20px; font-size: 1.2em; }
.book-year-main { color: var(--tg-theme-hint-color); font-style: italic; margin-bottom: 15px; font-size: 1em; }

.desc-collapsible { max-height: 0; overflow: hidden; transition: max-height 0.4s ease-out; width: 100%; margin-bottom: 10px; }
.desc-content { background-color: rgba(0,0,0,0.2); border-radius: 10px; padding: 15px; margin-top: 10px; text-align: left; font-size: 1em; line-height: 1.5; color: var(--tg-theme-text-color); border: 1px solid var(--brand-secondary); }
.btn-toggle-desc { background-color: transparent; border: 1px solid var(--brand-secondary); color: var(--brand-secondary); }

.meeting-grid-row { display: flex; gap: 10px; margin-bottom: 12px; width: 100%; }
.meeting-label-box { background-color: var(--tg-theme-button-color); color: var(--tg-theme-button-text-color); font-weight: bold; padding: 12px; border-radius: 10px; flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 1.1em; }
.meeting-value-box { background-color: transparent; border: 1px solid var(--tg-theme-button-color); color: var(--tg-theme-text-color); padding: 12px; border-radius: 10px; flex: 2; display: flex; align-items: center; justify-content: center; text-align: center; font-weight: bold; line-height: 1.2; }
.progress-wrapper { width: 100%; margin-top: 10px; margin-bottom: 20px; }
.progress-labels { display: flex; justify-content: space-between; font-size: 0.9em; color: var(--tg-theme-hint-color); margin-bottom: 5px; padding: 0 5px; }
.progress-track { width: 100%; height: 12px; background-color: rgba(255, 255, 255, 0.2); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 6px; overflow: hidden; }
.progress-fill { height: 100%; background-color: var(--brand-secondary); width: 0%; transition: width 0.6s cubic-bezier(0.25, 1, 0.5, 1); }
.calendar-section { width: 100%; margin-top: 20px; padding-top: 15px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.calendar-label { font-size: 0.9em; color: var(--tg-theme-hint-color); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 1px; }
.calendar-grid { display: flex; gap: 10px; width: 100%; }
.calendar-btn { flex: 1; font-size: 1em; padding: 12px; }
.status-badge { padding: 12px; border-radius: 8px; margin-bottom: 15px; width: 100%; box-sizing: border-box; font-weight: bold; }
.status-participant { background-color: rgba(76, 175, 80, 0.2); color: #81c784; border: 1px solid #4CAF50; }
.status-reserve { background-color: rgba(255, 193, 7, 0.2); color: #ffd54f; border: 1px solid #FFC107; }
#archive-years, #reports-years { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }

/* --- АРХИВ (ОБЫЧНЫЕ КАРТОЧКИ) --- */
.archive-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; padding-bottom: 20px; }
.archive-card { background-color: var(--tg-theme-secondary-bg-color); border-radius: 12px; overflow: hidden; position: relative; box-shadow: 0 4px 10px rgba(0,0,0,0.3); display: flex; flex-direction: column; cursor: pointer; }
.archive-cover-wrapper { position: relative; width: 100%; aspect-ratio: 2 / 3; }
.archive-cover { width: 100%; height: 100%; object-fit: cover; }
.archive-month-badge { position: absolute; top: 8px; right: 8px; background-color: rgba(0, 0, 0, 0.7); color: #fff; padding: 4px 8px; border-radius: 6px; font-size: 0.8em; font-weight: bold; backdrop-filter: blur(4px); z-index: 2; }
.archive-rating-badge { position: absolute; top: 8px; left: 8px; background-color: var(--brand-secondary); color: var(--brand-main); padding: 4px 8px; border-radius: 8px; font-size: 1.1em; font-weight: 900; line-height: 1; z-index: 2; display: flex; align-items: center; justify-content: center; gap: 4px; box-shadow: 0 2px 5px rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.2); }
.archive-info { padding: 10px; text-align: center; flex-grow: 1; display: flex; flex-direction: column; justify-content: center; }
.archive-title { font-size: 1em; font-weight: bold; margin-bottom: 4px; line-height: 1.2; }
.archive-author { font-size: 0.85em; color: var(--tg-theme-hint-color); }

/* Модальное окно книги */
.modal-book-title { font-size: 1.5em; font-weight: bold; margin-bottom: 5px; color: var(--tg-theme-text-color); }
.modal-book-author { font-size: 1.1em; color: var(--tg-theme-hint-color); font-style: italic; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 1px solid var(--brand-secondary); }
.modal-book-year { font-size: 0.9em; color: var(--brand-secondary); font-weight: bold; margin-bottom: 10px; }
.modal-book-desc { font-size: 1em; line-height: 1.5; color: var(--tg-theme-text-color); }

.action-button, .menu-button, .year-button { display: block; width: 100%; padding: 18px; box-sizing: border-box; border-radius: 12px; cursor: pointer; transition: all 0.2s ease; border: none; text-decoration: none; font-family: 'Cormorant Garamond', serif; font-size: 1.2em; font-weight: 700; font-style: italic; text-align: center; background-color: var(--tg-theme-button-color); color: var(--tg-theme-button-text-color); }
.action-button:hover, .menu-button:hover, .year-button:hover { opacity: 0.9; }
.year-button.active { background-color: var(--tg-theme-secondary-bg-color); color: var(--tg-theme-text-color); opacity: 1; }
.btn-secondary { background-color: transparent; border: 1px solid var(--tg-theme-button-color); color: var(--tg-theme-button-color); }
.btn-danger { background-color: rgba(244, 67, 54, 0.2); color: #e57373; border: 1px solid #F44336; }
.admin-only { display: none; }
.form-group { margin-bottom: 15px; }
.form-label { display: block; color: var(--tg-theme-hint-color); margin-bottom: 5px; font-size: 0.9em; }
.form-input { width: 100%; padding: 12px; box-sizing: border-box; border-radius: 10px; border: 1px solid var(--brand-secondary); background-color: rgba(0,0,0,0.2); color: var(--tg-theme-text-color); font-family: 'Cormorant Garamond', serif; font-size: 1.1em; }
.form-input:focus { outline: none; background-color: rgba(0,0,0,0.4); }
.admin-section { background-color: var(--tg-theme-secondary-bg-color); padding: 15px; border-radius: 12px; margin-bottom: 20px; }
.admin-section h3 { margin-top: 0; }
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.7); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-card { background-color: var(--brand-main); border: 1px solid var(--brand-secondary); padding: 25px; border-radius: 15px; width: 85%; max-width: 350px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.modal-title { font-size: 1.5em; margin-bottom: 20px; font-weight: bold; }
.ratings-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 20px; }
.rate-btn { background-color: var(--tg-theme-secondary-bg-color); color: var(--tg-theme-text-color); border: none; border-radius: 8px; padding: 10px 0; font-size: 1.2em; cursor: pointer; font-family: 'Cormorant Garamond', serif; }
.rate-btn:active, .rate-btn:hover { background-color: var(--brand-secondary); color: var(--brand-main); }
@keyframes shake { 0% { transform: rotate(0deg); } 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } 100% { transform: rotate(0deg); } }
@keyframes textFadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.fortune-instruction { font-size: 1.2em; text-align: center; margin-bottom: 30px; color: var(--brand-text-light); }
.fortune-loading-text { font-size: 1.3em; font-weight: bold; text-align: center; color: var(--brand-secondary); margin-top: 20px; animation: textFadeIn 0.5s ease-out; }
.magic-book-container { height: 150px; display: flex; align-items: center; justify-content: center; margin-bottom: 20px; }
.magic-book { font-size: 80px; filter: drop-shadow(0 0 15px var(--brand-secondary)); }
.shaking { animation: shake 0.5s infinite; }
.fortune-result-text { animation: textFadeIn 1s ease-out; background-color: var(--tg-theme-secondary-bg-color); padding: 25px; border-radius: 12px; border: 1px solid var(--brand-secondary); font-size: 1.2em; line-height: 1.6; margin-bottom: 20px; white-space: pre-wrap; text-align: center; font-style: italic; }
.fortune-footer-text { text-align: center; color: var(--brand-text-hint); font-style: italic; margin-top: 20px; font-size: 1em; }
#loading-screen { text-align: center; padding-top: 100px; color: var(--tg-theme-hint-color); }
.spinner { width: 40px; height: 40px; border: 4px solid var(--tg-theme-secondary-bg-color); border-top-color: var(--tg-theme-link-color); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 20px; }
@keyframes spin { to { transform: rotate(360deg); } }
.reports-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; padding-bottom: 20px; }
.report-card { background-color: var(--tg-theme-secondary-bg-color); border-radius: 12px; overflow: hidden; position: relative; box-shadow: 0 4px 10px rgba(0,0,0,0.3); aspect-ratio: 1 / 1; display: flex; flex-direction: column; }
.report-link-wrapper { display: block; width: 100%; height: 100%; position: relative; text-decoration: none; }
.report-image { width: 100%; height: 100%; object-fit: cover; display: block; }
.report-overlay { position: absolute; bottom: 0; left: 0; width: 100%; background: linear-gradient(to top, rgba(0,0,0,0.8), rgba(0,0,0,0)); padding: 10px; box-sizing: border-box; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 50%; }
.report-title { font-size: 1.1em; font-weight: bold; color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.8); text-align: center; margin-bottom: 5px; text-transform: capitalize; }
