:root {
  --paper: #f4efe6;
  --paper-deep: #e9dfd1;
  --ink: #24352d;
  --muted: #6f786f;
  --forest: #264b3a;
  --rust: #bd5d3a;
  --gold: #cf9a45;
  --sage: #7d9880;
  --blue: #718b91;
  --white: #fffdf9;
  --border: rgba(38, 75, 58, 0.14);
  --shadow: 0 18px 50px rgba(65, 55, 42, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "DM Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, select { cursor: pointer; }
.page-shell { min-height: 100vh; overflow: hidden; }
.site-header, main, footer { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }
.site-header { display: flex; align-items: center; justify-content: space-between; padding: 28px 0; }
.brand { display: flex; gap: 12px; align-items: center; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 46px; border: 1.5px solid var(--forest); border-radius: 50% 50% 48% 48%; font-family: "DM Serif Display"; font-size: 25px; }
.brand strong, .brand small { display: block; line-height: 1.05; }
.brand strong { font-family: "DM Serif Display"; font-size: 21px; font-weight: 400; }
.brand small { margin-top: 5px; color: var(--muted); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.primary-button, .secondary-button, .danger-button, .icon-button, .text-button { border: 0; transition: .2s ease; }
.primary-button { display: inline-flex; align-items: center; gap: 8px; padding: 12px 18px; color: #fff; background: var(--forest); border-radius: 99px; font-weight: 600; box-shadow: 0 5px 14px rgba(38,75,58,.16); }
.primary-button:hover { background: #183b2c; transform: translateY(-1px); }
.secondary-button { padding: 11px 18px; border: 1px solid var(--border); border-radius: 99px; background: transparent; }
.secondary-button:hover { background: var(--paper); }
.danger-button { padding: 11px 18px; border-radius: 99px; background: #f5dfd8; color: #9c3e27; }
.icon-button { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--border); border-radius: 50%; background: transparent; }
.icon-button:hover { background: rgba(255,255,255,.6); }
.icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.overview-header { display: flex; align-items: end; justify-content: space-between; gap: 30px; padding: 34px 2px 25px; border-bottom: 1px solid var(--border); }
.overview-header h1 { font-size: clamp(42px, 5vw, 60px); line-height: .95; }
.overview-copy { margin: 0 0 5px; color: var(--muted); font-size: 13px; }

.hero { position: relative; min-height: 340px; padding: 62px 8%; border: 1px solid rgba(255,255,255,.45); border-radius: 34px; background: linear-gradient(115deg, #dde4d5 0%, #e6e2cd 58%, #e5d4bd 100%); overflow: hidden; }
.hero::before { content: ""; position: absolute; inset: 0; opacity: .15; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.28'/%3E%3C/svg%3E"); pointer-events: none; }
.hero > div:first-child { position: relative; z-index: 2; max-width: 560px; }
.eyebrow { margin: 0 0 13px; color: var(--rust); font-size: 11px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; }
h1, h2, h3 { margin: 0; font-family: "DM Serif Display", serif; font-weight: 400; }
h1 { font-size: clamp(52px, 6.3vw, 80px); line-height: .9; letter-spacing: -.035em; }
h1 em { color: var(--rust); font-weight: 400; }
.hero-copy { max-width: 490px; margin: 26px 0 0; color: #56655d; line-height: 1.65; }
.hero-decoration { position: absolute; right: 6%; bottom: 0; width: 340px; height: 290px; }
.sun { position: absolute; right: 24px; top: -30px; width: 185px; height: 185px; border-radius: 50%; background: rgba(244, 235, 200, .65); }
.book { position: absolute; bottom: 23px; height: 44px; border-radius: 4px 9px 9px 4px; box-shadow: 0 11px 17px rgba(38, 53, 45, .12); transform: rotate(-4deg); }
.book::after { content: ""; position: absolute; inset: 7px 18px 7px auto; width: 2px; border-radius: 2px; background: rgba(255,255,255,.45); }
.book-one { left: 54px; width: 226px; background: var(--rust); }
.book-two { left: 65px; bottom: 67px; width: 210px; background: var(--gold); transform: rotate(3deg); }
.book-three { left: 81px; bottom: 110px; width: 195px; background: var(--forest); transform: rotate(-1deg); }
.plant-stem { position: absolute; right: 24px; bottom: 22px; width: 2px; height: 155px; background: var(--forest); transform: rotate(12deg); transform-origin: bottom; }
.leaf { position: absolute; width: 58px; height: 26px; border-radius: 100% 0 100% 0; background: var(--sage); }
.leaf-one { right: 9px; bottom: 115px; transform: rotate(-8deg); }
.leaf-two { right: 55px; bottom: 73px; transform: rotate(175deg); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); margin: 18px 0 48px; border: 1px solid var(--border); border-radius: 18px; background: rgba(255,253,249,.55); }
.stat-card { display: flex; gap: 15px; align-items: center; min-height: 100px; padding: 22px 28px; }
.stat-card + .stat-card { border-left: 1px solid var(--border); }
.stat-filter { width: 100%; color: var(--ink); text-align: left; border: 0; background: transparent; }
.stat-filter:hover { background: rgba(255,255,255,.6); }
.stat-filter:first-child { border-radius: 17px 0 0 17px; }
.stat-filter:last-child { border-radius: 0 17px 17px 0; }
.stat-icon { display: grid; place-items: center; flex: 0 0 38px; width: 38px; height: 38px; color: #fff; border-radius: 50%; font-size: 18px; }
.stat-icon.rust { background: var(--rust); }.stat-icon.green { background: var(--forest); }.stat-icon.gold { background: var(--gold); }.stat-icon.blue { background: var(--blue); }
.stat-card strong, .stat-card span { display: block; }
.stat-card strong { font-family: "DM Serif Display"; font-size: 27px; font-weight: 400; line-height: 1; }
.stat-card div span { margin-top: 7px; color: var(--muted); font-size: 12px; }

.library-section { min-height: 500px; padding-bottom: 100px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; }
.section-heading h2 { font-size: 34px; line-height: 1; }
.view-toggle { display: flex; padding: 4px; border: 1px solid var(--border); border-radius: 99px; }
.view-toggle button { display: grid; place-items: center; width: 36px; height: 30px; border: 0; border-radius: 99px; background: transparent; }
.view-toggle button.active { color: #fff; background: var(--forest); }
.view-toggle svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.view-toggle [data-view="grid"] svg { fill: currentColor; stroke: none; }
.toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) auto auto; gap: 15px; margin: 24px 0 32px; align-items: center; }
.search-field { position: relative; }
.search-field svg { position: absolute; left: 15px; top: 50%; width: 18px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 1.8; }
input, select, textarea { width: 100%; color: var(--ink); border: 1px solid var(--border); border-radius: 12px; outline: none; background: rgba(255,253,249,.75); transition: border-color .2s, box-shadow .2s; }
input:focus, select:focus, textarea:focus { border-color: var(--sage); box-shadow: 0 0 0 3px rgba(125,152,128,.14); }
.search-field input { height: 45px; padding: 0 16px 0 45px; border-radius: 99px; }
.filters { display: flex; gap: 5px; }
.filter-pill { padding: 9px 12px; color: var(--muted); border: 0; border-radius: 99px; background: transparent; font-size: 12px; font-weight: 600; white-space: nowrap; }
.filter-pill:hover { color: var(--ink); background: rgba(255,255,255,.5); }
.filter-pill.active { color: #fff; background: var(--forest); }
.filter-pill span { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 4px; padding: 0 5px; color: var(--forest); border-radius: 99px; background: var(--paper); font-size: 10px; }
.select-wrap select { min-width: 155px; height: 43px; padding: 0 34px 0 13px; border-radius: 99px; }
.select-group { display: flex; gap: 8px; }

.book-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 18px; }
.status-group-heading { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; margin: 16px 0 -5px; padding: 3px 2px 9px; color: var(--ink); border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 700; }
.status-group-heading:first-child { margin-top: 0; }
.status-group-heading::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--sage); }
.status-group-next::before { background: var(--gold); }.status-group-hold::before { background: #7b6b99; }.status-group-read::before { background: var(--rust); }
.status-group-heading small { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; color: var(--muted); border-radius: 99px; background: rgba(255,255,255,.6); font-size: 9px; }
.book-card { position: relative; min-width: 0; padding: 10px 10px 13px; border: 1px solid var(--border); border-radius: 15px; background: rgba(255,253,249,.62); box-shadow: 0 5px 25px rgba(65,55,42,.025); transition: transform .2s, box-shadow .2s; cursor: pointer; }
.book-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.book-card:has(.quick-menu[open]) { z-index: 50; transform: none; }
.drag-handle { position: absolute; z-index: 4; top: 16px; right: 16px; display: grid; place-items: center; width: 27px; height: 27px; color: #fff; border-radius: 8px; background: rgba(31,42,35,.7); box-shadow: 0 2px 8px rgba(0,0,0,.18); cursor: grab; opacity: .35; transition: opacity .2s, transform .2s; user-select: none; }
.book-card:hover .drag-handle, .drag-handle:focus { opacity: 1; }
.drag-handle:active { cursor: grabbing; transform: scale(.94); }
.book-card.dragging { opacity: .38; transform: scale(.98); }
.book-card.drop-before { box-shadow: inset 4px 0 var(--rust), var(--shadow); }
.book-card.drop-after { box-shadow: inset -4px 0 var(--rust), var(--shadow); }
.book-cover { position: relative; display: flex; flex-direction: column; justify-content: space-between; aspect-ratio: 3 / 4; padding: 26px 22px 20px; border-radius: 10px 15px 15px 8px; color: #fff; overflow: hidden; box-shadow: 7px 9px 18px rgba(42,39,33,.16); }
.book-cover-image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; }
.book-cover.has-cover { padding: 0; background: #e9e4dc; }
.book-cover.has-cover::before, .book-cover.has-cover::after { display: none; }
.book-cover.has-cover .cover-title, .book-cover.has-cover .cover-author { opacity: 0; }
.book-cover::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 8px; background: rgba(20,20,20,.12); box-shadow: inset -2px 0 rgba(255,255,255,.14); }
.book-cover::after { content: ""; position: absolute; right: -30px; bottom: -35px; width: 130px; height: 130px; border: 1px solid rgba(255,255,255,.2); border-radius: 50%; box-shadow: 0 0 0 22px rgba(255,255,255,.05), 0 0 0 46px rgba(255,255,255,.04); }
.cover-title { position: relative; z-index: 1; font-family: "DM Serif Display"; font-size: clamp(22px, 2vw, 29px); line-height: 1.05; overflow-wrap: anywhere; }
.cover-author { position: relative; z-index: 1; max-width: 90%; font-size: 10px; font-weight: 600; letter-spacing: .11em; text-transform: uppercase; }
.book-info { padding: 13px 2px 0; }
.book-info h3 { overflow: hidden; font-family: "DM Sans"; font-size: 14px; font-weight: 700; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.book-author { margin: 3px 0 10px; color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 99px; font-size: 10px; font-weight: 700; letter-spacing: .02em; }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-reading { color: #315f4a; background: #dce8dc; }.status-next { color: #98662c; background: #f2e5ca; }.status-read { color: #9d4830; background: #efdcd5; }
.status-hold { color: #62577c; background: #e7e1ef; }
.category-tag { color: var(--muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-controls { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.quick-menu { position: relative; min-width: 0; }
.quick-menu summary { list-style: none; }
.quick-menu summary::-webkit-details-marker { display: none; }
.quick-trigger { cursor: pointer; user-select: none; }
.quick-trigger > span { margin-left: 2px; opacity: .55; font-size: 9px; }
.category-menu { min-width: 0; }
.category-tag { display: flex; align-items: center; max-width: 82px; padding: 5px 2px; }
.quick-popover { position: absolute; z-index: 60; top: calc(100% + 6px); left: 0; min-width: 135px; padding: 5px; border: 1px solid var(--border); border-radius: 11px; background: var(--white); box-shadow: 0 14px 38px rgba(31,42,35,.2); }
.quick-popover-right { right: 0; left: auto; max-height: 230px; overflow-y: auto; }
.quick-option { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; padding: 8px 9px; text-align: left; white-space: nowrap; border: 0; border-radius: 7px; background: transparent; font-size: 11px; }
.quick-option:hover, .quick-option.selected { background: var(--paper); }
.quick-option span { color: var(--forest); }
.rating { margin-top: 10px; color: var(--gold); font-size: 11px; letter-spacing: 1px; }
.book-grid.list-view { grid-template-columns: 1fr; gap: 10px; }
.list-view .book-card { display: grid; grid-template-columns: 60px minmax(0, 1fr); gap: 16px; align-items: center; padding: 10px; }
.list-view .book-cover { width: 60px; height: 78px; padding: 8px; }
.list-view .cover-title { font-size: 9px; }.list-view .cover-author { font-size: 5px; }
.list-view .book-info { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(260px, .7fr) auto; gap: 16px; align-items: center; padding: 0 14px 0 0; }
.list-view .quick-controls { justify-content: flex-start; gap: 14px; }
.list-view .book-author { margin: 4px 0 0; }.list-view .rating { margin: 0; text-align: right; }
.empty-state { padding: 80px 20px; text-align: center; border: 1px dashed rgba(38,75,58,.2); border-radius: 18px; }
.empty-state > span { display: block; color: var(--sage); font-size: 40px; }.empty-state h3 { margin-top: 12px; font-size: 27px; }.empty-state p { color: var(--muted); }
.text-button { padding: 4px; color: var(--rust); background: transparent; font-weight: 700; }
footer { display: flex; justify-content: space-between; padding: 30px 0 36px; color: var(--muted); border-top: 1px solid var(--border); font-size: 11px; }

dialog { width: min(600px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 24px; color: var(--ink); background: var(--white); box-shadow: 0 30px 100px rgba(31,42,35,.3); }
dialog::backdrop { background: rgba(30,42,35,.54); backdrop-filter: blur(4px); }
#bookForm { padding: 28px; }
.modal-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 25px; }.modal-header h2 { font-size: 35px; }
.close-button { border: 0; font-size: 25px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.form-grid label { color: #536158; font-size: 12px; font-weight: 600; }.form-grid .full-width { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea { display: block; margin-top: 7px; padding: 11px 12px; }.form-grid textarea { resize: vertical; }
.modal-actions { display: flex; gap: 9px; align-items: center; margin-top: 27px; }.action-spacer { flex: 1; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; padding: 12px 18px; color: #fff; border-radius: 99px; background: var(--forest); box-shadow: var(--shadow); opacity: 0; transform: translateY(20px); pointer-events: none; transition: .25s ease; font-size: 13px; }
.toast.show { opacity: 1; transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .hero-decoration { right: -55px; opacity: .7; }.hero > div:first-child { max-width: 62%; }
  .stats { grid-template-columns: 1fr 1fr; }.stat-card:nth-child(3) { border-left: 0; border-top: 1px solid var(--border); }.stat-card:nth-child(4) { border-top: 1px solid var(--border); }
  .toolbar { grid-template-columns: 1fr auto; }.filters { grid-column: 1 / -1; grid-row: 2; }.select-group { grid-column: 2; grid-row: 1; }
  .book-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 650px) {
  .site-header, main, footer { width: min(100% - 24px, 1180px); }.site-header { padding: 18px 0; }.header-actions .icon-button { display: none; }
  .overview-header { display: block; padding: 22px 2px 18px; }.overview-copy { margin-top: 10px; }
  .book { transform: scale(.75) rotate(-4deg); transform-origin: right bottom; }.book-two { transform: scale(.75) rotate(3deg); }.book-three { transform: scale(.75) rotate(-1deg); }
  .stats { margin-bottom: 65px; }.stat-card { min-height: 85px; padding: 18px; }.stat-card strong { font-size: 23px; }
  .section-heading h2 { font-size: 30px; }.toolbar { grid-template-columns: 1fr; }.filters { grid-column: auto; grid-row: auto; overflow-x: auto; padding-bottom: 3px; }.select-group { grid-column: auto; grid-row: auto; display: grid; grid-template-columns: 1fr 1fr; }.select-wrap select { min-width: 0; }
  .book-grid { grid-template-columns: repeat(2, 1fr); gap: 11px; }.book-card { padding: 8px 8px 11px; }.book-cover { padding: 18px 15px 15px; }.cover-title { font-size: 20px; }
  .list-view .book-info { grid-template-columns: 1fr; gap: 8px; }.list-view .quick-controls { grid-column: 1; }.list-view .rating { grid-column: 1; grid-row: auto; text-align: left; }
  .form-grid { grid-template-columns: 1fr; }.form-grid .full-width { grid-column: auto; }#bookForm { padding: 22px; }.modal-actions { flex-wrap: wrap; }.modal-actions .action-spacer { display: none; }.modal-actions button { flex: 1; }
  footer { gap: 20px; }
}
@media (max-width: 390px) { .brand small { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; } }
