/* Get Manga — web. Built for e-ink as much as for phones:
 *   - black on white only, no greys in the chrome (one grey pixel is a slower
 *     waveform on an e-ink panel) and deliberately no dark theme
 *   - nothing animates: no transitions, no smooth scrolling, no spinners —
 *     every intermediate frame is a ghost on e-ink
 *   - feedback is an instant inversion on :active, never a hover effect
 *   - touch targets are at least 48px, lists page with ▲▼ (in the header)
 *     instead of relying on fling scrolling
 */
:root {
  --ink: #000;
  --paper: #fff;
  --rule: 2px solid var(--ink);
  --tap: 48px;
  --gutter: 16px;
  color-scheme: light;
}
*, *::before, *::after {
  box-sizing: border-box;
  animation: none !important;
  transition: none !important;
}
html { scroll-behavior: auto; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 18px/1.4 Georgia, "Noto Serif", "Times New Roman", serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
img { display: block; }
[hidden] { display: none !important; }

/* --------------------------------------------------------------- header -- */
#bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  min-height: calc(var(--tap) + 8px);
  padding: 4px var(--gutter);
  padding-top: max(4px, env(safe-area-inset-top));
  background: var(--paper);
  border-bottom: var(--rule);
}
#title {
  flex: 1; margin: 0; min-width: 0;
  font-size: 22px; font-weight: bold; letter-spacing: .02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#net {
  border: var(--rule); padding: 2px 8px; font-size: 14px;
  text-transform: uppercase; letter-spacing: .1em;
}
#dl-link { position: relative; text-decoration: none; }
#dl-count {
  position: absolute; top: 2px; right: 0;
  min-width: 20px; padding: 0 4px;
  background: var(--ink); color: var(--paper);
  font: bold 12px/20px sans-serif; text-align: center;
}

/* -------------------------------------------------------------- buttons -- */
.btn, .icon {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap);
  border: var(--rule); border-radius: 0;
  background: var(--paper);
  cursor: pointer; user-select: none;
  text-decoration: none;
}
.btn { padding: 0 18px; }
.icon { min-width: var(--tap); padding: 0; font-size: 26px; line-height: 1; }
#bar .icon { border-color: transparent; }
.btn:active, .icon:active, .row:active, .card:active { background: var(--ink); color: var(--paper); }
.btn.solid { background: var(--ink); color: var(--paper); }
.btn.solid:active { background: var(--paper); color: var(--ink); }
.btn:disabled { border-style: dashed; cursor: default; opacity: 1; color: var(--ink); }
.btn:disabled:active { background: var(--paper); color: var(--ink); }
.btn.solid:disabled { background: var(--paper); color: var(--ink); }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 16px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }

main { padding: var(--gutter); padding-bottom: 96px; max-width: 1100px; margin: 0 auto; }
h2 {
  margin: 24px 0 12px; font-size: 20px;
  border-bottom: var(--rule); padding-bottom: 4px;
}
h2:first-child { margin-top: 4px; }
.muted { font-style: italic; }
.note { margin: 12px 0; }
.error { border: var(--rule); border-style: dashed; padding: 12px; margin: 12px 0; }

/* -------------------------------------------------------------- filters -- */
.filters { border: var(--rule); padding: 4px 12px 12px; margin: 8px 0 16px; }
.fgroup { margin-top: 12px; }
.flabel { font-weight: bold; margin-bottom: 6px; }
.flabel.sub { font-weight: normal; font-style: italic; margin: 12px 0 6px; }
.fhint { font-size: 14px; margin: 4px 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 40px; padding: 0 10px;
  border: 2px solid var(--ink); border-radius: 0; background: var(--paper);
  font-size: 15px; cursor: pointer;
}
.chip.inc { background: var(--ink); color: var(--paper); }
.chip.exc { border-style: dashed; text-decoration: line-through; }
.chip sup { font-size: 11px; margin-left: 1px; }
.filter-summary { font-size: 15px; }

/* -------------------------------------------------------------- version -- */
.version { margin-top: 32px; font: 13px/1.4 sans-serif; letter-spacing: .02em; }
#update {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px var(--gutter); border-bottom: var(--rule);
  background: var(--paper); font-size: 16px;
}
#update span { flex: 1; min-width: 200px; }
body.reading #update { display: none !important; }

/* --------------------------------------------------------------- search -- */
form.search { display: flex; gap: 8px; margin-bottom: 8px; }
form.search input {
  flex: 1; min-width: 0; min-height: var(--tap);
  border: var(--rule); border-radius: 0; padding: 0 12px;
  background: var(--paper); outline: none;
}
form.search input:focus { border-width: 3px; }

/* ---------------------------------------------------------- cover shelf -- */
.shelf {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.card { position: relative; display: block; text-decoration: none; padding: 4px; }
.plate {
  position: relative;
  aspect-ratio: 2 / 3; width: 100%;
  border: var(--rule);
  background: var(--paper);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 48px; font-weight: bold;
}
.plate img { width: 100%; height: 100%; object-fit: cover; }
.card .name {
  margin-top: 6px; font-size: 16px; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ribbon {
  position: absolute; top: 0; left: 0; right: 0;
  background: var(--ink); color: var(--paper);
  font: bold 14px/26px sans-serif; text-align: center; letter-spacing: .04em;
}
.badge {
  position: absolute; bottom: 4px; left: 4px;
  width: 28px; height: 28px;
  background: var(--paper); border: 2px solid var(--ink);
  padding: 2px;
}
.badge img { width: 100%; height: 100%; object-fit: contain; filter: grayscale(1) contrast(2); }

/* ---------------------------------------------------------------- lists -- */
.rows { border-top: var(--rule); }
.row {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 8px 4px;
  border-bottom: 1px solid var(--ink);
  text-decoration: none; cursor: pointer;
}
.row .grow { flex: 1; min-width: 0; }
.row .sub { font-size: 15px; }
.row .plate { width: 64px; flex: none; font-size: 24px; }
.result .desc {
  font-size: 15px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.result .t { font-weight: bold; }

/* chapter rows: the tap area opens, the trailing button downloads */
.chapter { padding-right: 0; }
.chapter.read .t { text-decoration: line-through; text-decoration-thickness: 1px; }
.chapter .state {
  flex: none; min-width: 112px; justify-content: center; font-size: 15px;
}
.mark {
  display: inline-block; border: 1.5px solid var(--ink); padding: 0 6px;
  font: bold 12px/18px sans-serif; letter-spacing: .05em; text-transform: uppercase;
  margin-left: 6px; vertical-align: 2px;
}
.mark.solid { background: var(--ink); color: var(--paper); }

/* hatched, not solid: the same repaint per finished page for a fraction of
   the ink (as on the device) */
.progress { height: 12px; border: 2px solid var(--ink); margin-top: 6px; }
.progress > i {
  display: block; height: 100%;
  background: repeating-linear-gradient(-45deg, var(--ink) 0 2px, var(--paper) 2px 6px);
}

/* ------------------------------------------------------------- overview -- */
.overview { display: flex; gap: 16px; align-items: flex-start; }
.overview .plate { width: 132px; flex: none; }
.overview .meta { flex: 1; min-width: 0; }
.overview h2 { border: none; margin: 0 0 6px; font-size: 22px; padding: 0; }
.desc-full { white-space: pre-line; margin: 12px 0; }
.desc-full.clamp {
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
select.lang {
  min-height: var(--tap); border: var(--rule); border-radius: 0;
  background: var(--paper); padding: 0 8px; max-width: 100%;
}
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }

/* --------------------------------------------------------- page buttons -- */
/* in the sticky header rather than floating: a floating pair sits on top of
   the rows' own buttons on a phone */
#pager { display: flex; }
#pager .icon { font-size: 20px; }

#toast {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  bottom: max(24px, env(safe-area-inset-bottom));
  max-width: calc(100% - 2 * var(--gutter));
  background: var(--ink); color: var(--paper);
  padding: 12px 18px; border: 2px solid var(--paper); outline: 2px solid var(--ink);
}

/* --------------------------------------------------------------- reader -- */
body.reading #bar, body.reading #pager { display: none !important; }
body.reading main { padding: 0; max-width: none; }
.reader {
  position: fixed; inset: 0; background: var(--paper);
  touch-action: pan-x pan-y pinch-zoom;
  user-select: none; -webkit-user-select: none;
}
.reader .page {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
.reader .page img { max-width: 100%; max-height: 100%; object-fit: contain; }
.reader.fit-width { overflow-y: auto; }
.reader.fit-width .page { position: static; min-height: 100%; align-items: flex-start; }
.reader.fit-width .page img { max-height: none; width: 100%; height: auto; }
.reader .msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.reader .chrome {
  position: fixed; left: 0; right: 0; z-index: 5;
  background: var(--paper); padding: 8px var(--gutter);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.reader .chrome.top { top: 0; border-bottom: var(--rule); padding-top: max(8px, env(safe-area-inset-top)); }
.reader .chrome.bottom { bottom: 0; border-top: var(--rule); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.reader .chrome .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader input[type=range] { flex: 1; min-width: 120px; height: var(--tap); accent-color: var(--ink); }
.reader .folio {
  position: fixed; z-index: 4; right: 6px; bottom: max(4px, env(safe-area-inset-bottom));
  background: var(--paper); border: 1.5px solid var(--ink); padding: 0 6px;
  font: 13px/20px sans-serif;
}

/* ---------------------------------------------------------- kindle send -- */
.field { display: block; margin: 12px 0 4px; font-weight: bold; }
.field input {
  display: block; width: 100%; margin-top: 6px; min-height: var(--tap);
  border: var(--rule); border-radius: 0; padding: 0 12px;
  background: var(--paper); font-weight: normal; outline: none;
}
.field input:focus { border-width: 3px; }
.small-print { font-size: 15px; margin-top: 4px; }
.check { display: flex; align-items: center; gap: 12px; min-height: var(--tap); }
.check input { width: 24px; height: 24px; accent-color: var(--ink); margin: 0; }
.status { border: var(--rule); padding: 12px; margin: 12px 0; }
.status .sub { font-size: 15px; margin-top: 4px; }
.sent-list { margin: 8px 0 0; padding-left: 20px; font-size: 15px; }
.pick .box { font-size: 26px; width: 32px; text-align: center; flex: none; }
.pick.on .t { font-weight: bold; }

/* ------------------------------------------------------------- settings -- */
.setting { display: flex; align-items: center; gap: 12px; min-height: 56px; border-bottom: 1px solid var(--ink); }
.setting .grow { flex: 1; }

@media (max-width: 480px) {
  .shelf { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
  .overview .plate { width: 104px; }
  .chapter .state { min-width: 96px; }
}
