:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --text: #2b2620;
  --muted: #7a7166;
  --line: #e6dfd4;
  --accent: #b5562b;
  --accent-text: #ffffff;
  --ok: #2f7d4f;
  --warn: #a86b00;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1a17;
    --card: #26231f;
    --text: #efe9e0;
    --muted: #a69c8f;
    --line: #3a352e;
    --accent: #e0814f;
    --accent-text: #1c1a17;
    --ok: #6cc08f;
    --warn: #e0b050;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.45; }
a { color: var(--accent); }

.top {
  display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--card);
  position: sticky; top: 0; z-index: 1000;
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); font-size: 1.1rem; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 8px; }
nav a.active { color: var(--text); background: var(--bg); font-weight: 600; }

main { max-width: 760px; margin: 0 auto; padding: 20px 16px 60px; }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 28px 0 10px; }
.sub { color: var(--muted); margin: 0 0 18px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.stack > * + * { margin-top: 10px; }

label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%;
}
textarea { min-height: 60px; resize: vertical; }
input[type=checkbox] { width: auto; }

button, .button {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px; padding: 9px 14px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text); text-decoration: none;
  display: inline-block;
}
button.ghost { background: transparent; color: var(--accent); }
button.small { padding: 5px 10px; font-size: .9rem; }
button:disabled { opacity: .55; cursor: default; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1 1 180px; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs button { background: transparent; color: var(--muted); border-color: var(--line); }
.tabs button.on { color: var(--text); border-color: var(--text); }

.books { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.book {
  display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: start;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
}
.cover {
  width: 48px; height: 68px; border-radius: 4px; background: var(--line); object-fit: cover;
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem; overflow: hidden;
}
.title { font-weight: 600; }
.meta { color: var(--muted); font-size: .9rem; }
.tag { display: inline-block; font-size: .8rem; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.tag.ok { color: var(--ok); border-color: var(--ok); }
.tag.warn { color: var(--warn); border-color: var(--warn); }
.actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

.scan-row { display: grid; grid-template-columns: auto 1fr 1fr auto; gap: 8px; align-items: center; }
.scan-row.unsure input[type=text] { border-color: var(--warn); }
@media (max-width: 560px) {
  .scan-row { grid-template-columns: auto 1fr auto; }
  .scan-row .author { grid-column: 2 / 3; }
}

.map { height: 280px; border-radius: 10px; border: 1px solid var(--line); margin-top: 6px; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; }
.notice { border-left: 3px solid var(--warn); padding: 8px 12px; background: var(--card); border-radius: 6px; margin-bottom: 14px; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 2000;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; max-width: calc(100% - 32px);
}

@media (max-width: 560px) {
  .book { grid-template-columns: 48px 1fr; }
  .book .actions { grid-column: 2; flex-direction: row; align-items: center; justify-content: flex-start; }
}
