/* AquaDzannn Library */

:root {
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 15px;
    --button-radius: 14px;
    --font: Roboto, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-bs-theme="light"] {
    --body-color: #16231f;
    --heading: #173d34;
    --muted: #697771;
    --page-bg: radial-gradient(circle at top left, rgba(30, 127, 104, .10), transparent 26rem), linear-gradient(180deg, #f3f8f5 0%, #eef4f1 100%);
    --surface: rgba(255, 255, 255, .90);
    --surface-solid: #ffffff;
    --surface-muted: #f6faf8;
    --input-bg: #fbfdfc;
    --floating-bg: rgba(255, 255, 255, .90);
    --border: #d8e3de;
    --border-strong: #bfe4d6;
    --accent: #1e7f68;
    --accent-alt: #3b9078;
    --accent-rgb: 30, 127, 104;
    --accent-soft: #dff3eb;
    --accent-soft-2: #eef7f3;
    --accent-text: #0f5d4b;
    --warning-bg: #fff5ea;
    --warning-border: #a7641d;
    --warning-text: #87561c;
    --danger-bg: #fff2f2;
    --danger-border: #a33f3f;
    --danger-text: #963f3f;
    --success-bg: #e9f6ef;
    --success-text: #23634e;
    --shadow: 0 16px 42px rgba(22, 35, 31, .08);
    --hero-start: #173d34;
    --hero-end: #1c6757;
    --editor-overlay: rgba(255, 255, 255, .09);
    --editor-overlay-border: rgba(255, 255, 255, .18);
}

:root[data-bs-theme="dark"] {
    --body-color: #dce8e3;
    --heading: #edf5f1;
    --muted: #99aaa3;
    --page-bg: radial-gradient(circle at top left, rgba(55, 126, 103, .12), transparent 28rem), linear-gradient(180deg, #111b17 0%, #0c1512 100%);
    --surface: rgba(20, 32, 28, .92);
    --surface-solid: #17251f;
    --surface-muted: #1b2b25;
    --input-bg: #14211c;
    --floating-bg: rgba(19, 31, 27, .94);
    --border: #2b4037;
    --border-strong: #4e7f6d;
    --accent: #52977f;
    --accent-alt: #39765f;
    --accent-rgb: 82, 151, 127;
    --accent-soft: #203c32;
    --accent-soft-2: #1b3028;
    --accent-text: #a8d3c3;
    --warning-bg: #30271b;
    --warning-border: #a47b42;
    --warning-text: #d9b77f;
    --danger-bg: #312020;
    --danger-border: #a35a5a;
    --danger-text: #dca1a1;
    --success-bg: #1c342a;
    --success-text: #9bceb9;
    --shadow: 0 16px 42px rgba(0, 0, 0, .22);
    --hero-start: #173d34;
    --hero-end: #245f51;
    --editor-overlay: rgba(255, 255, 255, .08);
    --editor-overlay-border: rgba(255, 255, 255, .16);
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--body-color);
    background: var(--page-bg);
    background-attachment: fixed;
    font-family: var(--font);
    line-height: 1.6;
}
button, input, textarea, select { font: inherit; }
a { color: inherit; }
img { max-width: 100%; }
body.theme-transition, body.theme-transition * {
    transition: background-color .35s ease, color .2s ease, border-color .35s ease, box-shadow .35s ease !important;
}

.app-shell {
    width: min(1180px, calc(100% - 28px));
    margin: 0 auto;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Brand — shared with calculator */
.eyebrow { display: inline-flex; align-items: center; gap: 8px; position: relative; z-index: 1; }
.app-brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; text-decoration: none; }
.app-brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 7px;
    overflow: hidden;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--accent), var(--accent-alt));
    box-shadow: 0 12px 30px rgba(var(--accent-rgb), .18);
}
.app-brand-logo { display: block; width: 100%; height: 100%; object-fit: contain; }
.app-brand-title { display: block; color: #f4faf7; font-weight: 850; line-height: 1.05; letter-spacing: -.03em; }
.app-brand-subtitle { display: block; margin-top: 3px; color: rgba(244, 250, 247, .68); font-size: .76rem; line-height: 1.1; }

/* Hero */
.hero { padding: 32px 0 22px; }
.hero--compact { padding-bottom: 18px; }
.hero-card {
    position: relative;
    overflow: hidden;
    padding: 34px;
    border-radius: 32px;
    background: linear-gradient(135deg, var(--hero-start) 0%, var(--hero-end) 100%);
    color: #fff;
    box-shadow: var(--shadow);
}
.hero-card::before {
    content: "";
    position: absolute;
    right: -120px;
    top: -90px;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .09);
    pointer-events: none;
}
.hero h1 {
    position: relative;
    z-index: 1;
    max-width: 820px;
    margin: 16px 0 12px;
    font-size: clamp(34px, 5vw, 58px);
    line-height: 1.03;
    letter-spacing: -.04em;
}
.hero p {
    position: relative;
    z-index: 1;
    max-width: 820px;
    margin: 0;
    color: rgba(255, 255, 255, .83);
    font-size: 17px;
}
.hero--compact h1 { font-size: clamp(32px, 4vw, 48px); }

.quick-stats {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    margin-top: 28px;
}
.stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-width: 0;
    padding: 14px 26px;
    border: 1px solid rgba(255, 255, 255, .13);
    border-radius: 18px;
    background: rgba(255, 255, 255, .10);
}
.stat strong { display: block; font-size: 22px; }
.stat span { color: rgba(255, 255, 255, .74); font-size: 12px; }

/* Search */
.search-form { display: flex; align-items: center; }
.search-form--hero {
    position: relative;
    z-index: 1;
    /* width: min(700px, 100%); */
    margin-top: 28px;
    padding: 6px;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 18px;
    background: rgba(255,255,255,.10);
    backdrop-filter: blur(10px);
}
.search-form input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    outline: 0;
    padding: 10px 12px;
    background: transparent;
    color: #fff;
    font-size: 1rem;
}
.search-form input::placeholder { color: rgba(255,255,255,.58); }
.search-form button {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 13px;
    background: rgba(255,255,255,.14);
    color: #fff;
    cursor: pointer;
}
.search-form button:hover { background: rgba(255,255,255,.22); }
.search-form svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

/* Catalog */
.category-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0 22px;
}
.category-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 13px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--heading);
    font-weight: 700;
    text-decoration: none;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease, color .18s ease, transform .18s ease;
}
.category-chip:hover { transform: translateY(-1px); border-color: var(--border-strong); background: var(--accent-soft-2); }
.category-chip.is-active {
    border-color: rgba(var(--accent-rgb), .50);
    background: var(--accent-soft);
    color: var(--accent-text);
    box-shadow: 0 10px 26px rgba(var(--accent-rgb), .12);
}
.category-chip span { color: var(--muted); font-size: .8rem; }
.category-chip.is-active span { color: currentColor; opacity: .72; }
.category-chip--reset {
    border-style: dashed;
    background: transparent;
    color: var(--muted);
    box-shadow: none;
}
.category-chip--reset:hover { color: var(--accent-text); }
.catalog-groups, .search-results, .admin-list, .block-reference { padding-bottom: 60px; }
.catalog-group + .catalog-group { margin-top: 34px; }
.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin: 14px 0;
}
.section-kicker { display: block; margin-bottom: 2px; color: var(--muted); font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .09em; }
.section-heading h2 { margin: 0; color: var(--heading); font-size: 28px; line-height: 1.15; }
.section-count { display: grid; place-items: center; min-width: 34px; height: 34px; padding: 0 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-weight: 800; }
.page-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.page-card {
    display: flex;
    flex-direction: column;
    min-height: 230px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow);
    text-decoration: none;
    transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.page-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.page-card__category { align-self: flex-start; padding: 6px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: .72rem; font-weight: 800; }
.page-card h3, .search-result h3 { margin: 16px 0 4px; color: var(--heading); font-size: 21px; line-height: 1.15; }
.page-card__subtitle { margin: 0 0 10px !important; color: var(--accent-text) !important; font-weight: 700; }
.page-card p { margin: 0; color: var(--muted); font-size: .9rem; }
.page-card__meta { margin-top: auto; padding-top: 18px; color: var(--muted); font-size: .78rem; }

/* Search results */
.search-list { display: grid; gap: 12px; }
.search-result {
    display: block;
    padding: 20px 22px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
    text-decoration: none;
}
.search-result:hover { border-color: var(--border-strong); }
.search-result__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.search-result__count { color: var(--muted); font-size: .78rem; }
.search-result__snippet { margin: 12px 0 0; color: var(--muted); }
.search-result mark { padding: 1px 3px; border-radius: 4px; background: var(--accent-soft); color: var(--accent-text); font-weight: 800; }
.back-link { margin-top: 20px; }
.back-link a { color: var(--accent-text); font-weight: 700; }

/* Guide structure — geometry follows the source guide */
.layout {
    display: grid;
    grid-template-columns: 270px minmax(0, 1fr);
    gap: 22px;
    padding-bottom: 60px;
    scroll-margin-top: 18px;
}
.sidebar {
    position: sticky;
    top: 18px;
    align-self: start;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
}
.sidebar h2 { margin: 2px 8px 10px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.sidebar hr { border: 1px solid var(--accent-soft); border-top-style: none; border-radius: 50%; }
.tab-btn {
    display: flex;
    align-items: center;
    width: 100%;
    margin: 0;
    padding: 12px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--body-color);
    font-weight: 700;
    font-size: 15px;
    text-align: left;
    cursor: pointer;
}
.tab-btn:hover { background: var(--surface-muted); }
.tab-btn.active { background: var(--accent-soft); color: var(--accent-text); }
.content { min-width: 0; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.panel-intro {
    margin-bottom: 18px;
    padding: 26px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--surface-solid);
    box-shadow: var(--shadow);
}
.panel-intro h2 { margin: 0 0 8px; color: var(--heading); font-size: 28px; line-height: 1.15; }
.panel-intro p { margin: 0; color: var(--muted); }
.accordion { display: grid; gap: 14px; }
.acc-item { overflow: hidden; border: 1px solid var(--border); border-radius: 22px; background: var(--surface-solid); box-shadow: var(--shadow); }
.acc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    padding: 20px 22px;
    border: 0;
    background: transparent;
    color: var(--body-color);
    text-align: left;
    cursor: pointer;
}
.acc-title { display: flex; align-items: flex-start; gap: 14px; min-width: 0; }
.acc-number { display: grid; place-items: center; flex: 0 0 auto; width: 34px; height: 34px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-text); font-weight: 800; }
.acc-title strong { display: block; margin-bottom: 4px; color: var(--heading); font-size: 19px; line-height: 1.2; }
.acc-title span { display: block; color: var(--muted); font-size: 14px; }
.acc-icon { display: grid; place-items: center; flex: 0 0 auto; width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 50%; background: var(--surface-muted); color: var(--muted); font-size: 18px; transition: transform .22s ease; }
.acc-item.open .acc-icon { transform: rotate(45deg); color: var(--accent-text); }
.acc-body { display: none; padding: 0 22px 24px; }
.acc-item.open .acc-body { display: block; }

/* Content blocks */
.acc-body h3, .block-example__preview h3 { color: var(--heading); }
.acc-body h3, .editor-preview h3, .block-example__preview h3 {
    margin: 22px 0 8px;
    font-size: 1.12rem;
    line-height: 1.25;
}
.content-link {
    color: var(--accent-text);
    font-weight: 750;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}
.content-link:hover { color: var(--accent); }
.media-block {
    margin: 18px 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-muted);
}
.media-block img,
.media-block video,
.media-image,
.media-video {
    display: block;
    width: 100%;
    max-height: 720px;
    object-fit: contain;
    background: #09110e;
}
.media-block figcaption {
    padding: 10px 14px 12px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: .86rem;
    line-height: 1.4;
}

/* Lazy video player: poster first, video stream only after click */
.media-video-lazy {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 40%, rgba(var(--accent-rgb), .12), transparent 22rem),
        #09110e;
}

.media-video-lazy.has-video {
    min-height: 0;
    max-height: 720px;
    transition: height .36s cubic-bezier(.22, .61, .36, 1);
}

@media (prefers-reduced-motion: reduce) {
    .media-video-lazy.has-video {
        transition: none;
    }
}

.media-block .media-video-lazy {
    min-height: 220px;
}

.media-video-poster {
    display: block;
    width: 100%;
    max-height: 720px;
    object-fit: contain;
    background: #09110e;
}

.media-video-placeholder {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 5px;
    width: 100%;
    min-height: 280px;
    padding: 28px;
    color: rgba(255,255,255,.72);
    text-align: center;
}

.media-video-placeholder span {
    font-size: 1.05rem;
    font-weight: 850;
}

.media-video-placeholder small {
    color: rgba(255,255,255,.48);
    font-size: .78rem;
}

.media-video-play {
    position: absolute;
    inset: 50% auto auto 50%;
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    padding: 0;
    border: 1px solid rgba(255,255,255,.28);
    border-radius: 999px;
    background: rgba(7, 24, 20, .72);
    color: #fff;
    box-shadow: 0 18px 44px rgba(0,0,0,.28);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transform: translate(-50%, -50%);
    cursor: pointer;
    transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}

.media-video-play > span {
    width: 0;
    height: 0;
    margin-left: 5px;
    border-top: 11px solid transparent;
    border-bottom: 11px solid transparent;
    border-left: 17px solid currentColor;
}

.media-video-play:hover,
.media-video-play:focus-visible {
    background: rgba(var(--accent-rgb), .86);
    box-shadow: 0 20px 48px rgba(var(--accent-rgb), .24);
    transform: translate(-50%, -50%) scale(1.06);
}

.media-video-play:focus-visible {
    outline: 3px solid rgba(255,255,255,.48);
    outline-offset: 3px;
}

.media-video-lazy.is-loading::after {
    content: "";
    position: absolute;
    inset: auto 18px 18px auto;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,.25);
    border-top-color: #fff;
    border-radius: 999px;
    animation: media-spin .7s linear infinite;
}

.media-video-lazy > .media-video {
    display: block;
    width: 100%;
    height: 100%;
    max-height: 720px;
    object-fit: contain;
    background: #09110e;
}

@keyframes media-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 620px) {
    .media-video-play {
        width: 60px;
        height: 60px;
    }

    .media-video-play > span {
        border-top-width: 9px;
        border-bottom-width: 9px;
        border-left-width: 14px;
    }

    .media-video-placeholder {
        min-height: 210px;
    }
}
.lead { margin-top: 0; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 16px 0 0; }
.card { padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-muted); }
.card strong { display: block; margin-bottom: 4px; color: var(--heading); }
ul, ol { padding-left: 22px; }
li + li { margin-top: 6px; }
.param-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 16px 0; }
.param { padding: 14px; border: 1px solid var(--border-strong); border-radius: 16px; background: var(--accent-soft); }
.param b { display: block; margin-bottom: 4px; color: var(--accent-text); font-size: 13px; }
.param span { display: block; color: var(--heading); font-weight: 800; font-size: 20px; line-height: 1.2; }
.note, .warn, .danger { margin: 16px 0 0; padding: 14px 16px; border-left: 5px solid; border-radius: 16px; }
.note { border-color: var(--accent); background: var(--accent-soft); }
.warn { border-color: var(--warning-border); background: var(--warning-bg); color: var(--warning-text); }
.danger { border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger-text); }
.flow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
.pill { padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--accent-soft-2); color: var(--accent-text); font-weight: 700; font-size: 14px; }
.arrow { color: var(--muted); font-weight: 900; }
.checklist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; margin-top: 18px; }
.check { display: flex; align-items: flex-start; gap: 10px; padding: 12px 13px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-muted); cursor: pointer; user-select: none; }
.check input { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }
.check.done { opacity: .6; text-decoration: line-through; }

/* Buttons */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: var(--button-radius);
    font-weight: 800;
    letter-spacing: -.01em;
    text-decoration: none;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease, color .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button--primary { background: linear-gradient(135deg, var(--accent), var(--accent-alt)); color: #fff; box-shadow: 0 12px 26px rgba(var(--accent-rgb), .20); }
.button--ghost { border-color: var(--border); background: var(--surface-muted); color: var(--heading); }
.button--ghost:hover { border-color: var(--border-strong); background: var(--accent-soft); color: var(--accent-text); }
.button--light { border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.13); color: #fff; box-shadow: none; }
.button--light:hover { background: rgba(255,255,255,.20); }
.button--danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
.button--small { min-height: 38px; padding: 8px 12px; border-radius: 12px; font-size: .8rem; white-space: nowrap; }

/* Flash / toast notifications */
.flash-stack {
    position: fixed;
    top: 22px;
    right: 22px;
    z-index: 1200;
    display: grid;
    gap: 12px;
    width: min(420px, calc(100vw - 32px));
    pointer-events: none;
}

.flash {
    --toast-accent: var(--accent);
    --toast-accent-rgb: var(--accent-rgb);

    position: relative;
    overflow: hidden;
    width: 100%;
    border: 1px solid rgba(var(--toast-accent-rgb), .24);
    border-radius: 22px;
    background:
        linear-gradient(135deg, rgba(var(--toast-accent-rgb), .16), transparent 58%),
        var(--surface-solid);
    color: var(--body-color);
    box-shadow: 0 18px 45px rgba(2, 8, 23, .18);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    pointer-events: auto;
    animation: flash-in .28s cubic-bezier(.2, .8, .2, 1) both;
    transition: opacity .26s ease, transform .26s ease;
}

.flash__body {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    min-height: 58px;
    padding: 14px 14px 14px 18px;
}

.flash__marker {
    width: 11px;
    height: 11px;
    border-radius: 999px;
    background: var(--toast-accent);
    box-shadow: 0 0 0 6px rgba(var(--toast-accent-rgb), .12);
}

.flash__message {
    min-width: 0;
    color: var(--heading);
    font-size: .94rem;
    font-weight: 700;
    line-height: 1.35;
}

.flash__close {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    opacity: .58;
    cursor: pointer;
    transition: background-color .18s ease, color .18s ease, opacity .18s ease;
}

.flash__close svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

.flash__close:hover,
.flash__close:focus-visible {
    background: rgba(var(--toast-accent-rgb), .12);
    color: var(--heading);
    opacity: .9;
}

.flash__close:focus-visible {
    outline: 2px solid rgba(var(--toast-accent-rgb), .42);
    outline-offset: 2px;
}

.flash--success {
    --toast-accent: #22c55e;
    --toast-accent-rgb: 34, 197, 94;
}

.flash--warning {
    --toast-accent: #f59e0b;
    --toast-accent-rgb: 245, 158, 11;
}

.flash--danger,
.flash--error {
    --toast-accent: #ef4444;
    --toast-accent-rgb: 239, 68, 68;
}

.flash--info,
.flash--message {
    --toast-accent: var(--accent);
    --toast-accent-rgb: var(--accent-rgb);
}

:root[data-bs-theme="dark"] .flash {
    background:
        linear-gradient(135deg, rgba(var(--toast-accent-rgb), .18), transparent 60%),
        rgba(23, 37, 31, .96);
    box-shadow: 0 22px 60px rgba(0, 0, 0, .34);
}

.flash.is-hiding {
    opacity: 0;
    transform: translateX(22px) scale(.98);
    pointer-events: none;
}

@keyframes flash-in {
    from {
        opacity: 0;
        transform: translateX(24px) scale(.98);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@media (max-width: 620px) {
    .flash-stack {
        top: max(12px, env(safe-area-inset-top));
        right: 12px;
        left: 12px;
        width: auto;
        gap: 10px;
    }

    .flash {
        border-radius: 20px;
    }

    .flash__body {
        min-height: 54px;
        padding: 13px 13px 13px 16px;
        gap: 10px;
    }

    .flash__message {
        font-size: .9rem;
    }
}

/* Forms */
.field { display: grid; gap: 6px; }
.field > span, .mini-field { color: var(--muted); font-size: .78rem; font-weight: 800; }
.field input, .field textarea, .field select, .mini-field input {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 13px;
    outline: 0;
    background: var(--input-bg);
    color: var(--body-color);
}
.field input, .field select, .mini-field input { min-height: 44px; padding: 9px 11px; }
.field textarea { padding: 10px 11px; resize: none; overflow: hidden; }
.field input:focus, .field textarea:focus, .field select:focus, .mini-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .10); }

/* Auth */
.auth-page { display: grid; place-items: center; min-height: calc(100vh - 90px); padding: 32px 0 60px; }
.auth-card { width: min(100%, 620px); overflow: hidden; border: 1px solid var(--border); border-radius: 30px; background: var(--surface-solid); box-shadow: var(--shadow); }
.auth-card__hero { padding: 30px; background: linear-gradient(135deg, var(--hero-start), var(--hero-end)); color: #fff; }
.auth-card__hero h1 { margin: 24px 0 6px; font-size: 34px; line-height: 1.1; }
.auth-card__hero p { margin: 0; color: rgba(255,255,255,.75); }
.auth-form { display: grid; gap: 16px; padding: 28px 30px 32px; }

/* Admin list */
.admin-hero__row { position: relative; z-index: 1; display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; }
.admin-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.admin-actions form { margin: 0; }
.admin-page-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 22px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.admin-page-card + .admin-page-card { margin-top: 12px; }
.admin-page-card h2 { margin: 8px 0 3px; color: var(--heading); font-size: 21px; line-height: 1.15; }
.admin-page-card p { margin: 0 0 8px; color: var(--muted); }
.admin-page-card small { color: var(--muted); }
.admin-page-card__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; color: var(--muted); font-size: .76rem; }
.admin-page-card__actions { display: flex; flex: 0 0 auto; gap: 8px; }
.status-badge { padding: 4px 8px; border-radius: 999px; font-weight: 800; }
.status-badge--published { background: var(--success-bg); color: var(--success-text); }
.status-badge--draft { background: var(--warning-bg); color: var(--warning-text); }

/* Visual editor */
.editor-form { padding-top: 18px; }
.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding: 9px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--floating-bg);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
}
.editor-toolbar__left { display: flex; flex-wrap: wrap; gap: 7px; }
.panel-like { padding: 20px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.editor-meta { display: grid; gap: 14px; }
.editor-meta-grid { display: grid; grid-template-columns: 1.2fr 1fr .8fr; gap: 12px; }
.editor-hero { padding-top: 18px; }
.hero-input {
    position: relative;
    z-index: 1;
    display: block;
    width: min(820px, 100%);
    border: 1px solid transparent;
    outline: none;
    background: transparent;
    color: #fff;
    transition: background .18s ease, border-color .18s ease;
}
.hero-input:hover, .hero-input:focus { border-color: var(--editor-overlay-border); background: var(--editor-overlay); }
.hero-input::placeholder { color: rgba(255,255,255,.46); }
.hero-input--title { margin: 14px 0 8px; padding: 4px 8px; border-radius: 12px; font-size: clamp(34px, 5vw, 58px); font-weight: 850; line-height: 1.03; letter-spacing: -.04em; }
.hero-input--subtitle { min-height: 38px; padding: 6px 8px; border-radius: 10px; resize: none; overflow: hidden; font-size: 17px; }
.editor-stat { position: relative; gap: 3px; padding-right: 30px; }
.editor-stat input { width: 100%; min-width: 0; border: 1px solid transparent; outline: none; border-radius: 8px; background: transparent; color: #fff; }
.editor-stat input:hover, .editor-stat input:focus { border-color: var(--editor-overlay-border); background: var(--editor-overlay); }
.editor-stat__value { font-size: 22px; font-weight: 800; }
.editor-stat__label { color: rgba(255,255,255,.74) !important; font-size: 12px; }
.editor-remove { border: 0; border-radius: 10px; background: var(--danger-bg); color: var(--danger-text); font-size: .76rem; font-weight: 800; cursor: pointer; }
.editor-remove--stat { position: absolute; top: 7px; right: 7px; width: 23px; height: 23px; padding: 0; background: rgba(0,0,0,.16); color: rgba(255,255,255,.72); }
.editor-plus { border: 1px dashed var(--border-strong); border-radius: 13px; background: transparent; color: var(--accent-text); font-weight: 800; cursor: pointer; }
.editor-plus:hover { background: var(--accent-soft); }
.editor-plus--hero { position: relative; z-index: 1; margin-top: 8px; padding: 8px 12px; border-color: rgba(255,255,255,.24); color: rgba(255,255,255,.78); }
.editor-plus--hero:hover { background: rgba(255,255,255,.10); }
.editor-plus--menu { width: 100%; margin-top: 8px; padding: 10px; }
.editor-plus--section { width: 100%; margin-top: 14px; padding: 13px; }
.editor-tab-row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 4px; }
.editor-order-tools { display: flex; gap: 2px; opacity: .55; }
.editor-order-tools button, .editor-order, .editor-collapse { display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 8px; background: var(--surface-muted); color: var(--muted); cursor: pointer; }
.editor-panel-intro { position: relative; display: grid; gap: 8px; }
.editor-inline-actions { position: absolute; top: 14px; right: 14px; z-index: 2; }
.editor-heading-input, .editor-intro-input, .editor-section-title, .editor-section-subtitle, .editor-html {
    width: 100%;
    min-width: 0;
    border: 1px solid transparent;
    outline: none;
    background: transparent;
    color: var(--body-color);
}
.editor-heading-input:hover, .editor-heading-input:focus, .editor-intro-input:hover, .editor-intro-input:focus,
.editor-section-title:hover, .editor-section-title:focus, .editor-section-subtitle:hover, .editor-section-subtitle:focus {
    border-color: var(--border);
    background: var(--surface-muted);
}
.editor-heading-input { padding: 2px 8px; border-radius: 10px; color: var(--heading); font-size: 28px; font-weight: 800; line-height: 1.15; }
.editor-intro-input { padding: 5px 8px; border-radius: 9px; resize: none; overflow: hidden; color: var(--muted); }
.mini-field { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.mini-field input { max-width: 260px; min-height: 34px; padding: 5px 8px; font-size: .78rem; }
.editor-acc-item .acc-body { display: block; }
.editor-acc-header { cursor: default; }
.editor-section-headings { flex: 1 1 auto; min-width: 0; }
.editor-section-title { display: block; padding: 2px 6px; border-radius: 8px; color: var(--heading); font-size: 19px; font-weight: 800; }
.editor-section-subtitle { display: block; margin-top: 2px; padding: 2px 6px; border-radius: 8px; resize: none; overflow: hidden; color: var(--muted); font-size: 14px; }
.editor-section-actions { display: flex; flex: 0 0 auto; gap: 4px; }
.editor-section-actions .editor-remove { width: 26px; height: 26px; padding: 0; }
.editor-acc-body { border-top: 1px solid var(--border); padding-top: 18px; }
.editor-acc-item.editor-collapsed .editor-acc-body { display: none !important; }
.editor-content-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; color: var(--muted); font-size: .78rem; font-weight: 800; }
.form-check-line { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.form-check-line input { accent-color: var(--accent); }
.editor-html { display: block; min-height: 130px; padding: 12px; border-color: var(--border); border-radius: 13px; background: var(--input-bg); color: var(--body-color); resize: none; overflow: hidden; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .84rem; line-height: 1.5; }
.editor-html:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .10); }
.editor-preview-label { margin: 16px 0 8px; color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.editor-preview { padding: 16px; border: 1px dashed var(--border-strong); border-radius: 14px; background: var(--surface-muted); }
.editor-preview > :first-child { margin-top: 0; }
.editor-preview > :last-child { margin-bottom: 0; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 0 0 60px; border-color: var(--danger-border); }
.danger-zone strong { color: var(--danger-text); }
.danger-zone p { margin: 3px 0 0; color: var(--muted); }

/* Block reference */
.blocks-toolbar { margin-bottom: 16px; }
.block-reference { display: grid; gap: 16px; }
.block-example { overflow: hidden; border: 1px solid var(--border); border-radius: 22px; background: var(--surface-solid); box-shadow: var(--shadow); }
.block-example__header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.block-example__header h2 { margin: 0; color: var(--heading); font-size: 19px; }
.block-example__preview { padding: 20px; }
.block-example pre { margin: 0; padding: 18px 20px; overflow-x: auto; border-top: 1px solid var(--border); background: var(--surface-muted); color: var(--body-color); font-size: .82rem; line-height: 1.5; }

/* Media library */
.media-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 16px;
}
.media-toolbar__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.media-search {
    display: grid;
    grid-template-columns: auto minmax(160px, 320px) auto auto;
    align-items: center;
    min-height: 42px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-solid);
    box-shadow: var(--shadow-sm);
}
.media-search:focus-within {
    border-color: rgba(var(--accent-rgb), .58);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .09);
}
.media-search__icon {
    display: grid;
    place-items: center;
    width: 38px;
    color: var(--muted);
}
.media-search__icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}
.media-search input {
    min-width: 0;
    height: 40px;
    padding: 0 6px 0 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--body-color);
    font: inherit;
    font-size: .86rem;
}
.media-search input::-webkit-search-cancel-button { display: none; }
.media-search__reset {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 1.25rem;
    line-height: 1;
    text-decoration: none;
}
.media-search__reset:hover { background: var(--surface-muted); color: var(--heading); }
.media-search__submit {
    align-self: stretch;
    padding: 0 15px;
    border: 0;
    border-left: 1px solid var(--border);
    background: var(--accent-soft);
    color: var(--accent-text);
    font: inherit;
    font-size: .8rem;
    font-weight: 850;
    cursor: pointer;
}
.media-search__submit:hover { background: rgba(var(--accent-rgb), .18); }
@media (max-width: 760px) {
    .media-toolbar { align-items: stretch; flex-direction: column; }
    .media-toolbar__actions { width: 100%; }
    .media-search { width: 100%; grid-template-columns: auto minmax(0, 1fr) auto auto; }
}
.blocks-media-note { margin: 0 0 16px; }
.blocks-media-note code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.media-upload { margin-bottom: 18px; }
.media-section-heading h2 { margin: 0; color: var(--heading); font-size: 22px; }
.media-section-heading p { margin: 4px 0 0; color: var(--muted); }
.media-upload-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
    margin-top: 16px;
}

.media-dropzone {
    position: relative;
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    min-height: 164px;
    padding: 24px;
    overflow: hidden;
    border: 1px dashed rgba(var(--accent-rgb), .42);
    border-radius: 20px;
    background:
        radial-gradient(circle at 18% 20%, rgba(var(--accent-rgb), .10), transparent 18rem),
        var(--surface-muted);
    color: var(--body-color);
    text-align: left;
    cursor: pointer;
    transition:
        border-color .18s ease,
        background-color .18s ease,
        box-shadow .18s ease,
        transform .18s ease;
}

.media-dropzone:hover,
.media-dropzone:focus-within,
.media-dropzone.is-dragover {
    border-color: rgba(var(--accent-rgb), .78);
    background:
        radial-gradient(circle at 18% 20%, rgba(var(--accent-rgb), .16), transparent 18rem),
        var(--surface-muted);
    box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .08);
}

.media-dropzone.is-dragover {
    transform: translateY(-1px);
}

.media-dropzone.has-file {
    border-style: solid;
    border-color: rgba(var(--accent-rgb), .52);
}

.media-dropzone__input {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.media-dropzone__icon {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 62px;
    height: 62px;
    border-radius: 21px;
    background: var(--accent-soft);
    color: var(--accent);
    box-shadow: 0 12px 28px rgba(var(--accent-rgb), .12);
}

.media-dropzone__icon svg {
    width: 29px;
    height: 29px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.media-dropzone__copy {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 5px;
    min-width: 0;
    max-width: 620px;
}

.media-dropzone__copy strong {
    color: var(--heading);
    font-size: 1.02rem;
    line-height: 1.25;
}

.media-dropzone__copy > span:not(.media-dropzone__filename) {
    color: var(--muted);
    font-size: .86rem;
}

.media-dropzone__filename {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    margin-top: 5px;
    padding: 7px 10px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-solid);
    color: var(--muted);
    font-size: .79rem;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-dropzone.has-file .media-dropzone__filename {
    border-color: rgba(var(--accent-rgb), .28);
    background: var(--accent-soft);
    color: var(--accent-text);
}

.media-poster-upload {
    grid-column: 1 / -1;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-muted);
}

.media-poster-upload[hidden] {
    display: none !important;
}

.media-poster-upload__head {
    margin-bottom: 10px;
}

.media-poster-upload__head strong,
.media-poster-upload__head span {
    display: block;
}

.media-poster-upload__head strong {
    color: var(--heading);
    font-size: .9rem;
}

.media-poster-upload__head span {
    margin-top: 3px;
    color: var(--muted);
    font-size: .8rem;
    line-height: 1.4;
}

.media-poster-dropzone {
    position: relative;
    display: flex;
    align-items: center;
    gap: 13px;
    min-height: 92px;
    padding: 12px;
    overflow: hidden;
    border: 1px dashed rgba(var(--accent-rgb), .36);
    border-radius: 16px;
    background: var(--surface-solid);
    cursor: pointer;
}

.media-poster-dropzone:hover,
.media-poster-dropzone:focus-within {
    border-color: rgba(var(--accent-rgb), .72);
    background: var(--accent-soft);
}

.media-poster-dropzone__input {
    position: absolute;
    inset: 0;
    z-index: 3;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.media-poster-dropzone__preview {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 112px;
    height: 72px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #09110e;
    color: rgba(255,255,255,.55);
}

.media-poster-dropzone__preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-poster-dropzone__preview svg {
    width: 30px;
    height: 30px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.media-poster-dropzone__copy {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 4px;
    min-width: 0;
}

.media-poster-dropzone__copy strong {
    color: var(--heading);
    font-size: .9rem;
}

.media-poster-dropzone__copy span {
    color: var(--muted);
    font-size: .78rem;
    overflow-wrap: anywhere;
}

.media-poster-editor {
    grid-column: 1 / -1;
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-solid);
}

.media-poster-editor__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.media-poster-editor__head strong,
.media-poster-editor__head span {
    display: block;
}

.media-poster-editor__head strong {
    color: var(--heading);
    font-size: .9rem;
}

.media-poster-editor__head > div > span {
    margin-top: 3px;
    color: var(--muted);
    font-size: .78rem;
    line-height: 1.4;
}

.media-poster-status {
    flex: 0 0 auto;
    min-height: 27px;
    padding: 5px 9px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: .7rem;
    font-weight: 850;
    white-space: nowrap;
}

.media-poster-status--muted {
    background: var(--surface-muted);
    color: var(--muted);
}

.media-poster-edit-dropzone {
    position: relative;
    display: grid;
    grid-template-columns: 128px minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    min-height: 96px;
    padding: 10px 12px 10px 10px;
    overflow: hidden;
    border: 1px dashed rgba(var(--accent-rgb), .34);
    border-radius: 16px;
    background:
        radial-gradient(circle at 5% 50%, rgba(var(--accent-rgb), .08), transparent 13rem),
        var(--surface-muted);
    cursor: pointer;
    transition:
        border-color .18s ease,
        background-color .18s ease,
        box-shadow .18s ease,
        transform .18s ease;
}

.media-poster-edit-dropzone:hover,
.media-poster-edit-dropzone:focus-within,
.media-poster-edit-dropzone.is-dragover {
    border-color: rgba(var(--accent-rgb), .72);
    background:
        radial-gradient(circle at 5% 50%, rgba(var(--accent-rgb), .14), transparent 13rem),
        var(--surface-muted);
    box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .07);
}

.media-poster-edit-dropzone.is-dragover {
    transform: translateY(-1px);
}

.media-poster-edit-dropzone.has-file {
    border-style: solid;
    border-color: rgba(var(--accent-rgb), .52);
}

.media-poster-edit-dropzone__input {
    position: absolute;
    inset: 0;
    z-index: 4;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.media-poster-edit-dropzone__preview {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 128px;
    height: 76px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: #09110e;
    color: rgba(255,255,255,.52);
    box-shadow: 0 8px 22px rgba(0,0,0,.10);
}

.media-poster-edit-dropzone__preview > *,
.media-poster-dropzone__preview > * {
    grid-area: 1 / 1;
}

.media-poster-edit-dropzone__preview img[hidden],
.media-poster-edit-dropzone__preview svg[hidden],
.media-poster-dropzone__preview img[hidden],
.media-poster-dropzone__preview svg[hidden] {
    display: none !important;
}

.media-poster-edit-dropzone__preview img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-poster-edit-dropzone__preview svg {
    width: 31px;
    height: 31px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.media-poster-edit-dropzone__copy {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 4px;
    min-width: 0;
}

.media-poster-edit-dropzone__copy strong {
    color: var(--heading);
    font-size: .88rem;
    line-height: 1.25;
}

.media-poster-edit-dropzone__copy span {
    min-width: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: .76rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-poster-edit-dropzone.has-file .media-poster-edit-dropzone__copy span {
    color: var(--accent-text);
}

.media-poster-edit-dropzone__action {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 11px;
    border: 1px solid var(--border-strong);
    border-radius: 11px;
    background: var(--surface-solid);
    color: var(--accent-text);
    font-size: .74rem;
    font-weight: 850;
    white-space: nowrap;
}

.media-poster-remove-card {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-height: 54px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-muted);
    color: var(--muted);
    cursor: pointer;
    transition: border-color .18s ease, background-color .18s ease;
}

.media-poster-remove-card:hover,
.media-poster-remove-card:focus-within {
    border-color: rgba(239,68,68,.30);
    background: rgba(239,68,68,.055);
}

.media-poster-remove-card:has(input:checked) {
    border-color: rgba(239,68,68,.46);
    background: rgba(239,68,68,.09);
}

.media-poster-remove-card input {
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: #ef4444;
}

.media-poster-remove-card__icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 11px;
    background: rgba(239,68,68,.09);
    color: #dc5454;
}

.media-poster-remove-card__icon svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.media-poster-remove-card strong,
.media-poster-remove-card small {
    display: block;
}

.media-poster-remove-card strong {
    color: var(--heading);
    font-size: .78rem;
}

.media-poster-remove-card small {
    margin-top: 2px;
    color: var(--muted);
    font-size: .71rem;
    line-height: 1.35;
}

.media-card__preview .media-video-lazy {
    height: 100%;
    min-height: 280px;
}

.media-card__preview .media-video-poster {
    height: 100%;
    max-height: 520px;
}

@media (max-width: 620px) {
    .media-poster-dropzone {
        align-items: stretch;
        flex-direction: column;
    }

    .media-poster-dropzone__preview {
        width: 100%;
        height: 150px;
    }

    .media-poster-editor__head {
        align-items: stretch;
        flex-direction: column;
    }

    .media-poster-status {
        width: fit-content;
    }

    .media-poster-edit-dropzone {
        grid-template-columns: 1fr;
        padding: 10px;
    }

    .media-poster-edit-dropzone__preview {
        width: 100%;
        height: 160px;
    }

    .media-poster-edit-dropzone__action {
        width: 100%;
    }

    .media-poster-remove-card {
        grid-template-columns: auto auto minmax(0, 1fr);
    }
}

.media-library { display: grid; gap: 18px; padding-bottom: 60px; }
.media-card {
    display: grid;
    grid-template-columns: minmax(250px, 360px) minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--surface-solid);
    box-shadow: var(--shadow);
}
.media-card__preview { display: grid; place-items: center; min-height: 280px; background: #0b1511; }
.media-card__preview img,
.media-card__preview video { display: block; width: 100%; height: 100%; max-height: 520px; object-fit: contain; }
.media-card__body { display: grid; gap: 14px; min-width: 0; padding: 20px; }
.media-card__topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.media-card__topline h2 { margin: 7px 0 0; color: var(--heading); font-size: 21px; line-height: 1.2; overflow-wrap: anywhere; }
.media-type-badge, .media-id {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 9px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: .72rem;
    font-weight: 850;
}
.media-id { flex: 0 0 auto; background: var(--surface-muted); color: var(--muted); }
.media-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--muted); font-size: .78rem; }
.media-meta-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; padding: 12px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-muted); }
.media-code-block { overflow: hidden; border: 1px solid var(--border); border-radius: 16px; }
.media-code-block__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-muted); }
.media-code-block__head strong { color: var(--heading); font-size: .84rem; }
.media-code {
    display: block;
    width: 100%;
    min-height: 152px;
    margin: 0;
    padding: 13px;
    border: 0;
    outline: 0;
    resize: vertical;
    background: var(--input-bg);
    color: var(--body-color);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .78rem;
    line-height: 1.45;
}
.media-usages { padding: 13px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-muted); }
.media-usages__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--heading); }
.media-usages__head span { display: grid; place-items: center; min-width: 26px; height: 26px; padding: 0 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: .75rem; font-weight: 850; }
.media-usages p { margin: 8px 0 0; color: var(--muted); font-size: .86rem; }
.media-usages ul { display: grid; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.media-usages li { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0; padding: 9px 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-solid); }
.media-usages li strong { display: block; color: var(--heading); font-size: .86rem; }
.media-usages li span { display: block; margin-top: 2px; color: var(--muted); font-size: .76rem; }
.media-usage-actions { display: flex; flex: 0 0 auto; gap: 8px; }
.media-usage-actions a { color: var(--accent-text); font-size: .76rem; font-weight: 800; }
.media-card__footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.media-card__footer form { margin: 0; }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }

@media (max-width: 920px) {
    .media-upload-form { grid-template-columns: 1fr 1fr; }
    .media-upload-form > .button { grid-column: 1 / -1; align-self: stretch; }
    .media-card { grid-template-columns: 1fr; }
    .media-card__preview { min-height: 220px; max-height: 460px; }
}

@media (max-width: 620px) {
    .media-upload-form, .media-meta-form { grid-template-columns: 1fr; }
    .media-dropzone {
        align-items: center;
        flex-direction: column;
        min-height: 190px;
        padding: 22px 16px;
        text-align: center;
    }
    .media-dropzone__copy { justify-items: center; }
    .media-dropzone__filename { width: 100%; justify-content: center; }
    .media-card__body { padding: 14px; }
    .media-card__topline, .media-usages li, .media-card__footer { align-items: stretch; flex-direction: column; }
    .media-usage-actions { flex-wrap: wrap; }
    .media-card__footer .button, .media-card__footer form, .media-card__footer form .button { width: 100%; }
}

/* Errors and empty states */
.empty-state { padding: 30px; border: 1px solid var(--border); border-radius: 22px; background: var(--surface); text-align: center; box-shadow: var(--shadow); }
.empty-state h2, .empty-state h3 { margin: 0 0 6px; color: var(--heading); }
.empty-state p { margin: 0; color: var(--muted); }
.error-page { display: grid; place-items: center; min-height: calc(100vh - 120px); padding: 32px 0; }
.error-card { position: relative; width: min(100%, 720px); overflow: hidden; padding: clamp(28px, 6vw, 54px); border-radius: 32px; background: linear-gradient(135deg, var(--hero-start), var(--hero-end)); color: #fff; box-shadow: var(--shadow); }
.error-card::before { content: ""; position: absolute; top: -120px; right: -130px; width: 340px; height: 340px; border-radius: 50%; background: rgba(255,255,255,.08); }
.error-code { position: relative; z-index: 1; margin-top: 42px; color: rgba(255,255,255,.18); font-size: clamp(82px,18vw,150px); font-weight: 900; line-height: .8; letter-spacing: -.07em; }
.error-card h1 { position: relative; z-index: 1; margin: 28px 0 10px; font-size: clamp(28px,5vw,42px); line-height: 1.1; }
.error-card p { position: relative; z-index: 1; max-width: 580px; margin: 0 0 28px; color: rgba(255,255,255,.76); }

/* Floating tools */
.floating-tools {
    position: fixed;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 7px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--floating-bg);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}
.floating-tool { display: flex; align-items: center; justify-content: center; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 13px; background: transparent; color: var(--muted); text-decoration: none; cursor: pointer; transition: background-color .18s ease, color .18s ease, transform .18s ease; }
.floating-tools--left {
    right: auto;
    left: max(18px, env(safe-area-inset-left));
}

.floating-tool:hover { background: rgba(var(--accent-rgb), .12); color: var(--accent); }
.floating-tool:active { transform: scale(.92); }
.floating-tool:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.floating-tool__icon { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-icon--sun { display: none; }
[data-bs-theme="dark"] .theme-icon--moon { display: none; }
[data-bs-theme="dark"] .theme-icon--sun { display: block; }

.footer { padding: 0 0 44px; color: var(--muted); text-align: center; font-size: 13px; }
.footer a { font-weight: 700; }

@media (max-width: 920px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { position: relative; top: 0; display: flex; gap: 8px; overflow-x: auto; padding: 10px; }
    .sidebar h2 { display: none; }
    .sidebar hr { display: none; }
    .tab-btn { flex: 0 0 auto; width: auto; white-space: nowrap; background: var(--surface-muted); padding: 11px 14px; }
    .editor-sidebar { display: block; overflow: visible; }
    .editor-sidebar .tab-btn { width: 100%; white-space: normal; }
    .quick-stats, .param-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .page-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .admin-hero__row, .admin-page-card { align-items: flex-start; flex-direction: column; }
    .admin-actions { justify-content: flex-start; }
    .editor-meta-grid { grid-template-columns: 1fr 1fr; }
    .editor-meta-grid .field:last-child { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
    .flash-stack {
        top: 10px;
        right: 10px;
        width: calc(100vw - 20px);
    }

    .flash {
        padding: 13px 15px 13px 17px;
        border-radius: 14px;
        font-size: .86rem;
    }

    .app-shell { width: min(100% - 18px, 1180px); }
    .hero { padding-top: 18px; }
    .hero-card { padding: 24px; border-radius: 24px; }
    .hero h1 { font-size: 38px; }
    .quick-stats, .grid, .param-grid, .checklist, .page-grid { grid-template-columns: 1fr; }
    .panel-intro, .acc-item { border-radius: 18px; }
    .acc-header { padding: 18px; }
    .acc-body { padding: 0 18px 20px; }
    .floating-tools { right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); gap: 6px; padding: 6px; border-radius: 16px; }
    .floating-tools--left { right: auto; left: max(10px, env(safe-area-inset-left)); }
    .floating-tool { width: 40px; height: 40px; border-radius: 12px; }
    .editor-toolbar { align-items: stretch; flex-direction: column; }
    .editor-toolbar > .button { width: 100%; }
    .editor-meta-grid { grid-template-columns: 1fr; }
    .editor-meta-grid .field:last-child { grid-column: auto; }
    .editor-section-actions { flex-wrap: wrap; justify-content: flex-end; }
    .admin-page-card__actions { width: 100%; }
    .admin-page-card__actions .button { flex: 1 1 auto; }
    .danger-zone { align-items: stretch; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
    .flash { animation: none; }
    .flash.is-hiding { transform: none; }
}

@media print {
    body { background: #fff; color: #16231f; }
    .sidebar, .floating-tools, .footer, .flash-stack, .editor-toolbar { display: none !important; }
    .layout { display: block; }
    .tab-panel { display: block !important; margin-top: 14px; }
    .acc-body { display: block !important; }
    .panel-intro, .acc-item, .hero-card { border: 0 !important; box-shadow: none; }
    .panel-intro, .acc-header, .acc-body, .hero-card { padding-left: 0 !important; padding-right: 0 !important; }
    .hero { padding: 0 !important; }
    .hero-card, .hero-card p { background: #fff !important; color: #16231f !important; padding: 0 !important; border-radius: 0 !important; }
    .hero-card::before, .quick-stats { display: none !important; }
    .app-brand-title { color: #16231f; }
    .app-brand-subtitle { color: #697771; }
}
