/* Library cards on setup screen */
.library {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.stats-block {
  background: linear-gradient(180deg, var(--panel), var(--bg));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.stats-today {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.stats-today b { font-size: 18px; color: var(--accent-2); font-variant-numeric: tabular-nums; }
.stats-today .small-btn { margin-left: auto; }
/* Segmented control — one inset pill TRACK, mirrors .ds-seg (components.css)
   so the hand-rolled menus and the canonical .ds-seg look identical. The active
   segment is a soft raised fill (iOS/Linear), NEVER loud solid amber. */
.stats-tabs {
  display: inline-flex; gap: 2px; margin-bottom: 8px; padding: 3px;
  background: var(--bg); border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
}
.stats-tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--tap), background var(--tap);
}
.stats-tab:hover { color: var(--text); }
/* colour-only: the sliding .seg-ind pill provides the background (components.css) */
.stats-tab.active { background: transparent; color: var(--accent-2-strong); box-shadow: none; }
.stats-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 360px;
  overflow-y: auto;
}
.stats-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
}
.stats-row-label { color: var(--muted); font-size: 13px; flex: 1; }
.stats-row-words { font-variant-numeric: tabular-nums; text-align: right; cursor: pointer; }
.stats-row-words[data-edit="day"]:hover { color: var(--accent-2); text-decoration: underline; }
.stats-row-edit {
  width: 100px;
  text-align: right;
  background: var(--panel-2, var(--panel));
  border: 1px solid var(--accent-2);
  color: var(--text);
  padding: 2px 6px;
  border-radius: 4px;
  font: inherit;
  font-variant-numeric: tabular-nums;
}
.stats-empty { text-align: center; padding: 14px 12px; background: var(--panel-2); border: 1px dashed var(--border); border-radius: var(--radius-sm); color: var(--muted); font-size: 13px; }
.stats-breakdown {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.stats-src-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
}
.stats-src-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-src-words { font-variant-numeric: tabular-nums; cursor: pointer; }
.stats-src-words[data-edit="source"]:hover { color: var(--accent-2); text-decoration: underline; }
.stats-src-del {
  border: none; background: transparent; border-radius: 50%; padding: 0;
  width: 28px; height: 28px; opacity: 1; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--tap), color var(--tap);
}
.stats-src-del > svg { width: 14px; height: 14px; }
.stats-src-del:hover { background: var(--danger-soft); color: var(--accent); }
.stats-add-row {
  display: grid;
  grid-template-columns: 1fr 110px auto;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.stats-add-row input {
  background: var(--panel-2, var(--panel));
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 4px;
  font: inherit;
}
.stats-row-day { cursor: pointer; }
.stats-row-day .stats-row-caret { color: var(--muted); font-size: 10px; padding-right: 4px; }
.stats-day-sources {
  padding: 4px 0 8px 16px;
  margin: 0 0 4px 6px;
  border-left: 2px solid var(--border);
}
.rd-row {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.rd-row:last-child { border-bottom: none; }
.rd-row-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.rd-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-weight: 600;
}
a.rd-title { color: var(--accent-2); text-decoration: none; }
a.rd-title:hover { text-decoration: underline; }
.rd-title.rd-resume { cursor: pointer; color: var(--accent-2); }
.rd-title.rd-resume:hover { text-decoration: underline; }
.rd-time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.rd-range {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-family: monospace;
}
.rd-range [data-edit] { cursor: pointer; padding: 0 2px; border-radius: 2px; }
.rd-range [data-edit]:hover { background: var(--panel-2, var(--panel)); color: var(--accent-2); }
.rd-range.rd-manual { font-style: italic; font-family: inherit; }
.rd-words {
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  white-space: nowrap;
}
.rd-words:hover { color: var(--accent-2); text-decoration: underline; }
/* Delete-reading affordance — now a DsIconButton (.ds-icon-btn
   .ds-icon-btn--danger in markup); size/box/44px/red-on-hover come from
   .ds-icon-btn. The element keeps .small-btn in markup for layout grouping, but
   .ds-icon-btn wins the visual (it's listed after in the class list and the
   component rules are more specific to the icon role). Nothing extra needed
   here now; the rule is kept as a documented no-op anchor. */
.rd-excerpt {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  font-style: italic;
  line-height: 1.4;
  padding-left: 4px;
  border-left: 2px solid var(--border);
}

.lib-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  gap: 12px;
  transition: background var(--tap), border-color var(--tap), color var(--tap);
}
.lib-card:hover { background: var(--panel-2); border-color: var(--accent-2); }
.lib-card .info { flex: 1; min-width: 0; }
.lib-card .info .title {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lib-card .info .author {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lib-card .info .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.lib-card .type-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  /* Top-align with the title rather than floating in the middle of the
     multi-line text block. */
  align-self: flex-start;
  margin-top: 1px;
}
.lib-card .remove {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: 50%;
  /* ≥40px hit area for touch; top-aligned with the title. A real round icon
     button — quiet at rest, brightening on card hover, destructive (red) when
     you hover the button itself. */
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  transition: background var(--tap), color var(--tap);
}
.lib-card:hover .remove { color: var(--text); }
.lib-card .remove:hover { background: var(--danger-soft); color: var(--accent); }
.lib-card .remove:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-2-soft); }

.library-show-all {
  margin-top: 8px;
  width: 100%;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--muted);
}
.library-show-all:hover { background: var(--panel-2); color: var(--text); }

/* Library scan panel on the setup screen */
.lib-scan .scan-summary {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.lib-scan .scan-summary .totals {
  font-size: 14px;
}
.lib-scan .scan-summary .pace-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.lib-scan .scan-summary .pace-row label {
  color: var(--muted);
}
.lib-scan .scan-summary .pace-row input[type=number],
.lib-scan .scan-summary .pace-row select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 8px;
  border-radius: 6px;
  font: inherit;
}
.lib-scan .scan-summary .pace-row input[type=number] { width: 110px; }
.lib-scan .scan-summary .eta {
  font-size: 14px;
  margin-top: 8px;
}
.lib-scan .scan-summary details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}
.lib-scan .scan-table {
  margin-top: 8px;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.lib-scan .scan-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  align-items: baseline;
}
.lib-scan .scan-row:last-child { border-bottom: none; }
.lib-scan .scan-row .t {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.lib-scan .scan-row .a {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.lib-scan .scan-row .m {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.lib-scan .scan-row-err .t { color: var(--accent); }
.lib-scan .scan-row-click { cursor: pointer; }
.lib-scan .scan-row-click:hover { background: var(--panel-2); }
.lib-scan .scan-badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: middle;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.lib-scan .scan-badge.inprog {
  background: color-mix(in srgb, var(--orp) 18%, transparent);
  color: var(--orp);
  border: 1px solid var(--orp);
}
.lib-scan .scan-badge.done {
  background: color-mix(in srgb, var(--ok) 16%, transparent);
  color: var(--ok);
  border: 1px solid var(--ok);
}
.lib-scan .scan-badge.unread {
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.lib-scan .scan-badge.missing {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
}
.lib-scan .scan-row-missing { opacity: 0.7; }
.lib-scan .scan-row.selected {
  background: color-mix(in srgb, var(--orp) 14%, transparent);
  box-shadow: inset 2px 0 0 var(--orp);
}
.lib-scan .scan-row.selected:hover { background: color-mix(in srgb, var(--orp) 20%, transparent); }
.scan-context-menu {
  position: fixed;
  z-index: 9999;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  padding: 4px;
  min-width: 220px;
  font-size: 13px;
  user-select: none;
}
.scan-context-menu .item {
  padding: 7px 12px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text);
}
.scan-context-menu .item:hover { background: var(--panel-2); }
.scan-context-menu .item.muted { color: var(--muted); }
.scan-context-menu .sep {
  height: 1px;
  background: var(--border);
  margin: 4px 2px;
}
.scan-context-menu .header {
  padding: 5px 12px 6px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lib-scan .scan-series {
  display: inline;
  margin-left: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: normal;
  font-style: italic;
}
.lib-scan .scan-failures {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 6px;
  padding: 8px 12px;
}
.lib-scan .scan-failures summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.lib-scan .scan-failure-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lib-scan .scan-failure {
  font-size: 12px;
  padding: 6px 8px;
  background: var(--panel-2);
  border-radius: 4px;
  border-left: 2px solid var(--accent);
}
.lib-scan .scan-failure .t {
  color: var(--text);
  word-break: break-word;
  margin-bottom: 2px;
}
.lib-scan .scan-failure .m {
  color: var(--muted);
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.lib-scan .rec-basis {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ---------- Reading goal ---------- */
.goal-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.goal-hint { color: var(--muted); font-size: 12px; }

/* Empty state (no monthly goal set yet): an inviting prompt + a styled input,
   instead of a bare orphaned form field. */
.goal-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.goal-empty-title { font-size: 14px; font-weight: 600; color: var(--text); }
.goal-empty-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.goal-empty-input { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.goal-empty-input input {
  width: 150px;
  background: var(--panel-2, var(--panel));
  border: 1px solid var(--accent-2);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  font: inherit;
  font-variant-numeric: tabular-nums;
  outline: none;
}
.goal-empty-input input:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--accent-2-soft); }

/* Summary head: a compact "Monthly goal" label + editable value, shown above
   the chart once a goal is set so the user can adjust it without a separate row. */
.goal-summary-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.goal-summary-label { color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: 0.05em; }
.goal-set-input {
  width: 110px;
  background: var(--panel-2, var(--panel));
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 6px;
  font: inherit;
  font-variant-numeric: tabular-nums;
  outline: none;
}
.goal-set-input:focus { border-color: var(--accent-2); }
.goal-summary { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
/* Segmented control — same inset-pill TRACK as .stats-tabs / .ds-seg. */
.goal-view-tabs {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--bg); border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
}
.goal-view-tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--tap), background var(--tap);
}
.goal-view-tab:hover { color: var(--text); }
.goal-view-tab.active { background: transparent; color: var(--accent-2-strong); box-shadow: none; }
.stats-tab:focus-visible, .goal-view-tab:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.lib-card:focus-visible { outline: none; box-shadow: var(--focus-ring); border-color: var(--accent-2); }
.goal-headline { display: flex; align-items: baseline; gap: 8px; }
.goal-headline b { font-size: 26px; color: var(--text); font-variant-numeric: tabular-nums; }
.goal-headline-suffix { color: var(--muted); font-size: 14px; }
.goal-progress { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.goal-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--panel-2, var(--panel));
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.goal-progress-bar > div {
  height: 100%;
  width: 0;
  background: var(--accent-2);
  transition: width 200ms linear;
}
.goal-progress-label { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 130px; text-align: right; }
.goal-chart { width: 100%; }
.goal-chart-svg { width: 100%; height: auto; max-height: 240px; display: block; }
.goal-chart-grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.5; }
.goal-chart-label { fill: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.goal-chart-target { stroke: var(--accent-2); stroke-width: 1.5; stroke-dasharray: 4 4; opacity: 0.85; }
.goal-chart-actual { stroke: var(--ok); stroke-width: 2.5; }
.goal-chart-legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  padding-left: 4px;
}
.goal-chart-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.goal-chart-legend .lg-swatch { width: 16px; height: 0; border-top-width: 2px; border-top-style: solid; }
.goal-chart-legend .lg-target .lg-swatch { border-top-color: var(--accent-2); border-top-style: dashed; }
.goal-chart-legend .lg-actual .lg-swatch { border-top-color: var(--ok); }
.goal-chart-now { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.6; }
.goal-override-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  flex-wrap: wrap;
}
.goal-override-label { color: var(--muted); }
.goal-override-row input[type="number"] {
  width: 110px;
  background: var(--panel-2, var(--panel));
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 6px;
  font: inherit;
  font-variant-numeric: tabular-nums;
}
.goal-stats { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; }
.goal-stat { display: flex; align-items: baseline; gap: 6px; }
.goal-stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.goal-stat b { font-size: 18px; color: var(--text); font-variant-numeric: tabular-nums; }
.goal-stat-unit { color: var(--muted); font-size: 12px; }
.goal-delta.ahead { color: var(--ok); }
.goal-delta.behind { color: var(--muted); }
.goal-delta.level { color: var(--accent-2); }
.rd-pages { color: var(--muted); font-size: 12px; margin-left: 4px; font-variant-numeric: tabular-nums; }

