:root {
  --bg: #f4efe6; --paper: #fffdf8; --ink: #2b2622; --sub: #6f655b; --line: #e2d8c8; --accent: #8a4b2a;
  --own: #b3261e; --own-bg: #fbe4e1; --wish: #8a6400; --wish-bg: #fbf0cc; --series: #1d5a8a; --series-bg: #dfedf8;
  --none: #1f6b3a; --none-bg: #ddf1e3; --radius: 10px;
  font-family: system-ui, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1c1916; --paper: #262220; --ink: #efe8de; --sub: #a99e91; --line: #3a342f; --accent: #e09a6c;
    --own: #ff8a80; --own-bg: #3d1f1c; --wish: #f0c75e; --wish-bg: #3a3120; --series: #8cc4ef; --series-bg: #1c2d3b;
    --none: #7fd69d; --none-bg: #1b3324; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.5;
  padding-bottom: calc(64px + env(safe-area-inset-bottom)); -webkit-tap-highlight-color: transparent; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: var(--ink); color: var(--bg); }
.top h1 { margin: 0; font-size: 18px; letter-spacing: .2em; font-weight: 700; }
.sync { background: none; border: 1px solid #ffffff40; color: inherit; border-radius: 99px; padding: 4px 12px; font-size: 13px; min-height: 32px; }
main { padding: 16px; max-width: 760px; margin: 0 auto; outline: none; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--paper); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs a { flex: 1; text-align: center; padding: 12px 0; color: var(--sub); text-decoration: none; font-size: 14px; min-height: 48px; }
.tabs a[aria-current="page"] { color: var(--accent); font-weight: 700; box-shadow: inset 0 3px var(--accent); }
h2 { font-size: 18px; margin: 4px 0 12px; }
h3 { font-size: 15px; margin: 20px 0 8px; color: var(--sub); }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); min-height: 44px; }
textarea { min-height: 120px; }
label { display: block; font-size: 13px; color: var(--sub); margin: 10px 0 4px; }
button, .btn { border: 1px solid var(--line); background: var(--paper); border-radius: var(--radius); padding: 10px 14px; min-height: 44px; cursor: pointer; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.danger { color: var(--own); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > input { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 8px 0; }
.result { border-radius: 14px; padding: 18px; margin: 12px 0; border: 2px solid; }
.result .big { font-size: 26px; font-weight: 800; line-height: 1.3; }
.result.own { background: var(--own-bg); border-color: var(--own); color: var(--own); }
.result.wish, .result.released { background: var(--wish-bg); border-color: var(--wish); color: var(--wish); }
.result.series { background: var(--series-bg); border-color: var(--series); color: var(--series); }
.result.none { background: var(--none-bg); border-color: var(--none); color: var(--none); }
.result .detail { color: var(--ink); margin-top: 8px; }
.book { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.book img, .cover { width: 48px; height: 68px; object-fit: cover; border-radius: 3px; background: var(--line); flex: none; }
.book .t { font-weight: 600; }
.sub { color: var(--sub); font-size: 13px; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.chip { font-size: 12px; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line); background: var(--bg); }
.chip.miss { border-style: dashed; color: var(--own); }
.series-head { display: flex; justify-content: space-between; gap: 8px; cursor: pointer; }
video { width: 100%; max-height: 40vh; border-radius: var(--radius); background: #000; object-fit: cover; }
#toast { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 99px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; z-index: 9; }
#toast.show { opacity: 1; pointer-events: auto; }
#toast button { margin-left: 8px; min-height: 32px; padding: 2px 10px; background: none; color: inherit; border-color: #ffffff60; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.check input[type=checkbox] { width: 22px; height: 22px; min-height: 0; flex: none; margin-top: 2px; }
.check select { min-height: 36px; padding: 4px 8px; }
.tag { font-size: 12px; font-weight: 700; padding: 0 6px; border-radius: 4px; }
.tag.new { background: var(--none-bg); color: var(--none); } .tag.add { background: var(--series-bg); color: var(--series); } .tag.ask { background: var(--wish-bg); color: var(--wish); }
.empty { color: var(--sub); text-align: center; padding: 32px 0; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }
.scan { width: 100%; min-height: 72px; font-size: 18px; border-radius: 14px; }
video { margin-top: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; color: inherit; text-decoration: none; }
.acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.acts select { grid-column: 1 / -1; }
.acts .btn { grid-column: 1 / -1; }
.result img { width: 56px; height: 80px; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.result.unknown { background: var(--wish-bg); border-color: var(--wish); color: var(--wish); }
