/* Estilos do sistema BOOK BOOK */

:root {
    --paper: #f8f3ea;
    --paper-soft: #fffaf3;
    --surface: #fffefb;
    --surface-soft: #eef3e8;
    --text: #253229;
    --text-soft: #536150;
    --text-muted: #6f7766;
    --sage: #879a76;
    --sage-deep: #485f43;
    --sage-light: #dce8d8;
    --sage-very-light: #eef4eb;
    --sage-dark: #20351f;
    --sage-shadow: rgba(167, 179, 148, 0.22);
    --line: #d7d9ca;
    --line-soft: #ebe9d9;
    --sand: #c9a981;
    --sand-deep: #8b6847;
    --clay: #ae7257;
    --clay-dark: #724930;
    --cream: #fcf6ea;
    --olive: #657b5c;
    --danger: #b75b4a;
    --danger-soft: #ffecea;
    --success: #486b47;
    --success-soft: #e9f5ec;
    --shadow: rgba(37, 50, 41, 0.12);
    --font: "Inter", "Segoe UI", Arial, sans-serif;
}

html[data-theme="dark"] {
    --paper: #161a14;
    --paper-soft: #20251e;
    --surface: #151b16;
    --surface-soft: #20291f;
    --text: #eef6e9;
    --text-soft: #bcc8ae;
    --text-muted: #9da894;
    --sage: #c3d2a9;
    --sage-deep: #a9be9d;
    --sage-light: #27391f;
    --sage-very-light: #161d16;
    --sage-dark: #11170f;
    --sage-shadow: rgba(173, 194, 151, 0.14);
    --line: #34402c;
    --line-soft: #242b21;
    --sand: #c8a774;
    --sand-deep: #735738;
    --clay: #b68668;
    --clay-dark: #7b513a;
    --cream: #fbf4e8;
    --olive: #9cad8c;
    --danger: #ed9d90;
    --danger-soft: #442922;
    --success: #b7d3b1;
    --success-soft: #20301d;
    --shadow: rgba(0,0,0,0.45);
}

html[data-theme="dark"] .primary-button,
html[data-theme="dark"] .primary-button:hover,
html[data-theme="dark"] .cta-button,
html[data-theme="dark"] .cta-button:hover,
html[data-theme="dark"] .button,
html[data-theme="dark"] .button:hover {
    background-color: var(--sage-deep);
    color: #fffefb;
}

html[data-theme="dark"] .icon-button {
    color: #fffefb;
}

html[data-theme="dark"] .icon-button:hover {
    background-color: var(--sage-deep);
    color: #fffefb;
}

html[data-theme="dark"] .icon-button.delete:hover {
    background-color: var(--danger);
    color: #fffefb;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    background-color: var(--paper);
    color: var(--text);
    line-height: 1.5;
    overflow-x: hidden;
    transition: background-color 320ms ease, color 320ms ease, border-color 320ms ease;
}

body::before {
    content: "";
    position: fixed;
    inset: -90px;
    background-image: radial-gradient(var(--line-soft) 1px, transparent 1px);
    background-size: 38px 38px;
    opacity: 0.65;
    transform: rotate(-5deg);
    pointer-events: none;
}

.app {
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem 5rem;
    display: flex;
    flex-direction: column;
}

.app:has(.home) {
    padding-bottom: 1.5rem;
}

.home {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.site-header {
    padding: 1.6rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.site-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
    flex-wrap: wrap;
    margin: 0 auto;
}

.nav-link {
    color: var(--text-soft);
    text-decoration: none;
    font-weight: 800;
    font-size: 0.88rem;
    letter-spacing: 0.04em;
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: color 260ms ease, background-color 260ms ease, border-color 260ms ease, transform 260ms ease;
}

.nav-link:hover {
    color: var(--sage-deep);
    background-color: var(--sage-very-light);
    border-color: var(--line);
}

.nav-link.active {
    color: var(--sage-deep);
    background-color: var(--sage-very-light);
    border-color: var(--sage-deep);
}

.logo {
    text-decoration: none;
    color: var(--text);
    margin-left: -0.4rem;
}

.logo-mark {
    font-size: clamp(1.65rem, 2vw, 2.4rem);
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 700;
    letter-spacing: -0.03em;
    white-space: nowrap;
    display: inline-block;
    transform: translateX(-0.05rem);
}

.logo-mark::first-letter {
    color: var(--sage-deep);
}

.theme-toggle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background-color: var(--surface);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: background-color 320ms ease, color 320ms ease, transform 320ms ease, border-color 320ms ease;
}

.theme-toggle:hover {
    transform: translateY(-2px);
    border-color: var(--sage);
}

.home .hero-copy {
    transform: translateY(-35px);
}

.hero {
    width: min(1180px, calc(100vw - 4rem));
    min-height: min(680px, 70vh);
    display: grid;
    grid-template-columns: minmax(420px, 0.95fr) minmax(420px, 1.05fr);
    align-items: center;
    gap: 2rem;
}

.hero-copy {
    min-width: 360px;
}

@media (max-width: 1200px) {
    .hero {
        grid-template-columns: minmax(360px, 0.95fr) minmax(360px, 1.05fr);
        width: min(100%, calc(100vw - 2rem));
    }
}

@media (max-width: 1024px) {
    .hero {
        grid-template-columns: 1fr;
        width: min(100%, calc(100vw - 2rem));
    }

    .hero-copy {
        min-width: auto;
    }

    .hero-visual {
        min-height: auto;
    }

    .book-display {
        width: min(420px, 80vw);
        height: min(420px, 50vw);
    }
}

@media (max-width: 768px) {
    .hero {
        width: min(100%, 100vw);
    }

    .hero-copy {
        min-width: 0;
    }

    .hero-copy h1 {
        font-size: clamp(3rem, 14vw, 4rem);
    }

    .hero-text {
        max-width: 100%;
    }

    .hero .hero-visual {
        min-height: auto;
    }

    .book-display {
        width: min(350px, 90vw);
        height: min(350px, 70vw);
    }
}

@media (max-width: 480px) {
    .hero {
        width: min(100vw, calc(100vw - 1rem));
    }

    .hero-copy h1 {
        font-size: clamp(2.4rem, 14vw, 3rem);
    }

    .hero-copy {
        min-width: 0;
    }

    .hero-text {
        font-size: 1rem;
    }

    .book-display {
        width: min(260px, 90vw);
        height: min(260px, 80vw);
    }
}

.chapter-label {
    display: inline-block;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--sage-deep);
    text-transform: uppercase;
}

.hero-copy h1 {
    margin: 1rem 0 1rem;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(4.2rem, 6vw, 5.8rem);
    line-height: 0.92;
    color: var(--text);
    letter-spacing: -0.035em;
}

.hero-text {
    max-width: 500px;
    color: var(--text-soft);
    font-size: clamp(1.05rem, 2vw, 1.28rem);
    line-height: 1.7;
}

.hero-actions {
    margin-top: 2rem;
}

.cta-button {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.95rem 1.75rem;
    border-radius: 999px;
    border: 1px solid var(--sage);
    color: var(--text);
    background-color: var(--surface);
    text-decoration: none;
    font-weight: 800;
    font-size: 0.95rem;
    box-shadow: 0 12px 30px var(--sage-shadow);
    transition: transform 320ms ease, box-shadow 320ms ease, background-color 320ms ease, color 320ms ease;
}

.cta-button:hover {
    background-color: var(--sage-deep);
    color: var(--paper-soft);
    transform: translateY(-3px);
}

.hero-visual {
    min-height: 560px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-display {
    position: relative;
    width: min(480px, 42vw);
    height: min(480px, 40vw);
    min-width: 350px;
    min-height: 350px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-display::before {
    content: "";
    position: absolute;
    inset: 16%;
    border-radius: 50%;
    background-color: var(--sage-light);
    filter: blur(80px);
    opacity: 0.7;
}

.book-spine {
    position: absolute;
    display: block;
    width: 110px;
    height: 280px;
    background: linear-gradient(180deg, var(--paper-soft), var(--sage));
    border-radius: 14px 14px 2px 2px;
    border: 1px solid var(--line);
    transform-origin: center;
    box-shadow: 0 20px 40px var(--shadow);
}

.book-spine.one {
    left: 20%;
    bottom: 1%;
    transform: rotate(-12deg);
}

.book-spine.two {
    left: 35%;
    bottom: 15%;
    transform: rotate(-4deg);
}

.book-spine.three {
    right: 20%;
    bottom: 16%;
    transform: rotate(10deg);
}

.book-spine.four {
    right: 3%;
    bottom: 0%;
    transform: rotate(18deg);
}

.leaf {
    position: absolute;
    width: 92px;
    height: 230px;
    border-radius: 80% 15% 80% 15%;
    background: linear-gradient(135deg, var(--sage-light), var(--sage-deep));
    box-shadow: 0 8px 20px var(--sage-shadow);
    transform: rotate(25deg);
}

.leaf-one {
    left: 38%;
    top: -12%;
}

.leaf-two {
    left: 50%;
    top: -8%;
    width: 86px;
    height: 180px;
}

.leaf-three {
    left: 42%;
    top: 8%;
    width: 110px;
    height: 110px;
}

.shadow-line {
    position: absolute;
    left: 20%;
    right: 20%;
    height: 16px;
    bottom: 1%;
    border-radius: 50%;
    background-color: var(--shadow);
    filter: blur(10px);
}

.feature-dot {
    position: absolute;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--sand);
    border: 10px solid var(--paper-soft);
    left: 56%;
    top: 70%;
    box-shadow: 0 8px 20px var(--shadow);
}

/* Ocupa toda a largura do .app (que já centraliza e limita em 1400px).
   Sem o width: 100%, as margens "auto" fariam este flex item encolher até o
   tamanho do conteúdo, deixando o catálogo espremido no meio da tela. */
.catalog-wrap {
    width: 100%;
    margin: 2rem 0 0;
    padding: 2rem 0;
}

#mensagem {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    width: min(380px, calc(100vw - 2rem));
    max-width: min(380px, calc(100vw - 2rem));
    margin: 0;
    padding: 0.8rem 1rem;
    border-radius: 14px;
    border-left: 4px solid var(--sage);
    background: var(--sage-very-light);
    color: var(--text-soft);
    box-shadow: 0 14px 34px var(--shadow);
    pointer-events: none;
    opacity: 0;
    transform: translateX(125%);
    transition: transform 420ms ease, opacity 320ms ease, background-color 320ms ease, color 320ms ease;
}

#mensagem.mensagem.sucesso {
    opacity: 1;
    transform: translateX(0);
    color: var(--success);
    background: var(--success-soft);
    border-left-color: var(--success);
}

#mensagem.mensagem.erro {
    opacity: 1;
    transform: translateX(0);
    color: var(--danger);
    background: var(--danger-soft);
    border-left-color: var(--danger);
}

#mensagem.toast-visible {
    opacity: 1;
    transform: translateX(0);
}

#mensagem.toast-leaving {
    opacity: 0;
    transform: translateX(125%);
}

/* Título à esquerda e botão à direita. Quando os dois não cabem lado a lado,
   o botão desce para a linha de baixo em vez de colar no título. */
.catalog-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem 2.5rem;
    padding-bottom: 1rem;
}

.catalog-title-block {
    flex: 1 1 auto;
    min-width: 0;
}

.catalog-title-block h1 {
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.6rem, 4vw, 4.1rem);
    margin: 0.2rem 0 0;
    color: var(--text);
}

.catalog-actions {
    display: flex;
    align-items: center;
    /* O botão não encolhe nem quebra o texto no meio. */
    flex: 0 0 auto;
}

.primary-button {
    padding: 0.84rem 1.4rem;
    background-color: var(--sage-deep);
    color: var(--paper-soft);
    border: none;
    border-radius: 999px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    transition: background-color 280ms ease, transform 280ms ease;
}

.primary-button:hover {
    background-color: var(--sage-dark);
    transform: translateY(-2px);
}

.catalog-toolbar {
    background-color: var(--surface);
    border-radius: 20px;
    border: 1px solid var(--line-soft);
    padding: 1rem;
    box-shadow: 0 8px 24px var(--shadow);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    background-color: var(--paper-soft);
    border-radius: 999px;
    border: 1px solid var(--line);
    padding: 0.7rem 1rem;
    min-height: 48px;
    box-sizing: border-box;
}

.search-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sage-deep);
    font-size: 1.5rem;
    line-height: 1;
    flex: 0 0 38px;
    margin: 0;
    padding: 0;
    align-self: center;
}

.search-box input {
    width: 100%;
    height: 38px;
    border: none;
    outline: none;
    background-color: transparent;
    color: var(--text);
    font-family: inherit;
    padding: 0;
}

.filter-row {
    margin-top: 1rem;
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 1rem;
    align-items: end;
}

.filter-label {
    color: var(--text-soft);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 72px;
}

.filter-label span {
    display: block;
    margin-bottom: 0.4rem;
    line-height: 1.2;
}

.filter-label select {
    width: 100%;
    min-height: 42px;
    background-color: var(--paper-soft);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.65rem 2.2rem 0.65rem 0.8rem;
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--sage-deep) 50%), linear-gradient(135deg, var(--sage-deep) 50%, transparent 50%);
    background-position: calc(100% - 14px) calc(50% + 1px), calc(100% - 10px) calc(50% + 1px);
    background-size: 4px 4px, 4px 4px;
    background-repeat: no-repeat;
    background-color: var(--paper-soft);
}

.catalog-list-wrapper {
    margin-top: 1.2rem;
}

.catalog-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

/* Quantas colunas couberem na largura disponível, com os cards sempre do mesmo
   tamanho. O min(100%, 270px) evita que o card estoure telas bem estreitas. */
.catalog-list.exemplar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr));
    gap: 1rem;
}

.catalog-list.exemplar-grid .catalog-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: space-between;
}

.exemplar-card {
    min-height: 190px;
    padding: 1rem 1.1rem;
    background-color: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 12px 30px var(--shadow);
    transition: transform 260ms ease, box-shadow 260ms ease, border-color 260ms ease, background-color 260ms ease;
}

.exemplar-card:hover {
    transform: scale(1.035) translateY(-3px);
    box-shadow: 0 18px 46px var(--sage-shadow);
    border-color: var(--sage);
}

.exemplar-card .book-title {
    font-size: clamp(1.18rem, 1.8vw, 1.5rem);
    color: var(--text);
}

.exemplar-title-block {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.exemplar-disponiveis-tag {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--sage-deep);
    background-color: var(--sage-very-light);
    border: 1px solid var(--sage-light);
    padding: 0.15rem 0.55rem;
    border-radius: 6px;
    align-self: flex-start;
    display: inline-block;
}

.exemplar-card .book-author {
    font-size: 0.82rem;
    color: var(--text-soft);
}

.exemplar-card .book-actions {
    justify-content: flex-start;
    margin-top: 0.8rem;
}

.exemplar-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: flex-start;
    min-width: 110px;
    min-height: 34px;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    border: 1px solid var(--line);
    background-color: var(--surface-soft);
    color: var(--text-soft);
}

.exemplar-status.disponivel {
    background-color: var(--success-soft);
    color: var(--success);
    border-color: var(--sage);
}

.exemplar-status.emprestado {
    background-color: var(--danger-soft);
    color: var(--danger);
    border-color: var(--clay);
}

.catalog-item {
    display: grid;
    grid-template-columns: minmax(260px, 1.8fr) repeat(4, minmax(130px, 1fr)) minmax(120px, auto);
    align-items: center;
    gap: 1rem;
    background-color: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: 18px;
    padding: 1rem 1.2rem;
    box-shadow: 0 10px 28px var(--shadow);
    transition: transform 280ms ease, box-shadow 280ms ease, border-color 280ms ease;
}

.catalog-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 30px var(--sage-shadow);
    border-color: var(--sage);
}

.catalog-item.leitor-item {
    grid-template-columns: minmax(260px, 1.8fr) minmax(150px, 1fr) minmax(150px, 1fr) minmax(120px, auto);
}

.book-main {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.book-title {
    color: var(--text);
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.3rem, 2vw, 1.8rem);
    margin: 0;
}

.book-author {
    color: var(--text-soft);
    font-size: 0.86rem;
    font-weight: 700;
}

.book-meta-column {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.22rem;
    min-width: 0;
}

.book-label {
    display: block;
    color: var(--text-soft);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    white-space: normal;
    line-height: 1.2;
}

.book-value {
    display: block;
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.45;
    margin-top: 0.1rem;
}

.book-actions {
    display: flex;
    gap: 0.45rem;
    align-items: center;
    justify-content: flex-end;
}

.icon-button {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background-color: var(--paper-soft);
    color: var(--sage-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 260ms ease, color 260ms ease, transform 260ms ease;
}

.icon-button:hover {
    background-color: var(--sage-deep);
    color: var(--paper-soft);
    transform: translateY(-2px);
}

.icon-button.delete:hover {
    background-color: var(--danger);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.modal-backdrop.open {
    display: flex;
}

.modal-card {
    width: min(760px, calc(100vw - 2rem));
    background-color: var(--surface);
    border-radius: 24px;
    border: 1px solid var(--line);
    padding: 1.7rem 1.8rem;
    position: relative;
    box-shadow: 0 30px 90px var(--shadow);
}

.modal-head {
    padding-right: 44px;
    margin-bottom: 1rem;
}

.modal-head .chapter-label {
    display: block;
    color: var(--sage-deep);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.modal-head h2 {
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.9rem, 2.4vw, 2.4rem);
    margin: 0.4rem 0 0;
    color: var(--text);
    line-height: 1.2;
}

.modal-close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background-color: var(--paper-soft);
    color: var(--text);
    font-size: 1.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modal-close:hover {
    color: var(--sage-deep);
    background-color: var(--sage-very-light);
}

.view-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(230px, 1fr));
    gap: 1rem 1.25rem;
    align-items: stretch;
}

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

.view-grid dt,
.view-label {
    color: var(--text-soft);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.2rem;
}

.view-grid dd,
.view-value {
    min-height: 46px;
    background-color: var(--surface-soft);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.72rem 0.82rem;
    font-family: inherit;
    font-size: 0.94rem;
    line-height: 1.4;
    display: flex;
    align-items: center;
    margin: 0;
    box-shadow: none;
}

.view-grid dd {
    width: 100%;
}

.view-row-full {
    grid-column: 1 / -1;
}

.view-row-full .view-value {
    min-height: 80px;
    align-items: flex-start;
    white-space: pre-wrap;
    word-break: break-word;
}

.formulario {
    width: 100%;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(230px, 1fr));
    gap: 1rem 1.25rem;
}

.campo {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.campo label {
    color: var(--text-soft);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.2rem;
}

.campo input,
.campo textarea,
.campo select {
    width: 100%;
    min-height: 46px;
    background-color: var(--paper-soft);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.72rem 0.82rem;
    font-family: inherit;
    font-size: 0.94rem;
    outline: none;
    box-shadow: none;
    transition: border-color 220ms ease, box-shadow 220ms ease, background-color 220ms ease;
}

.campo textarea {
    min-height: 120px;
    max-height: 140px;
    resize: vertical;
}

.campo select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.8rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23879a76' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: calc(100% - 14px) 50%;
    background-size: 12px 8px;
}

.campo input:focus,
.campo textarea:focus,
.campo select:focus {
    border-color: var(--sage-deep);
    box-shadow: 0 0 0 3px var(--sage-shadow);
}

.campo input[readonly] {
    background-color: var(--surface-soft);
    color: var(--text-soft);
    cursor: not-allowed;
}

html[data-theme="dark"] .campo input,
html[data-theme="dark"] .campo textarea,
html[data-theme="dark"] .campo select,
body[data-theme="dark"] .campo input,
body[data-theme="dark"] .campo textarea,
body[data-theme="dark"] .campo select {
    background-color: var(--paper-soft);
    color: var(--text);
    border-color: var(--line);
}

html[data-theme="dark"] .campo select,
body[data-theme="dark"] .campo select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23c3d2a9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.mensagem {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.35;
    margin: 0 0 0.75rem;
    padding: 0.35rem 0.55rem;
    border-radius: 10px;
    border-left: 3px solid var(--sage);
    background: var(--sage-very-light);
    color: var(--text-soft);
}

.mensagem:empty {
    display: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    min-height: 0;
}

.mensagem.erro {
    color: var(--danger);
    background: var(--danger-soft);
    border-left-color: var(--danger);
}

.mensagem.sucesso {
    color: var(--success);
    background: var(--success-soft);
    border-left-color: var(--success);
}

.mensagem-formulario {
    width: 100%;
    margin: 0 0 1rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.8rem;
    margin-top: 1.2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line-soft);
}

.button {
    min-height: 46px;
    padding: 0.78rem 1.4rem;
    border-radius: 999px;
    font: inherit;
    font-weight: 800;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 280ms ease, background-color 280ms ease, border-color 280ms ease, color 280ms ease;
}

.button-primary {
    background-color: var(--sage-deep);
    color: var(--paper-soft);
    border: 1px solid var(--sage-deep);
}

.button-primary:hover {
    background-color: var(--sage-dark);
    color: var(--paper-soft);
    transform: translateY(-2px);
}

.button-muted {
    background-color: var(--paper-soft);
    color: var(--text);
    border: 1px solid var(--line);
}

.button-muted:hover {
    background-color: var(--sage-very-light);
    color: var(--text);
    transform: translateY(-2px);
}

html[data-theme="dark"] .button-primary,
body[data-theme="dark"] .button-primary {
    background-color: var(--sage-deep);
    color: #fffefb;
    border-color: var(--sage);
}

html[data-theme="dark"] .button-primary:hover,
body[data-theme="dark"] .button-primary:hover {
    background-color: var(--sage-dark);
    color: #fffefb;
}

html[data-theme="dark"] .button-muted,
body[data-theme="dark"] .button-muted {
    background-color: var(--paper-soft);
    color: var(--text);
    border-color: var(--line);
}

html[data-theme="dark"] .button-muted:hover,
body[data-theme="dark"] .button-muted:hover {
    background-color: var(--sage-very-light);
    color: var(--text);
}

@media (max-width: 1200px) {
    .hero {
        width: min(960px, calc(100vw - 3rem));
    }

    .hero-copy {
        min-width: 320px;
    }

    .hero-visual {
        min-height: auto;
    }

    .form-grid {
        grid-template-columns: repeat(2, minmax(210px, 1fr));
    }
}

@media (max-width: 1024px) {
    .hero {
        grid-template-columns: 1fr;
        gap: 1rem;
        min-height: auto;
    }

    .hero-copy {
        min-width: auto;
    }

    .hero-visual {
        min-height: 380px;
    }

    .book-display {
        width: min(420px, 80vw);
        min-width: auto;
        height: 320px;
    }

    .home .hero-copy {
        transform: translateY(-20px);
    }

    .filter-row {
        grid-template-columns: 1fr 1fr;
    }

    .catalog-item {
        grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(140px, 1fr));
        align-items: start;
    }

    .book-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    .app {
        padding: 0 1rem 3rem;
    }

    .site-header,
    .catalog-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .hero {
        width: min(100%, 100vw);
    }

    .hero-copy h1 {
        font-size: clamp(3rem, 14vw, 4rem);
    }

    .hero-text {
        font-size: 1rem;
        max-width: 100%;
    }

    .book-display {
        width: min(360px, 90vw);
        height: 280px;
        min-width: auto;
    }

    .home-image {
        width: 110%;
        height: 110%;
        object-fit: contain;
    }

    .filter-row,
    .two-columns {
        grid-template-columns: 1fr;
    }

    .catalog-item {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .book-actions {
        justify-content: flex-start;
        grid-column: auto;
    }

    .modal-card {
        width: min(100%, calc(100vw - 1rem));
        padding: 1.2rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-wrap: wrap;
    }

    .button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .hero-copy {
        min-width: 0;
    }

    .hero-copy h1 {
        font-size: clamp(2.6rem, 14vw, 3.2rem);
    }

    .hero-actions {
        width: 100%;
    }

    .cta-button {
        width: 100%;
        justify-content: center;
    }

    .hero-visual {
        min-height: 260px;
    }

    .book-display {
        width: min(280px, 90vw);
        height: 250px;
        min-width: auto;
    }

    .catalog-toolbar {
        padding: 0.8rem;
    }

    .search-box {
        border-radius: 16px;
    }

    .filter-label select {
        min-width: 100%;
    }
}

@media (max-width: 390px) {
    .hero-copy h1 {
        font-size: clamp(2.4rem, 13vw, 2.8rem);
    }

    .hero {
        width: min(100vw, calc(100vw - 1rem));
    }

    .book-display {
        width: 220px;
        height: 220px;
        min-width: auto;
    }

    .home .hero-copy {
        transform: translateY(-10px);
    }
}

.home-image {
    width: 125%;
    height: 125%;
    object-fit: contain;
}

/* Formulário do modal, popup de visualização, mensagens e cards do catálogo */

.modal-card {
    width: min(680px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

.modal-subtitle {
    margin: 0.4rem 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.modal-card .formulario {
    margin-top: 1.4rem;
}

.three-columns {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.campo {
    margin-bottom: 1.1rem;
}

.campo label {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 700;
}

.obrigatorio {
    margin-left: 0.15rem;
    color: var(--danger);
}

.campo input,
.campo textarea {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background-color: var(--paper-soft);
    color: var(--text);
    font: inherit;
    font-size: 0.95rem;
    transition: border-color 200ms ease, box-shadow 200ms ease;
}

body[data-theme="dark"] .campo input,
body[data-theme="dark"] .campo textarea {
    color-scheme: dark;
}

.campo input::placeholder,
.campo textarea::placeholder {
    color: var(--text-muted);
}

.campo input:focus,
.campo textarea:focus {
    outline: none;
    border-color: var(--sage);
    box-shadow: 0 0 0 3px var(--sage-shadow);
}

.campo input[readonly] {
    background-color: var(--surface-soft);
    color: var(--text-soft);
    cursor: default;
}

.campo textarea {
    min-height: 120px;
    max-height: 140px;
    resize: vertical;
    line-height: 1.6;
}

.campo-contador {
    display: block;
    margin-top: 0.35rem;
    text-align: right;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.campo-contador.limite {
    color: var(--danger);
    font-weight: 700;
}

.modal-card .form-actions {
    margin-top: 0.4rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--line-soft);
}

.button {
    padding: 0.7rem 1.8rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    transition: transform 200ms ease, opacity 200ms ease;
}

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

.button-primary {
    background-color: var(--sage-deep);
    border-color: var(--sage-deep);
    color: var(--paper-soft);
}

.button-primary:disabled {
    opacity: 0.6;
    cursor: default;
    transform: none;
}

.mensagem {
    margin: 1rem 0 0;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background-color: var(--sage-very-light);
    color: var(--text-soft);
}

.formulario .mensagem {
    margin: 0 0 1rem;
}

.mensagem:empty {
    display: none;
}

.mensagem.erro {
    background-color: var(--danger-soft);
    color: var(--danger);
}

.mensagem.sucesso {
    background-color: var(--success-soft);
    color: var(--success);
}

/* Popup de visualização */

.view-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin: 1.4rem 0;
    padding: 1rem 0;
    border-top: 1px solid var(--line-soft);
    border-bottom: 1px solid var(--line-soft);
}

.view-grid dt,
.view-resumo h3 {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.view-grid dd {
    margin: 0.3rem 0 0;
    font-weight: 700;
    color: var(--text);
}

.view-resumo p {
    margin: 0.5rem 0 0;
    color: var(--text-soft);
    line-height: 1.7;
    white-space: pre-line;
}

/* Cards do catálogo: título, gênero, ano, data de cadastro e ações */

.catalog-item {
    grid-template-columns: minmax(200px, 2fr) repeat(3, minmax(110px, 1fr)) auto;
}

.book-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--text-muted);
}

.book-value {
    color: var(--text);
    font-weight: 700;
}

/* Animação ao abrir os popups */

.modal-backdrop.open {
    animation: fundo-entrada 180ms ease;
}

.modal-backdrop.open .modal-card {
    animation: popup-entrada 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes fundo-entrada {
    from { opacity: 0; }
}

@keyframes popup-entrada {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
}

@media (prefers-reduced-motion: reduce) {
    .modal-backdrop.open,
    .modal-backdrop.open .modal-card {
        animation: none;
    }
}

@media (max-width: 900px) {
    .catalog-item {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .three-columns,
    .view-grid {
        grid-template-columns: 1fr;
    }
}

/* Fundo dos popups: escurece e desfoca de leve o que está atrás */

.modal-backdrop {
    background-color: rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

/* Popup de confirmação da exclusão */

.confirm-card {
    width: min(460px, calc(100vw - 2rem));
}

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

body[data-theme="dark"] .button-danger {
    background-color: #c0392b;
    border-color: #c0392b;
}

.button-danger:disabled {
    opacity: 0.6;
    cursor: default;
    transform: none;
}

/* Card de empréstimo: leitor, livro, código do exemplar, data, previsão de devolução, situação e ações */

.catalog-item.emprestimo-item {
    grid-template-columns: minmax(140px, 1.2fr) minmax(160px, 1.4fr) minmax(80px, 0.6fr) minmax(120px, 1fr) minmax(130px, 1.05fr) minmax(100px, 0.8fr) auto;
}

@media (max-width: 900px) {
    .catalog-item.emprestimo-item {
        grid-template-columns: 1fr;
    }
}

/* Input de Tags / Chips */
.tag-input-container {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.tag-required {
    color: var(--danger);
    font-weight: bold;
}

.tag-input-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.tag-input-row input {
    flex: 1;
}

.tag-add-btn {
    min-width: 44px;
    height: 46px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    flex-shrink: 0;
    line-height: 1;
}

.tag-chips-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    min-height: 28px;
    align-items: center;
    margin-top: 0.2rem;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    background-color: var(--surface-soft);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 500;
}

.tag-chip-remove {
    background: none;
    border: none;
    color: var(--text-soft);
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 150ms ease;
}

.tag-chip-remove:hover {
    color: var(--danger);
}


/* Campo de busca com lista de sugestões (livro, leitor e exemplar nos formulários) */

.campo-busca input {
    width: 100%;
}

.busca-lista {
    list-style: none;
    margin: 0.35rem 0 0;
    padding: 0.3rem;
    max-height: 15rem;
    overflow-y: auto;
    background-color: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 10px 28px var(--shadow);
}

.busca-opcao,
.busca-vazia {
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
}

.busca-opcao {
    color: var(--text);
    cursor: pointer;
}

.busca-opcao:hover,
.busca-opcao.ativa {
    background-color: var(--sage-very-light);
}

.busca-vazia {
    color: var(--text-muted);
    cursor: default;
}
