:root {
  --fg: #222;
  --bg: #fafafa;
  --muted: #777;
  --accent: #4a8;
  --error: #c33;
  --warn: #b80;
  --border: #e0e0e0;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--fg);
  background: var(--bg);
  max-width: 960px;
  margin: 2em auto;
  padding: 0 1em;
  line-height: 1.5;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5em;
  margin-bottom: 1em;
}
h1 { margin: 0; font-size: 1.5em; }
h2 { font-size: 1em; margin: 1.5em 0 0.5em; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.actions { display: flex; gap: 0.5em; }
.actions form { display: inline; margin: 0; }
button {
  font: inherit;
  padding: 0.4em 1.2em;
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}
button.btn-pause { background: #888; }
button:hover:not(:disabled) { filter: brightness(1.1); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.flash { padding: 0.6em 1em; margin: 1em 0; border-radius: 4px; border: 1px solid; }
.flash-info { background: #e8f0ff; border-color: #aac; color: #335; }
.flash-warn { background: #fef4e0; border-color: var(--warn); color: var(--warn); }
.flash-inline { padding: 0.2em 0.6em; border-radius: 3px; font-size: 0.85em; }
.summary dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.3em 1em; margin: 0; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; }
.ts { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 0.9em; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.4em 0.6em; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: normal; font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.04em; }
.status-sent, .status-ok { color: var(--accent); }
.status-error { color: var(--error); }
.status-empty, .status-running, .status-paused { color: var(--muted); }
.error { color: var(--error); }
.no-data { color: var(--muted); font-style: italic; }
details summary { cursor: pointer; color: var(--muted); list-style: none; }
details[open] summary { color: var(--fg); }
details pre {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 0.8em;
  background: #f0f0f0;
  padding: 0.6em 0.8em;
  margin: 0.5em 0 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 30em;
}
canvas { max-width: 100%; }
a { color: var(--fg); }
a:hover { color: var(--accent); }
.settings { margin-top: 3em; padding-top: 1em; border-top: 1px solid var(--border); }
.settings-form { display: flex; align-items: center; gap: 0.5em; flex-wrap: wrap; }
.settings-form input[type="number"] { font: inherit; padding: 0.3em 0.5em; width: 7em; border: 1px solid var(--border); border-radius: 3px; }
.settings-form label { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.9em; margin: 0.5em 0 0; }

.opds-hint { color: var(--muted); font-size: 0.85em; margin: -0.5em 0 1em; }
.opds-hint code { background: #eee; padding: 0.1em 0.4em; border-radius: 3px; font-size: 0.95em; }

.library h2 { display: flex; align-items: center; justify-content: space-between; }
.upload-form { display: flex; align-items: center; gap: 0.4em; text-transform: none; letter-spacing: 0; }
.upload-form input[type="file"] { display: none; }
.upload-form button { padding: 0.3em 0.9em; font-size: 0.85em; }

.book-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--border); }
.book { display: flex; align-items: center; gap: 0.8em; padding: 0.6em 0; border-bottom: 1px solid var(--border); }
.book .cover { width: 60px; height: 90px; object-fit: cover; background: #eee; flex-shrink: 0; border: 1px solid var(--border); }
.book-meta { flex-grow: 1; min-width: 0; }
.book-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-sub { color: var(--muted); font-size: 0.85em; margin-top: 0.2em; }
.book-delete { background: none; color: var(--muted); font-size: 1.4em; padding: 0 0.4em; line-height: 1; border-radius: 3px; }
.book-delete:hover { background: #fbe; color: var(--error); }

dialog { border: 1px solid var(--border); border-radius: 6px; padding: 1.2em 1.5em; max-width: 30em; }
dialog::backdrop { background: rgba(0,0,0,0.3); }
dialog p { margin: 0 0 1em; }
.dialog-actions { display: flex; gap: 0.5em; justify-content: flex-end; }
.dialog-actions button { background: #888; }
.dialog-actions .btn-danger { background: var(--error); }
