/*======================================================
    ROOT
======================================================*/

:root {

    /* Palette */

    --background:      #f7f1e8;
    --card:            #ffffff;

    --primary:         #3f6f52; 
    --primary-dark:    #3d5d45;

    --primary-light:   #dfe9e2;
    --primary-soft:    #eef5ef;

    --accent:          #ea7b1f;
    --accent-light:    #ffd3a0;
    --accent-dark:     #c45d08;

    --muted:           #65736a;

    --card-warm:       antiquewhite;

    --text:            #2f4638;
    --text-soft:       #5d695f;

    --border:          #e4d8ca;

    --shadow: 0 10px 24px rgba(65, 48, 28, .14);
    --shadow-strong: 0 16px 34px rgba(65, 48, 28, .22);
    
    --radius-s: .75rem;
    --radius-m: 1rem;
    --radius-l: 1.5rem;
    --radius-xl: 2rem;
    
    --font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        "Helvetica Neue",
        Arial,
        sans-serif;
    
    --font-size-xs: .75rem;
    --font-size-s: .875rem;
    --font-size-m: 1rem;
    --font-size-l: 1.125rem;
    --font-size-xl: 1.375rem;
    --font-size-xxl: 1.875rem;
    
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font-family);
    font-size: var(--font-size-m);
    font-weight: var(--font-weight-normal);
    line-height: 1.5;
    color: var(--text);
    background: var(--background);
    overflow-x: hidden;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

button,
input,
select,
textarea {
    font: inherit;
}

/*======================================================
    Titles
======================================================*/

h1 {
    margin: 0;
    font-size: var(--font-size-xxl);
    font-weight: var(--font-weight-semibold);
}

h2 {
    margin: 0;
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
}

h3 {
    margin: 0;
    font-size: var(--font-size-l);
    font-weight: var(--font-weight-medium);
}

/*======================================================
    Button
======================================================*/

button,
input,
select,
textarea {
    font: inherit;
}

/*======================================================
    SIDE MENU
======================================================*/

.side-menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(0, 0, 0, .28);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
}

.side-menu-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.side-menu {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 90;
    width: 12rem;
    max-width: 82vw;
    height: 100vh;
    padding: .65rem;
    background: linear-gradient(
        180deg,
        #fff6e8,
        #fffaf2
    );
    box-shadow: var(--shadow-strong);
    transform: translateX(-105%);
    transition: transform .26s ease;
    overflow-y: auto;
}

.side-menu.open {
    transform: translateX(0);
}

.side-menu-title {
    display: none;
}

.side-menu-item {
    display: grid;
    grid-template-columns: 1rem 1fr;
    align-items: center;
    column-gap: .42rem;
    min-height: 2.8rem;      /* about 45 px */
    padding: 0 .75rem;
    gap: .75rem;
    border-radius: var(--radius-s);
    color: var(--text);
    text-decoration: none;
    font-size: .90rem;
    font-weight: var(--font-weight-medium);
    line-height: 1.05;
}

.side-menu-text {
    display: block;
    line-height: 1.05;
}

.side-menu-item:hover,
.side-menu-item.active {
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-weight: var(--font-weight-semibold);
}

.side-menu-icon {
    display: block;
    justify-self: center;
    width: .88rem;
    height: .88rem;
    object-fit: contain;
}

.side-menu-item.active .side-menu-icon {
    filter: sepia(1) saturate(2.5) hue-rotate(345deg);
}

.side-menu hr {
    width: calc(100% - .50rem);
    margin: .30rem auto;
    border: 0;
    border-top: 1px solid var(--border);
    opacity: .55;
}

/*======================================================
    SIDE MENU - MOBILE
======================================================*/

@media (max-width: 600px) {

    .side-menu {
        top: 4.25rem;
        left: 0;
        width: 13.5rem;
        max-width: 86vw;
        height: auto;
        max-height: calc(100vh - 5rem);
        padding: .75rem;
        border-radius: var(--radius-l);
        transform: translateX(-105%);
        overflow-y: auto;
    }

    .side-menu.open {
        transform: translateX(0);
    }

    .side-menu-item {
        min-height: 2.35rem;
        padding: 0 .55rem;
        column-gap: .60rem;
        font-size: 1rem;
        line-height: 1.15;
    }

    .side-menu-icon {
        width: 1.15rem;
        height: 1.15rem;
    }

    .side-menu hr {
        margin: .38rem auto;
    }

}



/* ======================================================
   PUBLIC LANGUAGE SWITCH
   ====================================================== */

.public-language-switch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .2rem;
    margin: 0 auto 1rem;
    padding: .22rem;
    border: 1px solid rgba(63, 111, 82, .22);
    border-radius: 999px;
    background: var(--primary-soft);
    box-shadow: 0 .25rem .7rem rgba(40, 55, 45, .08);
}

.public-language-switch > span {
    display: none;
}

.public-language-switch a {
    min-width: 2.9rem;
    padding: .42rem .72rem;
    border-radius: 999px;
    color: var(--primary-dark);
    font-size: .95rem;
    font-weight: var(--font-weight-semibold);
    line-height: 1;
    text-align: center;
    text-decoration: none;
    transition:
        background-color .18s ease,
        color .18s ease,
        box-shadow .18s ease;
}

.public-language-switch a:hover,
.public-language-switch a:focus-visible {
    background: rgba(255, 255, 255, .72);
    outline: none;
}

.public-language-switch a[aria-current="true"] {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 .18rem .45rem rgba(40, 55, 45, .18);
}

/*======================================================
    LOGIN
======================================================*/

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: var(--background);
}

.login-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
}

.login-card {
    width: min(24rem, 100%);
    padding: 2rem;
    border-radius: var(--radius-l);
    background: var(--card);
    box-shadow: var(--shadow);
    text-align: center;
}

.login-logo {
    margin-bottom: 1rem;
}

.login-logo-image {
    display: block;
    width: min(100%, 14rem); 
    height: auto;
    margin: 0 auto .5rem;
}

.login-card h1 {
    margin: 0 0 .50rem;
    font-size: var(--font-size-xxl);
    font-weight: var(--font-weight-semibold);
    color: var(--primary-dark);
}

.login-subtitle {
    margin: 0 0 1.50rem;
    color: var(--text-soft);
    font-size: var(--font-size-m);
}

.login-card form {
    text-align: left;
}

.login-card .row {
    margin-bottom: 1rem;
}

.login-card label {
    display: block;
    margin-bottom: .35rem;
    font-size: var(--font-size-s);
    font-weight: var(--font-weight-medium);
    color: var(--text);
}

.login-card input {
    width: 100%;
    padding: .75rem .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    background: #fff;
    color: var(--text);
    outline: none;
}

.login-card input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 .18rem rgba(78, 107, 90, .14);
}

.login-submit {
    margin-top: .5rem;
    border-radius: var(--radius-s);
    font-weight: var(--font-weight-semibold);
    margin: .75rem 0;
    padding: .9rem 1.4rem;
}

/*
.login-button {
    width: 100%;
    margin-top: .50rem;
    padding: .85rem 1rem;
    border: 0;
    border-radius: var(--radius-s);
    background: var(--accent);
    color: #fff;
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
}

.login-button:hover {
    background: var(--accent-dark);
}
*/

.login-card .small {
    margin-top: 1.25rem;
    font-size: var(--font-size-s);
    line-height: 1.7;
}

.login-card .small a {
    color: var(--primary-dark);
    font-weight: var(--font-weight-medium);
}

.notice {
    display: flex;
    align-items: center;
    gap: .7rem;
    margin: 1rem 0 1.5rem;
    padding: .9rem 1rem;
    border-radius: 1rem;
    font-weight: 600;
    line-height: 1.35;
}

.notice-info {
    background: rgba(232, 242, 235, .95);
    border: 1px solid rgba(71, 111, 86, .28);
    box-shadow: 0 .25rem .8rem rgba(0, 0, 0, .05);
}

.notice-icon {
    flex: 0 0 auto;
    font-size: 1.15rem;
}

.home-search-card{
    background: var(--card-warm);
}

.ml-home {
    min-height: calc(100vh - 40px);
    position: relative;
    padding: 8px 0 120px;
    overflow-x: hidden;
}

.ml-menu-button {
    position: fixed;
    top: 18px;
    left: 18px;
    z-index: 80;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 16px;
    background: rgba(255,255,255,.82);
    box-shadow: 0 8px 24px rgba(40,55,45,.14);
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
}

.ml-menu-button span {
    width: 20px;
    height: 2px;
    border-radius: 999px;
    background: var(--primary-dark);
}

.ml-light-header {
    text-align: center;
    padding: 18px 18px 8px;
}

.ml-logo-mark {
    font-size: 30px;
    line-height: 1;
    margin-bottom: 6px;
}

.ml-light-header h1 {
    margin: 0;
    color: var(--primary-dark);
    font-size: 30px;
    letter-spacing: -.03em;
}

.ml-light-header p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.ml-home-main {
    max-width: 760px;
    margin: 0 auto;
    padding: 12px 18px 0;
}

.ml-source-filters {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    margin: .7rem 0 1rem;
}

.ml-source-filter {
    padding: .45rem .8rem;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 999px;
    background: rgba(255, 255, 255, .75);
    cursor: pointer;
    font: inherit;
    font-size: .82rem;
}

.ml-source-filter.active {
    font-weight: 600;
    background: rgba(0, 0, 0, .08);
}

.ml-find-pill {
    position: relative;
    isolation: isolate;
    min-height: 178px;
    margin: 14px auto 28px;
    max-width: 460px;
    border-radius: 42px;
    background: antiquewhite;
    border: 1px solid #efd7bc;
    box-shadow: 0 18px 42px rgba(181,120,45,.14);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--primary-dark);
    overflow: hidden;
    transform: translateZ(0);
    transition: transform .22s ease, box-shadow .22s ease;
}

.ml-find-pill:hover,
.ml-find-pill:focus-visible {
    transform: translateY(-3px) scale(1.015);
    box-shadow: 0 28px 56px rgba(40,55,45,.24);
    outline: none;
}

.ml-find-glow {
    position: absolute;
    width: 210px;
    height: 210px;
    border-radius: 50%;
    background: var(--accent-light);
    opacity: .75;
    top: -92px;
    right: -74px;
    z-index: -1;
    animation: ml-breathe 3.8s ease-in-out infinite;
}

.ml-find-icon {
    font-size: 44px;
    margin-bottom: 8px;
}

.ml-find-title {
    font-size: 34px;
    font-weight: 800;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.ml-find-title,
.ml-find-icon {
    color: var(--primary-dark);
}

.ml-find-subtitle {
    margin-top: 8px;
    color: var(--muted);
    font-size: 15px;
}

@keyframes ml-breathe {
    0%, 100% { transform: scale(1); opacity: .78; }
    50% { transform: scale(1.16); opacity: 1; }
}

.ml-section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-top: .35rem;
/*    margin-bottom: .45em; */
}

.ml-section-heading h2 {
    margin: 0;
    font-size: 20px;
    color: var(--primary-dark);
}

.ml-section-heading a {
    color: var(--accent-dark);
    font-weight: 700;
    text-decoration: none;
    font-size: 14px;
}

.ml-book-shelf {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 14px;
}

.ml-book-placeholder {
    aspect-ratio: 2 / 3;
    min-height: 112px;
    border-radius: 14px;
    background: linear-gradient(
        155deg,
        #cfdccf,
        #ffffff 72%
    );
    border: 1px solid rgba(63,115,84,.16);
    box-shadow: 0 12px 24px rgba(82,114,93,.12);
    overflow: hidden;
    position: relative;
}

.ml-book-placeholder:nth-child(2n) {
    background: linear-gradient(
        155deg,
        #f3d3bd,
        #ffffff 72%
    );
}

.ml-book-placeholder:nth-child(3n) {
    background: linear-gradient(
        155deg,
        #e4c88d,
        #ffffff 72%
    );
}

.ml-book-spine {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 18%;
    background: rgba(56,77,64,.20);
}

.ml-library-sheet {
    position: fixed;
    left: 50%;
    bottom: 0;
    width: min(760px, 100%);
    z-index: 70;
    transform: translateX(-50%);
    background: rgba(255,255,255,.96);
    border: 1px solid rgba(78,107,90,.13);
    border-bottom: 0;
    border-radius: 30px 30px 0 0;
    box-shadow: 0 -18px 42px rgba(40,55,45,.18);
    padding: 12px 22px 22px;
    transition: transform .28s ease;
    touch-action: none;
}

.ml-library-sheet.ml-collapsed {
    transform: translateX(-50%) translateY(calc(100% - 74px));
}

.ml-library-sheet.ml-expanded {
    transform: translateX(-50%) translateY(0);
}

.ml-sheet-handle {
    padding: 4px 0 8px;
    cursor: grab;
}

.ml-sheet-handle span {
    display: block;
    width: 64px;
    height: 6px;
    border-radius: 999px;
    background: var(--accent);
    margin: 0 auto;
}

.ml-sheet-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 38px;
}

.ml-sheet-title-row h2 {
    margin: 0;
    color: var(--primary-dark);
    font-size: 19px;
}

.ml-sheet-arrow {
    color: var(--muted);
    font-size: 20px;
    line-height: 1;
}

.ml-library-stats {
    display: grid;
/*    grid-template-columns: repeat(5, minmax(0, 1fr)); */
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.ml-stat-card {
    min-height: 88px;
    border-radius: 18px;
    background: #fff6e8;
    text-decoration: none;
    color: var(--primary-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(78,107,90,.13);
}

.ml-stat-card strong {
    font-size: 26px;
    line-height: 1;
    color: var(--primary-dark);
}

.ml-stat-card span {
    margin-top: 8px;
    font-size: 13px;
    color: var(--muted);
    text-align: center;
}

.ml-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(20,28,24,.36);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}

.ml-side-menu {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(310px, 84vw);
    z-index: 100;
    background: #fff;
    box-shadow: 18px 0 44px rgba(20,28,24,.20);
    transform: translateX(-105%);
    transition: transform .25s ease;
    padding: 20px;
}

body.ml-menu-opened .ml-menu-backdrop {
    opacity: 1;
    pointer-events: auto;
}

body.ml-menu-opened .ml-side-menu {
    transform: translateX(0);
}

.ml-side-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    color: var(--primary-dark);
    font-size: 22px;
}

.ml-side-menu-header button {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 14px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.ml-side-nav {
    display: grid;
    gap: 6px;
}

.ml-side-nav a {
    display: block;
    padding: 13px 12px;
    border-radius: 14px;
    color: var(--text);
    text-decoration: none;
    font-weight: 650;
}

.ml-side-nav a:hover {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

@media (max-width: 600px) {
    .ml-light-header {
        padding-top: 14px;
    }

    .ml-light-header h1 {
        font-size: 27px;
    }

    .ml-find-pill {
        min-height: 164px;
        border-radius: 36px;
    }

    .ml-book-shelf {
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 10px;
    }

    .ml-book-placeholder {
        min-height: 88px;
        border-radius: 11px;
    }

    .ml-library-stats {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
    /* Pannello biblioteca compatto quando chiuso */
    .ml-library-sheet.ml-collapsed {
        transform: translateX(-50%) translateY(calc(100% - 46px));
    }

    .ml-library-sheet.ml-collapsed .ml-sheet-handle {
        padding: 4px 0 2px;
    }

    .ml-library-sheet.ml-collapsed .ml-sheet-handle span {
        width: 48px;
        height: 4px;
    }

    .ml-library-sheet.ml-collapsed .ml-sheet-title-row {
        min-height: 28px;
    }

    .ml-library-sheet.ml-collapsed .ml-sheet-title-row h2 {
        font-size: 16px;
    }

    .ml-library-sheet.ml-collapsed .ml-sheet-arrow {
        font-size: 17px;
    }
}

/*======================================================
    HEADER
======================================================*/

.app-header {
    position: sticky;
    top: 0;
    z-index: 70;
    height: 4rem;
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    background: linear-gradient(
        90deg,
        #ffd69c,
        #ffb66d
    );
    border-bottom: 1px solid rgba(47,70,56,.12);
}

.app-title {
    color: var(--primary-dark);
    font-weight: 700;
    letter-spacing: -.02em;
}

.app-header-title {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    padding-right: 3rem;
    color: var(--primary-dark);
}

.app-header-logo {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    text-decoration: none;
}

.app-header-logo img {
    display: block;
    width: auto;
    height: 2rem;
}

.app-header-page-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
}

@media (max-width: 600px) {
    .app-header-title {
        gap: .5rem;
        padding-right: 2.5rem;
    }

    .app-header-logo img {
        height: 1.65rem;
    }

    .app-header-page-title {
        font-size: var(--font-size-l);
    }
}

.side-menu-button {
    width: 3rem;
    height: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
}

.side-menu-button span {
    display: block;
    width: 1.45rem;
    height: .16rem;
    border-radius: 999px;
    background: var(--primary-dark);
    transition:
        transform .22s ease,
        opacity .22s ease;
}

.side-menu-button.open span:nth-child(1) {
    transform:
        translateY(.51rem)
        rotate(45deg);
}

.side-menu-button.open span:nth-child(2) {
    opacity: 0;
}

.side-menu-button.open span:nth-child(3) {
    transform:
        translateY(-.51rem)
        rotate(-45deg);
}

.registration-message {
    margin: 0 0 1rem;
    color: var(--text);
    font-size: var(--font-size-m);
    line-height: 1.55;
}

.registration-hint {
    margin: 1.50rem 0 1rem;
    padding: 1rem;
    border-radius: var(--radius-s);
    background: #fff6e8;
    color: var(--text-soft);
    font-size: var(--font-size-s);
    line-height: 1.5;
}

.registration-email {
    margin: 0.6rem 0 1.5rem;
    font-size: 1.15em;
    font-weight: 700;
    color: #355d43;
    text-align: center;
    overflow-wrap: anywhere;
}

.registration-wrong-email {
    margin-top: 1.4rem;
    text-align: center;
    font-size: 0.95em;
}

.admin-page {
    max-width: 1100px;
    margin: 2rem auto 6rem;
    padding: 0 1rem;
}

.admin-card {
    background: var(--card);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.admin-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.admin-card-header h2 {
    color: var(--primary-dark);
}

.admin-card-header p {
    margin: .35rem 0 0;
    color: var(--text-soft);
}

.admin-action {
    color: var(--accent);
    font-weight: 700;
}

.admin-table-wrapper {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}

.admin-table th,
.admin-table td {
    padding: .75rem .65rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

.admin-table th {
    color: var(--primary-dark);
    font-weight: 700;
    background: #fff8ee;
}

.admin-table tbody tr:hover {
    background: #fffaf2;
}

.access-result {
    display: inline-block;
    padding: .20rem .55rem;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 700;
    font-size: .80rem;
}

.ml-find-open {
    width: 100%;
    min-height: 178px;
    padding: 1rem;
    border: 0;
    background: transparent;
    color: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.ml-find-open[hidden],
.ml-find-panel[hidden] {
    display: none;
}

.ml-find-pill.ml-find-active {
    min-height: auto;
    padding: 1rem;
}

.ml-find-pill.ml-find-active .ml-find-glow {
    display: none;
}

.ml-find-panel {
    width: 100%;
}

.ml-find-search-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto auto;
    align-items: center;
    gap: .45rem;
    width: 100%;
    padding: .55rem .65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-l);
    background: #fff;
}

.ml-find-search-row input {
    width: 100%;
    min-width: 0;
    padding: .55rem .25rem;
    border: 0;
    outline: none;
    color: var(--text);
    background: transparent;
}

.ml-find-search-icon {
    font-size: 1.15rem;
}

.ml-find-tool {
    width: 2.7rem;
    height: 2.7rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;

    font-size: 1.25rem;
    line-height: 1;
}

.ml-find-action {
    width: 2.6rem;
    height: 2.6rem;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border: 0;
    border-radius: 50%;

    font-size: 1.15rem;
    line-height: 1;

    cursor: pointer;
}

.ml-find-status {
    min-height: 1.4rem;
    margin-top: .55rem;
    color: var(--text-soft);
    font-size: var(--font-size-s);
    text-align: center;
}

.ml-book-shelf:has(.ml-search-book) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
}

.ml-search-book {
    min-width: 0;
    padding: .65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-m);
    background: var(--card);
    color: var(--text);
    display: grid;
    grid-template-columns: 3.5rem minmax(0, 1fr);
    gap: .75rem;
    text-decoration: none;
    box-shadow: 0 .4rem 1rem rgba(40, 55, 45, .09);
}

.ml-search-book-cover {
    width: 3.5rem;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    border-radius: .5rem;
    background: var(--primary-light);
}

.ml-search-book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ml-search-book-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ml-search-book-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.ml-search-book-info strong,
.ml-search-book-info span,
.ml-search-book-info small {
    overflow: hidden;
    text-overflow: ellipsis;
}

.ml-search-book-info strong {
    color: var(--primary-dark);
}

.ml-search-book-info span,
.ml-search-book-info small {
    margin-top: .18rem;
    color: var(--text-soft);
}

.ml-search-empty {
    grid-column: 1 / -1;
    margin: 1rem 0;
    color: var(--text-soft);
    text-align: center;
}

@media (max-width: 600px) {

    .ml-book-shelf:has(.ml-search-book) {
        grid-template-columns: 1fr;
    }

    .ml-find-search-row {
        gap: .25rem;
        padding: .45rem;
    }
}

/* Inline SVG icons */
.icon { width: 1.25em; height: 1.25em; flex: 0 0 auto; vertical-align: -0.2em; }
.side-menu-icon { width: 1.35rem; height: 1.35rem; }

/*
 * Milestone 1: minimal functional presentation.
 * The definitive visual design belongs to Milestone 2.
 */

.ml-book-shelf:has(.ml-search-group) {
    display: block;
}

.ml-search-group {
    margin: 1rem 0 1.5rem;
}

.ml-search-group-title {
    margin: 0 0 .75rem;
}

.ml-search-results {
    display: grid;
    gap: .75rem;
}

.ml-search-book {
    display: grid;
    grid-template-columns: 4rem 1fr;
    gap: .75rem;
    padding: .75rem;
    color: inherit;
    text-decoration: none;
    background: rgba(255, 255, 255, .58);
    border: 1px solid rgba(47, 79, 63, .14);
    border-radius: .8rem;
}

.ml-search-book-cover {
    display: grid;
    place-items: center;
    min-height: 5.5rem;
    overflow: hidden;
    background: rgba(47, 79, 63, .08);
    border-radius: .55rem;
}

.ml-search-book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ml-search-book-meta {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    min-width: 0;
}

.ml-search-book-meta strong,
.ml-search-book-meta span {
    overflow-wrap: anywhere;
}

.ml-search-book-meta small {
    margin-top: .25rem;
    opacity: .7;
}

.ml-search-sources {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: .8rem;
}

.ml-search-source {
    padding: .35rem .65rem;
    border: 1px solid rgba(47, 79, 63, .18);
    border-radius: 999px;
    font-size: .88rem;
}

.ml-search-state {
    margin: .25rem 0;
    opacity: .78;
}

/* ==========================================================================
   Home Search — waiting state on smartphones
   ========================================================================== */

/*
 * The normal library view uses a six-column grid.
 * During a search, however, the two groups must span the full width.
 * The class is explicitly added and removed by home_search.js.
 */
.ml-book-shelf.ml-book-shelf-search {
    display: block;
    overflow: visible;
}

.ml-book-shelf-search .ml-search-group {
    width: 100%;
    min-width: 0;
}

.ml-book-shelf-search .ml-search-group + .ml-search-group {
    margin-top: 1.25rem;
}

.ml-book-shelf-search .ml-search-group-title {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin: 0 0 .65rem;
    font-size: 1.05rem;
    line-height: 1.25;
}

.ml-book-shelf-search .ml-search-results {
    display: grid;
    gap: .65rem;
    width: 100%;
    min-width: 0;
}

.ml-book-shelf-search .ml-search-state {
    display: flex;
    align-items: center;
    min-height: 3.2rem;
    margin: 0;
    padding: .8rem 1rem;
    line-height: 1.35;
    background: rgba(255, 255, 255, .58);
    border: 1px solid rgba(78, 107, 90, .12);
    border-radius: var(--radius-l, 1rem);
    opacity: .82;
}

/* Source status: readable pills, not narrow columns. */
.ml-book-shelf-search #ml-online-status {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    width: 100%;
    margin: 0 0 .75rem;
}

.ml-book-shelf-search #ml-online-status .ml-search-source {
    display: inline-flex;
    align-items: center;
    width: auto;
    max-width: 100%;
    padding: .4rem .7rem;
    font-size: .82rem;
    line-height: 1.2;
    white-space: normal;
    background: rgba(255, 255, 255, .64);
    border: 1px solid rgba(78, 107, 90, .12);
    border-radius: 999px;
}

/* The general message remains compact above the results. */
.ml-find-status:not(:empty) {
    margin-top: .65rem;
    font-size: .88rem;
    line-height: 1.25;
}

/* Prevents the search title from breaking the layout with long text. */
.ml-book-shelf-search + *,
#ml-books-title {
    min-width: 0;
}

#ml-books-title {
    overflow-wrap: anywhere;
}

@media (max-width: 600px) {

    .ml-book-shelf-search .ml-search-group + .ml-search-group {
        margin-top: 1rem;
    }

    .ml-book-shelf-search .ml-search-group-title {
        font-size: 1rem;
    }

    .ml-book-shelf-search .ml-search-state {
        min-height: 2.9rem;
        padding: .7rem .8rem;
        font-size: .92rem;
    }

    .ml-book-shelf-search #ml-online-status {
        gap: .4rem;
    }

    .ml-book-shelf-search #ml-online-status .ml-search-source {
        padding: .38rem .62rem;
        font-size: .78rem;
    }
}

/* Import from an online result */
.ml-search-import {
    align-self: flex-start;
    margin-top: .7rem;
    padding: .48rem .75rem;
    font-size: .78rem;
}

.save-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: .7rem;
}

@media (max-width: 600px) {
    .ml-search-import {
        width: 100%;
    }

    .save-bar > .button,
    .save-bar > button,
    .save-bar > a {
        flex: 1 1 100%;
    }
}

/* ==========================================================
   COMPONENTS / BUTTONS
   ========================================================== */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;

    min-height: 2.65rem;
    justify-content:center;
    text-align:center;
/*    padding: .65rem 1.10rem; */

    font: inherit;
    font-size: .95rem;
    font-weight: 600;
    line-height: 1;

    text-decoration: none;
    white-space: nowrap;

    border: 1px solid transparent;
    border-radius: var(--radius-m);

    cursor: pointer;
    user-select: none;

    transition:
        background-color .18s ease,
        border-color .18s ease,
        color .18s ease,
        box-shadow .18s ease,
        transform .18s ease;
}

.button-form {
    min-height: 3rem;
    font-size: 1rem;
    font-weight: 700;
}

/* Hover */

.button:hover {
    transform: translateY(-1px);
}

/* Active */

.button:active {
    transform: translateY(0);
}

/* Focus */

.button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 .18rem rgba(84,125,92,.28);
}

/* Disabled */

.button:disabled,
.button.disabled {
    opacity: .55;
    cursor: default;
    pointer-events: none;
    transform: none;
}

/* ==========================================================
   PRIMARY
   ========================================================== */

.button-primary {

    background: var(--primary);
    color: #fff;

    border-color: var(--primary);
}

.button-primary:hover {

    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* ==========================================================
   SECONDARY
   ========================================================== */

.button-secondary {

    background: #fffaf3;

    color: var(--primary-dark);

    border-color: rgba(84,125,92,.35);
}

.button-secondary:hover {

    background: #f6f1e8;

    border-color: rgba(84,125,92,.55);
}

/* ==========================================================
   DANGER
   ========================================================== */

.button-danger {

    background: #c74d4d;

    color: white;

    border-color: #c74d4d;
}

.button-danger:hover {

    background: #b13f3f;

    border-color: #b13f3f;
}

/* ==========================================================
   DIMENSIONS
   ========================================================== */

.button-small {

    min-height: 2.20rem;

    padding: .45rem .80rem;

    font-size: .88rem;
}

.button-large {

    min-height: 3rem;

    padding: .80rem 1.50rem;

    font-size: 1rem;
}

.button-full {

    display: flex;

    width: 100%;
}

/* ==========================================================
   GROUP
   ========================================================== */

.button-group {

    display: flex;

    gap: .60rem;

    flex-wrap: wrap;

    align-items: center;
}

/* ======================================================
   HOME - RECENT BOOKS
   ====================================================== */

.ml-recent-book {
    position: relative;
    min-width: 0;
    aspect-ratio: 2 / 3;
    overflow: hidden;

    border: 1px solid rgba(63, 115, 84, .16);
    border-radius: .9rem;

    background: linear-gradient(
        155deg,
        #cfdccf,
        #ffffff 72%
    );

    color: var(--text);
    text-decoration: none;

    box-shadow:
        0 .75rem 1.5rem rgba(82, 114, 93, .12);

    transition:
        transform .18s ease,
        box-shadow .18s ease;
}

.ml-recent-book:nth-child(2n) {
    background: linear-gradient(
        155deg,
        #f3d3bd,
        #ffffff 72%
    );
}

.ml-recent-book:nth-child(3n) {
    background: linear-gradient(
        155deg,
        #e4c88d,
        #ffffff 72%
    );
}

.ml-recent-book:hover,
.ml-recent-book:focus-visible {
    transform: translateY(-.2rem);
    box-shadow:
        0 1rem 1.8rem rgba(82, 114, 93, .18);
}

.ml-recent-book > img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ml-recent-book .ml-book-spine {
    position: absolute;
    inset: 0 auto 0 0;
    width: 18%;
    background: rgba(56, 77, 64, .2);
}

.ml-recent-book-placeholder {
    position: absolute;
    inset: 0;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    gap: .4rem;
    padding: .75rem 1rem .75rem 1.4rem;

    text-align: center;
}

.ml-recent-book-placeholder strong {
    color: var(--primary-dark);
    font-size: 2rem;
    line-height: 1;
}

.ml-recent-book-placeholder small {
    display: -webkit-box;
    overflow: hidden;

    font-size: .72rem;
    line-height: 1.25;

    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.ml-recent-book-info {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;

    display: none;
    padding: .55rem;

    background: rgba(255, 255, 255, .92);
}

.ml-recent-book-info strong,
.ml-recent-book-info small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ml-recent-book-info strong {
    font-size: .78rem;
}

.ml-recent-book-info small {
    margin-top: .15rem;
    color: var(--text-soft);
    font-size: .68rem;
}

.ml-recent-book:hover .ml-recent-book-info,
.ml-recent-book:focus-visible .ml-recent-book-info {
    display: block;
}

.ml-recent-empty {
    grid-column: 1 / -1;
    padding: 1.25rem;

    border: 1px solid rgba(63, 115, 84, .13);
    border-radius: var(--radius-m);

    background: rgba(255, 255, 255, .55);
    color: var(--text-soft);
    text-align: center;
}

@media (max-width: 600px) {

    .ml-recent-book-info {
        display: none;
    }

    .ml-recent-book-placeholder small {
        font-size: .66rem;
    }
}

/* ======================================================
   Page-actions
   ====================================================== */

.page-actions,
.bottom-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem;
}

.page-actions .button,
.bottom-actions .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;

    width: auto;
    min-width: 0;
    min-height: 2.9rem;
    padding: .7rem 1.1rem;

    white-space: nowrap;
}

.bottom-actions {
    margin-top: 1.25rem;
}

@media (max-width: 600px) {

    .page-actions .button {
        flex: 1 1 auto;
    }

    .bottom-actions .button {
        flex: 1 1 calc(50% - .65rem);
    }
}

/* ==========================================================================
 * Library
 * ========================================================================== */

.library-page {
    width: min(calc(100% - 2rem), 70rem);
    margin: 1.25rem auto 3rem;
}

.library-page > .page-actions {
    margin-bottom: 1.2rem;
}

.library-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;

    margin-bottom: 1rem;
}

.library-heading h1 {
    margin: 0;
}

.library-count {
    margin: .3rem 0 0;
    opacity: .72;
}

.library-search {
    margin-bottom: 1.2rem;
}

.library-search-field {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: .55rem;

    padding: .55rem;

    border: 1px solid rgba(63, 111, 82, .18);
    border-radius: 1.2rem;

    background: rgba(255, 255, 255, .82);

    box-shadow:
        0 .4rem 1.4rem rgba(44, 59, 49, .08);
}

.library-search-icon {
    padding-left: .5rem;
    font-size: 1.2rem;
}

.library-search-field input {
    width: 100%;
    min-width: 0;
    height: 3rem;

    padding: 0 .7rem;

    border: 0;
    outline: 0;

    background: transparent;
    color: var(--primary);

    font: inherit;
}

.library-search-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 2.5rem;
    height: 2.5rem;

    border-radius: 50%;

    background: rgba(63, 111, 82, .1);
    color: inherit;

    text-decoration: none;
    font-size: 1.25rem;
}

.library-search-field .button {
    width: auto;
    min-width: 0;
    padding: .7rem 1.15rem;
}

.library-search-summary {
    margin: 0 0 1rem;
    font-size: .92rem;
    opacity: .76;
}

.library-results {
    display: grid;
    gap: .85rem;
}

.ml-search-book-card {
    min-width: 0;
}

.library-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .65rem;

    padding: 3rem 1.5rem;

    border: 1px solid rgba(63, 111, 82, .15);
    border-radius: 1.2rem;

    background: rgba(255, 255, 255, .65);

    text-align: center;
}

.library-empty-icon {
    font-size: 3rem;
}

.library-empty h2,
.library-empty p {
    margin: 0;
}

.library-empty .button {
    width: auto;
    margin-top: .5rem;
    padding-inline: 1.2rem;
}

@media (max-width: 600px) {

    .library-page {
        width: calc(100% - 1.5rem);
        margin: .9rem .75rem 2rem;
    }

    .library-heading h1 {
        font-size: 1.8rem;
    }

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

    .library-search-field .button {
        grid-column: 1 / -1;
        width: 100%;
    }
}

/* ======================================================
   Invite user
   ====================================================== */

.invite-page {
    display: flex;
    justify-content: center;
    padding: 2rem 1rem;
}

.invite-card {
    width: 100%;
    max-width: 42rem;
    padding: 2rem;
    background: var(--surface, #fff);
    border-radius: var(--radius-l, 1rem);
    box-shadow: 0 0.25rem 1.25rem rgba(0, 0, 0, 0.08);
}

.invite-card h1 {
    margin: 0 0 1rem;
}

.invite-intro {
    margin: 0 0 2rem;
    line-height: 1.5;
}

.invite-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.invite-form .row {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.invite-form label {
    font-weight: 600;
}

.invite-form input,
.invite-form select {
    box-sizing: border-box;
    width: 100%;
    min-height: 2.8rem;
    padding: 0.6rem 0.75rem;
    font: inherit;
    border: 1px solid #aaa;
    border-radius: 0.5rem;
    background: #fff;
}

.invite-form input:focus,
.invite-form select:focus {
    outline: 2px solid var(--primary, #4f7d61);
    outline-offset: 1px;
}

.invite-form .page-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.invite-form .button {
    min-width: 10rem;
}

@media (max-width: 600px) {

    .invite-page {
        padding: 1rem;
    }

    .invite-card {
        padding: 1.25rem;
    }

    .invite-form .page-actions {
        justify-content: stretch;
    }

    .invite-form .button {
        width: 100%;
    }
}

.invite-success {
    padding: 2rem 0;
    text-align: center;
}

.invite-success h2 {
    margin: 0 0 1rem;
}

.invite-success p {
    margin: 0 0 2rem;
}

.invite-success .button {
    display: inline-block;
    padding: 0.8rem 2rem;
    min-width: 12rem;
    text-align: center;
}

.invite-success-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.invite-success-actions .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 2rem;
    min-width: 12rem;
    text-align: center;
}

.invitation-form .notice,
.invite-card .notice {
    padding: 1rem 1.25rem;
    margin: 1rem 0 1.5rem;
}

.registration-wrong-email {
    margin: 1.4rem 0 0.35rem;
    text-align: center;
}

.registration-wrong-email-action {
    margin: 0;
    text-align: center;
}

.profile-card {
    margin-top: 1.5rem;
    padding: 1.5rem 1.75rem;

    background: #fff;
    border-radius: 1.5rem;

    box-shadow:
        0 0.25rem 1rem rgba(0, 0, 0, 0.06);
}

.profile-row {
    display: flex;
    gap: 0.6rem;
    padding: 0.65rem 0;

    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.profile-row:last-child {
    border-bottom: 0;
}

.profile-label {
    min-width: 7rem;
    font-weight: 700;
}

.profile-value {
    flex: 1;
}

@media (max-width: 600px) {

    .invite-success-actions {
        flex-direction: column;
    }

    .invite-success-actions .button {
        width: 100%;
    }
}

.app-card {
    background: #ffffff;
    border-radius: 2rem;
    padding: 2rem;
    box-shadow:
        0 0.25rem 1rem rgba(0, 0, 0, 0.06);
}

.app-main {
    padding: 1rem;
}

.profile-card {
    max-width: 46rem;
    margin: 1rem auto;
}

.library-selection {
    display: grid;
    gap: 0.8rem;
    margin: 1.5rem 0;
}

.library-choice {
    display: flex;
    align-items: center;
    gap: 1rem;

    padding: 1rem 1.2rem;

    border: 1px solid #d7d7d7;
    border-radius: 1rem;

    cursor: pointer;
}

.library-choice-content {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.library-choice input {
    flex: 0 0 auto;
}

.library-choice {
    display: flex;
    align-items: center;
    gap: 1rem;

    padding: 1rem 1.2rem;

    background: #fffaf2;
    border: 1px solid #d7d7d7;
    border-radius: 1rem;

    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.06);

    cursor: pointer;
    transition:
        box-shadow 0.2s ease,
        transform 0.2s ease,
        border-color 0.2s ease;
}

.library-choice:hover {
    box-shadow: 0 5px 14px rgba(0, 0, 0, 0.09);
}

.library-choice:has(input:checked) {
    border-color: #477a5b;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.10);
}

.library-selection {
    display: grid;
    gap: 0.9rem;
    margin: 1.5rem 0;
}

.library-choice-form {
    margin: 0;
}

.library-choice-button {
    width: 100%;

    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;

    padding: 1.2rem 1.4rem;

    background: #fffaf2;
    border: 1px solid #d7d7d7;
    border-radius: 1rem;

    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.06);

    color: inherit;
    text-align: left;
    cursor: pointer;

    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        border-color 0.15s ease;
}

.library-choice-button:hover {
    transform: translateY(-1px);

    border-color: #477a5b;

    box-shadow:
        0 5px 14px rgba(0, 0, 0, 0.09);
}

.library-choice-name {
    font-weight: 700;
    font-size: 1.05em;
}

.library-choice-role {
    font-size: 0.95em;
}

.library-choice-button {
    appearance: none;
    -webkit-appearance: none;
}

.ml-manual-add {
    margin-top: 1.5rem;
    padding: 1rem;
    text-align: center;
}

.ml-manual-add p {
    margin: 0 0 .75rem;
    font-size: .95rem;
}

.ml-manual-add .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .8rem 1.75rem;
    text-decoration: none;
}

/*======================================================
    EXPLORE
======================================================*/
.explore-page { max-width: 100%; margin: 1.5rem auto 5rem; padding: 0 1rem; }
.explore-heading, .explore-status, .explore-mobile-sort, .explore-pagination { display: flex; align-items: center; gap: .75rem; }
.explore-heading { justify-content: space-between; margin-bottom: 1rem; }
.explore-heading h1 { color: var(--primary-dark); }
.explore-heading p { margin: .25rem 0 0; color: var(--text-soft); }
.explore-status { justify-content: space-between; margin-bottom: .75rem; color: var(--text-soft); }
.explore-clear, .explore-filter-button { border: 0; background: transparent; color: var(--accent-dark); font-weight: 700; cursor: pointer; }
.explore-filter-button { display: none; padding: .65rem .9rem; border-radius: var(--radius-s); background: var(--primary-soft); color: var(--primary-dark); }
.explore-table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-m); background: var(--card); box-shadow: var(--shadow); }
.explore-table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: .88rem; }
.explore-table th, .explore-table td { min-width: 9rem; max-width: 18rem; padding: .62rem .7rem; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }

/* Balanced desktop widths for the 12 information units. */
.explore-table th:nth-child(1),  .explore-table td:nth-child(1)  { min-width: 17rem; max-width: 22rem; } /* Title */
.explore-table th:nth-child(2),  .explore-table td:nth-child(2)  { min-width: 14rem; max-width: 18rem; } /* Author */
.explore-table th:nth-child(3),  .explore-table td:nth-child(3)  { min-width: 12rem; max-width: 16rem; } /* Publisher */
.explore-table th:nth-child(4),  .explore-table td:nth-child(4)  { min-width: 11rem; max-width: 15rem; } /* Series */
.explore-table th:nth-child(5),  .explore-table td:nth-child(5)  { min-width: 6rem;  max-width: 7rem; } /* Language */
.explore-table th:nth-child(6),  .explore-table td:nth-child(6)  { min-width: 5rem;  max-width: 5.5rem; } /* Year */
.explore-table th:nth-child(7),  .explore-table td:nth-child(7)  { min-width: 11rem; max-width: 14rem; } /* Publication place */
.explore-table th:nth-child(8),  .explore-table td:nth-child(8)  { min-width: 10rem; max-width: 11rem; } /* ISBN */
.explore-table th:nth-child(9),  .explore-table td:nth-child(9)  { min-width: 14rem; max-width: 18rem; } /* Dewey */
.explore-table th:nth-child(10), .explore-table td:nth-child(10) { min-width: 10rem; max-width: 13rem; } /* Category */
.explore-table th:nth-child(11), .explore-table td:nth-child(11) { min-width: 11rem; max-width: 14rem; } /* Subject */
.explore-table th:nth-child(12), .explore-table td:nth-child(12) { min-width: 9rem;  max-width: 12rem; } /* Collocation */

.explore-filter-row th:nth-child(5) input { min-width: 4.8rem; }
.explore-filter-row th:nth-child(6) input { min-width: 3.8rem; }
.explore-headings th { position: sticky; top: 0; z-index: 2; padding: 0; background: #fff8ee; }
.explore-sort { width: 100%; padding: .72rem; border: 0; background: transparent; color: var(--primary-dark); font-weight: 700; text-align: left; cursor: pointer; white-space: nowrap; }
.explore-filter-row th { padding: .4rem; background: #fffdf9; }
.explore-filter-row input { width: 100%; min-width: 7rem; padding: .45rem .5rem; border: 1px solid var(--border); border-radius: .5rem; background: #fff; }
.explore-table tbody tr { cursor: pointer; }
.explore-table tbody tr:hover { background: var(--primary-soft); }
.explore-cards, .explore-mobile-sort { display: none; }
.explore-pagination { justify-content: center; margin-top: 1rem; }
.explore-pagination button { padding: .55rem .8rem; border: 1px solid var(--border); border-radius: var(--radius-s); background: #fff; color: var(--primary-dark); cursor: pointer; }
.explore-pagination button:disabled { opacity: .45; cursor: default; }
.explore-filter-overlay, .explore-filter-panel { display: none; }

@media (max-width: 760px) {
    .explore-page { margin-top: 1rem; padding: 0 .75rem; }
    .explore-heading p { font-size: .9rem; }
    .explore-filter-button { display: inline-flex; }
    .explore-table-wrap { display: none; }
    .explore-mobile-sort { display: grid; grid-template-columns: auto 1fr auto; margin: .75rem 0 1rem; }
    .explore-mobile-sort select, .explore-mobile-sort button { min-height: 2.6rem; border: 1px solid var(--border); border-radius: var(--radius-s); background: #fff; }
    .explore-mobile-sort select { width: 100%; padding: .45rem .6rem; }
    .explore-mobile-sort button { width: 2.8rem; color: var(--primary-dark); font-weight: 700; }
    .explore-cards { display: grid; gap: .8rem; }
    .explore-card { padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius-m); background: var(--card); box-shadow: 0 5px 14px rgba(65,48,28,.08); cursor: pointer; }
    .explore-card h2 { margin: 0 0 .75rem; color: var(--primary-dark); font-size: 1.05rem; }
    .explore-card dl { display: grid; gap: .38rem; margin: 0; }
    .explore-card dl div { display: grid; grid-template-columns: minmax(6.5rem, 38%) 1fr; gap: .55rem; }
    .explore-card dt { color: var(--muted); font-size: .82rem; font-weight: 700; }
    .explore-card dd { margin: 0; font-size: .88rem; overflow-wrap: anywhere; }
    .explore-filter-overlay { display: block; position: fixed; inset: 0; z-index: 100; background: rgba(20,28,24,.35); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
    .explore-filter-overlay.open { opacity: 1; pointer-events: auto; }
    .explore-filter-panel { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 110; max-height: 86vh; flex-direction: column; background: #fff; border-radius: 1.4rem 1.4rem 0 0; box-shadow: 0 -18px 42px rgba(40,55,45,.22); transform: translateY(105%); transition: transform .25s ease; }
    .explore-filter-panel.open { transform: translateY(0); }
    .explore-filter-panel-head, .explore-filter-panel-actions { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1rem; }
    .explore-filter-panel-head { border-bottom: 1px solid var(--border); }
    .explore-filter-panel-head button { border: 0; background: transparent; font-size: 1.7rem; color: var(--primary-dark); }
    .explore-filter-panel-body { overflow-y: auto; display: grid; gap: .75rem; padding: 1rem; }
    .explore-filter-panel-body label { display: grid; gap: .25rem; color: var(--text-soft); font-size: .85rem; font-weight: 600; }
    .explore-filter-panel-body input { width: 100%; padding: .65rem .7rem; border: 1px solid var(--border); border-radius: var(--radius-s); }
    .explore-filter-panel-actions { border-top: 1px solid var(--border); }
    .explore-filter-panel-actions button { flex: 1; min-height: 2.8rem; border: 0; border-radius: var(--radius-s); font-weight: 700; cursor: pointer; }
    .explore-filter-panel-actions .primary { background: var(--primary); color: #fff; }
}


/* ======================================================
   CONTEXTUAL PAGE HELP
   ====================================================== */

.app-header-help {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.35rem;
    height: 2.35rem;
    margin-left: auto;
    padding: 0;
    border: 1px solid rgba(63, 111, 82, .22);
    border-radius: 50%;
    background: rgba(255, 255, 255, .72);
    color: var(--primary-dark);
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.app-header-help:hover,
.app-header-help:focus-visible {
    background: #fff;
    border-color: var(--primary);
}

.context-help-dialog {
    width: min(42rem, calc(100% - 2rem));
    max-height: min(82vh, 48rem);
    padding: 0;
    border: 0;
    border-radius: 1.2rem;
    background: transparent;
    box-shadow: 0 1.25rem 3.5rem rgba(34, 47, 39, .24);
}

.context-help-dialog::backdrop {
    background: rgba(24, 31, 27, .48);
}

.context-help-shell {
    display: flex;
    max-height: min(82vh, 48rem);
    flex-direction: column;
    overflow: hidden;
    background: var(--card, #fff);
    color: var(--text);
}

.context-help-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.15rem 1.25rem .9rem;
    border-bottom: 1px solid var(--border);
}

.context-help-kicker {
    display: block;
    margin-bottom: .2rem;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.context-help-header h2 {
    margin: 0;
    color: var(--primary-dark);
    font-size: 1.3rem;
}

.context-help-close {
    flex: 0 0 auto;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--primary-dark);
    font-size: 1.7rem;
    line-height: 1;
    cursor: pointer;
}

.context-help-close:hover,
.context-help-close:focus-visible {
    background: var(--primary-soft);
}

.context-help-body {
    overflow-y: auto;
    padding: 1rem 1.25rem 1.25rem;
}

.context-help-body p {
    margin: 0 0 1rem;
    line-height: 1.55;
}

.context-help-body h3 {
    margin: 1.15rem 0 .35rem;
    color: var(--primary-dark);
    font-size: 1rem;
    font-weight: 700;
}

.context-help-note {
    margin: .9rem 0 1.1rem;
    padding: .9rem 1rem;
    border-left: .25rem solid var(--primary);
    border-radius: .6rem;
    background: var(--primary-soft);
}

.context-help-note p {
    margin: .35rem 0 0;
}

.context-help-footer {
    display: flex;
    justify-content: flex-end;
    padding: .85rem 1.25rem 1rem;
    border-top: 1px solid var(--border);
}

.intro-svg-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.intro-menu-icon {
    width: 3.6rem;
    height: 3.6rem;
    color: var(--primary-dark);
}

@media (max-width: 600px) {
    .app-header-help {
        width: 2.15rem;
        height: 2.15rem;
        font-size: 1.05rem;
    }

    .context-help-dialog {
        width: calc(100% - 1rem);
        max-height: 88vh;
        margin: auto .5rem .5rem;
        border-radius: 1.2rem 1.2rem .8rem .8rem;
    }

    .context-help-shell {
        max-height: 88vh;
    }

    .context-help-header,
    .context-help-body,
    .context-help-footer {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}


/* ==========================================================================
   INTRODUCTORY GUIDE
   ========================================================================== */

body.intro-open { overflow: hidden; }

.intro-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(28, 37, 31, .54);
    backdrop-filter: blur(.2rem);
}

.intro-card {
    width: min(34rem, 100%);
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding: 1.35rem;
    border: 1px solid rgba(63, 111, 82, .15);
    border-radius: var(--radius-xl);
    background: #fffaf3;
    color: var(--text);
    box-shadow: var(--shadow-strong);
}

.intro-progress {
    display: flex;
    justify-content: center;
    gap: .45rem;
    margin: 0 0 1.1rem;
}

.intro-dot {
    width: .55rem;
    height: .55rem;
    border-radius: 999px;
    background: var(--border);
    transition: width .18s ease, background-color .18s ease;
}

.intro-dot.is-active {
    width: 1.5rem;
    background: var(--accent);
}

.intro-slides {
    min-height: 18rem;
    display: flex;
    align-items: center;
}

.intro-slide {
    width: 100%;
    text-align: center;
}

.intro-slide[hidden] { display: none; }

.intro-illustration {
    display: grid;
    place-items: center;
    width: 5.5rem;
    height: 5.5rem;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: var(--primary-soft);
    font-size: 2.8rem;
    line-height: 1;
}

.intro-hamburger {
    color: var(--primary-dark);
    font-size: 3.1rem;
    font-weight: 700;
}

.intro-slide h1 {
    margin: 0 0 .85rem;
    color: var(--primary-dark);
    font-size: 1.55rem;
}

.intro-slide p {
    margin: 0 auto;
    max-width: 28rem;
    color: var(--text-soft);
    line-height: 1.55;
}

.intro-slide p + p { margin-top: .85rem; }

.intro-tip {
    padding: .8rem 1rem;
    border-radius: var(--radius-m);
    background: #fff1dd;
    color: var(--text);
}

.intro-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-top: 1.1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.intro-nav {
    display: flex;
    gap: .55rem;
}

.intro-actions .button {
    padding: .7rem 1rem;
}

.intro-skip {
    padding: .5rem;
    border: 0;
    background: transparent;
    color: var(--muted);
    text-decoration: underline;
    cursor: pointer;
}

.intro-error {
    margin: .85rem 0 0;
    color: #9b3434;
    font-size: .88rem;
    text-align: center;
}

.profile-help-actions { margin-top: 1.25rem; }

@media (max-width: 600px) {
    .intro-overlay {
        padding: .6rem;
        align-items: end;
    }

    .intro-card {
        width: 100%;
        max-height: calc(100vh - 1.2rem);
        padding: 1.15rem;
        border-radius: 1.5rem 1.5rem .9rem .9rem;
    }

    .intro-slides { min-height: 16.5rem; }

    .intro-illustration {
        width: 4.7rem;
        height: 4.7rem;
        font-size: 2.35rem;
    }

    .intro-slide h1 { font-size: 1.35rem; }
    .intro-slide p { font-size: .95rem; }

    .intro-nav {
        flex: 1;
        justify-content: flex-end;
    }

    .intro-actions .button {
        min-width: 0;
        padding: .65rem .8rem;
    }
}


.intro-official-icon {
    display: grid;
    place-items: center;
    width: 7rem;
    height: 7rem;
    margin: 0 auto 1rem;
}

.intro-official-icon img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/*
 * Context help should normally grow to fit its contents.
 * Internal scrolling remains only as a safety fallback on short viewports.
 */
.context-help-dialog {
    width: min(50rem, calc(100% - 2rem));
    max-height: calc(100vh - 2rem);
}

.context-help-shell {
    max-height: calc(100vh - 2rem);
}

.context-help-body {
    overflow-y: visible;
}

@media (max-height: 700px) {
    .context-help-body {
        overflow-y: auto;
    }
}

@media (max-width: 600px) {
    .intro-official-icon {
        width: 5.5rem;
        height: 5.5rem;
    }

    .context-help-dialog {
        width: calc(100% - 1rem);
        max-height: calc(100vh - 1rem);
    }

    .context-help-shell {
        max-height: calc(100vh - 1rem);
    }
}

/* MyLibrary - Library pagination */

.library-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .7rem;
    margin: 1.5rem 0 .35rem;
}

.library-page-numbers {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
}

.library-page-link,
.library-page-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.4rem;
    min-height: 2.4rem;
    padding: .45rem .7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    background: #fff;
    color: var(--primary-dark);
    font-weight: 700;
    text-decoration: none;
}

.library-page-link:hover,
.library-page-number:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.library-page-number.is-current {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.library-page-link.is-disabled {
    opacity: .42;
    pointer-events: none;
}

.library-page-ellipsis {
    padding: 0 .15rem;
    color: var(--muted);
}

.library-pagination-summary {
    margin: .45rem 0 0;
    color: var(--muted);
    font-size: .85rem;
    text-align: center;
}

@media (max-width: 600px) {
    .library-pagination {
        flex-wrap: wrap;
        gap: .5rem;
    }

    .library-page-link {
        flex: 1 1 calc(50% - .5rem);
    }

    .library-page-numbers {
        order: 3;
        width: 100%;
        overflow-x: auto;
        padding-bottom: .2rem;
    }
}

/* ======================================================
   CONTEXTUAL HELP - MOBILE SCROLL FIX
   ====================================================== */

.context-help-header,
.context-help-footer {
    flex: 0 0 auto;
}

.context-help-body {
    min-height: 0;
}

@media (max-width: 600px) {
    .context-help-dialog {
        width: calc(100% - 1rem);
        max-height: calc(100dvh - 1rem);
        margin: .5rem;
    }

    .context-help-shell {
        max-height: calc(100dvh - 1rem);
    }

    .context-help-body {
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
}


/* ======================================================
   CONTEXTUAL HELP - MOBILE CONTINUATION HINT
   ====================================================== */

.context-help-scroll-hint {
    display: none;
}

@media (max-width: 600px) {

    /*
     * Keep the dialog almost full-width.
     * The small outer gap is only to avoid touching the screen edge.
     */
    .context-help-dialog {
        width: calc(100% - .5rem);
        max-height: calc(100dvh - .5rem);
        margin: .25rem;
    }

    .context-help-shell {
        max-height: calc(100dvh - .5rem);
    }

    /*
     * The body is the only scrolling area.
     */
    .context-help-body {
        position: relative;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /*
     * Visible only while more content remains below.
     * The gradient makes the continuation perceptible even before
     * the user notices the text.
     */
    .context-help-scroll-hint {
        position: relative;
        z-index: 2;

        display: flex;
        align-items: center;
        justify-content: center;
        gap: .4rem;

        min-height: 2.1rem;
        margin-top: -2.1rem;
        padding: .65rem 1rem .45rem;

        background:
            linear-gradient(
                to bottom,
                rgba(255, 255, 255, 0),
                rgba(255, 255, 255, .94) 38%,
                rgba(255, 255, 255, 1)
            );

        color: var(--primary-dark);
        font-size: .82rem;
        font-weight: 700;
        pointer-events: none;

        transition:
            opacity .18s ease,
            visibility .18s ease;
    }

    .context-help-scroll-hint > span:first-child {
        font-size: 1rem;
        line-height: 1;
        animation: context-help-scroll-arrow 1.2s ease-in-out infinite;
    }

    .context-help-scroll-hint.is-hidden {
        opacity: 0;
        visibility: hidden;
    }
}

@keyframes context-help-scroll-arrow {
    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(.18rem);
    }
}


/* ======================================================
   CONTEXTUAL HELP - CENTERED BOOK CARD
   ====================================================== */

.context-help-dialog {
    position: fixed;
    top: calc(var(--header-height, 64px) + 1rem);
    left: 50%;
    right: auto;
    bottom: auto;

    width: min(46rem, calc(100% - 2rem));
    max-width: 46rem;
    max-height: calc(100dvh - var(--header-height, 64px) - 2rem);
    margin: 0;
    padding: 0;

    transform: translateX(-50%);

    border: 0;
    border-radius: 1.15rem;
    overflow: hidden;

    box-shadow:
        0 1.15rem 3rem rgba(54, 42, 28, .22),
        0 .2rem .7rem rgba(54, 42, 28, .10);
}

.context-help-dialog::backdrop {
    background: rgba(44, 37, 29, .24);
}

.context-help-shell {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - var(--header-height, 64px) - 2rem);
    background: var(--surface, #fff);
}

.context-help-header,
.context-help-footer {
    flex: 0 0 auto;
}

.context-help-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 601px) {
    .context-help-dialog {
        top: 50%;
        max-height: min(
            38rem,
            calc(100dvh - var(--header-height, 64px) - 2rem)
        );
        transform: translate(-50%, -46%);
    }

    .context-help-shell {
        max-height: min(
            38rem,
            calc(100dvh - var(--header-height, 64px) - 2rem)
        );
    }
}

@media (max-width: 600px) {
    .context-help-dialog {
        top: calc(
            var(--header-height, 64px) +
            (
                100dvh - var(--header-height, 64px)
                - min(78dvh, calc(100dvh - var(--header-height, 64px) - 1.25rem))
            ) / 2
        );

        width: calc(100% - 1rem);
        max-width: none;
        max-height: min(
            78dvh,
            calc(100dvh - var(--header-height, 64px) - 1.25rem)
        );
        margin: 0;

        transform: translateX(-50%);
        border-radius: 1rem;
    }

    .context-help-shell {
        max-height: min(
            78dvh,
            calc(100dvh - var(--header-height, 64px) - 1.25rem)
        );
    }

    .context-help-body {
        min-height: 0;
        overflow-y: auto;
    }
}


/* ======================================================
   CONTEXTUAL HELP - MOBILE BOTTOM CARD
   ====================================================== */

/*
 * On smartphones the Help card follows the same visual logic as the
 * introductory guide: it rests near the bottom of the viewport.
 * This keeps the application header and logo visible above it and makes
 * the card feel like part of MyLibrary rather than a separate window.
 */
@media (max-width: 600px) {
    .context-help-dialog {
        top: auto;
        bottom: .5rem;
        left: 50%;

        width: calc(100% - 1rem);
        max-width: none;
        max-height: min(
            78dvh,
            calc(100dvh - var(--header-height, 64px) - 1rem)
        );

        margin: 0;
        transform: translateX(-50%);

        border-radius: 1.5rem 1.5rem .9rem .9rem;
    }

    .context-help-shell {
        max-height: min(
            78dvh,
            calc(100dvh - var(--header-height, 64px) - 1rem)
        );
    }
}


/* Language switch inside the authenticated profile */
.profile-language-switch {
    margin: 0;
    vertical-align: middle;
}

.logout-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}



/* ==========================================================
   HOME PROTOTYPE — library-first layout
   ========================================================== */

.ml-home-main {
    padding-top: .55rem;
}

/* Search is immediately available: no large TROVA card. */
.ml-find-pill {
    min-height: 0;
    max-width: none;
    margin: .55rem 0 1.15rem;
    padding: .35rem;
    border-radius: 1.55rem;
    box-shadow: 0 .55rem 1.4rem rgba(181,120,45,.10);
}

.ml-find-pill .ml-find-glow,
.ml-find-pill .ml-find-open {
    display: none !important;
}

.ml-find-panel {
    display: block !important;
}

.ml-find-search-row {
    border-radius: 1.35rem;
}

.ml-find-status:empty {
    display: none;
}

/* Five useful covers instead of six tiny covers. */
.ml-book-shelf {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: .7rem;
}

.ml-recent-book,
.ml-book-placeholder {
    min-height: 0;
    border-radius: .75rem;
}

.ml-library-loader {
    min-height: 4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-soft);
    font-size: .85rem;
}

.ml-library-loader:empty {
    min-height: 2.5rem;
}

@media (max-width: 600px) {
    .ml-home-main {
        padding-left: .55rem;
        padding-right: .55rem;
    }

    .ml-find-pill {
        min-height: 0;
        margin-top: .35rem;
        margin-bottom: .9rem;
        border-radius: 1.35rem;
    }

    .ml-book-shelf {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: .42rem;
    }

    .ml-recent-book,
    .ml-book-placeholder {
        border-radius: .6rem;
    }
}

/* ==========================================================
   HOME PROTOTYPE — compact header + compact search
   2026-09-30
   ========================================================== */

/* Header: keep all controls, but reclaim vertical space. */
.app-header {
    height: 3.25rem;
    padding-left: .85rem;
    padding-right: .85rem;
}

.side-menu-button {
    width: 2.5rem;
    height: 2.5rem;
    gap: .28rem;
}

.side-menu-button span {
    width: 1.3rem;
    height: .14rem;
}

.app-header-title {
    gap: .55rem;
    padding-right: 2.5rem;
}

.app-header-logo img {
    height: 1.7rem;
}

.app-header-page-title {
    font-size: 1.2rem;
}

.app-header-help {
    width: 2rem;
    height: 2rem;
    font-size: 1rem;
}

/* The old TROVA card no longer exists visually: the container must
   shrink to the height of the compact search row. */
.ml-find-pill,
.ml-find-pill.ml-find-active {
    width: 100%;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: .35rem 0 .8rem;
    padding: .35rem !important;
    align-items: stretch;
    justify-content: flex-start;
    border-radius: 1.35rem;
}

.ml-find-panel {
    width: 100%;
    height: auto !important;
    min-height: 0 !important;
}

.ml-find-search-row {
    min-height: 3.35rem;
    padding: .4rem .55rem;
}

.ml-home-main {
    padding-top: .25rem;
}

@media (max-width: 600px) {
    .app-header {
        height: 3.1rem;
        padding-left: .55rem;
        padding-right: .55rem;
    }

    .side-menu-button {
        width: 2.35rem;
        height: 2.35rem;
    }

    .app-header-title {
        gap: .4rem;
        padding-right: 2.15rem;
    }

    .app-header-logo img {
        height: 1.45rem;
    }

    .app-header-page-title {
        font-size: 1.05rem;
    }

    .app-header-help {
        width: 1.9rem;
        height: 1.9rem;
        font-size: .95rem;
    }

    .ml-find-pill,
    .ml-find-pill.ml-find-active {
        margin-top: .25rem;
        margin-bottom: .7rem;
        padding: .3rem !important;
    }

    .ml-find-search-row {
        min-height: 3.15rem;
        padding: .35rem .45rem;
    }
}


    
  
/* HOME — anteprima compatta libro */
.ml-book-preview[hidden] { display: none !important; }

.ml-book-preview {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.ml-book-preview-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(35, 43, 38, .34);
    backdrop-filter: blur(2px);
}

.ml-book-preview-sheet {
    position: relative;
    z-index: 1;
    width: min(100%, 34rem);
    max-height: 78vh;
    overflow: auto;
    background: var(--surface, #fffdf8);
    border-radius: 1.35rem 1.35rem 0 0;
    padding: 1.05rem 1rem calc(1rem + env(safe-area-inset-bottom));
    box-shadow: 0 -1rem 3rem rgba(40, 50, 44, .18);
}

.ml-book-preview-close {
    position: absolute;
    top: .55rem;
    right: .65rem;
    width: 2.15rem;
    height: 2.15rem;
    border: 0;
    border-radius: 50%;
    background: rgba(255,255,255,.82);
    font-size: 1.55rem;
    line-height: 1;
    cursor: pointer;
}

.ml-book-preview-top {
    display: grid;
    grid-template-columns: 5.2rem minmax(0, 1fr);
    gap: .9rem;
    padding-right: 2rem;
}

.ml-book-preview-cover img,
.ml-book-preview-no-cover {
    width: 5.2rem;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: .55rem;
    box-shadow: 0 .35rem .8rem rgba(30, 40, 34, .15);
}

.ml-book-preview-no-cover {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e9eee7;
    font-size: 2rem;
    font-weight: 700;
}

.ml-book-preview-heading h3 {
    margin: .15rem 0 .3rem;
    font-size: 1.12rem;
    line-height: 1.22;
}

.ml-book-preview-subtitle,
.ml-book-preview-authors {
    margin: .2rem 0;
    line-height: 1.25;
}

.ml-book-preview-authors { font-weight: 600; }
.ml-book-preview-subtitle { color: var(--text-soft, #68716b); }

.ml-book-preview-data {
    margin-top: .9rem;
    border-top: 1px solid rgba(80, 95, 84, .12);
}

.ml-book-preview-row {
    display: grid;
    grid-template-columns: 6.2rem minmax(0, 1fr);
    gap: .65rem;
    padding: .42rem 0;
    border-bottom: 1px solid rgba(80, 95, 84, .09);
}

/* Anteprima libro: più compatta */
.ml-book-preview-card {
    width: min(440px, calc(100vw - 1.2rem));
}

/* Ricerca home: niente spazio vuoto sotto */
.ml-find-pill,
.ml-find-pill.ml-find-active {
    margin-bottom: .45rem;
    padding: .3rem !important;
}

.ml-find-panel {
    margin: 0 !important;
    padding: 0 !important;
}

.ml-find-status:empty {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
}

/* ======================================================
   EXPLORE - PANNELLO FILTRI / COLONNE
   ====================================================== */

.explore-filter-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(20, 28, 24, .35);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}

.explore-filter-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

/* ---------- DESKTOP ---------- */

.explore-filter-panel {
    display: flex;
    position: fixed;
    top: 5rem;
    right: 1.5rem;
    bottom: auto;
    left: auto;
    z-index: 110;

    width: min(30rem, calc(100vw - 3rem));
    max-height: calc(100vh - 6.5rem);

    flex-direction: column;

    background: #fff;
    border-radius: 1rem;
    box-shadow: var(--shadow-strong);

    transform: translateX(calc(100% + 3rem));
    transition: transform .25s ease;
    overflow: hidden;
}

.explore-filter-panel.open {
    transform: translateX(0);
}

.explore-filter-panel-body {
    overflow-y: auto;
    padding: 1rem 1.25rem;
}

/* Su desktop i filtri sono già sotto le intestazioni */
.explore-filter-panel-body .explore-panel-section:first-child {
    display: none;
}

/* Rimane soltanto la scelta delle colonne */
.explore-column-selector {
    margin: 0 !important;
    padding: 0 !important;
    border-top: 0 !important;
}

.explore-column-selector h3 {
    margin: 0 0 1rem;
}

.explore-column-checks {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .65rem 1.25rem;
}

.explore-column-check {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: .5rem;
}

.explore-column-check input {
    width: auto !important;
    margin: 0;
}

/* ---------- MOBILE ---------- */

@media (max-width: 760px) {

    .explore-filter-panel {
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;

        width: 100%;
        max-height: 86vh;

        border-radius: 1.4rem 1.4rem 0 0;

        transform: translateY(105%);
    }

    .explore-filter-panel.open {
        transform: translateY(0);
    }

    .explore-filter-panel-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        padding: 1rem;
    }

    /* Su mobile ricompaiono i filtri di ricerca */
    .explore-filter-panel-body .explore-panel-section:first-child {
        display: block;
    }

    .explore-column-selector {
        margin-top: 1.25rem !important;
        padding-top: 1rem !important;
        border-top: 1px solid var(--border) !important;
    }

    .explore-column-checks {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 761px) {

    /* Testata */
    .explore-filter-panel-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding: 1rem 1.25rem;
        border-bottom: 1px solid var(--border);
    }

    .explore-filter-panel-head h2 {
        margin: 0;
        color: var(--primary-dark);
        font-size: 1.15rem;
    }

    /* X all'estrema destra */
    .explore-filter-panel-head button {
        flex: 0 0 auto;
        width: 2.25rem;
        height: 2.25rem;
        margin-left: auto;
        padding: 0;
        border: 0;
        border-radius: 50%;
        background: var(--primary-soft);
        color: var(--primary-dark);
        font-size: 1.35rem;
        line-height: 1;
        cursor: pointer;
    }

    /* Corpo più compatto */
    .explore-filter-panel-body {
        padding: 1.1rem 1.25rem;
    }

    .explore-column-selector h3 {
        margin: 0 0 .9rem;
        color: var(--primary-dark);
        font-size: 1rem;
    }

    .explore-column-checks {
        gap: .5rem 1.25rem;
    }

    /* Barra dei pulsanti */
    .explore-filter-panel-actions {
        display: flex;
        justify-content: flex-end;
        gap: .65rem;
        padding: .85rem 1.25rem;
        border-top: 1px solid var(--border);
    }

    .explore-filter-panel-actions button {
        flex: 0 0 auto;
        min-height: 2.5rem;
        padding: .55rem 1rem;
        border: 1px solid var(--border);
        border-radius: var(--radius-s);
        background: #fff;
        color: var(--primary-dark);
        font-weight: 700;
        cursor: pointer;
    }

    .explore-filter-panel-actions .primary {
        border-color: var(--primary);
        background: var(--primary);
        color: #fff;
    }
}

/* ======================================================
   HOME - ACCESSO ALLA RICERCA AVANZATA
   ====================================================== */

.ml-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.ml-explore-link {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 2.35rem;
    height: 2.35rem;

    border: 1px solid var(--border);
    border-radius: 50%;

    background: var(--primary-soft);
    color: var(--primary-dark);

    font-size: 1.05rem;
    line-height: 1;
    text-decoration: none;

    transition:
        background-color .15s ease,
        transform .15s ease;
}

.ml-explore-link:hover,
.ml-explore-link:focus-visible {
    background: #fff;
    transform: translateY(-1px);
}

.intro-add-content {
    text-align: left;
    width: 100%;
}

.intro-add-content p {
    margin: 0 0 16px;
    line-height: 1.5;
}

.intro-search-methods {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 18px 0 20px;
}

.intro-search-method {
    display: flex;
    align-items: center;
    gap: 12px;
    line-height: 1.35;
}

.intro-search-icon {
    flex: 0 0 32px;
    width: 32px;
    text-align: center;
    font-size: 1.35rem;
}

.intro-search-method > span:last-child {
    font-weight: 600;
}

.intro-title-search-icon {
    text-align: center;
    margin-bottom: 8px;
}

.intro-title-search-icon .ml-find-search-icon {
    font-size: 2.5rem;
    line-height: 1;
}

.context-help-body h3 {
    margin: 20px 0 8px;
    font-weight: 700;
}

.context-help-search-methods {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0 18px;
}

.context-help-search-method {
    display: flex;
    align-items: center;
    gap: 10px;
}

.context-help-search-method > span {
    flex: 0 0 28px;
    width: 28px;
    text-align: center;
    font-size: 1.15rem;
}

.logout-actions .button {
    width: 120px;
    box-sizing: border-box;
    text-align: center;
}

