/* Rozcestník knihovny. Hlavička, patička a dialogy zůstávají v asets/app.css. */

.library-topbar.topbar {
    grid-template-columns: auto minmax(0, 1fr);
}

.library-topbar .topbar-center {
    justify-self: end;
}

.library-topbar .lang-switch-menu {
    left: auto;
    right: 0;
    transform: none;
}

.library-main {
    min-height: calc(100vh - 160px);
}

.library-wrap {
    width: 100%;
    margin: 0 auto;
    padding: 18px 0 48px;
}

.library-head {
    display: flex;
    align-items: center;
    gap: 16px 24px;
    margin: 0 0 28px;
}

.library-head h1 {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
}

.library-add {
    flex: 0 0 auto;
    margin-left: auto;
}

.library-wrap h1 {
    margin: 0 0 28px;
    color: var(--night);
    font-size: clamp(2.05rem, 4.2vw, 3.15rem);
    line-height: 1.12;
    letter-spacing: -0.04em;
    font-weight: 800;
}

.library-lead {
    margin: 0 0 28px;
    color: var(--ink-soft);
    font-size: 1.05rem;
    line-height: 1.55;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.library-card {
    position: relative;
    height: calc(236px + 2.7rem);
    min-height: calc(236px + 2.7rem);
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(12px);
    cursor: pointer;
    transform: translateY(0);
    transition:
        transform .22s ease,
        box-shadow .22s ease,
        border-color .22s ease;
}

.library-card:hover {
    z-index: 2;
    transform: translateY(-3px);
    border-color: rgba(114, 89, 255, 0.22);
    box-shadow:
        0 22px 40px rgba(22, 28, 55, 0.14),
        0 8px 16px rgba(22, 28, 55, 0.08);
}

@media (prefers-reduced-motion: reduce) {
    .library-card {
        transition: none;
    }
    .library-card:hover {
        transform: none;
    }
}

.library-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 1.9rem;
}

.library-card h2 {
    margin: 14px 0 8px;
    color: var(--ink);
    font-size: 1.18rem;
    letter-spacing: -0.03em;
    line-height: 1.25;
    font-weight: 750;
}

.library-card-perex {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0 0 16px;
    color: var(--ink-soft);
    font-size: 0.9rem;
    line-height: 1.5;
    font-weight: 450;
    overflow: hidden;
}

.library-card-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: auto;
}

.library-card-read {
    color: var(--violet);
    font-size: 0.9rem;
    font-weight: 700;
}

.library-card-time {
    color: var(--ink-soft);
    font-size: 0.86rem;
    font-weight: 650;
    text-align: right;
}

.library-edit {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--ink-soft);
    cursor: pointer;
    opacity: 0.55;
}

.library-edit:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.95);
    color: var(--ink);
}

.library-edit svg {
    display: block;
    width: 18px;
    height: 18px;
}

.library-card:has(.library-edit) .library-card-meta {
    padding-right: 30px;
}

.library-empty {
    margin: 0;
    color: var(--ink-soft);
    font-size: 1rem;
    line-height: 1.5;
}

@media (max-width: 1180px) {
    .library-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 930px) {
    .library-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 620px) {
    .library-head {
        align-items: flex-start;
    }
}

.library-editor {
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 108px);
    min-height: 320px;
    padding: 8px 0 0;
}

.library-editor-loader {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.58);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .32s ease;
}

.library-editor.is-busy .library-editor-loader {
    opacity: 1;
    pointer-events: auto;
}

.library-editor-loader-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    max-width: min(36rem, calc(100% - 32px));
    padding: 0 16px;
}

.library-editor-loader-status {
    margin: 0;
    color: var(--night);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
}

.library-editor-loader-status.is-error {
    color: #b4233c;
}

.library-editor-loader-spin {
    width: 75px;
    height: 15px;
    flex: 0 0 auto;
    display: grid;
    --_g: no-repeat radial-gradient(farthest-side, var(--violet) 94%, #0000);
}

.library-editor-loader-spin:before,
.library-editor-loader-spin:after {
    content: "";
    grid-area: 1 / 1;
    background:
        var(--_g) left,
        var(--_g) right;
    background-size: 20% 100%;
    animation: library-editor-loader-spin 1s infinite;
}

.library-editor-loader-spin:after {
    background:
        var(--_g) calc(1 * 100% / 3),
        var(--_g) calc(2 * 100% / 3);
    background-size: 20% 100%;
    animation-direction: reverse;
}

@keyframes library-editor-loader-spin {
    80%, 100% { transform: rotate(.5turn); }
}

@media (prefers-reduced-motion: reduce) {
    .library-editor-loader {
        transition: none;
    }
    .library-editor-loader-spin:before,
    .library-editor-loader-spin:after {
        animation: none;
    }
}

.library-editor-form {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
}

.library-editor-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: stretch;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.library-editor-fields {
    display: flex;
    flex-direction: column;
    gap: 14px;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.library-editor-label {
    display: grid;
    gap: 6px;
    color: var(--ink);
    font-size: 0.84rem;
    font-weight: 750;
}

.library-editor-label input,
.library-editor-label textarea,
.library-editor-label select {
    width: 100%;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--ink);
    font: inherit;
    font-size: 1rem;
    font-weight: 550;
}

.library-editor-label textarea {
    resize: none;
    overflow-y: auto;
}

.library-editor-label textarea[data-library-perex] {
    height: calc(1.35em * 3 + 24px);
    min-height: calc(1.35em * 3 + 24px);
    flex: none;
    font-weight: 450;
}

.library-editor-label-picks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.library-editor-label-picks .training-tag {
    margin: 0;
    border: 0;
    cursor: pointer;
    opacity: 0.55;
}

.library-editor-label-picks .training-tag.is-on {
    opacity: 1;
    box-shadow: 0 0 0 2px rgba(19, 34, 56, 0.18);
}

.library-editor-right {
    display: flex;
    flex-direction: column;
    gap: 14px;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.library-editor-body-label {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.library-editor-body-label textarea {
    flex: 1 1 auto;
    min-height: 0;
}

.library-editor-fields-foot {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: auto;
}

.library-editor-status {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    color: var(--ink-soft);
    font-size: 0.92rem;
    font-weight: 650;
}

.library-editor-status.is-error {
    color: #b4233c;
}

.library-editor-save-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
}

.library-editor-save {
    flex: 0 0 auto;
    margin-left: auto;
}

.library-editor-preview {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    padding: 22px 24px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--shadow-soft);
}

.library-editor-preview h1,
.library-editor-preview h2,
.library-editor-preview h3,
.library-editor-preview h4,
.library-editor-preview h5,
.library-editor-preview h6 {
    margin: 0.9em 0 0.4em;
    color: var(--night);
    line-height: 1.2;
    letter-spacing: -0.03em;
    font-weight: 800;
}

.library-editor-preview h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
.library-editor-preview h2 { font-size: 1.45rem; }
.library-editor-preview h3 { font-size: 1.22rem; }
.library-editor-preview h4,
.library-editor-preview h5,
.library-editor-preview h6 { font-size: 1.05rem; }

.library-editor-preview h1:first-child,
.library-editor-preview-body > :first-child {
    margin-top: 0;
}

.library-editor-preview-body {
    flex: 1 1 auto;
    min-height: 0;
    outline: none;
    color: var(--ink);
    font-size: 1.02rem;
    line-height: 1.4;
    font-weight: 450;
}

.library-editor-preview-body p {
    margin: 0 0 0.7em;
}

.library-editor-preview-body p:last-child {
    margin-bottom: 0;
}

.library-editor-preview-body:empty::before {
    content: attr(data-empty);
    color: var(--ink-soft);
    font-weight: 450;
}

.library-editor-preview hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 1em 0;
}

.library-editor-preview q {
    display: block;
    margin: 0.85em 0 0.85em 0.15em;
    padding: 0.4em 0.7em 0.4em 0.85em;
    border-left: 2px solid rgba(19, 34, 56, 0.22);
    border-radius: 0 10px 10px 0;
    background: rgba(19, 34, 56, 0.045);
    quotes: "\201E" "\201C" "\201A" "\2018";
    font-style: normal;
}

.library-editor-preview-body ul {
    margin: 0.85em 0;
    padding: 0 0 0 1.3em;
}

.library-editor-preview-body li {
    margin: 0 0 0.28em;
}

.library-article {
    width: min(760px, 100%);
    margin: 0 auto;
    padding: 18px 0 48px;
}

.library-article h1 {
    margin: 0 0 24px;
    color: var(--night);
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    line-height: 1.15;
    letter-spacing: -0.04em;
    font-weight: 800;
}

.library-article-date {
    display: block;
    margin: 0 0 22px;
    color: var(--ink-soft);
    font-size: 0.86rem;
    font-weight: 650;
}

.library-article-body {
    color: var(--ink);
    font-size: 1.05rem;
    line-height: 1.4;
    font-weight: 450;
}

.library-article-body h1,
.library-article-body h2,
.library-article-body h3,
.library-article-body h4,
.library-article-body h5,
.library-article-body h6 {
    margin: 0.9em 0 0.4em;
    color: var(--night);
    line-height: 1.2;
    letter-spacing: -0.03em;
    font-weight: 800;
}

.library-article-body h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
.library-article-body h2 { font-size: 1.45rem; }
.library-article-body h3 { font-size: 1.22rem; }
.library-article-body h4,
.library-article-body h5,
.library-article-body h6 { font-size: 1.05rem; }

.library-article-body h1:first-child,
.library-article-body > :first-child {
    margin-top: 0;
}

.library-article-body p {
    margin: 0 0 0.7em;
}

.library-article-body p:last-child {
    margin-bottom: 0;
}

.library-article-body hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 1em 0;
}

.library-article-body q {
    display: block;
    margin: 0.85em 0 0.85em 0.15em;
    padding: 0.4em 0.7em 0.4em 0.85em;
    border-left: 2px solid rgba(19, 34, 56, 0.22);
    border-radius: 0 10px 10px 0;
    background: rgba(19, 34, 56, 0.045);
    quotes: "\201E" "\201C" "\201A" "\2018";
    font-style: normal;
}

.library-article-body ul {
    margin: 0.85em 0;
    padding: 0 0 0 1.3em;
}

.library-article-body li {
    margin: 0 0 0.28em;
}

.library-article-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.55em;
    margin: 1.6em 0 0;
}

.library-try-training,
.library-share-article {
    color: var(--violet);
    font-weight: 700;
    text-decoration: none;
}

.library-action-icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    margin: 0 0.38em 0 0;
    vertical-align: -0.14em;
    flex: 0 0 auto;
}

.library-share-article {
    display: inline-flex;
    align-items: center;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    cursor: pointer;
}

.library-try-training:hover,
.library-try-training:focus-visible {
    text-decoration: underline;
}

.library-share-article:hover span,
.library-share-article:focus-visible span {
    text-decoration: underline;
}

.library-share-article.is-copied {
    color: var(--mint-dark);
    text-decoration: none;
}

@media (max-width: 800px) {
    .library-editor {
        height: calc(100dvh - 88px);
    }

    .library-editor-split {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
        min-height: 0;
    }

    .library-editor-save-row {
        flex-wrap: wrap;
    }
}
