:root {
  --fg: #1b1b1b;
  --fg-muted: #5b5b5b;
  --bg: #fafafa;
  --bg-soft: #f0f0f0;
  --accent: #2b2b2b;
  --bar-bg: #e6e6e6;
  --bar-fill: #2b2b2b;
  --ok-bg: #e6f4ea;
  --ok-fg: #1e6b35;
  --err-bg: #fdecea;
  --err-fg: #a01a1a;
  --border: #e0e0e0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  line-height: 1.5;
}

body {
  max-width: 880px;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
}

a { color: var(--accent); }
a:hover { text-decoration: underline; }

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
}
.site-back { font-size: 0.85rem; color: var(--fg-muted); text-decoration: none; }
.site-title { font-size: 1.15rem; margin: 0; flex: 1; }
.site-title a { text-decoration: none; color: var(--fg); }
.site-nav a { font-size: 0.9rem; }

.site-footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--fg-muted);
}

.book-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
.book-card { background: #fff; border: 1px solid var(--border); border-radius: 6px; }
.book-link {
  display: flex;
  gap: 0.9rem;
  padding: 0.75rem;
  text-decoration: none;
  color: inherit;
  align-items: flex-start;
}
.book-link:hover { background: var(--bg-soft); }

.cover {
  width: 60px;
  height: 90px;
  object-fit: cover;
  flex-shrink: 0;
  border-radius: 3px;
  background: var(--bg-soft);
}
.cover-placeholder {
  background: repeating-linear-gradient(45deg, #ececec, #ececec 6px, #e2e2e2 6px, #e2e2e2 12px);
}
.cover-large { width: 120px; height: 180px; }

.book-meta { flex: 1; min-width: 0; }
.book-title { font-weight: 600; }
.book-author { color: var(--fg-muted); font-size: 0.9rem; margin-top: 0.1rem; }

.bar {
  margin-top: 0.5rem;
  height: 8px;
  background: var(--bar-bg);
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill { height: 100%; background: var(--bar-fill); }

.book-sub {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--fg-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.empty { color: var(--fg-muted); padding: 1rem 0; }

.book-page .book-header {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin: 0.5rem 0 1.5rem;
}
.book-header-meta { flex: 1; min-width: 0; }
.book-header-meta .book-title { font-size: 1.3rem; }
.book-filename code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.85em; }

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.history-table th, .history-table td {
  text-align: left;
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.history-table tbody tr:nth-child(even) { background: var(--bg-soft); }
.history-table code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.85em; word-break: break-all; }

.danger-zone { margin-top: 2rem; }
button, .btn-danger {
  font: inherit;
  background: #fff;
  border: 1px solid var(--border);
  padding: 0.45rem 0.9rem;
  border-radius: 4px;
  cursor: pointer;
}
button:hover { background: var(--bg-soft); }
.btn-danger { color: var(--err-fg); border-color: #f2c0bc; }
.btn-danger:hover { background: var(--err-bg); }

.upload { max-width: 560px; }
.upload-form { display: flex; flex-direction: column; gap: 0.75rem; margin: 1rem 0; }
.upload-drop {
  display: block;
  border: 2px dashed var(--border);
  border-radius: 6px;
  padding: 1.25rem;
  text-align: center;
  cursor: pointer;
  color: var(--fg-muted);
  background: #fff;
}
.upload-drop:hover { background: var(--bg-soft); }
.upload-drop input[type=file] { display: block; margin: 0 auto 0.5rem; }

.flash { padding: 0.55rem 0.8rem; border-radius: 4px; margin: 0.5rem 0 1rem; }
.flash-ok { background: var(--ok-bg); color: var(--ok-fg); }
.flash-err { background: var(--err-bg); color: var(--err-fg); }
