:root {
  --bg: #f6f1e9;
  --surface: #fffdf9;
  --surface-2: #efe7da;
  --text: #2a2420;
  --muted: #7a6e63;
  --line: #e2d8c9;
  --accent: #8a3b2e;
  --accent-text: #fff;
  --lendo: #c47f17;
  --lido: #3f7d4f;
  --quero: #4f6fa8;
  --abandonado: #8f8578;
  --loan: #9b4d96;
  --shadow: 0 1px 2px rgb(60 40 20 / .08), 0 4px 14px rgb(60 40 20 / .08);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1714; --surface: #24201c; --surface-2: #2e2924; --text: #efe7dc; --muted: #a89c8f;
    --line: #3a342e; --accent: #d9826f; --accent-text: #1a1714;
    --lendo: #e0a33e; --lido: #6fb27f; --quero: #87a3d8; --abandonado: #a3998c; --loan: #c98bc5;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 14px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1714; --surface: #24201c; --surface-2: #2e2924; --text: #efe7dc; --muted: #a89c8f;
  --line: #3a342e; --accent: #d9826f; --accent-text: #1a1714;
  --lendo: #e0a33e; --lido: #6fb27f; --quero: #87a3d8; --abandonado: #a3998c; --loan: #c98bc5;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: Fraunces, Georgia, serif; font-weight: 700; margin: 0; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* topo */
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 16px; padding-bottom: 8px; }
h1 { font-size: 28px; }
.sub { margin: 0; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.admin-badge { font-size: 12px; color: var(--accent); border: 1px solid var(--accent); border-radius: 99px; padding: 2px 10px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 12px; }
.toolbar input[type=search] { flex: 1 1 240px; }
input, select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); padding: 7px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.danger { color: #b3261e; border-color: color-mix(in srgb, #b3261e 40%, var(--line)); }
.btn:disabled { opacity: .5; cursor: default; }

/* grade */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 22px 16px; padding: 20px 0 60px; }
@media (max-width: 480px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 16px 10px; } }
.card { cursor: pointer; background: none; border: 0; padding: 0; text-align: left; }
.cover { position: relative; aspect-ratio: 2 / 3; border-radius: 4px 8px 8px 4px; overflow: hidden; background: var(--surface-2); box-shadow: var(--shadow); transition: transform .15s; }
.card:hover .cover, .card:focus-visible .cover { transform: translateY(-3px); }
.cover img { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .dot, .cover .loan-tag, .cover .stack { z-index: 2; }
.cover .ph { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 10px; color: #fff; font-family: Fraunces, Georgia, serif; font-size: 14px; line-height: 1.2; }
.cover .ph small { font-family: Inter, sans-serif; font-size: 11px; opacity: .85; }
.cover .stack { position: absolute; right: 6px; bottom: 6px; background: rgb(0 0 0 / .7); color: #fff; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 99px; }
.dot { position: absolute; top: 6px; right: 6px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid #fff; }
.dot.lendo { background: var(--lendo); } .dot.lido { background: var(--lido); } .dot.quero_ler { background: var(--quero); } .dot.abandonado { background: var(--abandonado); }
.loan-tag { position: absolute; left: 0; top: 10px; background: var(--loan); color: #fff; font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 0 99px 99px 0; }
.card-title { margin-top: 8px; font-weight: 600; font-size: 13.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* painéis */
dialog.sheet { border: 0; padding: 0; border-radius: 14px; background: var(--surface); color: var(--text); width: min(760px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 20px 60px rgb(0 0 0 / .35); }
dialog::backdrop { background: rgb(20 14 8 / .55); }
@media (max-width: 600px) {
  dialog.sheet { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 14px 14px 0 0; max-height: 92dvh; }
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 8px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.x { border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.sheet-foot { display: flex; gap: 8px; padding: 12px 18px 18px; position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); }
.grow { flex: 1; }

.d-wrap { display: grid; grid-template-columns: 170px 1fr; gap: 20px; padding: 6px 18px 20px; }
@media (max-width: 600px) { .d-wrap { grid-template-columns: 110px 1fr; gap: 14px; } }
.d-wrap .cover { box-shadow: var(--shadow); }
.d-title { font-size: 22px; line-height: 1.2; }
.d-authors { color: var(--muted); margin: 4px 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--text); }
.chip.st { color: #fff; } .chip.lendo { background: var(--lendo); } .chip.lido { background: var(--lido); } .chip.quero_ler { background: var(--quero); } .chip.abandonado { background: var(--abandonado); } .chip.loan { background: var(--loan); color: #fff; }
.stars { color: var(--lendo); letter-spacing: 2px; font-size: 16px; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 13px; margin: 10px 0; }
.meta dt { color: var(--muted); } .meta dd { margin: 0; }
.section { padding: 0 18px 18px; }
.section h3 { font-size: 16px; margin: 6px 0 8px; }
.desc { white-space: pre-line; font-size: 14px; }
.desc.clamp { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.linkish { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-weight: 500; }
.review { border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; font-style: italic; white-space: pre-line; }
.private { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 13px; white-space: pre-line; }

.vols { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 14px 10px; padding: 4px 18px 20px; }
.vols .card-title { -webkit-line-clamp: 1; }

.loans { list-style: none; padding: 0; margin: 0 0 10px; font-size: 14px; }
.loans li { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.loans li.done { color: var(--muted); }
.loan-form { display: flex; gap: 8px; flex-wrap: wrap; }
.loan-form input { flex: 1 1 140px; }

/* formulário */
#form .isbn-row { display: flex; gap: 8px; padding: 0 18px; }
#form .isbn-row input { flex: 1; }
.scan { padding: 10px 18px 0; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.scan video { width: 100%; max-height: 260px; border-radius: 8px; background: #000; object-fit: cover; }
.hint { color: var(--muted); font-size: 13px; padding: 0 18px; margin: 6px 0 0; min-height: 1em; }
.fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 12px; padding: 12px 18px 16px; }
.fields label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
.fields label > * { color: var(--text); font-size: 14px; font-weight: 400; }
.fields .span2 { grid-column: span 2; } .fields .span3 { grid-column: 1 / -1; }
@media (max-width: 600px) { .fields { grid-template-columns: 1fr 1fr; } .fields .span2 { grid-column: 1 / -1; } }
#form:not(.is-manga) .manga-f { display: none; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 20; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
