:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --text: #1b2430;
  --muted: #5b6675;
  --primary: #2f5d9e;
  --primary-dark: #223f6b;
  --accent: #b5872a;
  --border: #d8e0ea;
  --tint: #eef3fa;
  --green: #2f7d54;
  --amber: #b57320;
  --grey: #6b7684;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { font-size: 20px; }
body {
  margin: 0;
  font-family: "Segoe UI", Verdana, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header.site-header {
  background: var(--primary);
  color: #fff;
  padding: 1rem;
}
header.site-header .bar {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}
header.site-header h1 { margin: 0; font-size: 1.5rem; }
header.site-header nav a {
  color: #fff;
  text-decoration: none;
  background: var(--primary-dark);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  white-space: nowrap;
}
header.site-header nav a[aria-current="page"] { background: var(--accent); }

main { max-width: 820px; margin: 0 auto; padding: 1.25rem; }
h2 { color: var(--primary-dark); font-size: 1.4rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: 1rem;
}
.note {
  background: var(--tint);
  border: 1px dashed var(--primary);
  border-radius: var(--radius);
  padding: 0.9rem;
  font-size: 0.95rem;
}

.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.6rem 1.1rem;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: var(--surface); color: var(--primary-dark); border: 1px solid var(--border); }
.btn:disabled { background: #97a2b0; cursor: not-allowed; }

label { display: block; font-weight: bold; margin-top: 0.8rem; font-size: 0.95rem; }
input[type="text"], input[type="url"], input[type="email"], input[type="password"],
input[type="number"], select {
  font-size: 1rem;
  padding: 0.45rem 0.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 100%;
  max-width: 340px;
}

/* ---- status badges ---- */
.badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: bold;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}
.st-finished { background: #d7efe0; color: var(--green); }
.st-in-progress { background: #f6e6cf; color: var(--amber); }
.st-not-started { background: #e6eaef; color: var(--grey); }

/* ---- library (index.html) ---- */
.grp { margin-bottom: 0.6rem; }
.grp.lvl-0 { margin-bottom: 0.9rem; }
.grp-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.grp-head:hover { border-color: var(--primary); }
.grp-head .chev { color: var(--muted); font-size: 0.85rem; transition: transform 0.15s; flex-shrink: 0; }
.grp[data-open="true"] > .grp-head .chev { transform: rotate(90deg); }
.grp-head .grp-name { flex: 1; min-width: 0; font-weight: bold; }
.grp-head .frac { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.grp.lvl-0 > .grp-head .grp-name { color: var(--primary-dark); font-size: 1.05rem; }
.grp.lvl-1 > .grp-head { background: var(--tint); padding: 0.6rem 0.9rem; font-size: 0.95rem; }
.grp.lvl-2 > .grp-head { padding: 0.55rem 0.9rem; font-size: 0.95rem; }

.grp-body { display: none; padding: 0.5rem 0 0.1rem 1rem; }
.grp[data-open="true"] > .grp-body { display: block; }
.grp.lvl-2 > .grp-body { padding-left: 0.5rem; }
.book-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.8rem;
  padding: 0.55rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.book-row:last-child { border-bottom: none; }
.book-row .num { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 1.8rem; }
.book-row .bt { flex: 1; min-width: 10rem; }
.book-row .bt .ty { color: var(--muted); font-size: 0.82rem; }
.book-row select { width: auto; max-width: none; font-size: 0.9rem; padding: 0.3rem 0.4rem; }
.book-row a.acq { font-size: 0.85rem; }

/* ---- manage table (manage.html) ---- */
.table-wrap { overflow-x: auto; }
table.grid { border-collapse: collapse; width: 100%; }
table.grid th, table.grid td {
  border: 1px solid var(--border);
  padding: 0.35rem;
  vertical-align: top;
}
table.grid th { background: var(--tint); text-align: left; font-size: 0.9rem; }
table.grid input[type="text"], table.grid input[type="url"], table.grid input[type="number"] {
  width: 100%;
  max-width: none;
  min-width: 6rem;
  font-size: 0.92rem;
  padding: 0.3rem;
}
table.grid input[type="number"] { min-width: 3.5rem; }
table.grid select { width: 100%; max-width: none; min-width: 7rem; font-size: 0.92rem; padding: 0.3rem; }
table.grid td:last-child { white-space: nowrap; }
table.grid .btn { font-size: 0.85rem; padding: 0.35rem 0.6rem; margin: 0.1rem; }

footer.site-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

#status {
  display: none;
  background: var(--tint);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.9rem;
  font-size: 0.95rem;
}

@media (max-width: 480px) {
  html { font-size: 16px; }
  .grp-body { padding-left: 0.5rem; }
}
