/* Palette and components follow the other QXRay apps (the red brand strip comes from /apps/qx-brand.css). */
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1c2330;
  --muted: #5d6778;
  --border: #dde1e8;
  --accent: #1f6feb;
  --accent-soft: #e7f0ff;
  --accent-line: #b9d1fb;
  --soft: #eef2f7;
  --hover: #f8fafc;
  --error: #b42318;
  --ok: #15803d;
  --ok-soft: #dff3e7;
  --warn-soft: #fff4dc;
  --warn: #8a5a00;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151c;
    --card: #1a2029;
    --text: #e6e9ef;
    --muted: #9aa4b5;
    --border: #2d3542;
    --accent: #5b9dff;
    --accent-soft: #1d2c45;
    --accent-line: #2f4a75;
    --soft: #222a35;
    --hover: #202733;
    --error: #ff8a80;
    --ok: #4ade80;
    --ok-soft: #1c3326;
    --warn-soft: #3a2f17;
    --warn: #f5c76a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.page { max-width: 1480px; margin: 0 auto; padding: 24px 16px 48px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
h1 { margin: 0; font-size: 1.6rem; }
.sub { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

button, .btn { font: inherit; padding: 6px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--card); color: var(--text); }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.small { font-size: .85rem; padding: 4px 10px; }
button.danger { color: var(--error); }
button:disabled { opacity: .5; cursor: not-allowed; }
input[type=text], textarea { font: inherit; width: 100%; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--card); color: var(--text); }
textarea { resize: vertical; min-height: 44px; }

.status { padding: 4px 0 12px; font-size: 13px; min-height: 28px; color: var(--muted); }
.status.error { color: var(--error); }
.status.ok { color: var(--ok); }

.layout { display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 760px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.sidebar, .main { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; min-width: 0; }
@media (max-width: 760px) { .sidebar, .main { padding: 14px 12px; } }
.side-head { display: flex; justify-content: space-between; align-items: center; }
.side-head h2 { margin: 0; font-size: 1.1rem; }
.muted { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.list-nav { list-style: none; margin: 8px 0 0; padding: 0; }
.list-nav li { padding: 8px 10px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.list-nav li:hover { background: var(--hover); }
.list-nav li.active { background: var(--accent-soft); border-color: var(--accent-line); }
.list-nav .nm { font-weight: 600; display: block; }
.list-nav .meta { font-size: 12px; color: var(--muted); }
.badge { font-size: 11px; background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 1px 7px; margin-left: 6px; }

.empty { text-align: center; color: var(--muted); padding: 50px 10px; }

/* use view */
.view-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.view-head h2 { margin: 0; font-size: 1.3rem; }
.view-head p { margin: 4px 0 0; color: var(--muted); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.progress { height: 10px; background: var(--border); border-radius: 6px; overflow: hidden; margin: 14px 0 4px; }
.progress > div { height: 100%; background: var(--ok); width: 0; transition: width .2s; }
.progress-text { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.chapter { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; break-inside: avoid; }
.chapter > h3 { margin: 0; padding: 9px 14px; background: var(--soft); font-size: 1rem; display: flex; justify-content: space-between; }
.chapter > h3 small { font-weight: 400; color: var(--muted); }
.chapter.done > h3 { background: var(--ok-soft); }
.items { list-style: none; margin: 0; padding: 4px 0; }
.items label { display: flex; gap: 10px; align-items: flex-start; padding: 7px 14px; cursor: pointer; }
.items label:hover { background: var(--hover); }
.items input[type=checkbox] { width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--ok); }
.items input:checked + span { text-decoration: line-through; color: var(--muted); }

/* edit view */
.ed-chapter { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; margin: 12px 0; background: var(--hover); }
.ed-row { display: flex; gap: 6px; align-items: center; margin: 5px 0; }
.ed-row.title input { font-weight: 600; }
.ed-items { margin-left: 22px; }
.ed-row button { padding: 4px 8px; flex: none; }
.field { margin: 10px 0; }
.field > label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 3px; }
.hint { font-size: 13px; color: var(--muted); }

@media print {
  .sidebar, .actions, .btn-row, .status { display: none; }
  .layout { display: block; }
  .main { border: none; padding: 0; }
}

.badge.unverified { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); font-weight: 600; }
.view-head h2 .badge { font-size: 12px; vertical-align: middle; margin-left: 10px; }
.disclaimer { max-width: 460px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); color: var(--text); padding: 20px 22px; }
.disclaimer::backdrop { background: rgba(0, 0, 0, .45); }
.disclaimer h2 { margin: 0 0 10px; font-size: 1.1rem; }
.disclaimer .btn-row { justify-content: flex-end; margin-top: 16px; }
.warn-box { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); border-radius: 8px; padding: 8px 10px; margin: 0 0 8px; }
.warn-box[hidden] { display: none; }
input.short { max-width: 140px; }
.meta-line { font-size: 13px; }
.list-nav li { position: relative; }
.list-nav li:has(.save-icon) .nm { padding-right: 52px; }
.save-icon { position: absolute; top: 6px; right: 6px; padding: 2px 8px; margin-left: 0; font-size: 26px; line-height: 30px; border-radius: 6px; vertical-align: middle; }
