/* Flashcard pages. Loaded after app.css. */
html { --fc-study-scale: 1; }
html[data-fc-study-font="s"] { --fc-study-scale: 0.84; }
html[data-fc-study-font="m"] { --fc-study-scale: 1; }
html[data-fc-study-font="l"] { --fc-study-scale: 1.2; }
html[data-fc-study-font="xl"] { --fc-study-scale: 1.42; }
.back-to-set {
    display: inline-flex;
    align-items: center;
    margin-bottom: 0.75rem;
    color: var(--teal-text);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}
.back-to-set:hover { color: var(--teal); text-decoration: underline; }
.set-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.15rem;
    align-items: center;
    margin-bottom: 0.75rem;
}
.set-nav .back-to-set { margin-bottom: 0; }
.set-page-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
    width: 100%;
}
.set-page-bar-left { min-width: 0; }
.set-page-bar-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: auto;
    flex: 0 0 auto;
    position: relative;
    z-index: 6;
}
.set-page-bar .set-page-library {
    flex: 0 0 auto;
}
.icon-tip {
    position: absolute;
    left: 50%;
    top: calc(100% + 0.45rem);
    transform: translateX(-50%) translateY(4px);
    width: max-content;
    max-width: 12.5rem;
    padding: 0.4rem 0.65rem;
    border-radius: var(--r-md);
    background: var(--ink);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.35;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    z-index: 5;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
    transition: opacity 0.16s ease, transform 0.16s ease;
}
.icon-btn:hover .icon-tip,
.icon-btn:focus-visible .icon-tip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.set-page-bar-actions .icon-btn:last-child .icon-tip {
    left: auto;
    right: 0;
    transform: translateY(4px);
}
.set-page-bar-actions .icon-btn:last-child:hover .icon-tip,
.set-page-bar-actions .icon-btn:last-child:focus-visible .icon-tip {
    transform: translateY(0);
}
html.night .icon-tip {
    background: #171717;
    color: #f4f4f1;
}
.panel {
    background: var(--glass);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--r-xl);
    padding: clamp(1.1rem, 2.5vw, 1.4rem) clamp(1rem, 2.5vw, 1.35rem);
    margin-bottom: 1rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.05);
}
h1 {
    font-family: var(--font-ui);
    font-weight: 650;
    font-size: clamp(1.55rem, 3vw, 1.95rem);
    letter-spacing: -0.02em;
    margin-bottom: 0.3rem;
    color: var(--ink);
}
.sub {
    color: var(--ink-soft);
    font-size: 0.96rem;
    line-height: 1.5;
    max-width: 46ch;
}
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem 1.1rem;
    align-items: end;
    margin-top: 1rem;
}
.field { display: grid; gap: 0.35rem; }
label {
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-soft);
}
select, input[type="text"], input[type="number"], textarea {
    appearance: none;
    background: var(--card);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 0.65rem 0.9rem;
    font: inherit;
    font-weight: 500;
}
select {
    padding-right: 2.3rem;
    min-width: 11rem;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23171717' d='M1.4.3 6 4.9 10.6.3 12 1.7 6 7.7 0 1.7z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
}
textarea { min-height: 5rem; resize: vertical; width: 100%; }
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--teal); }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.55rem; justify-content: center; }
button, .btn {
    font: inherit;
    font-weight: 600;
    font-size: 0.92rem;
    border-radius: var(--r-md);
    padding: 0.7rem 1.05rem;
    cursor: pointer;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
button[hidden], .btn[hidden] {
    display: none !important;
}
button.primary, .btn.primary {
    background: var(--teal);
    border-color: var(--teal);
    color: #fff;
}
button.danger, .btn.danger {
    color: var(--bad);
    border-color: rgba(180, 35, 24, 0.28);
    background: rgba(180, 35, 24, 0.06);
}
button.danger:hover, .btn.danger:hover {
    border-color: var(--bad);
    background: rgba(180, 35, 24, 0.12);
}
button:hover, .btn:hover { transform: translateY(-1px); border-color: var(--teal); }
button.primary:hover, .btn.primary:hover { background: var(--teal-deep); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
button.icon-btn,
.btn.icon-btn {
    position: relative;
    width: 2.45rem;
    height: 2.45rem;
    min-width: 2.45rem;
    min-height: 2.45rem;
    padding: 0.4rem;
    border-radius: var(--r-md);
    gap: 0;
    box-sizing: border-box;
}
button.icon-btn svg,
.btn.icon-btn svg {
    width: 1.5rem;
    height: 1.5rem;
    flex: none;
    display: block;
    overflow: visible;
}
.chip {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ink-soft);
    background: rgba(255,255,255,0.7);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    padding: 0.28rem 0.65rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    max-width: 100%;
}
.deck-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.deck-card {
    background: linear-gradient(165deg, rgba(255,255,255,0.9), rgba(255, 255, 255, 0.75));
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 0.55rem 0.65rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-height: 0;
}
.deck-card.is-folder-card {
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.95), rgba(240, 240, 236, 0.78));
}
.deck-card.is-folder-card .chip {
    background: color-mix(in srgb, var(--teal) 12%, transparent);
    color: var(--teal-text);
}
.deck-card-main {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}
.deck-card-top {
    display: flex;
    justify-content: space-between;
    gap: 0.45rem;
    align-items: flex-start;
}
.deck-card h3 {
    font-family: var(--font-ui);
    font-size: 0.98rem;
    font-weight: 650;
    line-height: 1.2;
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
}
.deck-card h3 a {
    color: var(--ink);
    text-decoration: none;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
}
.deck-card h3 a:hover { color: var(--teal); }
.deck-card .chip {
    font-size: 0.7rem;
    padding: 0.18rem 0.45rem;
    flex: 0 0 auto;
}
.deck-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 0.55rem;
    font-size: 0.72rem;
    color: var(--ink-soft);
    line-height: 1.3;
}
.deck-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    margin-top: auto;
    min-height: 1.9rem;
}
.deck-actions .btn,
.deck-actions button {
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
    border-radius: 8px;
}
.deck-actions form { display: inline; }
.deck-actions .primary.is-saved,
.set-head-actions .primary.is-saved {
    cursor: pointer;
}
.home-tile.is-saved-folder .home-tile-badge {
    font-size: 0.68rem;
    color: var(--ink-soft);
}
.home-tile.has-tile-actions {
    cursor: default;
}
.home-tile.has-tile-actions .home-tile-body {
    cursor: pointer;
}
.home-tile.has-tile-actions .home-tile-copy {
    position: absolute;
    right: 0.4rem;
    bottom: 0.4rem;
    z-index: 3;
    width: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.22rem;
}
.home-tile.has-tile-actions .home-tile-copy form {
    display: block;
    margin: 0;
}
.home-tile.has-tile-actions .home-tile-copy .btn,
.home-tile.has-tile-actions .home-tile-copy button {
    width: auto;
    padding: 0.28rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 650;
    border-radius: 8px;
}
.home-tile.has-tile-actions .home-tile-copy .btn {
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
html.night .home-tile.has-tile-actions .home-tile-copy .btn {
    background: rgba(30, 30, 30, 0.96);
}
.library-segment-bar {
    display: flex;
    justify-content: center;
    flex: 0 0 auto;
    padding: 0.85rem 1rem 0.25rem;
}
.library-segment-bar-page {
    padding: 0 0 1rem;
}
.library-segment-bar-page .library-segment-bar {
    padding: 0 0 1rem;
}
.library-segmented {
    position: relative;
    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    gap: 0;
    padding: 3px;
    border-radius: var(--r-pill);
    background: rgba(0, 0, 0, 0.08);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}
.library-segment-thumb {
    position: absolute;
    top: 3px;
    bottom: 3px;
    left: 3px;
    width: calc((100% - 6px) / 2);
    border-radius: var(--r-pill);
    background: var(--card);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
    transform: translateX(0);
    transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
    z-index: 0;
}
.library-segmented[data-active="shared"] .library-segment-thumb {
    transform: translateX(100%);
}
html[dir="rtl"] .library-segmented[data-active="shared"] .library-segment-thumb {
    transform: translateX(-100%);
}
.library-segment {
    position: relative;
    z-index: 1;
    appearance: none;
    font: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--ink-soft);
    background: transparent;
    border: 0;
    border-radius: var(--r-pill);
    padding: 0.48rem 1.2rem;
    text-align: center;
    justify-content: center;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.2;
    cursor: pointer;
    transition: color 0.18s ease;
}
.library-segment:hover {
    color: var(--ink);
    background: transparent;
    transform: none;
}
.library-segment.is-active {
    color: var(--ink);
    background: transparent;
    box-shadow: none;
    cursor: default;
}
.library-segment.is-active:hover {
    background: transparent;
}
.library-screen.is-public-browse {
    padding-bottom: max(0.85rem, env(safe-area-inset-bottom));
}
.library-screen.is-public-browse .library-screen-bar {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    margin-bottom: 0.35rem;
}
.library-screen.is-public-browse .library-screen-body,
.library-screen.is-public-browse .public-browse-body {
    overflow: visible;
}
.public-browse-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 0.55rem;
}
.public-search-panel {
    flex: 0 0 auto;
    width: 100%;
    margin: 0;
    padding: 0.15rem 0.15rem 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    backdrop-filter: none;
    box-shadow: none;
}
.search-pill {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 0.35rem;
    padding: 0.22rem 0.22rem 0.22rem 0.3rem;
    background: linear-gradient(165deg, rgba(255,255,255,0.96), rgba(255,255,255,0.82));
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.search-pill.is-hero {
    padding: 0.28rem 0.85rem 0.28rem 0.35rem;
}
.search-pill input[type="search"] {
    flex: 1 1 auto;
    min-width: 0;
    height: 2.35rem;
    margin: 0;
    padding: 0 0.95rem;
    border: 0;
    border-radius: var(--r-pill);
    background: transparent;
    box-shadow: none;
    font-size: 0.98rem;
    font-weight: 500;
}
.search-pill.is-hero input[type="search"] {
    height: 2.55rem;
    font-size: 1.02rem;
}
.search-pill input[type="search"]:focus {
    outline: none;
    border-color: transparent;
}
.search-pill input[type="search"]::-webkit-search-decoration,
.search-pill input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
}
.search-pill > button.primary,
.search-pill > .primary {
    flex: 0 0 auto;
    height: 2.35rem;
    padding: 0 1.05rem;
    border-radius: var(--r-pill);
    font-size: 0.88rem;
    font-weight: 650;
    white-space: nowrap;
}
.search-pill.is-hero > button.primary,
.search-pill.is-hero > .primary {
    height: 2.55rem;
    padding: 0 1.2rem;
}
.public-search-form {
    display: grid;
    gap: 0.65rem;
}
.public-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.55rem;
    overflow: visible;
}
.public-sort-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    min-width: 0;
}
.public-filter-chip {
    text-decoration: none;
    color: var(--ink-soft);
    background: rgba(255, 255, 255, 0.55);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
a.public-filter-chip:hover,
.public-lang-chip:hover {
    color: var(--ink);
    border-color: color-mix(in srgb, var(--teal) 28%, var(--line));
}
.public-filter-chip.is-active {
    color: var(--teal-text);
    background: color-mix(in srgb, var(--teal) 14%, transparent);
    border-color: color-mix(in srgb, var(--teal) 35%, var(--line));
}
.public-lang-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-inline-start: auto;
    overflow: visible;
}
.public-lang-pair {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}
.public-lang-arrow {
    flex: 0 0 auto;
    color: var(--ink-soft);
    font-size: 0.92rem;
    line-height: 1;
    pointer-events: none;
    user-select: none;
}
.public-lang-chip {
    display: inline-flex;
    align-items: stretch;
    gap: 0.35rem;
    margin: 0;
    min-height: 2rem;
    min-width: 0;
    max-width: 100%;
    overflow: visible;
    cursor: pointer;
    touch-action: manipulation;
}
.public-lang-chip .mlh-select {
    flex: 1 1 auto;
    min-width: 4.5rem;
    max-width: 11rem;
    display: flex;
    align-items: stretch;
    align-self: stretch;
    z-index: 1;
}
.public-lang-chip .mlh-select.is-open {
    z-index: 80;
}
.public-lang-chip .mlh-select-btn {
    flex: 1;
    width: 100%;
    min-width: 0;
    min-height: 100%;
    padding: 0.28rem 0.15rem 0.28rem 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    gap: 0.4rem;
    box-shadow: none;
    touch-action: manipulation;
}
.public-lang-chip .mlh-select-btn:hover,
.public-lang-chip .mlh-select-btn:focus-visible,
.public-lang-chip .mlh-select.is-open .mlh-select-btn {
    border: 0;
    background: transparent;
    box-shadow: none;
    color: inherit;
    transform: none;
}
.public-lang-chip.is-active,
.public-lang-chip:has(.mlh-select.is-open) {
    color: var(--teal-text);
    background: color-mix(in srgb, var(--teal) 14%, transparent);
    border-color: color-mix(in srgb, var(--teal) 35%, var(--line));
}
.public-lang-chip .mlh-select-btn::after {
    width: 0.38rem;
    height: 0.38rem;
    opacity: 0.7;
    flex-shrink: 0;
}
.public-lang-chip .mlh-select-menu {
    min-width: 12rem;
}
.public-search-panel,
.public-browse-body {
    overflow: visible;
}
.public-guest-note {
    margin: 0.15rem 0.15rem 0;
    font-size: 0.86rem;
}
.public-browse-body > .library-scope.public-results,
.library-screen-body .library-scope.public-results {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0.15rem 0.15rem 0.5rem;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}
.public-results .empty-state { margin-top: 0.35rem; }
.public-deck-grid.deck-grid {
    margin-top: 0.15rem;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.5rem), 1fr));
    gap: 0.65rem;
}
@media (max-width: 36rem) {
    .public-lang-filters {
        margin-inline-start: 0;
        width: 100%;
    }
    .public-lang-chip {
        flex: 1 1 calc(50% - 0.2rem);
        min-width: 0;
    }
    .public-lang-chip .mlh-select {
        max-width: none;
        min-width: 0;
    }
    .search-pill.is-hero input[type="search"] {
        font-size: 0.95rem;
    }
}
.public-deck-grid .deck-card {
    min-height: 7.25rem;
    padding: 0.7rem 0.75rem 0.65rem;
    border-radius: var(--r-xl);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.04);
}
.public-deck-grid .deck-card h3 {
    font-size: 1.02rem;
}
.public-deck-grid .deck-meta {
    font-size: 0.76rem;
    gap: 0.25rem 0.65rem;
}
.public-tile-link {
    text-decoration: none;
    color: inherit;
    min-height: 0;
}
.public-tile-link:hover .home-tile-title {
    color: var(--teal);
}
.public-tile-actions {
    flex: 0 0 auto;
    margin-top: auto;
    width: 100%;
    min-width: 0;
}
.public-tile-actions form {
    display: block;
    margin: 0;
}
.public-tile-actions .btn,
.public-tile-actions button {
    width: 100%;
    padding: 0.35rem 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 8px;
}
.library-tab-bar-wrap { margin-bottom: 0; }
.panel.has-tabs {
    padding-top: 0.85rem;
}
.library-screen {
    width: 100%;
    height: 100%;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: clamp(0.75rem, 2vw, 1.25rem);
    padding-bottom: max(clamp(0.75rem, 2vw, 1.25rem), env(safe-area-inset-bottom));
    box-sizing: border-box;
}
.library-screen:has(> .library-screen-bar > .library-segment-bar):has(.library-screen-actions) {
    container-type: inline-size;
    container-name: library-chrome;
}
.library-screen-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(min-content, 1fr);
    align-items: center;
    column-gap: 0.85rem;
    row-gap: 0.4rem;
    flex: 0 0 auto;
    margin-bottom: 0.55rem;
    min-width: 0;
}
.library-screen-heading {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    min-width: 0;
    grid-column: 1;
    grid-row: 1;
}
.library-screen-bar > .library-segment-bar {
    grid-column: 2;
    grid-row: 1;
    justify-content: center;
    padding: 0;
}
.library-screen-actions,
.library-screen-bar > .create-bar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
    flex: 0 0 auto;
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    min-width: 0;
    max-width: 100%;
}
.library-screen-actions > .btn {
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}
.library-screen-bar h1 {
    margin: 0;
    flex: 0 0 auto;
    line-height: 1.15;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.library-screen-bar > .sub,
.library-screen-heading .sub {
    margin: 0;
    max-width: 62ch;
    font-size: 0.9rem;
    line-height: 1.4;
}
.library-screen-bar > .sub {
    grid-column: 1 / -1;
    grid-row: 2;
}
@media (min-width: 861px) {
    .library-screen-bar > .sub,
    .library-screen-heading .sub {
        max-width: min(100%, 92ch);
    }
}
@media (max-width: 720px) {
    .library-screen-bar {
        grid-template-columns: minmax(0, 1fr) auto;
    }
    .library-screen-bar > .library-segment-bar {
        grid-column: 1 / -1;
        grid-row: 2;
    }
    .library-screen-actions,
    .library-screen-bar > .create-bar-actions {
        grid-column: 2;
        grid-row: 1;
    }
    .library-screen-bar > .sub {
        grid-row: 3;
    }
}
/* Librarian (and any other squeeze of the library column) is not a viewport
   shrink — reuse the same narrow chrome once the screen itself is ≤720. */
@container library-chrome (max-width: 720px) {
    .library-screen-bar {
        grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
        overflow-x: clip;
    }
    .library-screen-bar > .library-segment-bar {
        grid-column: 1 / -1;
        grid-row: 2;
        min-width: 0;
        max-width: 100%;
    }
    .library-screen-bar > .library-segment-bar .library-segmented {
        min-width: 0;
        max-width: 100%;
    }
    .library-screen-bar > .library-segment-bar .library-segment {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .library-screen-actions {
        grid-column: 2;
        grid-row: 1;
        justify-content: flex-end;
    }
    .library-screen-actions > .btn {
        min-width: 0;
    }
    .library-screen-actions:has([data-new-folder]) > .icon-btn {
        min-width: 2.45rem;
        overflow: visible;
    }
    .library-screen-bar > .sub {
        grid-row: 3;
        min-width: 0;
    }
}
.library-screen-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--r-xl);
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}
.library-screen-body.is-bare {
    background: transparent;
    border: 0;
    border-radius: 0;
    backdrop-filter: none;
    box-shadow: none;
}
.library-screen-body .library-scope {
    padding: 0.35rem 1rem 1rem;
    overflow: auto;
    overflow-anchor: none;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
}
.library-scope {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.home-hint {
    margin: 0.45rem 0 0.5rem;
    font-size: 0.82rem;
    color: var(--ink-soft);
    flex: 0 0 auto;
}
.home-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: auto;
    justify-content: stretch;
    gap: 0.9rem;
    margin-top: 0.25rem;
    touch-action: manipulation;
    align-content: start;
    flex: 0 0 auto;
    width: 100%;
    min-height: 12rem;
}
.home-cell {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: var(--r-lg);
    isolation: isolate;
}
.home-cell:has(> .home-tile.is-folder),
.home-cell[data-kind="folder"] {
    border-radius: var(--r-xl);
}
.library-scope.is-rearranging:has(.home-tile.is-dragging.is-folder) .home-cell.is-drop-target {
    border-radius: var(--r-xl);
}
.home-cell.is-empty {
    background: rgba(0, 0, 0, 0.03);
    border: 1px dashed rgba(0, 0, 0, 0.1);
}
.library-scope.is-rearranging .home-cell:has(> .home-tile.is-dragging) {
    background: rgba(0, 0, 0, 0.03);
    border: 1px dashed rgba(0, 0, 0, 0.1);
}
.home-cell.is-drop-target {
    background: color-mix(in srgb, var(--teal) 12%, transparent);
    border-color: color-mix(in srgb, var(--teal) 45%, transparent);
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--teal) 20%, transparent);
}
.home-tile {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: var(--r-lg);
    border: 1px solid var(--line);
    background: linear-gradient(165deg, rgba(255,255,255,0.95), rgba(255, 255, 255, 0.8));
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.05);
    padding: 0.55rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: pan-y;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
    text-align: left;
    color: inherit;
    font: inherit;
    overflow: hidden;
    min-width: 0;
}
.home-tile-body {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: visible;
    appearance: none;
    -webkit-appearance: none;
    text-decoration: none;
    color: inherit;
    background: transparent;
    border: 0;
    padding: 0;
    margin: 0;
    font: inherit;
    text-align: inherit;
    cursor: pointer;
    box-sizing: border-box;
    border-radius: calc(var(--r-lg) - 0.4rem);
}
.home-tile-body:focus {
    outline: none;
}
.home-tile-body:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--teal) 70%, transparent);
    outline-offset: 1px;
}
.home-tile-body > * {
    min-width: 0;
    max-width: 100%;
}
.home-tile:active { cursor: grabbing; }
/* Lift via stable .home-cell hit box — translating .home-tile under its own
   :hover drops the bottom edge out from under the cursor and oscillates. */
.home-cell:hover > .home-tile:not(.is-dragging):not(.is-drop-target):not(.is-folder-ready):not(.is-drag-host) {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--teal) 35%, transparent);
}
html.is-library-dragging,
html.is-library-dragging * {
    touch-action: none !important;
}
@media (max-width: 860px) {
    html.is-library-dragging .fc-main-scroll,
    html.is-library-dragging .library-scope,
    html.is-library-dragging .library-screen-body {
        overflow: hidden !important;
    }
}
.home-tile.is-dragging {
    opacity: 0.35;
    transform: scale(0.96);
}
.library-scope.is-rearranging .home-tile.is-dragging {
    opacity: 1;
    transform: none;
    background: transparent;
    box-shadow: none;
    border: 2px solid color-mix(in srgb, var(--teal) 55%, transparent);
    color: transparent;
    transition: none;
}
.library-scope.is-rearranging .home-tile.is-dragging.is-folder {
    background: transparent;
}
.library-scope.is-rearranging .home-tile.is-dragging .home-tile-body {
    visibility: hidden;
}
.home-tile.is-drop-target {
    border-color: var(--teal);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--teal) 25%, transparent), 0 10px 22px rgba(0, 0, 0, 0.08);
    transform: scale(1.03);
}
.home-tile.is-folder-ready {
    transform: scale(1.12);
    border-color: var(--teal);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 32%, transparent), 0 14px 32px rgba(0, 0, 0, 0.14);
    z-index: 2;
}
.home-tile.is-swap-ready {
    border-color: color-mix(in srgb, var(--teal) 32%, transparent);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
}
.library-scope.is-rearranging .home-tile.is-swap-push {
    transition: transform 0.2s cubic-bezier(0.33, 1, 0.32, 1);
    z-index: 2;
}
.home-tile.is-drag-host {
    position: absolute;
    inset: auto;
    left: 0;
    top: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    pointer-events: none;
    z-index: 0;
}
.home-tile.is-drag-host.is-drag-parked {
    position: fixed !important;
    left: -80px !important;
    top: -80px !important;
    width: 24px !important;
    height: 24px !important;
    pointer-events: auto !important;
    z-index: 10001;
}
.home-tile.is-folder {
    background: linear-gradient(165deg, rgba(255,248,241, 0.95), rgba(236, 245, 241, 0.88));
    border-radius: var(--r-xl);
}
.home-tile.is-flipping {
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 1;
}
.chip.saved-badge {
    background: color-mix(in srgb, var(--teal) 12%, transparent);
    color: var(--teal-text);
    font-size: 0.64rem;
    letter-spacing: 0.02em;
}
.home-tile-title {
    flex: 0 0 auto;
    font-family: var(--font-ui);
    font-weight: 650;
    font-size: 0.92rem;
    line-height: 1.2;
    letter-spacing: -0.02em;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    overflow-wrap: anywhere;
}
.home-tile-lang {
    flex: 0 0 auto;
    width: calc(100% + 0.4rem);
    max-width: none;
    min-width: 0;
    margin-top: auto;
    margin-left: -0.4rem;
    overflow: visible;
}
.home-tile-lang .chip {
    display: block;
    width: max-content;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.68rem;
    padding: 0.12rem 0.4rem;
    text-align: left;
}
.home-tile-meta {
    flex: 0 0 auto;
    margin-top: auto;
    display: flex;
    flex-wrap: nowrap;
    gap: 0.25rem;
    align-items: center;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}
.home-tile-lang + .home-tile-meta {
    margin-top: 0;
}
.home-tile-meta .chip {
    flex: 0 1 auto;
    width: auto;
    max-width: 100%;
    font-size: 0.68rem;
    padding: 0.12rem 0.4rem;
}
.home-tile-count {
    flex: 0 0 auto;
    font-size: 0.72rem;
    color: var(--ink-soft);
    font-weight: 600;
}
.home-tile-rating {
    flex: 0 1 auto;
    min-width: 0;
    font-size: 0.68rem;
    font-weight: 650;
    color: var(--ink-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.folder-preview {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.28rem;
    flex: 1;
    min-width: 0;
    min-height: 0;
    width: 100%;
    overflow: hidden;
}
.folder-preview-pair {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: minmax(0, 1fr);
}
.folder-preview-pair span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}
.folder-preview span {
    display: block;
    text-align: center;
    font-size: 0.62rem;
    font-weight: 600;
    line-height: 1.15;
    color: var(--ink-soft);
    background: rgba(255,255,255,0.75);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--r-md);
    padding: 0.2rem;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.drag-ghost {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 10000;
    pointer-events: none;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.55rem;
    margin: 0;
    border-radius: var(--r-lg);
    border: 1px solid var(--line);
    background: linear-gradient(165deg, rgba(255,255,255,0.95), rgba(255, 255, 255, 0.8));
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
    overflow: hidden;
    opacity: 0.96;
    transform: scale(1.08) rotate(-3deg);
    color: inherit;
    font: inherit;
    text-align: left;
    will-change: left, top, transform;
}
.drag-ghost.is-folder {
    border-radius: var(--r-xl);
    background: linear-gradient(165deg, rgba(255,248,241, 0.95), rgba(236, 245, 241, 0.88));
}
.drag-ghost .home-tile-body {
    pointer-events: none;
}
.home-cell.is-folder-drop {
    background: color-mix(in srgb, var(--teal) 10%, transparent);
    border: 2px dashed color-mix(in srgb, var(--teal) 45%, transparent);
}
.folder-modal.is-drop-ready,
.folder-modal.is-drop-target {
    border-color: var(--folder-line);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 38%, transparent),
        0 24px 60px rgba(0,0,0,0.22);
}
.fc-main { position: relative; }
html.is-folder-open .fc-main-scroll { overflow: hidden; }
.folder-move-out {
    display: none;
}
.folder-modal-backdrop.is-narrow .folder-move-out {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 30;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    min-height: 5.25rem;
    padding: 1.6rem 1rem 0.85rem;
    box-sizing: border-box;
    pointer-events: none;
    text-align: center;
    font-size: 0.86rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #f4f4f1;
    border: 0;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.42) 55%, rgba(0, 0, 0, 0.62) 100%);
    transition: opacity 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.folder-move-out[hidden] {
    display: none !important;
}
.folder-modal-backdrop.is-narrow.is-move-out-armed .folder-move-out {
    pointer-events: auto;
}
.folder-move-out.is-ready {
    color: #fff;
    background: linear-gradient(180deg, color-mix(in srgb, var(--teal) 0%, transparent) 0%, color-mix(in srgb, var(--teal) 50%, transparent) 50%, color-mix(in srgb, var(--teal) 78%, transparent) 100%);
}
.folder-modal-backdrop {
    position: absolute;
    inset: 0;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.1rem;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.26s ease, visibility 0.26s ease;
}
.folder-modal-backdrop.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
.folder-modal-backdrop.is-open.is-drag-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none !important;
}
.folder-modal-backdrop.is-open.is-drag-out,
.folder-modal-backdrop.is-open.is-drag-out * {
    pointer-events: none !important;
}
.folder-modal-backdrop.is-page.is-narrow {
    top: calc(3.25rem + env(safe-area-inset-top, 0px));
    padding: 0.7rem 0.55rem;
    align-items: center;
    justify-content: center;
}
.folder-modal-backdrop.is-page.is-narrow .folder-stack {
    --peek: 2.2rem;
    width: 100%;
    max-width: none;
    height: auto;
    max-height: min(70vh, calc(100% - 1.4rem));
    min-height: 0;
}
.folder-modal-backdrop.is-drag-out .folder-stack {
    pointer-events: none;
    transform: scale(0.92);
    opacity: 0;
}
.folder-stack {
    --peek: clamp(1.05rem, 3.4vw, 1.45rem);
    --folder-r: var(--r-2xl);
    --behind: 0;
    --folder-line: rgba(0, 0, 0, 0.2);
    position: relative;
    width: min(42rem, calc(100% - 0.5rem));
    min-height: 18rem;
    max-height: min(84vh, 720px);
    box-sizing: border-box;
    overflow: hidden;
    border-radius: var(--folder-r);
    transition: transform 0.36s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.28s ease;
}
.folder-layer-sizer {
    visibility: hidden;
    pointer-events: none;
    min-height: 18rem;
    transition: height 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}
.folder-layers {
    position: absolute;
    inset: 0;
}
.folder-layer {
    --depth: 0;
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(var(--depth) * var(--peek));
    width: calc(100% - var(--behind) * var(--peek));
    z-index: calc(var(--depth) + 1);
    pointer-events: none;
    transition: left 0.38s cubic-bezier(0.22, 1, 0.36, 1),
        width 0.38s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.38s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}
.folder-stack.is-vertical {
    --peek: 2.2rem;
}
.folder-layer.is-stack-up {
    left: 0;
    width: 100%;
    right: 0;
    top: auto;
    height: calc(100% - var(--behind) * var(--peek));
    bottom: calc(var(--depth) * var(--peek));
    transition: bottom 0.38s cubic-bezier(0.22, 1, 0.36, 1),
        height 0.38s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.38s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}
.folder-layer.is-front {
    z-index: 20;
    pointer-events: none;
    transform: none;
    opacity: 1;
}
.folder-layer.is-front .folder-modal {
    pointer-events: auto;
}
.folder-layer:not(.is-front) .folder-modal {
    pointer-events: none;
    user-select: none;
    visibility: hidden;
}
.folder-layer-peek {
    display: none;
    transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, color 0.16s ease;
}
.folder-layer:not(.is-front):not(.is-tucked) .folder-layer-peek {
    display: block;
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--peek);
    z-index: 6;
    pointer-events: auto;
    cursor: pointer;
    padding: 0;
    margin: 0;
    border-radius: var(--folder-r) 0 0 var(--folder-r);
    background: var(--card);
    border: 1.5px solid var(--folder-line);
    border-right: 0;
    box-shadow: none;
    transform: none;
    overflow: visible;
}
.folder-layer:not(.is-front):not(.is-tucked) .folder-layer-peek.is-bottom {
    display: flex;
    align-items: center;
    justify-content: center;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: 100%;
    height: var(--peek);
    border-radius: 0 0 var(--folder-r) var(--folder-r);
    border: 1.5px solid var(--folder-line);
    border-top: 0;
    box-shadow: none;
    overflow: visible;
}
.folder-layer-peek.is-bottom .folder-layer-peek-ear {
    display: block;
    left: auto;
    top: auto;
    bottom: 100%;
    width: var(--folder-r);
    height: var(--folder-r);
}
.folder-layer-peek.is-bottom .folder-layer-peek-ear[data-ear="top"] {
    left: 0;
    right: auto;
}
.folder-layer-peek.is-bottom .folder-layer-peek-ear[data-ear="bottom"] {
    right: 0;
    left: auto;
    bottom: 100%;
}
.folder-layer-peek.is-bottom .folder-layer-peek-name {
    position: static;
    inset: auto;
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    transform: none;
    width: 100%;
    height: auto;
    padding: 0 0.85rem;
    font-size: 0.82rem;
    letter-spacing: 0.02em;
}
.folder-layer-peek-ear {
    position: absolute;
    left: 100%;
    width: var(--folder-r);
    height: var(--folder-r);
    background: inherit;
    pointer-events: auto;
    z-index: 2;
    overflow: hidden;
}
.folder-layer-peek-ear[data-ear="top"] {
    top: 0;
}
.folder-layer-peek-ear[data-ear="bottom"] {
    bottom: 0;
}
.folder-layer-peek-ear::before,
.folder-layer-peek-ear::after {
    content: "";
    position: absolute;
    pointer-events: none;
}
.folder-layer-peek-ear::after {
    box-sizing: border-box;
    width: calc(var(--folder-r) * 2);
    height: calc(var(--folder-r) * 2);
    border: 1.5px solid var(--folder-line);
    border-radius: 50%;
}
.folder-layer-peek:not(.is-bottom) .folder-layer-peek-ear[data-ear="top"]::before {
    left: 0;
    right: 0;
    top: 0;
    height: 1.5px;
    background: var(--folder-line);
}
.folder-layer-peek:not(.is-bottom) .folder-layer-peek-ear[data-ear="top"]::after {
    left: 0;
    top: 0;
}
.folder-layer-peek:not(.is-bottom) .folder-layer-peek-ear[data-ear="bottom"]::before {
    left: 0;
    right: 0;
    bottom: 0;
    height: 1.5px;
    background: var(--folder-line);
}
.folder-layer-peek:not(.is-bottom) .folder-layer-peek-ear[data-ear="bottom"]::after {
    left: 0;
    top: calc(-1 * var(--folder-r));
}
.folder-layer-peek.is-bottom .folder-layer-peek-ear[data-ear="top"]::before {
    left: 0;
    top: 0;
    bottom: 0;
    width: 1.5px;
    background: var(--folder-line);
}
.folder-layer-peek.is-bottom .folder-layer-peek-ear[data-ear="top"]::after {
    left: 0;
    top: calc(-1 * var(--folder-r));
}
.folder-layer-peek.is-bottom .folder-layer-peek-ear[data-ear="bottom"]::before {
    right: 0;
    top: 0;
    bottom: 0;
    width: 1.5px;
    background: var(--folder-line);
}
.folder-layer-peek.is-bottom .folder-layer-peek-ear[data-ear="bottom"]::after {
    left: calc(-1 * var(--folder-r));
    top: calc(-1 * var(--folder-r));
}
.folder-layer-peek-name {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-family: var(--font-ui);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--ink-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
    padding: 0.7rem 0;
}
.folder-layer:not(.is-front) .folder-layer-peek:hover,
.folder-layer-peek.is-drop-ready,
.folder-layer:not(.is-front):not(.is-tucked) .folder-layer-peek:hover,
.folder-layer:not(.is-front):not(.is-tucked) .folder-layer-peek.is-drop-ready {
    transform: none;
    background: color-mix(in srgb, var(--teal) 28%, var(--card));
    background: color-mix(in srgb, var(--teal) 32%, var(--card));
    z-index: 8;
}
.folder-layer:not(.is-front):not(.is-tucked) .folder-layer-peek:not(.is-bottom):hover,
.folder-layer:not(.is-front):not(.is-tucked) .folder-layer-peek:not(.is-bottom).is-drop-ready {
    border-color: color-mix(in srgb, var(--teal) 72%, transparent);
    border-right: 0;
}
.folder-layer-peek.is-bottom.is-drop-ready,
.folder-layer:not(.is-front):not(.is-tucked) .folder-layer-peek.is-bottom:hover {
    border-color: color-mix(in srgb, var(--teal) 55%, transparent);
    border-top: 0;
    box-shadow: 0 8px 18px color-mix(in srgb, var(--teal) 16%, transparent);
}
.folder-layer-peek.is-drop-ready .folder-layer-peek-name,
.folder-layer:not(.is-front) .folder-layer-peek:hover .folder-layer-peek-name {
    color: var(--teal-text);
    font-weight: 700;
}
.folder-layer-peek.is-drop-ready .folder-layer-peek-ear::after,
.folder-layer:not(.is-front) .folder-layer-peek:hover .folder-layer-peek-ear::after {
    border-color: color-mix(in srgb, var(--teal) 55%, transparent);
}
.folder-layer-peek.is-drop-ready .folder-layer-peek-ear::before,
.folder-layer:not(.is-front) .folder-layer-peek:hover .folder-layer-peek-ear::before {
    background: color-mix(in srgb, var(--teal) 55%, transparent);
}
.folder-layer.is-tucked {
    transform: translateX(112%);
    opacity: 1;
    pointer-events: none !important;
    z-index: calc(32 + var(--depth));
    transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}
.folder-layer.is-stack-up.is-tucked {
    transform: translateY(-112%);
}
.folder-modal {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    max-height: none;
    overflow: hidden;
    background: var(--card);
    border: 1.5px solid var(--folder-line);
    border-radius: var(--folder-r);
    box-shadow: 0 22px 56px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.05);
    padding: 0;
    transform: none;
    opacity: 1;
    box-sizing: border-box;
}
.folder-modal-scroll {
    height: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
    overflow-anchor: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding: 0.85rem 1.15rem 1.05rem;
}
.folder-modal .home-grid {
    overflow: visible;
    touch-action: pan-y;
}
.folder-modal .home-tile {
    touch-action: pan-y;
}
.folder-modal-head {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    margin-bottom: 0.65rem;
    flex: 0 0 auto;
}
.folder-modal-toolbar {
    display: flex;
    gap: 0.55rem;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    min-width: 0;
}
.folder-modal-toolbar input {
    flex: 1 1 8rem;
    min-width: 0;
}
.folder-modal-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    margin-left: auto;
}
.folder-crumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem 0.35rem;
    align-items: center;
    min-width: 0;
    padding: 0.05rem 0.1rem 0.15rem;
    font-size: 0.82rem;
    color: var(--ink-soft);
}
.folder-crumbs button {
    padding: 0.15rem 0.25rem;
    border: 0;
    background: transparent;
    box-shadow: none;
    color: var(--teal-text);
    font-size: 0.82rem;
    font-weight: 600;
    transform: none;
}
.folder-crumbs button:hover {
    transform: none;
    color: var(--teal);
    background: transparent;
    border-color: transparent;
}
.folder-crumbs .sep {
    opacity: 0.55;
}
.folder-modal-toolbar-actions .btn,
.folder-modal-toolbar-actions a.btn,
.folder-modal-toolbar [data-folder-new] {
    flex: 0 0 auto;
    padding: 0.55rem 0.75rem;
}
.folder-modal-toolbar [data-folder-delete] {
    flex: 0 0 auto;
    padding: 0.55rem 0.75rem;
    color: var(--bad);
    border-color: rgba(180, 35, 24, 0.28);
    background: rgba(180, 35, 24, 0.06);
}
html.is-library-dragging .folder-modal-toolbar [data-folder-delete] {
    display: none !important;
}
.folder-modal .home-grid {
    margin-top: 0.35rem;
}
.folder-modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.85rem;
}
.home-empty {
    margin-top: 0.85rem;
}
.set-meta-review-slot {
    display: grid;
    grid-template-columns: 0fr;
    min-width: 0;
    overflow: hidden;
    transition: grid-template-columns 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}
.set-meta-review-slot.is-in {
    grid-template-columns: 1fr;
}
.set-meta-review-slot > .set-meta-review {
    overflow: hidden;
    white-space: nowrap;
    min-width: 0;
    opacity: 0;
    transform: translateX(110%);
    pointer-events: none;
    transition: opacity 0.28s ease, transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}
.set-meta-review-slot.is-in > .set-meta-review {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}
.set-meta [data-visibility-status],
.set-head-actions [data-visibility-btn] {
    overflow: hidden;
    white-space: nowrap;
    vertical-align: middle;
}
.set-head-actions [data-visibility-btn] {
    transition: width 0.38s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.28s ease, color 0.28s ease, border-color 0.28s ease;
}
.set-meta [data-visibility-status] {
    transition: width 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}
@media (prefers-reduced-motion: reduce) {
    .set-meta-review-slot,
    .set-meta-review-slot > .set-meta-review,
    .set-meta [data-visibility-status],
    .set-head-actions [data-visibility-btn] {
        transition: none;
        transform: none;
    }
}
.star-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--ink);
    user-select: none;
}
.star-toggle input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
.star-toggle .switch {
    flex: 0 0 auto;
    width: 2.45rem;
    height: 1.38rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.16);
    border: 1px solid var(--line);
    position: relative;
    transition: background 0.18s ease, border-color 0.18s ease;
}
.star-toggle .switch::after {
    content: "";
    position: absolute;
    top: 0.11rem;
    left: 0.11rem;
    width: 1.08rem;
    height: 1.08rem;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
    transition: transform 0.18s ease;
}
.star-toggle input:checked + .switch {
    background: var(--teal);
    border-color: var(--teal);
}
.star-toggle input:checked + .switch::after {
    transform: translateX(1.07rem);
}
.star-toggle input:focus-visible + .switch {
    outline: 2px solid var(--teal);
    outline-offset: 2px;
}
.star-toggle.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.checks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem 1rem;
}
.checks label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
}
.checks input { width: 1rem; height: 1rem; accent-color: var(--teal); }
.study-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 1.1rem;
    background: rgba(12, 20, 18, 0.42);
    backdrop-filter: blur(6px);
}
.study-modal-backdrop[hidden] { display: none !important; }
.study-modal {
    width: min(100%, 28rem);
    background: var(--card);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    padding: 1.2rem 1.15rem 1.1rem;
    box-shadow: 0 22px 48px rgba(0, 0, 0, 0.18);
    text-align: left;
}
.study-modal h2 {
    font-family: var(--font-ui);
    font-size: 1.25rem;
    margin: 0 0 0.35rem;
}
.study-modal-actions {
    justify-content: flex-end;
    margin-top: 1.1rem;
}
.set-top {
    display: grid;
    grid-template-columns: minmax(6.5rem, 1fr) minmax(0, 2.4fr) minmax(6.5rem, 1fr);
    align-items: start;
    gap: 0.35rem 0.85rem;
    flex: 0 0 auto;
    margin-bottom: 0.55rem;
    min-height: 2.4rem;
    padding: 0.1rem 0 0.2rem;
}
.set-top-back {
    display: inline-flex;
    align-items: center;
    margin: 0.28rem 0 0;
    white-space: nowrap;
    font-weight: 600;
    font-size: 0.9rem;
    justify-self: start;
}
.set-top-back.back-to-set { margin-bottom: 0; }
.set-heading {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin: 0 auto;
    max-width: 36rem;
    min-width: 0;
}
.set-heading h1 {
    margin: 0;
    font-size: clamp(1.35rem, 2.8vw, 1.85rem);
    line-height: 1.2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
}
.set-heading .sub {
    margin: 0.3rem 0 0;
    font-size: 0.9rem;
    line-height: 1.4;
    max-width: 42ch;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
}
.set-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.3rem;
    margin-top: 0.55rem;
}
.set-meta span:not(.set-meta-review-slot),
.set-meta .set-meta-review {
    display: inline-flex;
    align-items: center;
    padding: 0.16rem 0.5rem;
    border: 0;
    border-radius: var(--r-pill);
    background: rgba(0, 0, 0, 0.06);
    font: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ink-soft);
}
.set-meta .set-meta-review {
    cursor: pointer;
}
.set-meta .set-meta-review:hover,
.set-meta .set-meta-review:focus-visible {
    background: rgba(0, 0, 0, 0.11);
    color: var(--ink);
}
.set-head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    justify-content: flex-end;
    justify-self: end;
    margin: 0;
}
.set-head-actions .btn,
.set-head-actions button {
    padding: 0.48rem 0.95rem;
    border-radius: var(--r-pill);
    font-size: 0.86rem;
}
#review-modal .study-modal {
    width: min(100%, 32rem);
    max-height: min(80vh, 40rem);
    overflow: auto;
}
.review-panel {
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}
.review-panel-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.35rem 0.8rem;
    margin-bottom: 0.65rem;
}
.review-panel h2 {
    margin: 0;
    font-family: var(--font-ui);
    font-size: 1.05rem;
}
.review-score {
    margin: 0;
    font-size: 0.84rem;
    font-weight: 650;
    color: var(--ink-soft);
}
.review-form {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.review-form-label {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 650;
}
.review-form textarea {
    width: 100%;
    height: 6.4rem;
    min-height: 6.4rem;
    max-height: 6.4rem;
    resize: none;
    border-radius: var(--r-md);
}
.review-form .primary {
    justify-self: start;
}
.review-signin {
    margin: 0 0 0.65rem;
    font-size: 0.88rem;
}
.star-picker {
    display: inline-flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 0.08rem;
}
.star-picker input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}
.star-picker label {
    color: rgba(0, 0, 0, 0.18);
    font-size: 1.45rem;
    line-height: 1;
    cursor: pointer;
}
.star-picker input:checked ~ label,
.star-picker label:hover,
.star-picker label:hover ~ label {
    color: #d4a017;
}
.review-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.65rem;
}
.review-item p {
    margin: 0.2rem 0 0;
    font-size: 0.9rem;
    line-height: 1.4;
}
.review-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.55rem;
    font-size: 0.78rem;
    font-weight: 650;
    color: var(--ink-soft);
}
.review-item-stars {
    letter-spacing: 0.04em;
    color: #d4a017;
}
html.night .star-toggle .switch {
    background: rgba(255, 255, 255, 0.16);
}
html.night .star-toggle input:checked + .switch {
    background: var(--teal);
    border-color: var(--teal);
}
html.night .study-modal {
    background: var(--glass);
    box-shadow: 0 22px 48px rgba(0, 0, 0, 0.38);
}
html.night .set-meta span:not(.set-meta-review-slot),
html.night .set-meta .set-meta-review {
    background: rgba(255, 255, 255, 0.08);
}
html.night .set-meta .set-meta-review:hover,
html.night .set-meta .set-meta-review:focus-visible {
    background: rgba(255, 255, 255, 0.14);
}
html.night .star-picker label {
    color: rgba(255, 255, 255, 0.22);
}
html.night .star-picker input:checked ~ label,
html.night .star-picker label:hover,
html.night .star-picker label:hover ~ label {
    color: #f0c44a;
}
.section-head {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.25rem;
}
.section-head h2 {
    font-family: var(--font-ui);
    font-size: 1.2rem;
    font-weight: 650;
}
.progress-rail {
    height: 8px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 999px;
    overflow: hidden;
    margin: 0.75rem 0 0.35rem;
}
.progress-rail > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--teal), var(--teal-deep));
    width: 0%;
    transition: width 0.25s ease;
}
.meta-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
    color: var(--ink-soft);
}
.meta-row strong { color: var(--ink); }
.feedback {
    margin-top: 0.85rem;
    padding: 0.75rem 0.9rem;
    border-radius: var(--r-md);
    font-size: 0.92rem;
    line-height: 1.45;
    display: none;
}
.feedback.is-on { display: block; }
.feedback.ok {
    background: rgba(31, 122, 76, 0.12);
    border: 1px solid rgba(31, 122, 76, 0.28);
    color: var(--good);
}
.feedback.bad {
    background: rgba(180, 35, 24, 0.1);
    border: 1px solid rgba(180, 35, 24, 0.25);
    color: var(--bad);
}
.choice-list { display: grid; gap: 0.55rem; margin-top: 1rem; }
.choice-list button {
    width: 100%;
    text-align: left;
    padding: 0.85rem 1rem;
}
.choice-list button.is-correct {
    background: rgba(31, 122, 76, 0.12);
    border-color: var(--good);
}
.choice-list button.is-wrong {
    background: rgba(180, 35, 24, 0.08);
    border-color: var(--bad);
}
.empty-state {
    color: var(--ink-soft);
    line-height: 1.5;
    margin-top: 0.75rem;
}
@media (max-width: 860px) {
    .set-top {
        grid-template-columns: auto minmax(0, 1fr) auto;
    }
    .set-heading { max-width: none; }
    .set-head-actions { max-width: 10.5rem; }
}
@media (max-width: 560px) {
    .set-head-actions .btn,
    .set-head-actions button { width: auto; }
}
@media (max-width: 860px) {
    .folder-stack.is-vertical,
    .folder-modal-backdrop.is-page.is-narrow .folder-stack {
        --peek: 2.2rem;
    }
    /* Same-size cards, offset from the bottom — the vertical analog of
       left: depth*peek and width: 100% - behind*peek. */
    .folder-stack.is-vertical .folder-layer,
    .folder-modal-backdrop.is-page.is-narrow .folder-layer {
        left: 0 !important;
        width: 100% !important;
        right: 0;
        top: auto !important;
        height: calc(100% - var(--behind) * var(--peek)) !important;
        bottom: calc(var(--depth) * var(--peek)) !important;
        transition: opacity 0.18s ease;
    }
    .folder-stack.is-vertical .folder-layer.is-tucked,
    .folder-stack.is-vertical .folder-layer.is-stack-up.is-tucked,
    .folder-modal-backdrop.is-page.is-narrow .folder-layer.is-tucked,
    .folder-modal-backdrop.is-page.is-narrow .folder-layer.is-stack-up.is-tucked {
        transform: none;
        opacity: 0;
    }
    /* Peek is this layer's own back edge, like the left strip on desktop. */
    .folder-stack.is-vertical .folder-layer:not(.is-front):not(.is-tucked) .folder-layer-peek,
    .folder-modal-backdrop.is-page.is-narrow .folder-layer:not(.is-front):not(.is-tucked) .folder-layer-peek {
        display: flex !important;
        align-items: center;
        justify-content: center;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        bottom: 0 !important;
        width: 100% !important;
        height: var(--peek) !important;
        border-radius: 0 0 var(--folder-r) var(--folder-r);
        border: 1.5px solid var(--folder-line);
        border-top: 0;
        box-shadow: none;
        overflow: visible;
    }
    .folder-stack.is-vertical .folder-layer-peek.is-drop-ready,
    .folder-modal-backdrop.is-page.is-narrow .folder-layer-peek.is-drop-ready {
        background: color-mix(in srgb, var(--teal) 28%, var(--card));
        background: color-mix(in srgb, var(--teal) 32%, var(--card));
        border-color: color-mix(in srgb, var(--teal) 55%, transparent);
        border-top: 0;
        box-shadow: 0 8px 18px color-mix(in srgb, var(--teal) 16%, transparent);
    }
    .folder-stack.is-vertical .folder-layer-peek-ear,
    .folder-modal-backdrop.is-page.is-narrow .folder-layer-peek-ear {
        display: block !important;
        left: auto;
        top: auto;
        bottom: 100%;
        width: var(--folder-r);
        height: var(--folder-r);
    }
    .folder-stack.is-vertical .folder-layer-peek-ear[data-ear="top"],
    .folder-modal-backdrop.is-page.is-narrow .folder-layer-peek-ear[data-ear="top"] {
        left: 0;
        right: auto;
    }
    .folder-stack.is-vertical .folder-layer-peek-ear[data-ear="bottom"],
    .folder-modal-backdrop.is-page.is-narrow .folder-layer-peek-ear[data-ear="bottom"] {
        right: 0;
        left: auto;
        bottom: 100%;
    }
    .folder-stack.is-vertical .folder-layer-peek-name,
    .folder-modal-backdrop.is-page.is-narrow .folder-layer-peek-name {
        position: static !important;
        inset: auto !important;
        writing-mode: initial !important;
        writing-mode: horizontal-tb !important;
        text-orientation: mixed !important;
        transform: none !important;
        width: 100%;
        height: auto;
        padding: 0 0.85rem;
        font-size: 0.82rem;
        letter-spacing: 0.02em;
        justify-content: center;
    }
    .folder-stack.is-vertical,
    .folder-stack.is-vertical .folder-layer.is-stack-up,
    .folder-stack.is-vertical .folder-layer-sizer,
    .folder-modal-backdrop.is-page.is-narrow .folder-stack,
    .folder-modal-backdrop.is-page.is-narrow .folder-layer-sizer {
        transition: opacity 0.18s ease;
    }
}
@media (max-width: 560px) {
    .section-head { align-items: stretch; }
    .section-head .btn,
    .section-head button { width: 100%; }
    .set-page-bar .btn { width: auto; }
    .set-page-bar .icon-btn { width: 2.45rem; height: 2.45rem; min-width: 2.45rem; padding: 0.4rem; }
    select { min-width: 0; width: 100%; }
    .controls { align-items: stretch; }
    .field { width: 100%; }
    .btn-row button, .btn-row .btn { flex: 1 1 auto; }
    .mastery-bars { grid-template-columns: 1fr; }
    .folder-modal-toolbar input { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
    button, .btn { transition: none; }
    .folder-modal, .folder-stack, .folder-layer { transition: none; animation: none; }
}
html.night .home-cell.is-empty,
html.night .library-scope.is-rearranging .home-cell:has(> .home-tile.is-dragging) {
    background: rgba(255, 255, 255, 0.07);
    border: 1px dashed rgba(255, 255, 255, 0.32);
}
html.night .prompt-box,
html.night .mastery-bars div,
html.night .folder-preview span,
html.night .card-row,
html.night .question {
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
}
@media (min-width: 861px) {
    html.night .folder-layer:not(.is-front) .folder-modal {
        filter: saturate(0.92);
    }
}
html.night .folder-modal-toolbar [data-folder-delete],
html.night button.danger,
html.night .btn.danger {
    color: var(--bad);
    background: rgba(180, 35, 24, 0.14);
    border-color: rgba(180, 35, 24, 0.35);
}
html.night .folder-stack {
    --folder-line: rgba(255, 255, 255, 0.28);
}
html.night .folder-layer-peek-name {
    color: var(--ink-soft);
}
html.night .folder-layer-peek.is-drop-ready,
html.night .folder-layer:not(.is-front) .folder-layer-peek:hover,
html.night .folder-layer:not(.is-front):not(.is-tucked) .folder-layer-peek.is-drop-ready,
html.night .folder-layer:not(.is-front):not(.is-tucked) .folder-layer-peek:hover {
    background: color-mix(in srgb, var(--teal) 36%, var(--card));
}
html.night .folder-layer:not(.is-front):not(.is-tucked) .folder-layer-peek:not(.is-bottom).is-drop-ready,
html.night .folder-layer:not(.is-front):not(.is-tucked) .folder-layer-peek:not(.is-bottom):hover {
    border-color: color-mix(in srgb, var(--teal) 72%, transparent);
    border-right: 0;
}
html.night .folder-move-out {
    color: #f4f4f1;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.5) 55%, rgba(0, 0, 0, 0.72) 100%);
}
html.night .folder-move-out.is-ready {
    background: linear-gradient(180deg, color-mix(in srgb, var(--teal) 0%, transparent) 0%, color-mix(in srgb, var(--teal) 48%, transparent) 50%, color-mix(in srgb, var(--teal) 78%, transparent) 100%);
}
html.night .face {
    background: linear-gradient(165deg, #242424 0%, #1a1a1a 100%);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
}
html.night .face.back {
    background: linear-gradient(165deg, #222222 0%, #1a1a1a 100%);
}
html.night .star-btn.is-on {
    color: #f0a45c;
}

/* Learn / daily / test study chrome lives in page templates (match cards study). */
/* Anki-style SRS settings */
.srs-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 0.85rem;
    margin: 0.85rem 0 0.35rem;
    text-align: left;
}
.srs-settings-grid .field {
    display: grid;
    gap: 0.3rem;
    margin: 0;
}
.srs-settings-grid .field-wide { grid-column: 1 / -1; }
.srs-settings-grid span {
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-soft);
}
.srs-settings-modal { width: min(100%, 34rem); }
@media (max-width: 560px) {
    .srs-settings-grid { grid-template-columns: 1fr; }
}

.library-screen-actions .icon-btn {
    background: transparent;
    border-color: transparent;
}
.library-screen-actions .icon-btn:hover,
.library-screen-actions .icon-btn:focus-visible {
    background: color-mix(in srgb, var(--teal) 8%, transparent);
    border-color: transparent;
    transform: none;
}
.library-screen-actions .icon-btn:last-child .icon-tip {
    left: auto;
    right: 0;
    transform: translateY(4px);
}
.library-screen-actions .icon-btn:last-child:hover .icon-tip,
.library-screen-actions .icon-btn:last-child:focus-visible .icon-tip {
    transform: translateY(0);
}
/* My Library top-right actions only (folder / create set / librarian). */
.library-screen-actions:has([data-new-folder]) {
    flex-wrap: nowrap;
    gap: 0.2rem;
}
.library-screen-actions:has([data-new-folder]) > .icon-btn {
    flex: 0 0 auto;
    min-width: 2.45rem;
    overflow: visible;
    text-overflow: unset;
}
.library-screen-actions:has([data-new-folder]) > .icon-btn.library-action-create:hover,
.library-screen-actions:has([data-new-folder]) > .icon-btn.library-action-create:focus-visible {
    background: color-mix(in srgb, var(--teal) 12%, transparent);
    color: var(--teal);
}

.fc-ai-rail .ai-pane-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    min-height: 3.1rem;
    padding: 0.45rem 0.65rem 0.45rem 1.05rem;
    border-bottom: 1px solid var(--line);
    background: var(--paper);
    flex: 0 0 auto;
}
.fc-ai-rail .ai-pane-bar h2 {
    margin: 0;
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 650;
    letter-spacing: -0.015em;
    min-width: 0;
    flex: 1 1 auto;
}
.fc-ai-rail .ai-chip,
.fc-ai-rail .ai-icon-btn,
.fc-ai-rail .ai-send {
    font-weight: 600;
    box-shadow: none;
    transition: background 0.2s ease, border-color 0.2s ease, opacity 0.18s ease, transform 0.2s ease, color 0.18s ease;
}
.fc-ai-rail .ai-icon-btn,
.fc-ai-rail .ai-send {
    width: 2.15rem;
    height: 2.15rem;
    min-width: 2.15rem;
    padding: 0;
    border: 0;
    border-radius: var(--r-md);
    display: grid;
    place-items: center;
    text-decoration: none;
    color: inherit;
}
.fc-ai-rail .ai-icon-btn {
    background: transparent;
    color: var(--ink-soft);
}
.fc-ai-rail .ai-icon-btn:hover {
    background: color-mix(in srgb, var(--teal) 8%, transparent);
    color: var(--ink);
    border-color: transparent;
    transform: none;
}
.fc-ai-rail .ai-icon-btn svg,
.fc-ai-rail .ai-send svg { width: 1.05rem; height: 1.05rem; }
.ai-thread {
    flex: 1;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
    padding: 1.15rem 1.1rem 0.65rem;
}
.ai-thread.is-empty {
    justify-content: center;
    align-items: center;
}
.ai-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.85rem;
    max-width: 22.5rem;
    padding: 0.5rem 0.35rem 1rem;
}
.ai-empty .ai-avatar {
    width: 2.15rem;
    height: 2.15rem;
    margin: 0;
    border-radius: 0.85rem;
}
.ai-empty .ai-avatar svg { width: 1.05rem; height: 1.05rem; }
.ai-empty p {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 550;
    line-height: 1.5;
    letter-spacing: -0.02em;
    color: var(--ink);
}
.ai-msg {
    display: flex;
    gap: 0.7rem;
    align-items: flex-start;
    max-width: 100%;
}
.ai-msg.is-you { justify-content: flex-end; }
.ai-avatar {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: var(--r-md);
    background: var(--teal);
    color: #fff;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    margin-top: 0.08rem;
}
.ai-avatar svg { width: 0.78rem; height: 0.78rem; }
.ai-msg.is-you .ai-avatar { display: none; }
.ai-msg-body {
    min-width: 0;
    flex: 1 1 auto;
    max-width: 34rem;
    font-size: 0.92rem;
    line-height: 1.55;
    color: var(--ink);
}
.ai-msg.is-you .ai-msg-body {
    flex: 0 1 auto;
    max-width: min(88%, 28rem);
    background: transparent;
    padding: 0;
    border: 0;
    border-radius: 0;
    text-align: right;
}
.ai-msg.is-you.has-files .ai-msg-body {
    padding: 0;
    background: transparent;
    border: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.4rem;
}
.ai-msg-files {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.4rem;
}
.ai-msg-tile,
.ai-pending-file {
    position: relative;
    flex: 0 0 auto;
    width: 4.6rem;
    height: 4.6rem;
    border-radius: 0.95rem;
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--card);
    contain: layout paint;
}
.ai-msg-tile img,
.ai-pending-file img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.ai-msg-tile.is-waiting img,
.ai-pending-file.is-waiting img,
.ai-msg-tile.is-loading img,
.ai-pending-file.is-loading img {
    filter: grayscale(1);
    opacity: 0.55;
}
.ai-msg-tile-doc,
.ai-pending-file.is-pdf .ai-msg-tile-doc {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.22rem;
    width: 100%;
    height: 100%;
    padding: 0.4rem;
    color: var(--ink);
    background: color-mix(in srgb, var(--teal) 10%, var(--card));
}
.ai-msg-tile-doc svg,
.ai-pending-file.is-pdf svg {
    width: 1.35rem;
    height: 1.35rem;
    flex: 0 0 auto;
}
.ai-msg-tile-doc span,
.ai-pending-name {
    font-size: 0.62rem;
    font-weight: 650;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}
.ai-msg-tile-spin {
    position: absolute;
    inset: 0;
    display: none;
    place-items: center;
    background: rgba(0, 0, 0, 0.32);
}
.ai-msg-tile.is-loading .ai-msg-tile-spin,
.ai-pending-file.is-loading .ai-msg-tile-spin { display: grid; }
.ai-msg-tile-spin::after {
    content: "";
    width: 1.35rem;
    height: 1.35rem;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ai-spin 0.7s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }
.ai-msg.is-you.has-files .ai-msg-text {
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
    text-align: right;
}
.ai-msg-body > p { margin: 0; }
.ai-msg-body.is-bad { color: var(--bad); }
.ai-msg.is-typing .ai-msg-body {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem 0.7rem;
    min-height: 1.35rem;
}
.ai-progress {
    margin: 0;
    font-size: 0.84rem;
    font-weight: 550;
    color: var(--ink-soft);
    line-height: 1.3;
}
.ai-typing {
    display: flex;
    align-items: center;
    gap: 0.28rem;
    margin: 0;
    min-height: 1.1rem;
}
.ai-typing span {
    width: 0.38rem;
    height: 0.38rem;
    border-radius: 50%;
    background: var(--teal);
    animation: ai-dot 1s ease-in-out infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.12s; }
.ai-typing span:nth-child(3) { animation-delay: 0.24s; }
@keyframes ai-dot {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
    40% { transform: translateY(-4px); opacity: 1; }
}
.ai-composer-dock {
    flex: 0 0 auto;
    padding: 0.2rem 0.85rem 0.95rem;
}
.explore-chat,
.fc-ai-rail {
    --ai-lang-dock-h: 2.6rem;
    --ai-pending-h: 5.4rem;
    --ai-file-actions-h: 0px;
    --ai-composer-row-h: 3.15rem;
}
.explore-chat .ai-composer-dock,
.fc-ai-rail .ai-composer-dock {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: calc(
        1.15rem
        + var(--ai-lang-dock-h)
        + var(--ai-file-actions-h)
        + var(--ai-pending-h)
        + var(--ai-composer-row-h)
    );
}
.explore-chat .ai-thread.is-empty,
.fc-ai-rail .ai-thread.is-empty {
    padding-top: calc(1.15rem + var(--ai-lang-dock-h, 2.6rem));
}
.ai-lang-dock {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    min-height: var(--ai-lang-dock-h, 2.6rem);
    padding: 0 0.1rem 0.35rem;
    box-sizing: border-box;
}
.ai-lang-dock #ai-action-explore,
.ai-lang-dock #ai-action-auto,
.ai-lang-dock #ai-action-guided,
.ai-lang-dock #ai-action-fill-meta {
    flex: 0 0 auto;
}
.ai-lang-dock[hidden] { display: none; }
.ai-lang-dock .ai-chip {
    max-width: min(14rem, calc(100% - 2.5rem));
    min-width: 0;
    width: max-content;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}
.ai-lang-dock .ai-icon-btn {
    flex: 0 0 auto;
    color: var(--ink);
}
.ai-lang-picker {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    justify-content: flex-end;
    background: rgba(0, 0, 0, 0.28);
}
.ai-lang-picker[hidden] { display: none; }
.ai-lang-picker-panel {
    width: min(26rem, 96vw);
    height: 100%;
    background: var(--paper);
    border-left: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    min-width: 0;
    box-shadow: -8px 0 28px rgba(0, 0, 0, 0.12);
}
.ai-lang-picker-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--line);
}
.ai-lang-picker-bar h2 {
    font-size: 1.05rem;
    font-weight: 650;
    flex: 1;
}
.ai-lang-picker-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-content: flex-start;
    flex: 1;
    overflow: auto;
    padding: 0.9rem 1rem 1.2rem;
}
.ai-chip {
    appearance: none;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
    padding: 0.38rem 0.75rem;
    border-radius: var(--r-pill);
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
    cursor: pointer;
    box-shadow: none;
}
.ai-chip.is-on,
.ai-chip.is-primary {
    background: var(--teal);
    border-color: var(--teal);
    color: #fff;
}
.ai-chip:disabled {
    opacity: 0.4;
    cursor: default;
}
.ai-empty .ai-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
}
.ai-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.55rem;
}
.ai-composer {
    flex: 0 0 auto;
    margin: 0;
    padding: 0.4rem 0.42rem 0.4rem 0.5rem;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--card);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.2rem;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.05);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.ai-pending {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    padding: 0.2rem 0.15rem 0.35rem;
}
.ai-pending[hidden] { display: none; }
.ai-pending-file { background: var(--paper); }
.ai-pending-file.is-pdf { display: block; }
.ai-pending-x {
    position: absolute;
    top: 0.2rem;
    right: 0.2rem;
    width: 1.2rem;
    height: 1.2rem;
    min-width: 1.2rem;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.62);
    color: #fff;
    font-size: 0.85rem;
    line-height: 1;
    display: grid;
    place-items: center;
    cursor: pointer;
}
.ai-pending-x:hover { background: rgba(0, 0, 0, 0.82); }
.ai-composer-row {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    min-width: 0;
}
.ai-composer:focus-within {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 14%, transparent);
}
.ai-composer textarea {
    min-height: 2.15rem;
    max-height: 8.5rem;
    flex: 1;
    width: auto;
    resize: none;
    border: 0;
    background: transparent;
    padding: 0.38rem 0.35rem;
    font-size: 0.92rem;
    line-height: 1.4;
    box-shadow: none;
}
.ai-composer textarea:focus { outline: none; }
.ai-send {
    background: var(--teal);
    color: #fff;
}
.ai-send:hover { background: var(--teal-deep); color: #fff; opacity: 1; transform: none; }
.ai-send:disabled { opacity: 0.35; }
.ai-send.is-stop { opacity: 1; }
.ai-send.is-stop svg { width: 0.82rem; height: 0.82rem; }
.fc-ai-rail input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
    opacity: 0;
}
.ai-drop {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background: color-mix(in srgb, var(--paper) 55%, var(--teal) 45%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}
.fc-ai-rail.is-drop .ai-drop { opacity: 1; }
.ai-drop p {
    margin: 0;
    padding: 0.85rem 1.15rem;
    border: 1.5px dashed color-mix(in srgb, var(--teal) 70%, transparent);
    border-radius: 16px;
    background: var(--card);
    color: var(--ink);
    font-size: 0.95rem;
    font-weight: 600;
}
html.night .ai-composer,
html.night .ai-msg-tile,
html.night .ai-pending-file,
html.night .ai-drop p { background: var(--card); }
html.night .ai-pending-x { background: rgba(0, 0, 0, 0.72); }
@media (prefers-reduced-motion: reduce) {
    .ai-typing span,
    .ai-msg-tile-spin::after,
    .ex-history-spin { animation: none; }
}
.ex-history {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    justify-content: flex-start;
    background: rgba(0, 0, 0, 0.28);
}
.ex-history[hidden] { display: none; }
.ex-history-panel {
    width: min(22rem, 92vw);
    height: 100%;
    background: var(--paper);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    min-width: 0;
    box-shadow: 8px 0 28px rgba(0, 0, 0, 0.12);
}
.ex-history-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--line);
}
.ex-history-bar h2 {
    font-size: 1.05rem;
    font-weight: 650;
    flex: 1;
}
#ex-history-close {
    font: inherit;
    border: 0;
    background: transparent;
    cursor: pointer;
    color: var(--ink-soft);
    font-size: 1.3rem;
    line-height: 1;
}
.ex-history-new {
    margin: 0.75rem 1rem 0.35rem;
    display: block;
    text-align: center;
    text-decoration: none;
    padding: 0.45rem 0.75rem;
    border-radius: var(--r-pill);
    background: var(--teal);
    color: #fff;
    font-weight: 600;
    font-size: 0.88rem;
    border: 0;
    cursor: pointer;
    font: inherit;
}
.ex-history-list { flex: 1; overflow: auto; padding: 0.4rem 0.55rem 1rem; }
.ex-history-item {
    display: block;
    text-decoration: none;
    color: inherit;
    padding: 0.7rem 0.75rem;
    border-radius: 12px;
    margin-bottom: 0.25rem;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    cursor: pointer;
    font: inherit;
}
.ex-history-item:hover,
.ex-history-item.is-on { background: var(--bot-bg); }
.ex-history-item strong { display: block; font-size: 0.92rem; font-weight: 600; line-height: 1.35; }
.ex-history-item span { display: block; margin-top: 0.2rem; font-size: 0.75rem; color: var(--ink-soft); }
.ex-history-empty { padding: 1.2rem 0.9rem; color: var(--ink-soft); font-size: 0.9rem; }
.ex-history-end {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 1.7rem;
    padding: 0.55rem 0.5rem 0.55rem;
    background: transparent;
    border: 0;
    box-shadow: none;
}
.ex-history-end[hidden] { display: none; }
.ex-history-end:has(.ex-history-spin:not([hidden])) {
    position: sticky;
    bottom: 0;
}
.ex-history-spin {
    width: 1.05rem;
    height: 1.05rem;
    flex: 0 0 auto;
    border: 2px solid color-mix(in srgb, var(--ink-soft) 28%, transparent);
    border-top-color: var(--ink-soft);
    border-radius: 50%;
    background: transparent;
    box-shadow: none;
    animation: ai-spin 0.7s linear infinite;
}
.ex-history-spin[hidden] { display: none; }
.ex-history-beginning {
    margin: 0;
    padding: 0.15rem 0.4rem 0.2rem;
    color: var(--ink-soft);
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.35;
    text-align: center;
    background: transparent;
}
.ex-history-beginning[hidden] { display: none; }

.ai-stage-full-btn {
    width: 2.15rem;
    height: 2.15rem;
    min-width: 2.15rem;
    padding: 0;
    border: 0;
    border-radius: var(--r-md);
    display: grid;
    place-items: center;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
}
.ai-stage-full-btn:hover {
    background: color-mix(in srgb, var(--teal) 8%, transparent);
    color: var(--ink);
}
.ai-stage-full-btn svg { width: 1.05rem; height: 1.05rem; }
.ai-guided-bar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 2.15rem;
}
.ai-guided-bar .ai-photo-nav {
    flex: 1;
    min-width: 0;
}
.ai-guided-bar .ai-stage-full-btn { margin-left: auto; }
.ai-guided-host .ai-icon-btn {
    width: 2.15rem;
    height: 2.15rem;
    min-width: 2.15rem;
    padding: 0;
    border: 0;
    border-radius: var(--r-md);
    display: grid;
    place-items: center;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
}
.ai-guided-host .ai-icon-btn:hover {
    background: color-mix(in srgb, var(--teal) 8%, transparent);
    color: var(--ink);
}
.ai-guided-host .ai-icon-btn svg { width: 1.05rem; height: 1.05rem; }
.ai-stage.is-laid,
.explore-stage.is-laid {
    overflow: hidden;
    touch-action: none;
}
.ai-stage.is-zoomed,
.explore-stage.is-zoomed {
    overflow: hidden;
    overscroll-behavior: contain;
    cursor: grab;
    /* Flex-center + auto margins eat start-side overflow; scroll cannot
       go below 0, so left/top edges are unreachable. Start-align when
       zoomed so scrollLeft/Top cover every edge. */
    justify-content: flex-start;
    align-items: flex-start;
}
.ai-stage.is-zoomed .ai-stage-fit,
.explore-stage.is-zoomed .explore-stage-fit {
    margin: 0;
}
.ai-stage.is-zoomed .ai-boxes,
.explore-stage.is-zoomed .explore-boxes {
    cursor: grab;
}
.ai-stage.is-zoomed.is-over-glyph,
.explore-stage.is-zoomed.is-over-glyph,
.ai-stage.is-zoomed.is-over-glyph .ai-boxes,
.explore-stage.is-zoomed.is-over-glyph .explore-boxes {
    cursor: text;
}
.ai-stage.is-panning,
.explore-stage.is-panning,
.ai-stage.is-panning .ai-boxes,
.explore-stage.is-panning .explore-boxes {
    cursor: grabbing;
}
.ai-stage.is-laid .ai-stage-fit,
.explore-stage.is-laid .explore-stage-fit {
    max-width: none;
    min-width: 0;
    min-height: 0;
    flex: 0 0 auto;
}
.ai-stage.is-laid .ai-stage-fit img,
.explore-stage.is-laid .explore-stage-fit img {
    max-width: none;
    max-height: none;
    min-width: 0;
    min-height: 0;
}
/* In-rail preview was the grey slab over the chat. Picker is fullscreen only. */
.fc-ai-rail > .ai-guided-host:not(.is-stage-full) {
    display: none !important;
}
.ai-guided-host[hidden] { display: none !important; }
.ai-guided {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 0.7rem 1.05rem 0.8rem;
}
.ai-guided[hidden] { display: none !important; }
.ai-photo-nav[hidden] { display: none !important; }
.ai-photo-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--ink-soft);
}
.ai-stage {
    --ai-stage-h: clamp(11rem, 36dvh, 24rem);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background: color-mix(in srgb, var(--paper) 88%, #000 6%);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    width: 100%;
    height: var(--ai-stage-h);
    min-height: 11rem;
    contain: layout paint;
}
.ai-stage-fit {
    position: relative;
    display: block;
    width: fit-content;
    height: fit-content;
    max-width: 100%;
    margin: 0 auto;
    line-height: 0;
    overflow: hidden;
}
.ai-stage-fit img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: var(--ai-stage-h);
    object-fit: contain;
}
.ai-stage-fit.is-reading .ai-boxes,
.ai-stage.is-reading .ai-boxes { cursor: wait; }
.ai-photo-reading {
    position: absolute;
    inset: 0;
    display: none;
    place-items: center;
    background: rgba(0, 0, 0, 0.28);
    pointer-events: none;
    z-index: 2;
}
.ai-stage.is-reading .ai-photo-reading { display: grid; }
.ai-photo-reading::after {
    content: "";
    width: 1.7rem;
    height: 1.7rem;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ai-spin 0.7s linear infinite;
}
.ai-boxes {
    position: absolute;
    inset: 0;
    pointer-events: auto;
    cursor: text;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.ai-hl {
    position: absolute;
    pointer-events: none;
    background: rgba(255, 214, 10, 0.48);
    border-radius: 2px;
}
.ai-hl.is-live { background: rgba(255, 214, 10, 0.32); }
html.night .ai-hl { background: rgba(255, 214, 10, 0.4); }
.ai-hl-hint {
    margin: 0;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--ink-soft);
}
.ai-guided-host.is-stage-full,
.explore-doc.is-stage-full {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: flex !important;
    flex-direction: column;
    min-height: 100dvh;
    background: var(--paper);
    border: 0;
}
.ai-guided-host.is-stage-full .ai-guided {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0.7rem 1.05rem 1rem;
}
.ai-guided-host.is-stage-full .ai-stage {
    flex: 1 1 auto;
    height: 0;
    min-height: 12rem;
    --ai-stage-h: 100%;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}
.ai-guided-host.is-stage-full .ai-stage-fit,
.ai-guided-host.is-stage-full .ai-stage-fit img {
    max-width: none;
    max-height: none;
}
.explore-doc.is-stage-full {
    display: flex !important;
}
.explore-doc.is-stage-full .explore-stage-wrap {
    flex: 1 1 auto;
    height: 0;
    min-height: 12rem;
    overflow: hidden;
    padding: 0;
    display: flex;
    flex-direction: column;
}
.explore-doc.is-stage-full .explore-paper {
    flex: 1 1 auto;
    height: 0;
    min-height: 0;
    width: 100%;
    max-width: none;
    display: flex;
    flex-direction: column;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}
.explore-doc.is-stage-full .explore-stage {
    flex: 1 1 auto;
    height: 0;
    min-height: 12rem;
    overflow: hidden;
}
.explore-doc.is-stage-full .explore-stage-fit img { max-height: none; }
.explore-doc.is-stage-full .explore-doc-text {
    flex: 1;
    overflow: auto;
    font-size: 1.12rem;
}
html.is-image-stage-full,
html.is-image-stage-full body {
    overflow: hidden;
}
html.is-image-stage-full .pop,
html.is-image-stage-full .hl-card-pop { z-index: 80; }

.hl-card-pop {
    position: fixed;
    z-index: 80;
    width: min(18.5rem, calc(100vw - 1.5rem));
    padding: 0.7rem 0.8rem 0.75rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.08);
    font-family: var(--font-ui);
    font-size: 0.92rem;
}
.hl-card-pop[hidden] { display: none; }
.hl-card-field {
    display: grid;
    gap: 0.2rem;
    margin: 0 0 0.5rem;
}
.hl-card-field span {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ink-soft);
    letter-spacing: 0.01em;
}
.hl-card-field input {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--line);
    background: transparent;
    border-radius: var(--r-md);
    padding: 0.48rem 0.55rem;
    font: inherit;
    color: inherit;
}
.hl-card-field input:focus {
    outline: none;
    background: color-mix(in srgb, var(--teal) 7%, transparent);
    border-color: color-mix(in srgb, var(--teal) 28%, var(--line));
}
.hl-card-note {
    margin: -0.15rem 0 0.5rem;
    font-size: 0.78rem;
    line-height: 1.35;
    color: var(--ink-soft);
}
.hl-card-note[hidden] { display: none; }
.hl-card-acts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}
html.night .hl-card-pop { background: var(--card); }
html.night .hl-card-field input:focus {
    background: color-mix(in srgb, var(--teal) 12%, transparent);
}
