/* Světlý motiv = výchozí, tmavý = noc (podle času) nebo nastavení systému. */
:root {
    --bg: #fdfbf7;
    --surface: #ffffff;
    --text: #2c2a27;
    --muted: #6d675f;
    --accent: #8a5a2b;
    --line: #e6ded2;
    --shadow: 0 1px 2px rgba(0, 0, 0, .06);
}

html.night {
    color-scheme: dark;
    --bg: #14161a;
    --surface: #1c1f25;
    --text: #e6e3dd;
    --muted: #9b968d;
    --accent: #d7b07a;
    --line: #2b2f37;
    --shadow: none;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --bg: #14161a;
        --surface: #1c1f25;
        --text: #e6e3dd;
        --muted: #9b968d;
        --accent: #d7b07a;
        --line: #2b2f37;
        --shadow: none;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 1.5rem 1rem 3rem;
    background: var(--bg);
    color: var(--text);
    font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
    font-size: 1.0625rem;
    line-height: 1.7;
    -webkit-text-size-adjust: 100%;
}

header,
main,
footer {
    max-width: 44rem;
    margin: 0 auto;
}

.site-header {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--line);
    margin-bottom: 2rem;
}

.site-header h1 {
    margin: 0;
    font-size: 1.9rem;
}

.lead {
    margin: .4rem 0 0;
    color: var(--muted);
}

a {
    color: var(--accent);
}

.back {
    display: inline-block;
    padding: .35rem 0;
    text-decoration: none;
    color: var(--muted);
}

.back:hover {
    color: var(--accent);
}

/* Seznam sekcí i pohádek */
.page-title {
    margin: 1rem 0 1.25rem;
    font-size: 1.6rem;
}

.list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: .6rem;
}

.list a {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: .25rem 1rem;
    padding: .9rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: .6rem;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text);
}

.list a:hover,
.list a:focus {
    border-color: var(--accent);
}

.item-title {
    font-size: 1.1rem;
}

.item-meta {
    color: var(--muted);
    font-size: .85rem;
    white-space: nowrap;
}

.admin-tale-link {
    align-items: center;
}

.admin-tale-details {
    display: grid;
    gap: 0;
    min-width: 0;
}

.admin-tale-section {
    margin-left: auto;
    text-align: right;
}

.empty {
    color: var(--muted);
    font-style: italic;
}

/* Text pohádky */
.tale {
    margin-top: 1.5rem;
}

.tale h1 {
    margin: .2rem 0 1.5rem;
    font-size: 1.8rem;
    line-height: 1.25;
}

.tale-section {
    margin: 0;
    color: var(--muted);
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.tale p {
    margin: 0 0 1.15rem;
}

.tale p:not(.tale-section) {
    font-size: 1.4em;
}

.tale h1 + p::first-letter {
    float: left;
    font-size: 3em;
    line-height: .9;
    padding: .1rem .5rem .1rem 0;
    color: var(--accent);
}

.tale-edit {
    margin: 2rem 0 0;
    display: flex;
    justify-content: flex-end;
}

body:has(.autoscroll-toggle, .admin-gear) .site-header {
    padding-right: 3rem;
}

button.autoscroll-toggle,
.admin-gear {
    position: fixed;
    top: max(.6rem, env(safe-area-inset-top));
    right: max(.6rem, env(safe-area-inset-right));
    z-index: 10;
}

button.autoscroll-toggle,
.admin-gear,
.tale-edit-link {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: .4rem;
    background: var(--bg);
    color: var(--muted);
}

button.autoscroll-toggle:hover,
button.autoscroll-toggle[aria-pressed="true"],
.admin-gear:hover,
.admin-gear:focus-visible,
.tale-edit-link:hover,
.tale-edit-link:focus-visible {
    color: var(--accent);
    border-color: var(--accent);
}

button.autoscroll-toggle:focus-visible,
.admin-gear:focus-visible,
.tale-edit-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.autoscroll-toggle[hidden],
.autoscroll-pause,
.autoscroll-toggle[aria-pressed="true"] .autoscroll-play {
    display: none;
}

.autoscroll-toggle[aria-pressed="true"] .autoscroll-pause {
    display: block;
}

.site-footer {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: .85rem;
    text-align: center;
}

.site-footer p {
    margin: 0 0 .3rem;
}

.site-footer p:last-child {
    margin-bottom: 0;
}

.footer-home {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
}

/* Správa */
.admin-nav a {
    margin-right: 1rem;
    font-size: .9rem;
}

.admin h2 {
    margin: 2rem 0 .75rem;
    font-size: 1.25rem;
}

.card {
    display: grid;
    gap: .75rem;
    padding: 1rem;
    margin-bottom: .6rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: .6rem;
}

.card.row,
.list .row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}

.list .row {
    gap: .5rem;
}

.list .grow {
    flex: 1 1 12rem;
}

label {
    display: grid;
    gap: .3rem;
    font-size: .9rem;
    color: var(--muted);
}

.hint {
    font-size: .8rem;
}

input,
select,
textarea,
button,
.button {
    font: inherit;
    padding: .55rem .7rem;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: .4rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
    width: 100%;
    min-width: 0;
}

.card.row input[type="text"] {
    flex: 1 1 12rem;
    width: auto;
}

.card.row input[type="number"] {
    width: 5rem;
}

textarea {
    font-family: inherit;
    line-height: 1.6;
    resize: vertical;
}

button,
.button {
    cursor: pointer;
    text-decoration: none;
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

button:disabled {
    cursor: wait;
    opacity: .7;
}

.save-status {
    color: var(--muted);
    font-size: .85rem;
}

.save-status.saved {
    color: #287a45;
}

html.night button:not(.danger):not(.autoscroll-toggle),
html.night .button {
    color: #14161a;
}

@media (prefers-color-scheme: dark) {
    button,
    .button {
        color: #14161a;
    }
}

button.danger {
    background: transparent;
    border-color: var(--line);
    color: var(--muted);
}

button.danger:hover {
    border-color: #b3261e;
    color: #b3261e;
}

.error {
    margin: 0;
    color: #b3261e;
}

.generated-output {
    overflow: auto;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: .4rem;
    font: .9rem/1.6 ui-monospace, "Cascadia Code", monospace;
    white-space: pre-wrap;
}

@media (min-width: 40rem) {
    body {
        padding: 2.5rem 2rem 4rem;
        font-size: 1.125rem;
    }

    .site-header h1 {
        font-size: 2.3rem;
    }

    .page-title {
        font-size: 2rem;
    }

    .tale h1 {
        font-size: 2.2rem;
    }
}

@media print {
    body {
        background: #fff;
        color: #000;
    }

    .site-header,
    .site-footer,
    .admin-gear,
    .tale-edit,
    button.autoscroll-toggle {
        display: none;
    }
}
