:root {
    --paper: #f8f6f1;
    --ink: #1b1b19;
    --muted: #8b8982;
    --line: rgba(27, 27, 25, 0.12);
    --accent: #292824;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
}

button { font: inherit; }

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 50% 40%, #f0eee9 0%, #e7e5df 45%, #dcdbd6 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: "DM Sans", sans-serif;
    color: var(--ink);
}

.app {
    width: min(100%, 430px);
    height: min(900px, calc(100vh - 48px));
    background: var(--paper);
    border-radius: 32px;
    overflow: hidden;
    box-shadow:
        0 30px 80px rgba(20, 20, 18, 0.10),
        0 4px 20px rgba(20, 20, 18, 0.05);
    display: flex;
    flex-direction: column;
    position: relative;
}

.app::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.22;
    background-image: radial-gradient(rgba(0, 0, 0, 0.025) 0.6px, transparent 0.6px);
    background-size: 5px 5px;
}

.header {
    height: 94px;
    padding: 28px 28px 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    position: relative;
    z-index: 4;
    transition: opacity 700ms ease, transform 700ms cubic-bezier(.22,.8,.25,1);
}

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

.brand-mark {
    width: 32px;
    height: 32px;
    border: 1px solid var(--ink);
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-family: "Newsreader", serif;
    font-size: 18px;
    font-style: italic;
}

.brand-name {
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.library-button {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 0;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: background 180ms ease, transform 180ms ease;
}

.library-button:hover { background: rgba(0, 0, 0, 0.045); }
.library-button:active { transform: scale(0.94); }

.library-button svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.quote-section {
    flex: 1;
    padding: 15px 34px 20px;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 2;
}

.date {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.18em;
    transition: opacity 650ms ease, transform 650ms ease;
}

.date-line {
    width: 24px;
    height: 1px;
    background: var(--line);
}

.closed-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding-bottom: 35px;
    transition:
        opacity 650ms ease,
        transform 800ms cubic-bezier(.22,.8,.25,1),
        filter 650ms ease;
}

.quote-symbol {
    width: 62px;
    height: 62px;
    border: 1px solid var(--line);
    border-radius: 50%;
    display: grid;
    place-items: center;
    margin-bottom: 31px;
}

.quote-symbol span {
    font-family: "Newsreader", serif;
    font-size: 42px;
    line-height: 1;
    height: 25px;
}

.closed-state h1 {
    margin: 0;
    font-family: "Newsreader", serif;
    font-size: clamp(38px, 10vw, 46px);
    font-weight: 400;
    line-height: 0.99;
    letter-spacing: -0.035em;
}

.closed-state p {
    margin: 20px 0 36px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.65;
}

.reveal-button {
    height: 52px;
    padding: 0 19px 0 22px;
    border: none;
    border-radius: 100px;
    background: var(--accent);
    color: #f8f6f1;
    display: flex;
    align-items: center;
    gap: 18px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(20, 20, 18, 0.12);
    transition: transform 200ms ease, box-shadow 200ms ease;
}

.reveal-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(20, 20, 18, 0.16);
}

.reveal-button:active { transform: scale(0.97); }

.reveal-button svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Reveal ritual */
.ritual-state {
    position: absolute;
    inset: 0 34px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding-bottom: 20px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 700ms ease, transform 900ms cubic-bezier(.22,.8,.25,1);
}

.book-stage {
    width: 118px;
    height: 104px;
    position: relative;
    display: grid;
    place-items: center;
    margin-bottom: 24px;
}

.book-icon {
    width: 106px;
    height: auto;
    position: relative;
    z-index: 2;
    fill: none;
    stroke: var(--ink);
    stroke-width: 1.35;
    stroke-linecap: round;
    stroke-linejoin: round;
    transform-origin: center bottom;
    opacity: 0;
}


.app.ritual .closed-state {
    opacity: 0;
    transform: translateY(-14px) scale(.985);
    filter: blur(5px);
    pointer-events: none;
}

.app.ritual .header,
.app.ritual .footer,
.app.ritual .date-block {
    opacity: 0;
    pointer-events: none;
}

.app.ritual .header { transform: translateY(-10px); }
.app.ritual .footer { transform: translateY(10px); }
.app.ritual .date-block { transform: translateY(-6px); }

.app.ritual .ritual-state {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.app.ritual .book-icon {
    animation: bookRitual 8.2s linear 0.5s forwards;
}

@keyframes bookRitual {
    /* first 0.5 s: intentionally invisible */
    0% {
        transform: scale(.965);
        opacity: 0;
    }
    6.1% {
        transform: scale(.965);
        opacity: 0;
    }

    /* gentle fade-in */
    10% {
        transform: scale(.98);
        opacity: .78;
    }

    /* pulse 1 */
    23% {
        transform: scale(1.055);
        opacity: 1;
    }
    36% {
        transform: scale(.965);
        opacity: .78;
    }

    /* pulse 2 */
    49% {
        transform: scale(1.055);
        opacity: 1;
    }
    62% {
        transform: scale(.965);
        opacity: .78;
    }

    /* final pulse starts immediately, no resting frame */
    75% {
        transform: scale(1.06);
        opacity: 1;
        filter: blur(0);
    }

    /* fade happens while the final pulse is still moving */
    87% {
        transform: scale(1.025);
        opacity: .48;
        filter: blur(.5px);
    }
    100% {
        transform: scale(.98);
        opacity: 0;
        filter: blur(2px);
    }
}

/* Quote */
.revealed-state {
    position: absolute;
    left: 34px;
    right: 34px;
    top: 50%;
    transform: translateY(-48%);
    opacity: 0;
    visibility: hidden;
}

.reveal-piece {
    opacity: 0;
    filter: blur(6px);
    transform: translateY(10px);
}

.small-quote {
    font-family: "Newsreader", serif;
    font-size: 42px;
    margin-bottom: 19px;
}

blockquote {
    margin: 0;
    font-family: "Newsreader", serif;
    font-size: 39px;
    font-weight: 400;
    line-height: 1.08;
    letter-spacing: -0.035em;
}

.quote-line {
    display: block;
}

.author {
    margin-top: 38px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.author-line {
    width: 27px;
    height: 1px;
    margin-top: 8px;
    background: var(--ink);
}

.author strong,
.author small { display: block; }

.author strong {
    font-size: 11px;
    font-weight: 600;
}

.author small {
    margin-top: 5px;
    color: var(--muted);
    font-family: "Newsreader", serif;
    font-size: 12px;
    font-style: italic;
}

.app.revealing .ritual-state {
    opacity: 0;
    transform: translateY(-7px);
    transition: opacity 850ms ease, transform 850ms ease;
}

.app.revealing .revealed-state,
.app.revealed .revealed-state {
    opacity: 1;
    visibility: visible;
}

.app.revealing .reveal-piece,
.app.revealed .reveal-piece {
    animation: lineReveal 2200ms cubic-bezier(.16,1,.3,1) forwards;
}

.app.revealing .small-quote { animation-delay: 220ms; }
.app.revealing .quote-line:nth-child(1) { animation-delay: 900ms; }
.app.revealing .quote-line:nth-child(2) { animation-delay: 1850ms; }
.app.revealing .author { animation-delay: 3100ms; }

@keyframes lineReveal {
    from {
        opacity: 0;
        filter: blur(6px);
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        filter: blur(0);
        transform: translateY(0);
    }
}

.app.revealed .header,
.app.revealed .footer,
.app.revealed .date-block {
    opacity: 1;
    transform: translateY(0);
}

.app.revealed .closed-state,
.app.revealed .ritual-state {
    display: none;
}

.footer {
    min-height: 62px;
    margin: 0 28px;
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    color: var(--muted);
    font-size: 9px;
    letter-spacing: 0.05em;
    position: relative;
    z-index: 4;
    transition: opacity 700ms ease, transform 700ms cubic-bezier(.22,.8,.25,1);
}

.footer-dot {
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: var(--muted);
}

@media (max-width: 520px) {
    body {
        background: var(--paper);
        align-items: stretch;
    }

    .app {
        width: 100%;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        box-shadow: none;
    }
}

@media (max-height: 700px) {
    .header {
        height: 75px;
        padding-top: 20px;
    }

    .quote-symbol { margin-bottom: 20px; }

    .closed-state h1 { font-size: 37px; }

    .closed-state p { margin: 15px 0 25px; }

    blockquote { font-size: 34px; }
}



/* =========================================================
   LIBRARY
   ========================================================= */

.library-view,
.quote-detail {
    position: absolute;
    inset: 0;
    z-index: 20;
    background: var(--paper);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateX(22px);
    pointer-events: none;
    transition:
        opacity 520ms ease,
        transform 650ms cubic-bezier(.22,.8,.25,1),
        visibility 0s linear 650ms;
}

.app.library-open .library-view,
.app.detail-open .quote-detail {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
    transition:
        opacity 520ms ease,
        transform 650ms cubic-bezier(.22,.8,.25,1),
        visibility 0s;
}

.app.library-open > .header,
.app.library-open > .quote-section,
.app.library-open > .footer,
.app.detail-open > .header,
.app.detail-open > .quote-section,
.app.detail-open > .footer {
    opacity: 0;
    transform: translateX(-18px);
    pointer-events: none;
    transition:
        opacity 420ms ease,
        transform 600ms cubic-bezier(.22,.8,.25,1);
}

.app.detail-open .library-view {
    opacity: 0;
    transform: translateX(-18px);
    pointer-events: none;
}

.library-topbar {
    min-height: 82px;
    padding: 24px 25px 0;
    display: grid;
    grid-template-columns: 42px 1fr 42px;
    align-items: start;
}

.back-button {
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: transparent;
    color: var(--ink);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition:
        background 180ms ease,
        transform 180ms ease;
}

.back-button:hover {
    background: rgba(0,0,0,.035);
}

.back-button:active {
    transform: scale(.94);
}

.back-button svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.35;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.library-kicker {
    padding-top: 13px;
    text-align: center;
    color: var(--muted);
    font-size: 8px;
    font-weight: 600;
    letter-spacing: .2em;
}

.library-content {
    flex: 1;
    min-height: 0;
    padding: 28px 30px 12px;
    overflow-y: auto;
    scrollbar-width: none;
}

.library-content::-webkit-scrollbar {
    display: none;
}
.library-heading h2 {
    margin: 0;
    font-family: "Newsreader", serif;
    font-size: 45px;
    line-height: .98;
    font-weight: 400;
    letter-spacing: -.04em;
}

.library-heading p {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.65;
}

.library-rule {
    height: 0;
    margin: 32px 0 0;
    background: transparent;
}

.library-list {
    padding-bottom: 24px;
}
.library-item + .library-item {
    border-top: 1px solid var(--line);
}
.library-empty {
    padding: 34px 0;
    color: var(--muted);
    font-family: "Newsreader", serif;
    font-size: 20px;
    line-height: 1.35;
}

.library-bottom {
    min-height: 58px;
    margin: 0 28px;
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    color: var(--muted);
    font-size: 9px;
    letter-spacing: .05em;
}

/* Detail */

.detail-content {
    flex: 1;
    padding: 40px 34px 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.detail-meta {
    margin-bottom: 30px;
    color: var(--muted);
    font-size: 8px;
    font-weight: 600;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.detail-quote-mark {
    margin-bottom: 18px;
    font-family: "Newsreader", serif;
    font-size: 42px;
    line-height: .7;
}

.detail-quote {
    margin: 0;
    font-family: "Newsreader", serif;
    font-size: 37px;
    font-weight: 400;
    line-height: 1.08;
    letter-spacing: -.035em;
}

.detail-author {
    margin-top: 36px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.detail-author strong,
.detail-author small {
    display: block;
}

.detail-author strong {
    font-size: 11px;
    font-weight: 600;
}

.detail-author small {
    margin-top: 5px;
    color: var(--muted);
    font-family: "Newsreader", serif;
    font-size: 12px;
    font-style: italic;
}

/* Tiny development helper. Remove before launch. */
.dev-day-picker {
    position: fixed;
    right: 12px;
    bottom: 12px;
    z-index: 100;
    padding: 7px 9px;
    border: 1px solid rgba(0,0,0,.1);
    border-radius: 9px;
    background: rgba(255,255,255,.88);
    backdrop-filter: blur(10px);
    color: #333;
    font: 10px/1 "DM Sans", sans-serif;
}

@media (max-width: 520px) {
    .library-topbar {
        padding-top: max(24px, env(safe-area-inset-top));
    }

    .library-content {
        padding-left: 28px;
        padding-right: 28px;
    }
}


/* v11 — stabilní knihovna: hlavička a zápatí stojí, scrolluje jen seznam */
.brand-home {
    padding: 0;
    border: 0;
    font: inherit;
    cursor: pointer;
}

.library-heading-wrap {
    flex: 0 0 auto;
    padding: 28px 30px 20px;
}

.library-content {
    flex: 1 1 auto;
    min-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    mask-image: linear-gradient(to bottom, transparent 0, #000 12px, #000 calc(100% - 18px), transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 12px, #000 calc(100% - 18px), transparent 100%);
}

.library-list {
    padding-bottom: 26px;
}

.library-bottom {
    flex: 0 0 auto;
    background: var(--paper);
}

/* Již viděný dnešní citát: žádný rituál, jen klidný návrat celého citátu. */
.app.returning-quote .closed-state {
    opacity: 0;
    pointer-events: none;
}

.app.returning-quote .revealed-state {
    opacity: 0;
    transform: translateY(8px);
}

.app.returning-quote.returning-quote-visible .revealed-state {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 900ms ease, transform 1100ms cubic-bezier(.16,1,.3,1);
}

@media (max-width: 520px) {
    .library-heading-wrap {
        padding-left: 28px;
        padding-right: 28px;
    }
}


/* v12 — celé "K pro Katku" je jeden neviditelný klikací celek */
.brand-home {
    appearance: none;
    -webkit-appearance: none;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent !important;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.brand-home:hover,
.brand-home:focus,
.brand-home:focus-visible,
.brand-home:active {
    background: transparent !important;
    outline: 0;
    box-shadow: none;
}

.brand-home .brand-mark {
    flex: 0 0 auto;
}

/* Návrat domů: současná obrazovka nejdřív klidně odpluje. */
.app.home-leaving > .quote-section,
.app.home-leaving > .library-view,
.app.home-leaving > .quote-detail {
    opacity: 0;
    transform: translateY(7px);
    transition:
        opacity 520ms ease,
        transform 700ms cubic-bezier(.22,.8,.25,1);
}

/* Hlavní zavřená stránka se pak vrátí stejným měkkým fade principem. */
.app.home-entering > .header,
.app.home-entering > .quote-section,
.app.home-entering > .footer {
    opacity: 0;
    transform: translateY(7px);
}

.app.home-entering.home-entering-visible > .header,
.app.home-entering.home-entering-visible > .quote-section,
.app.home-entering.home-entering-visible > .footer {
    opacity: 1;
    transform: translateY(0);
    transition:
        opacity 900ms ease,
        transform 1100ms cubic-bezier(.16,1,.3,1);
}

/* v13 — narozeninový prolog */
.intro-view{position:absolute;inset:0;z-index:80;background:var(--paper);opacity:0;visibility:hidden;pointer-events:none;transition:opacity 900ms ease,visibility 0s linear 900ms}
.app.intro-open .intro-view{opacity:1;visibility:visible;pointer-events:auto;transition:opacity 900ms ease,visibility 0s}
.intro-stage{appearance:none;-webkit-appearance:none;width:100%;height:100%;padding:0 34px;border:0;outline:0;background:transparent;color:var(--ink);text-align:left;cursor:pointer;display:flex;flex-direction:column;justify-content:center;align-items:flex-start;-webkit-tap-highlight-color:transparent}
.intro-stage:hover,.intro-stage:active,.intro-stage:focus,.intro-stage:focus-visible{background:transparent;outline:0;box-shadow:none}
.intro-copy{width:100%;max-width:350px;opacity:0;transform:translateY(5px);filter:blur(1px)}
.intro-view.page-visible .intro-copy{opacity:1;transform:translateY(0);filter:blur(0);transition:opacity 900ms ease,transform 1100ms cubic-bezier(.16,1,.3,1),filter 900ms ease}
.intro-view.page-leaving .intro-copy{opacity:0;transform:translateY(-4px);filter:blur(1px);transition:opacity 520ms ease,transform 650ms cubic-bezier(.4,0,.6,1),filter 520ms ease}
.intro-text{margin:0;white-space:pre-line;font-family:"Newsreader",serif;font-size:39px;line-height:1.08;font-weight:400;letter-spacing:-.035em}
.intro-signature{display:none;margin-top:31px;font-family:"Newsreader",serif;font-size:24px;font-style:italic}.intro-signature.visible{display:block}
.intro-arrow{position:absolute;left:34px;bottom:46px;color:var(--muted);font-size:19px;font-weight:300;opacity:0;transform:translateX(-3px)}
.intro-view.page-visible .intro-arrow{opacity:.72;transform:translateX(0);transition:opacity 700ms ease 420ms,transform 850ms cubic-bezier(.16,1,.3,1) 420ms}
.intro-view.page-leaving .intro-arrow{opacity:0;transition:opacity 280ms ease}
.intro-view.punchline .intro-copy{transition-duration:1250ms,1450ms,1200ms}
.app.intro-finishing .intro-view{opacity:0;transition:opacity 1100ms ease}
@media(max-width:520px){.intro-stage{padding-left:30px;padding-right:30px}.intro-arrow{left:30px;bottom:max(40px,calc(env(safe-area-inset-bottom) + 24px))}.intro-text{font-size:clamp(35px,10vw,42px)}}


/* v14 — intro: centrované, kurzíva, jednotný čistý fade */
.intro-stage {
    align-items: center;
    text-align: center;
}

.intro-copy {
    max-width: 370px;
    margin: 0 auto;
    opacity: 0;
    transform: none;
    filter: none;
}

.intro-text {
    text-align: center;
    font-style: italic;
}

.intro-signature {
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

/* Všechny stránky bez výjimky používají přesně stejný fade. */
.intro-view.page-visible .intro-copy,
.intro-view.punchline.page-visible .intro-copy {
    opacity: 1;
    transform: none;
    filter: none;
    transition: opacity 900ms ease;
}

.intro-view.page-leaving .intro-copy,
.intro-view.punchline.page-leaving .intro-copy {
    opacity: 0;
    transform: none;
    filter: none;
    transition: opacity 520ms ease;
}

/* Zrušení speciální animace pointy z předchozí verze. */
.intro-view.punchline .intro-copy {
    transition-duration: 900ms;
}

.intro-arrow {
    left: 50%;
    transform: translateX(-50%);
}

.intro-view.page-visible .intro-arrow {
    opacity: .72;
    transform: translateX(-50%);
    transition: opacity 700ms ease 420ms;
}

.intro-view.page-leaving .intro-arrow {
    opacity: 0;
    transform: translateX(-50%);
    transition: opacity 280ms ease;
}

@media (max-width: 520px) {
    .intro-arrow {
        left: 50%;
    }
}


/* v15 — intro bez kurzívy + letter-by-letter reveal */
.intro-text {
    font-style: normal;
}

.intro-char {
    opacity: 0;
    transition: opacity 280ms ease;
}

.intro-char.visible {
    opacity: 1;
}

/* Text už nefadeuje jako celek při nástupu; písmena si řídí JS. */
.intro-view.page-visible .intro-copy,
.intro-view.punchline.page-visible .intro-copy {
    opacity: 1;
    transition: none;
}

/* Odchod stránky zůstává jednotný čistý fade. */
.intro-view.page-leaving .intro-copy,
.intro-view.punchline.page-leaving .intro-copy {
    opacity: 0;
    transition: opacity 520ms ease;
}


/* v16 — pomalejší intro + správné zalamování v pravém okraji */
.intro-copy {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.intro-text {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: normal;
}

.intro-char {
    opacity: 0;
    transition: opacity 420ms ease;
}


/* v18 — systematický responsive reading grid */
:root {
    --page-gutter: clamp(28px, 7vw, 38px);
    --reading-width: 350px;
    --intro-reading-width: 330px;
}

/* Shell může být přes celý mobil, obsah ale drží konzistentní vnitřní rytmus. */
.intro-stage {
    padding-left: var(--page-gutter);
    padding-right: var(--page-gutter);
}

.intro-copy {
    width: min(100%, var(--intro-reading-width));
    max-width: var(--intro-reading-width);
    margin-left: auto;
    margin-right: auto;
}

.intro-text {
    width: 100%;
    max-width: var(--intro-reading-width);
    margin-left: auto;
    margin-right: auto;
}

/* Hlavní literární obsah drží podobnou maximální čtecí šířku. */
.quote-section > * {
    max-width: var(--reading-width);
    margin-left: auto;
    margin-right: auto;
}

/* Knihovna zůstává vzdušná, ale textové části nejsou přehnaně široké. */
.library-heading,
.library-list,
.quote-detail-inner {
    width: min(calc(100% - (var(--page-gutter) * 2)), var(--reading-width));
    margin-left: auto;
    margin-right: auto;
}

/* Mobilní breakpoint už gutter nezmenšuje — používá stejný systém. */
@media (max-width: 520px) {
    .intro-stage {
        padding-left: var(--page-gutter);
        padding-right: var(--page-gutter);
    }

    .intro-copy,
    .intro-text {
        max-width: var(--intro-reading-width);
    }
}

/* Na opravdu úzkých displejích necháváme trochu rezervy. */
@media (max-width: 360px) {
    :root {
        --page-gutter: 24px;
        --intro-reading-width: 300px;
        --reading-width: 320px;
    }
}


/* =========================================================
   v19 — vstup přes tajný kód
   Testovací režim: nic se neukládá, screen se ukáže po každém reloadu.
   ========================================================= */

.auth-view {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--paper);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 900ms ease, visibility 0s;
}

.auth-view.is-leaving {
    opacity: 0;
    pointer-events: none;
}

.auth-view.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.auth-panel {
    width: min(calc(100% - (var(--page-gutter) * 2)), 340px);
    margin: 0 auto;
    text-align: center;
}

.auth-title {
    margin: 0 0 38px;
    font-family: "Newsreader", serif;
    font-size: clamp(36px, 9vw, 43px);
    line-height: 1.06;
    font-weight: 400;
    letter-spacing: -.035em;
}

.auth-form {
    position: relative;
    width: 100%;
}

.auth-input {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 62px;
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    opacity: 0;
    background: transparent;
    color: transparent;
    caret-color: transparent;
    font-size: 16px;
}

.auth-slots {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
}

.auth-slots span {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 58px;
    border-bottom: 1px solid var(--line);
    font-family: "DM Sans", sans-serif;
    font-size: 19px;
    font-weight: 400;
    line-height: 1;
    color: var(--ink);
    transition:
        border-color 260ms ease,
        opacity 260ms ease;
}

.auth-slots span.active {
    border-color: var(--ink);
}

.auth-slots span.filled {
    border-color: rgba(28, 27, 24, .34);
}

.auth-error {
    min-height: 18px;
    margin: 19px 0 0;
    font-family: "DM Sans", sans-serif;
    font-size: 12px;
    line-height: 1.4;
    letter-spacing: .01em;
    color: var(--muted);
    opacity: 0;
    transform: translateY(3px);
    transition:
        opacity 300ms ease,
        transform 420ms cubic-bezier(.16,1,.3,1);
}

.auth-error.visible {
    opacity: .9;
    transform: translateY(0);
}

.auth-panel.shake .auth-slots {
    animation: authShake 420ms cubic-bezier(.36,.07,.19,.97);
}

@keyframes authShake {
    0%, 100% { transform: translateX(0); }
    22% { transform: translateX(-5px); }
    46% { transform: translateX(4px); }
    70% { transform: translateX(-2px); }
}

@media (max-width: 360px) {
    .auth-panel {
        width: min(calc(100% - 48px), 320px);
    }

    .auth-slots {
        gap: 6px;
    }
}


/* =========================================================
   v20 — auth alignment + typography + seamless handoff
   ========================================================= */

/* Auth screen follows the same left-aligned reading rhythm as intro. */
.auth-panel {
    width: min(calc(100% - (var(--page-gutter) * 2)), var(--intro-reading-width));
    margin-left: auto;
    margin-right: auto;
    text-align: left;
}

.auth-title {
    margin: 0 0 38px;
    font-family: "Newsreader", serif;
    font-size: clamp(35px, 10vw, 42px);
    line-height: 1.08;
    font-weight: 400;
    letter-spacing: -.035em;
    text-align: left;
}

.auth-form,
.auth-error {
    text-align: left;
}

/* Keep the app hidden behind auth until intro has already covered it. */
.app.auth-active > .header,
.app.auth-active > .quote-section,
.app.auth-active > .footer,
.app.auth-active > .library-view,
.app.auth-active > .quote-detail {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* During the auth -> intro handoff, intro sits fully above the hidden app. */
.app.auth-handoff .intro-view {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: none;
}


/* v22 — samostatný podpis, který přijde až po dokončení věty */
.intro-signature {
    display: block;
    margin-top: 31px;
    opacity: 0;
    transform: translateY(3px);
    transition:
        opacity 520ms ease,
        transform 650ms cubic-bezier(.16,1,.3,1);
}

.intro-signature.visible {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.intro-view.page-leaving .intro-signature {
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity 300ms ease;
}


/* v23 — kalendářní datum */
.date-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
}

.date-calendar {
    font-family: "DM Sans", sans-serif;
    font-size: 11px;
    line-height: 1;
    font-weight: 400;
    letter-spacing: .04em;
    color: var(--muted);
}

.library-item-meta,
.detail-meta {
    letter-spacing: .07em;
}


/* =========================================================
   v25 — knihovna: čistší hlavička a lepší práce s datem / šipkou
   ========================================================= */

.library-heading-wrap {
    padding-top: 24px;
}

.library-heading h2 {
    margin-top: 0;
}
@media (max-width: 520px) {
}


/* =========================================================
   v26 — knihovna: finální spacing data / citátu
   ========================================================= */

.library-item {
    width: 100%;
    padding: 24px 0 22px;
    border: 0;
    border-bottom: 0;
    background: transparent;
    color: var(--ink);
    display: grid;
    grid-template-columns: 62px minmax(0, 1fr);
    grid-template-areas:
        "date copy"
        ".    arrow";
    column-gap: 14px;
    row-gap: 10px;
    align-items: start;
    text-align: left;
    cursor: pointer;
}

.library-number {
    grid-area: date;
    min-width: 0;
    padding-top: 2px;
    font-family: "Newsreader", serif;
    font-size: 24px;
    line-height: 1;
    font-weight: 400;
    letter-spacing: -.03em;
    font-variant-numeric: tabular-nums;
}

.library-copy {
    grid-area: copy;
    min-width: 0;
}

.library-item-meta {
    display: block;
    margin: 1px 0 8px;
    color: var(--muted);
    font-size: 8px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.library-preview {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    max-width: 100%;
    font-family: "Newsreader", serif;
    font-size: 18px;
    line-height: 1.18;
    letter-spacing: -.015em;
}

.library-author {
    display: block;
    margin-top: 10px;
    color: var(--muted);
    font-size: 9px;
}

.library-arrow {
    grid-area: arrow;
    justify-self: end;
    align-self: end;
    padding-top: 0;
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
    opacity: .9;
    transition:
        transform 220ms ease,
        opacity 220ms ease;
}

.library-item:hover .library-arrow {
    transform: translateX(3px);
    opacity: 1;
}

@media (max-width: 520px) {
    .library-item {
        grid-template-columns: 60px minmax(0, 1fr);
        column-gap: 12px;
    }

    .library-number {
        min-width: 0;
        font-size: 22px;
    }
}


/* =========================================================
   v27 — iOS Safari fixes + consistent cinematic motion
   ========================================================= */

/* Prevent iOS from tinting buttons / currentColor SVGs system blue. */
button {
    -webkit-appearance: none;
    appearance: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
}

.library-button {
    padding: 0;
    color: var(--ink);
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
}

.library-button svg {
    stroke: var(--ink);
}

/* Date + calendar date behave as one unit during reveal. */
.date-block {
    transition:
        opacity 650ms ease,
        transform 650ms ease;
}

.app.ritual .date-block {
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
}

.app.revealed .date-block {
    opacity: 1;
    transform: translateY(0);
}

/* Make SVG transform origin deterministic in Safari. */
.book-icon {
    transform-box: fill-box;
    -webkit-transform-origin: center bottom;
    transform-origin: center bottom;
    will-change: transform, opacity, filter;
}

/* Help iOS keep animated layers composited smoothly. */
.intro-copy,
.intro-arrow,
.ritual-state,
.revealed-state,
.reveal-piece,
.library-view,
.quote-detail,
.header,
.footer,
.date-block {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/*
 * No blanket prefers-reduced-motion override:
 * the previous rule collapsed every animation to 0.01ms on affected iPhones,
 * which caused hard cuts and made the book finish instantly at opacity: 0.
 */


/* =========================================================
   v28 — mobile viewport lock / no page bounce / no double-tap zoom
   ========================================================= */

/* The document itself is never a scroll surface. */
html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    touch-action: manipulation;
}

body {
    position: fixed;
    inset: 0;
    overscroll-behavior-x: none;
    overscroll-behavior-y: none;
}

/*
 * `touch-action: manipulation` keeps normal taps and pinch zoom,
 * but prevents Safari's double-tap zoom on app controls.
 */
button,
.intro-stage,
.auth-view,
.library-item,
.back-button,
.brand-home,
.reveal-button {
    touch-action: manipulation;
}

.intro-stage,
.auth-view,
.library-item,
.brand-home {
    -webkit-user-select: none;
    user-select: none;
}

/* Only the library list is intentionally scrollable. */
.library-content {
    touch-action: pan-y;
    overscroll-behavior-y: contain;
    overscroll-behavior-x: none;
}

/*
 * Stable mobile height:
 * use the small viewport rather than dynamic viewport height,
 * so Safari's browser chrome cannot recenter the whole app while tapping.
 */
@media (max-width: 520px) {
    body {
        min-height: 100svh;
        height: 100svh;
    }

    .app {
        width: 100%;
        height: 100svh;
        min-height: 100svh;
        max-height: 100svh;
        overflow: hidden;
    }
}


/* =========================================================
   v30 — iOS: spolehlivá aktivace klávesnice na prvním načtení
   ========================================================= */

.auth-code-field {
    position: relative;
    display: block;
    width: 100%;
    min-height: 58px;
    cursor: text;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/*
 * Input zůstává přes celou plochu kódových polí a je prakticky neviditelný.
 * Ne používáme display:none / visibility:hidden: Safari ho tak může nativně
 * aktivovat přímo prvním tapem na label/pole.
 */
.auth-code-field .auth-input {
    position: absolute;
    inset: 0;
    z-index: 3;
    width: 100%;
    height: 100%;
    opacity: .001;
    cursor: text;
    touch-action: manipulation;
}

/* Vizuální sloty nejsou samostatný hit-target; tap patří inputu/labelu. */
.auth-code-field .auth-slots {
    position: relative;
    z-index: 1;
    pointer-events: none;
}


/* =========================================================
   FINAL — production data states
   ========================================================= */

.reveal-button:disabled {
    cursor: default;
    transform: none;
    box-shadow: 0 8px 24px rgba(20, 20, 18, 0.08);
    opacity: .58;
}

.reveal-button:disabled:hover,
.reveal-button:disabled:active {
    transform: none;
    box-shadow: 0 8px 24px rgba(20, 20, 18, 0.08);
}

#todayWork[hidden],
#detailWork[hidden] {
    display: none;
}
