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

:root {
  --bg:          #f5f0e8;
  --header-bg:   #1a1a2e;
  --accent:      #e94560;
  --text:        #2d2d2d;
  --muted:       #6b6b6b;
  --border:      #ddd;
  --card-bg:     #ffffff;
  --radius:      6px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 36px; /* room for fixed footer */
}

/* ── Header ─────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--header-bg);
  padding: 0 2rem;
  transition: box-shadow 0.25s ease;
}
header.scrolled {
  box-shadow: 0 2px 14px rgba(0,0,0,0.45);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: height 0.25s ease;
}
header.scrolled .header-inner { height: 44px; }
.site-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  letter-spacing: -0.3px;
}
.site-title span { color: var(--accent); }

.header-nav { display: flex; align-items: center; gap: 0.5rem; }
.nav-link {
  color: #e0e0e0;
  text-decoration: none;
  font-size: 0.875rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.2);
  transition: background 0.15s;
}
.nav-link:hover { background: rgba(255,255,255,0.1); }
.nav-link--subtle { border-color: transparent; }
.nav-user {
  font-size: 0.875rem;
  color: #a0a0c0;
  padding: 0 0.5rem;
}

/* ── Main ────────────────────────────────────────────── */
main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 2rem;
}

/* ── Footer ──────────────────────────────────────────── */
footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 199;
  height: 36px;
  background: var(--header-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.footer-inner {
  font-size: 0.72rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: #4a4a6a;
  letter-spacing: 0.03em;
}

/* ── Alerts ──────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}
.alert-error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  border: 1px solid var(--border);
}

/* ── Forms ───────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"] {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(233,69,96,0.12);
}
.form-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s;
  line-height: 1;
}
.btn:hover  { opacity: 0.88; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-block   { width: 100%; text-align: center; padding-top: 0.75rem; padding-bottom: 0.75rem; }

/* ── Auth pages ──────────────────────────────────────── */
.auth-container {
  max-width: 400px;
  margin: 3rem auto;
}
.auth-container h1 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}
.text-muted {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

/* ── Hero ────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 5rem 2rem;
}
.hero h1 {
  font-size: 2.75rem;
  font-weight: 700;
  margin-bottom: 1rem;
}
.hero-sub {
  font-size: 1.1rem;
  color: var(--muted);
}

/* ── Admin layout ────────────────────────────────────── */
.nav-link--admin {
  background: rgba(233,69,96,0.15);
  border-color: rgba(233,69,96,0.4);
}
.nav-link--admin:hover { background: rgba(233,69,96,0.25); }

main.admin-main {
  max-width: none;
  padding: 0;
  display: flex;
  align-items: flex-start;
}

.admin-sidebar {
  width: 210px;
  flex-shrink: 0;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  min-height: calc(100vh - 60px - 36px);
  padding: 1.5rem 0;
}

.admin-sidebar-heading {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0 1.25rem;
  margin-bottom: 0.4rem;
}

.admin-nav a {
  display: block;
  padding: 0.5rem 1.25rem;
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background 0.12s;
}
.admin-nav a:hover  { background: var(--bg); }
.admin-nav a.active { border-left-color: var(--accent); font-weight: 600; color: var(--accent); }

.admin-nav-sub a {
  display: block;
  padding: 0.35rem 1.25rem 0.35rem 2.1rem;
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-nav-sub a:hover  { background: var(--bg); color: var(--text); }
.admin-nav-sub a.active { border-left-color: var(--accent); color: var(--accent); font-weight: 600; }

.admin-content {
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 860px;
}

.admin-page-title {
  font-size: 1.6rem;
  margin-bottom: 1.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* ── Config page ─────────────────────────────────────── */
.config-section {
  margin-bottom: 2.5rem;
}
.config-section h2 {
  font-size: 1.1rem;
  margin-bottom: 0.35rem;
}
.section-desc {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

.info-row {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.info-label { color: var(--muted); width: 110px; flex-shrink: 0; }
.info-value { font-family: monospace; font-size: 0.9rem; color: var(--text); }

/* ── Badges ──────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  vertical-align: middle;
}
.badge-saved { background: #dbeafe; color: #1e40af; }
.badge-ok    { background: #d1fae5; color: #065f46; }
.badge-warn  { background: #fef9c3; color: #854d0e; }

/* ── Button row & variants ───────────────────────────── */
.btn-row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg); }
.btn-danger  { background: #dc2626; color: #fff; }
.btn-danger:hover { opacity: 0.88; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ── B2 test result ──────────────────────────────────── */
.test-result {
  margin-top: 0.85rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
}
.test-result--ok    { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.test-result--error { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }

/* ── Data table ──────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th {
  text-align: left;
  padding: 0.55rem 0.85rem;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.data-table td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #fafaf8; }

/* ── Misc admin helpers ──────────────────────────────── */
.section-divider { border: none; border-top: 2px solid var(--border); margin: 2.5rem 0; }
.tc { text-align: center; }

input[type="file"] {
  display: block;
  width: 100%;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  font-size: 0.875rem;
  cursor: pointer;
}

/* ── Collection select in header ─────────────────────────────── */
.collection-select {
  background: rgba(255,255,255,0.08);
  color: #e0e0e0;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius);
  padding: 0.3rem 0.6rem;
  font-size: 0.875rem;
  cursor: pointer;
  outline: none;
  appearance: auto;
}
.collection-select:hover { background: rgba(255,255,255,0.14); }
.collection-select option { background: var(--header-bg); color: #e0e0e0; }

/* ── Comic viewer ────────────────────────────────────────────── */
.comic-viewer {
  max-width: 900px;
  margin: 0 auto;
}
.comic-meta {
  text-align: center;
  margin-bottom: 1.25rem;
}
.comic-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}
.comic-date {
  color: var(--muted);
  font-size: 0.95rem;
}
/* ── Breadcrumb ──────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 1rem;
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); text-decoration: underline; }
.breadcrumb [aria-current="page"] { color: var(--text); font-weight: 500; }

.comic-image-wrap {
  position: relative;
  text-align: center;
  margin-bottom: 1.5rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.comic-img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 2px;
}
.comic-controls {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}
.nav-btns {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-shrink: 0;
  padding-top: 0.25rem;
}
.nav-btn { min-width: 90px; text-align: center; }
.nav-btn[disabled] { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

/* ── Month calendar ──────────────────────────────────────────── */
.cal-widget {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem 1rem;
  min-width: 220px;
}
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
  margin-bottom: 0.6rem;
}
.cal-nav-btn {
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text);
  text-decoration: none;
  padding: 0 0.2rem;
  flex-shrink: 0;
  transition: color 0.12s;
}
.cal-nav-btn:hover { color: var(--accent); }
.cal-nav-btn--off  { color: var(--border); cursor: default; pointer-events: none; }
.cal-selects {
  display: flex;
  gap: 0.3rem;
  flex: 1;
  justify-content: center;
}
.cal-select {
  padding: 0.2rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8rem;
  background: #fff;
  cursor: pointer;
  max-width: 100px;
}
.cal-select:focus { outline: none; border-color: var(--accent); }
.cal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.cal-table th {
  text-align: center;
  padding: 0.2rem;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
}
.cal-table td {
  text-align: center;
  padding: 0.2rem;
  width: 2rem;
  height: 2rem;
  vertical-align: middle;
  border-radius: 3px;
}
.cal-table td a {
  display: block;
  width: 100%;
  height: 100%;
  line-height: 1.6rem;
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
  border-radius: 3px;
  transition: background 0.12s;
}
.cal-table td a:hover { background: rgba(233,69,96,0.1); }
.cal-table td.cal-current { background: var(--accent); border-radius: 3px; }
.cal-table td.cal-current a { color: #fff; }
.cal-table td.cal-current a:hover { background: rgba(0,0,0,0.1); }

/* ── Collection stats bar ────────────────────────────────────── */
.collection-stats {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.6rem 0;
  margin-bottom: 0.75rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.stat-author { color: var(--muted); }
.stat-about  { flex: 1; }
.stat-about summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.stat-about summary::-webkit-details-marker { display: none; }
.stat-about summary::after { content: '▾'; font-size: 0.75rem; }
details[open].stat-about summary::after { content: '▴'; }
.stat-about-body {
  padding: 0.75rem 0 0;
  color: var(--text);
  line-height: 1.65;
}
.stat-about-body p  { margin-bottom: 0.5rem; }
.stat-about-body h1,.stat-about-body h2,.stat-about-body h3 { margin: 0.5rem 0 0.3rem; }
.stat-about-body ul,.stat-about-body ol { padding-left: 1.5rem; margin-bottom: 0.5rem; }

/* ── Numbered strip counter ──────────────────────────────────── */
.strip-counter {
  font-size: 0.95rem;
  color: var(--muted);
  align-self: center;
  padding: 0.25rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ── Comic image link ────────────────────────────────────────── */
.comic-img-link { display: block; line-height: 0; cursor: zoom-in; }

/* ── Comic tap zones (left/right image navigation) ──────────── */
.comic-tap-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 28%;
  z-index: 2;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0 0.6rem;
}
.comic-tap-zone--prev { left: 0; justify-content: flex-start; }
.comic-tap-zone--next { right: 0; justify-content: flex-end; }
.comic-tap-arrow {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: rgba(255,255,255,0.92);
  box-shadow: 0 1px 6px rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text);
  opacity: 0;
  transition: opacity 0.18s;
  pointer-events: none;
  user-select: none;
}
.comic-tap-zone:hover .comic-tap-arrow { opacity: 1; }
/* Always show on touch devices */
@media (hover: none) {
  .comic-tap-arrow { opacity: 0.35; }
}

/* ── Admin metadata card ─────────────────────────────────────── */
.meta-card {
  margin-top: 1.5rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.meta-card-toggle {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  list-style: none;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.meta-card-toggle::-webkit-details-marker { display: none; }
.meta-card-toggle::before { content: '▶'; font-size: 0.65rem; margin-right: 0.5rem; transition: transform 0.15s; }
details[open] .meta-card-toggle::before { transform: rotate(90deg); }
.meta-card-body { padding: 0.75rem 1rem; }
.meta-card-body .info-row { border-bottom: 1px solid var(--border); }
.meta-card-body .info-row:last-of-type { border-bottom: none; }

/* ── Admin comics toolbar ────────────────────────────────────── */
.comics-toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0;
}
.toolbar-search {
  flex: 1;
  min-width: 160px;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: #fff;
}
.toolbar-search:focus { outline: none; border-color: var(--accent); }
.toolbar-perpage {
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: #fff;
  cursor: pointer;
}

/* ── Sortable table headers ──────────────────────────────────── */
.sort-th { color: inherit; text-decoration: none; white-space: nowrap; }
.sort-th:hover { color: var(--accent); }
.sort-th--active { color: var(--accent); }

/* ── Pagination ──────────────────────────────────────────────── */
.pager { display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; margin-top: 1rem; }
.pager-btn { font-size: 0.8rem; padding: 0.3rem 0.6rem; min-width: 2rem; text-align: center; }
.pager-btn--active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pager-ellipsis { color: var(--muted); padding: 0 0.25rem; }

/* ── About editor + preview (admin config) ───────────────────── */
.about-editor {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 700px) { .about-editor { grid-template-columns: 1fr; } }
.about-preview-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  min-height: 10rem;
}
.about-preview-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.6rem;
}
.about-preview h1,.about-preview h2,.about-preview h3 { margin: 0.75rem 0 0.4rem; }
.about-preview p  { margin-bottom: 0.75rem; line-height: 1.65; }
.about-preview ul,.about-preview ol { padding-left: 1.5rem; margin-bottom: 0.75rem; }
.about-preview li { margin-bottom: 0.25rem; }
.about-preview a  { color: var(--accent); }
.about-preview code { background: #eee; padding: 0.1em 0.35em; border-radius: 3px; font-size: 0.875em; }
.about-preview pre { background: #eee; padding: 0.75rem; border-radius: var(--radius); overflow-x: auto; margin-bottom: 0.75rem; }

/* ── About page ──────────────────────────────────────────────── */
.about-page {
  max-width: 680px;
  margin: 0 auto;
}
.about-page h1 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
}
.about-text p {
  line-height: 1.7;
  margin-bottom: 1rem;
  color: var(--text);
  font-size: 1rem;
}
