:root {
  --bg-page:         #f5f5f5;
  --bg-card:         #ffffff;
  --bg-hover:        #fafafa;
  --bg-btn-hover:    #f0f0f0;
  --bg-th:           #f9f9f9;
  --bg-danger-hover: #fff0f0;
  --color-text:      #222222;
  --color-muted:     #888888;
  --color-meta:      #666666;
  --color-th:        #444444;
  --color-danger:    #cc0000;
  --border-card:     #dddddd;
  --border-input:    #cccccc;
  --border-btn:      #888888;
  --border-divider:  #eeeeee;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-page:         #1a1a1a;
    --bg-card:         #2a2a2a;
    --bg-hover:        #333333;
    --bg-btn-hover:    #3a3a3a;
    --bg-th:           #333333;
    --bg-danger-hover: #3a1010;
    --color-text:      #e0e0e0;
    --color-muted:     #888888;
    --color-meta:      #999999;
    --color-th:        #aaaaaa;
    --color-danger:    #ff6666;
    --border-card:     #444444;
    --border-input:    #555555;
    --border-btn:      #666666;
    --border-divider:  #3a3a3a;
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, sans-serif;
  background: var(--bg-page);
  color: var(--color-text);
  padding: 2rem 1rem;
}

main { max-width: 900px; margin: 0 auto; }

h1 { font-size: 1.4rem; display: flex; align-items: center; gap: 0.8rem; }
h1 .signout { margin-left: auto; text-decoration: none; margin-top: 2px; margin-bottom: -2px; }
h1 .signout svg { fill: var(--color-muted); width: 18px; height: 18px; }
h1 .signout:hover svg { fill: var(--color-text); }

.tabs {
  display: flex;
  gap: 1.25rem;
  margin: 1rem 0 1.5rem;
  border-bottom: 1px solid var(--border-card);
}
.tabs a {
  padding: 0.4rem 0.15rem;
  font-size: 0.9rem;
  color: var(--color-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a:hover { color: var(--color-text); }
.tabs a.active {
  color: var(--color-text);
  font-weight: 600;
  border-bottom-color: var(--color-text);
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
.panel h2 { font-size: 1rem; margin-bottom: 0.75rem; }

#add-form { display: flex; gap: 0.5rem; }
#url-input { flex: 1; }
#add-error { color: var(--color-danger); font-size: 0.85rem; margin-top: 0.5rem; }

.book-list { list-style: none; display: flex; flex-direction: column; gap: 0.75rem; }
.book-list li { font-size: 0.88rem; display: flex; align-items: center; gap: 0.75rem; }
.book-list .cover-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }

.book-info { min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.book-date { color: var(--color-meta); font-size: 0.78rem; }
.book-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.4rem; }
.book-author { color: var(--color-meta); }
.book-series { color: var(--color-muted); }

/* One separator rule for the whole line, so an absent author leaves no stray
   dot behind, and the mobile override below turns the line into stacked
   rows just by dropping it. */
.book-line > :not(:first-child)::before { content: "·"; margin-right: 0.4rem; color: var(--color-muted); }

.empty-state { padding: 1rem; color: var(--color-muted); font-size: 0.85rem; }
.empty-panel { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.empty-panel p { color: var(--color-muted); font-size: 0.9rem; }
.empty-panel .button-link {
  margin-left: auto;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border-btn);
  border-radius: 4px;
  font-size: 0.85rem;
  text-decoration: none;
  white-space: nowrap;
}
.empty-panel .button-link:hover { background: var(--bg-btn-hover); }

@media (max-width: 560px) {
  body { padding: 1rem 0.5rem; }
  button { min-height: 44px; padding: 0.4rem 0.75rem; }
  .tabs a { padding: 0.7rem 0.15rem; }
  .book-line { flex-direction: column; gap: 0.1rem; }
  .book-line > :not(:first-child)::before { content: none; margin-right: 0; }
  .book-author, .book-series { font-size: 0.82rem; }
}

button {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border-btn);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--color-text);
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
}
button:hover { background: var(--bg-btn-hover); }
button.danger { border-color: var(--color-danger); color: var(--color-danger); }
button.danger:hover { background: var(--bg-danger-hover); }
button:disabled { opacity: 0.5; cursor: default; }

input {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border-input);
  border-radius: 4px;
  font-size: 0.9rem;
  background: var(--bg-card);
  color: var(--color-text);
}

a { color: inherit; text-decoration-color: var(--color-muted); }
a:hover { text-decoration-color: var(--color-text); }

.series-menu-wrap {
  position: relative;
  flex-shrink: 0;
}
.menu-btn {
  min-width: 2rem;
  aspect-ratio: 1;
  font-size: 1.1rem;
  line-height: 1;
}
.series-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 10;
  min-width: 130px;
  flex-direction: column;
  overflow: hidden;
}
.series-menu.open {
  display: flex;
}
.series-menu button {
  border: none;
  border-radius: 0;
  text-align: left;
  padding: 0.7rem 1rem;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0;
}
.menu-icon {
  display: inline-block;
  width: 1.6rem;
  text-align: center;
  flex-shrink: 0;
}
.series-menu button:not(:last-child) {
  border-bottom: 1px solid var(--border-divider);
}
