/* Comics uses Hearth's existing library tokens on desktop and /m. */
.comic-shelf-toolbar, .comic-shelf-head, .comic-shelf-actions {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
}
.comic-shelf-toolbar { margin-bottom: 18px; }
.comic-shelf-intro { flex: 1 1 220px; min-width: 0; }
.comic-shelf-intro h2 { margin: 0; font-size: 18px; }
.comic-shelf-intro p, .comic-shelf-summary, .comic-shelf-empty {
  margin: 5px 0; color: var(--text-dim); font-size: 13px;
}
.comic-shelf-button, .comic-shelf-toggle {
  color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px); font: inherit; cursor: pointer;
  min-height: 44px; padding: 8px 12px; touch-action: manipulation;
}
.comic-shelf-choice:focus-within { background: var(--surface-2); }
/* Hover is a POINTER state. On a phone it latches onto the last thing tapped and
   stays there, so the control reads as still-selected. Guarded here; the
   aria-state and :focus halves stay outside, because those are real state. */
@media (hover: hover) {
  .comic-shelf-button:hover, .comic-shelf-toggle:hover { background: var(--surface-2); border-color: var(--accent); }
  .comic-shelf-choice:hover { background: var(--surface-2); }
}
.comic-shelf-button:active, .comic-shelf-toggle:active { background: var(--surface-3, var(--surface-2)); }
.comic-shelf-button:disabled { cursor: wait; opacity: .6; }
.comic-shelf-primary { border-color: var(--accent); }
.comic-shelf-button:focus-visible, .comic-shelf-toggle:focus-visible,
.comic-shelf-editor input:focus-visible, .comic-shelf .tile:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}
.comic-shelf { grid-column: 1 / -1; min-width: 0; }
.comic-shelf-head { border-bottom: 1px solid var(--border); padding-bottom: 6px; margin-bottom: 12px; }
.comic-shelf-head h3 { flex: 1; min-width: 0; margin: 0; font-size: 15px; }
.comic-shelf-toggle { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border-color: transparent; background: transparent; }
.comic-shelf-toggle::before { content: '−'; flex: none; color: var(--text-dim); }
.comic-shelf-toggle[aria-expanded="false"]::before { content: '+'; }
.comic-shelf-name { min-width: 0; overflow-wrap: anywhere; }
.comic-shelf-count { color: var(--text-dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.comic-shelf-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); gap: 14px; }
.comic-shelf-row[hidden] { display: none; }
.comic-shelf-row > * { min-width: 0; }
.comic-shelf-row > .comic-shelf-empty { grid-column: 1 / -1; padding: 12px 0; }
.comic-shelf-unfiled { grid-column: 1 / -1; margin: 12px 0 0; font-size: 15px; }
.comic-shelf-overlay {
  position: fixed; inset: 0; z-index: var(--comic-shelf-layer, 1100); padding: 16px;
  display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.7);
}
.comic-shelf-editor {
  display: flex; flex-direction: column; gap: 14px; width: min(560px, 100%); min-width: 0;
  max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain;
  padding: 20px; border: 1px solid var(--border); border-radius: var(--radius, 14px);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-card);
}
.comic-shelf-editor h2 { font-size: 18px; margin: 0; }
.comic-shelf-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.comic-shelf-field input {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; font-size: 16px;
  background: var(--bg); color: var(--text); border: 1px solid var(--border-strong, var(--border));
  border-radius: var(--radius-sm, 8px);
}
.comic-shelf-picker { min-height: 60px; max-height: 38dvh; overflow-y: auto; overscroll-behavior: contain; }
.comic-shelf-choice {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px;
  border-radius: var(--radius-sm, 8px); cursor: pointer;
  content-visibility: auto; contain-intrinsic-size: auto 44px;
}
.comic-shelf-choice input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.comic-shelf-choice span { min-width: 0; overflow-wrap: anywhere; }
.comic-shelf-status { margin: 0; font-size: 13px; color: var(--text); overflow-wrap: anywhere; }
.comic-shelf-status:empty { display: none; }
.comic-shelf-actions { justify-content: flex-end; }
.comic-shelf-remove { margin-right: auto; }
@media (max-width: 600px) {
  /* Top-aligned on a phone: iOS shrinks only the visual viewport, so a centred
     dialog puts its own Save and Cancel behind the keyboard. */
  .comic-shelf-overlay { align-items: flex-start; padding-top: 24px; }
    /* 3-up, matching .grid-c in the phone stylesheet: a shelf's comics were drawn
     2-up while the unfiled ones below them were 3-up, on the same screen. */
  .comic-shelf-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .comic-shelf-toolbar > .comic-shelf-button { flex: 1; }
  .comic-shelf-editor { padding: 16px; }
  .comic-shelf-intro { flex-basis: 100%; }
}
