body { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.5; }
.site-header { grid-template-columns: auto minmax(180px, 1fr) auto; gap: 20px; padding: 14px max(20px, calc((100vw - 1120px)/2)); }
.brand strong { font: 700 19px/1.3 system-ui, sans-serif; letter-spacing: 0; }
.brand small { display: none; }
.brand-mark { font-family: system-ui, sans-serif; box-shadow: none; border-radius: 10px; }
.header-search { border-radius: 10px; grid-column: auto; grid-row: auto; }
.nav-link { display: inline-flex; }
.auth-actions, .telegram-login.header-login.loading { min-width: 0; }
.telegram-direct-button { box-shadow: none; font-weight: 600; }
.continue-section, .catalog-layout, .page-shell { max-width: 1160px; padding: 30px 20px; }
.continue-section { padding-bottom: 0; }
.catalog-layout { display: block; }
.section-heading { align-items: center; margin-bottom: 24px; }
.section-heading h1, .section-heading h2, .page-shell h1 { font: 650 25px/1.4 system-ui, sans-serif; letter-spacing: -.02em; margin: 0; }
.section-heading select { font-size: 13px; padding: 8px 10px; }
.story-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 18px; }
.story-card { border-radius: 12px; box-shadow: none; }
.story-card:hover { transform: translateY(-2px); box-shadow: none; border-color: var(--green-soft); }
.story-cover { aspect-ratio: 2/3; background: var(--paper-deep); }
.story-card-body { padding: 14px; }
.story-card h3 { font: 600 16px/1.5 system-ui, sans-serif; }
.story-author { margin: 6px 0 14px; }
.story-card-tags span, .tag-filter button { color: var(--muted); font-weight: 500; }
.tag-filter button.active { color: var(--on-solid); }
.story-price-row strong { font-size: 14px; font-weight: 600; }
.story-badge { font-weight: 600; padding: 4px 8px; top: 10px; left: 10px; }
.library-header { align-items: center; margin-bottom: 24px; }
.library-header p { font-size: 14px; }
.cover-frame { display: block; position: relative; width: 100%; height: 100%; background: var(--paper-deep); overflow: hidden; }
.cover-frame img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
.cover-fallback, .cover-placeholder { display: grid; place-items: center; width: 100%; height: 100%; padding: 18px; color: var(--muted); text-align: center; font: 500 16px/1.6 system-ui, sans-serif; background: var(--paper-deep); }
.cover-frame.mini-cover { width: 70px; height: auto; aspect-ratio: 3/4; }
.cover-frame.mini-cover .cover-fallback { padding: 6px; font-size: 10px; }
.detail-cover .cover-frame { min-height: 330px; }
footer { min-height: 64px; max-width: 1120px; margin: 30px auto 0; padding: 20px 0; border-top: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 13px; }
.modal {
    --modal-top: max(12px, env(safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px));
    --modal-bottom: max(12px, env(safe-area-inset-bottom, 0px), var(--tg-content-safe-area-inset-bottom, 0px));
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    height: min(100dvh, var(--tg-viewport-height, 100dvh));
    padding: var(--modal-top) 12px var(--modal-bottom);
    overflow: hidden;
}
.modal-card, .story-detail-card {
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}
.detail-body { min-width: 0; }
.detail-body h2 { font: 650 clamp(24px, 4vw, 36px)/1.35 system-ui, sans-serif; letter-spacing: -.02em; overflow-wrap: anywhere; }
.detail-description { max-height: none; overflow: visible; }
.detail-actions { position: sticky; top: 0; z-index: 3; margin: 12px 0; padding: 12px 0; background: var(--paper); border-bottom: 1px solid var(--line); }
.genre-pill { max-width: 100%; overflow-wrap: anywhere; }
@media (max-width: 760px) {
    .detail-cover { min-height: 0; height: clamp(120px, 22dvh, 180px); max-height: none; }
    .detail-cover .cover-frame { min-height: 0; height: 100%; }
    .detail-cover img { object-fit: contain; }
    .detail-body { padding: 18px; }
    .detail-body h2 { font-size: 24px; }
    .detail-actions { flex-direction: row; }
    .detail-actions .button { width: auto; flex: 1 1 130px; min-width: 0; white-space: normal; }
}
@media (max-width: 960px) {
    .site-header { grid-template-columns: auto 1fr; gap: 12px; padding: 12px 20px; }
    .main-nav { grid-column: 2; grid-row: 1; }
    .header-search { grid-column: 1 / -1; grid-row: 2; }
    .main-nav [data-view="home"] { display: none; }
}
@media (max-width: 600px) {
    .site-header { padding: 10px 14px; gap: 10px; }
    .site-header .brand > span { display: block; }
    .site-header .brand .brand-mark { display: none; }
    .brand strong { font-size: 16px; }
    .main-nav { gap: 4px; }
    .nav-link { padding: 8px; font-size: 13px; }
    .theme-toggle { width: 34px; height: 34px; }
    .telegram-direct-button { min-height: 34px; padding: 7px 9px; font-size: 12px; gap: 5px; }
    .telegram-direct-button svg { width: 15px; height: 15px; }
    .continue-section, .catalog-layout, .page-shell { padding: 24px 14px; }
    .story-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .story-card-body { padding: 12px; }
    .story-card h3 { font-size: 15px; }
    .section-heading h1, .section-heading h2, .page-shell h1 { font-size: 22px; }
    footer { margin: 16px 14px 0; }
}
