/* ============================================================
   BookFollower
   ============================================================ */

:root {
  color-scheme: light;
  --bg: #fbfbf9;
  --surface: #ffffff;
  --sunk: #f3f3f0;
  --border: #e9e9e4;
  --border-2: #dbdbd4;
  --ink: #191917;
  --ink-2: #6a6a64;
  --ink-3: #9c9c94;
  --accent: #1f6f52;
  --accent-soft: #e7f1ec;
  --warn: #b06a1d;
  --warn-soft: #f6ecdf;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-cover: 0 1px 2px rgba(20, 20, 14, 0.12), 0 6px 18px rgba(20, 20, 14, 0.10);
  --shadow-pop: 0 1px 2px rgba(20, 20, 14, 0.06), 0 12px 34px rgba(20, 20, 14, 0.13);
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0c0c0d;
    --surface: #161618;
    --sunk: #1f1f21;
    --border: #262628;
    --border-2: #35353a;
    --ink: #f1f1ee;
    --ink-2: #a0a09a;
    --ink-3: #6b6b66;
    --accent: #45b98c;
    --accent-soft: #16261f;
    --warn: #d99f5c;
    --warn-soft: #2b2117;
    --shadow-cover: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 22px rgba(0, 0, 0, 0.45);
    --shadow-pop: 0 1px 2px rgba(0, 0, 0, 0.4), 0 14px 40px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* author `display` rules (e.g. .empty { display:flex }) otherwise beat the UA
   [hidden] rule, so el.hidden = true never actually hides the element */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.55;
  letter-spacing: -0.006em;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }

h1, h2, h3 { letter-spacing: -0.022em; font-weight: 600; margin: 0; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.44rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.13s, border-color 0.13s, opacity 0.13s;
}
.btn:hover { background: var(--sunk); }
.btn--primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn--primary:hover { opacity: 0.88; background: var(--ink); }
.btn--ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--sunk); color: var(--ink); }
.btn--sm { padding: 0.28rem 0.6rem; font-size: 0.78rem; border-radius: 7px; }
.btn:disabled { opacity: 0.45; cursor: default; }

.icon {
  display: inline-grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  transition: background 0.13s, color 0.13s;
}
.icon:hover { background: var(--sunk); color: var(--ink); }
.icon:disabled { opacity: 0.4; cursor: default; }

/* ---------- topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.8rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 0.55rem; margin-right: auto; }
.brand__mark {
  display: grid; place-items: center;
  width: 1.9rem; height: 1.9rem;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
}
.brand h1 { font-size: 1.05rem; font-weight: 600; }

.topbar__controls { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.search {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 0 0.7rem;
  color: var(--ink-3);
}
.search input {
  border: none; background: transparent; color: var(--ink);
  font: inherit; font-size: 0.85rem; padding: 0.42rem 0; width: 150px; outline: none;
}
.search:focus-within { border-color: var(--ink-3); }

/* ---------- add panel ---------- */

.addpanel { border-bottom: 1px solid var(--border); background: var(--surface); }
.addpanel__inner { max-width: 1120px; margin: 0 auto; padding: 1.2rem 1.5rem 1.4rem; }
.addbar { display: flex; margin-bottom: 1rem; }
.tabs { display: flex; align-items: center; gap: 1.4rem; margin-bottom: 1.1rem; border-bottom: 1px solid var(--border); }
.tabs button {
  border: none; background: transparent; color: var(--ink-3);
  font-size: 0.86rem; font-weight: 500; padding: 0 0 0.7rem; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.on { color: var(--ink); border-color: var(--ink); }
.stat {
  margin-left: auto; padding-bottom: 0.7rem;
  display: flex; align-items: baseline; gap: 0.3rem;
  font-size: 0.78rem; color: var(--ink-3); white-space: nowrap;
}
.stat__n { font-size: 1.02rem; font-weight: 600; color: var(--accent); }
.stat__sub { color: var(--ink-3); }

.field { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.field input {
  flex: 1; min-width: 220px;
  background: var(--bg); border: 1px solid var(--border-2); border-radius: 8px;
  padding: 0.55rem 0.85rem; font: inherit; font-size: 0.88rem; color: var(--ink); outline: none;
}
.field input:focus { border-color: var(--ink-3); }
.note { font-size: 0.8rem; color: var(--ink-3); margin: 0.7rem 0 0; }

.results { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 1rem; }
.results__group { display: flex; flex-direction: column; gap: 0.4rem; }
.results__group + .results__group { margin-top: 0.9rem; }
.results__label {
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-3); margin: 0.6rem 0 0.1rem;
}
.result {
  display: flex; align-items: center; gap: 0.8rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.55rem 0.75rem;
}
.result__cover {
  width: 38px; aspect-ratio: 2/3; object-fit: cover; border-radius: 3px;
  background: var(--sunk); box-shadow: var(--shadow-cover); flex-shrink: 0;
}
.result__meta { flex: 1; min-width: 0; }
.result__title { font-weight: 550; font-size: 0.88rem; }
.result__sub { font-size: 0.77rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result__actions { display: flex; gap: 0.35rem; align-items: center; flex-shrink: 0; }

select.mini, .field select {
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 7px;
  padding: 0.3rem 0.5rem; font: inherit; font-size: 0.78rem; color: var(--ink); cursor: pointer; outline: none;
}

/* ---------- page ---------- */

.page { max-width: 1120px; margin: 0 auto; padding: 1.8rem 1.5rem 5rem; }
.section { margin-bottom: 2.8rem; }
.section__head { display: flex; align-items: baseline; gap: 0.55rem; margin-bottom: 1.15rem; }
.section__head h2 { font-size: 0.95rem; font-weight: 600; }
.section__count { font-size: 0.8rem; color: var(--ink-3); }

/* ---------- watch card ---------- */

.watches { display: flex; flex-direction: column; gap: 1rem; }

.watch {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.15s;
}
.watch:hover { border-color: var(--border-2); }

.watch__top { display: flex; gap: 1.1rem; padding: 1.15rem 1.25rem; }
.watch__cover {
  width: 74px; flex-shrink: 0; aspect-ratio: 2/3;
  border-radius: 5px; object-fit: cover;
  background: var(--sunk); box-shadow: var(--shadow-cover);
}
.watch__cover--ph {
  display: grid; place-items: center;
  font-weight: 600; font-size: 1rem; color: var(--ink-3);
  letter-spacing: 0;
}
.watch__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.watch__row1 { display: flex; align-items: flex-start; gap: 0.6rem; }
.watch__titles { flex: 1; min-width: 0; }
.watch__name { font-size: 1.02rem; font-weight: 600; line-height: 1.3; }
.watch__by { font-size: 0.8rem; color: var(--ink-2); margin-top: 0.05rem; }
.watch__meta { font-size: 0.78rem; color: var(--ink-3); margin-top: 0.15rem; display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.watch__tools { display: flex; gap: 0.15rem; flex-shrink: 0; }

.chip {
  font-size: 0.68rem; font-weight: 550;
  padding: 0.11rem 0.42rem; border-radius: 999px;
  background: var(--sunk); color: var(--ink-2);
}
.chip--ended { background: var(--warn-soft); color: var(--warn); }

.bar {
  display: flex; align-items: center; gap: 0.65rem;
}
.bar__track { flex: 1; height: 5px; border-radius: 999px; background: var(--sunk); overflow: hidden; }
.bar__fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.35s ease; }
.bar__label { font-size: 0.77rem; color: var(--ink-2); white-space: nowrap; }

.alert {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.83rem; font-weight: 500;
  padding: 0.5rem 0.65rem; border-radius: 8px;
  background: var(--sunk); color: var(--ink);
}
.alert svg { flex-shrink: 0; color: var(--ink-3); }
.alert--go { background: var(--accent-soft); color: var(--accent); }
.alert--go svg { color: currentColor; }
.alert--wait { background: var(--warn-soft); color: var(--warn); }
.alert--wait svg { color: currentColor; }
.alert__txt { flex: 1; }
.alert button {
  border: none; background: currentColor; border-radius: 6px;
  padding: 0.2rem 0.55rem; font-size: 0.72rem; font-weight: 600; cursor: pointer; flex-shrink: 0;
}
.alert button span { color: var(--surface); }

/* ---------- tome strip ---------- */

.strip {
  display: flex; gap: 0.55rem;
  padding: 0.1rem 1.25rem 1.25rem;
  overflow-x: auto;
  scrollbar-width: thin;
}
.strip::-webkit-scrollbar { height: 4px; }
.strip::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 999px; }

.tome { position: relative; width: 44px; flex-shrink: 0; border: none; background: none; padding: 0; cursor: pointer; }
.tome__c {
  width: 100%; aspect-ratio: 2/3; border-radius: 4px; object-fit: cover;
  background: var(--sunk); box-shadow: var(--shadow-cover);
  outline: 2px solid transparent; outline-offset: 1.5px;
  transition: transform 0.12s, outline-color 0.12s, opacity 0.12s;
}
.tome:hover .tome__c { transform: translateY(-2px); }
.tome.read .tome__c { outline-color: var(--accent); }
.tome.reading .tome__c { outline-color: var(--warn); }
.tome.wait .tome__c, .tome.future .tome__c { opacity: 0.5; outline: 1.5px dashed var(--border-2); }
.tome__n {
  position: absolute; bottom: -5px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  font-size: 0.58rem; font-weight: 600; padding: 0.02rem 0.3rem; border-radius: 999px;
}
.tome.read .tome__n { background: var(--accent); color: #fff; }
.tome.reading .tome__n { background: var(--warn); color: #fff; }
.tome__k {
  position: absolute; top: 3px; right: 3px;
  width: 13px; height: 13px; border-radius: 999px;
  display: grid; place-items: center; color: #fff;
}
.tome__note {
  position: absolute; top: 3px; left: 3px;
  background: rgba(15, 15, 10, 0.72); color: #f0c65a;
  font-size: 0.54rem; font-weight: 600; padding: 0.02rem 0.22rem; border-radius: 3px;
}
.tome.read .tome__k { background: var(--accent); }
.tome.reading .tome__k { background: var(--warn); }

/* ---------- disclosures / panel ---------- */

.disc {
  width: 100%; text-align: left; border: none; cursor: pointer;
  border-top: 1px solid var(--border);
  background: transparent; color: var(--ink-3);
  font-size: 0.79rem; font-weight: 500;
  padding: 0.6rem 1.25rem;
  display: flex; align-items: center; gap: 0.4rem;
}
.disc:hover { background: var(--sunk); color: var(--ink); }
.disc svg { transition: transform 0.15s; }
.disc.open svg { transform: rotate(90deg); }

.panel {
  border-top: 1px solid var(--border); background: var(--sunk);
  padding: 0.95rem 1.25rem; display: flex; flex-direction: column; gap: 0.7rem;
}
.panel__row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; font-size: 0.82rem; color: var(--ink-2); }
.panel__row label { display: flex; align-items: center; gap: 0.35rem; }
.panel input[type=text], .panel input[type=search], .panel input[type=number] {
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 7px;
  padding: 0.38rem 0.6rem; font: inherit; font-size: 0.8rem; color: var(--ink); outline: none;
}
.panel input:focus { border-color: var(--ink-3); }
.panel__hint { font-size: 0.77rem; color: var(--ink-3); }

.items { border-top: 1px solid var(--border); }
.item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1.25rem; border-bottom: 1px solid var(--border);
}
.item:last-child { border-bottom: none; }
.item.dim { opacity: 0.6; }
.item.is-done {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}
.item.is-done .item__t { color: var(--accent); }
.item__c {
  width: 30px; aspect-ratio: 2/3; object-fit: cover; border-radius: 3px;
  background: var(--sunk); box-shadow: var(--shadow-cover); flex-shrink: 0;
}
.item__info { flex: 1; min-width: 0; }
.item__t { font-size: 0.85rem; font-weight: 550; display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.item__s { font-size: 0.74rem; color: var(--ink-3); }
.item__ctl { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

.tag {
  font-size: 0.6rem; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase;
  padding: 0.06rem 0.34rem; border-radius: 4px; background: var(--sunk); color: var(--ink-3);
}
.item__t .tag { margin-left: 0.3rem; }
.tlink { color: inherit; text-decoration: none; }
.tlink:hover { text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--ink-3); }
.tag--wait { background: var(--warn-soft); color: var(--warn); }
.tag--src { background: transparent; color: var(--ink-3); border: 1px solid var(--border-2); }

/* ---------- status + stars ---------- */

.status { display: inline-flex; border: 1px solid var(--border-2); border-radius: 999px; overflow: hidden; background: var(--surface); }
.status button {
  border: none; background: transparent; color: var(--ink-3);
  font-size: 0.7rem; font-weight: 550; padding: 0.28rem 0.6rem; cursor: pointer; white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.status button:hover { color: var(--ink); }
.status button.on { color: #fff; }
.status button.on.a_lire { background: var(--ink-2); }
.status button.on.en_cours { background: var(--warn); }
.status button.on.termine { background: var(--accent); }


/* ---------- books grid ---------- */

.books { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1.7rem 1.2rem; }
.book { display: flex; flex-direction: column; gap: 0.5rem; }
.book__frame {
  position: relative; aspect-ratio: 2/3; border-radius: 5px; overflow: hidden;
  background: var(--sunk); box-shadow: var(--shadow-cover);
  outline: 2.5px solid transparent; outline-offset: 2px;
  transition: outline-color 0.12s;
}
.book.is-done .book__frame {
  outline-color: var(--accent);
  box-shadow: var(--shadow-cover), 0 0 0 5px var(--accent-soft);
}
.book.is-done .book__check {
  position: absolute; top: 6px; left: 6px; z-index: 2;
  width: 19px; height: 19px; border-radius: 999px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 1px 3px rgba(20, 20, 14, 0.35);
}
.book__frame img { width: 100%; height: 100%; object-fit: cover; }
.book__ph {
  position: absolute; inset: 0; display: grid; place-items: center;
  padding: 0.85rem; text-align: center; font-size: 0.86rem; font-weight: 550; color: var(--ink-3);
}
.book__ribbon { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; }
.book__ribbon.a_lire { background: var(--ink-3); }
.book__ribbon.en_cours { background: var(--warn); }
.book__ribbon.termine { background: var(--accent); }
.book__t { font-size: 0.87rem; font-weight: 550; line-height: 1.3; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book__a { font-size: 0.75rem; color: var(--ink-3); margin: -0.15rem 0 0; }
.book__bn { font-size: 0.73rem; color: #b8860b; margin: 0.1rem 0 0; }
@media (prefers-color-scheme: dark) { .book__bn { color: #e0b040; } }
.book__foot { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; }
.book__x { border: none; background: none; color: var(--ink-3); cursor: pointer; padding: 0.1rem; }
.book__x:hover { color: var(--warn); }

/* ---------- forms: cover picker, hand-filled panels, modal ---------- */

.panel--form {
  border-top: none; border: 1px solid var(--border); border-radius: 10px;
  background: var(--sunk);
}
.flabel { min-width: 76px; }
.addout { width: 100%; display: flex; flex-direction: column; gap: 0.4rem; }
.result input[type=text], .result input[type=search], .result input[type=number] {
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 7px;
  padding: 0.38rem 0.6rem; font: inherit; font-size: 0.8rem; color: var(--ink); outline: none;
}
.result input:focus { border-color: var(--ink-3); }

.cpick { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; flex: 1; min-width: 200px; }
.cpick__img {
  width: 32px; aspect-ratio: 2/3; object-fit: cover; border-radius: 4px;
  background: var(--surface); box-shadow: var(--shadow-cover); flex-shrink: 0;
}
.cpick__img--ph { display: grid; place-items: center; color: var(--ink-3); }

.modal {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(20, 20, 14, 0.42);
  display: flex; align-items: center; justify-content: center; padding: 1.2rem;
}
.modal__box {
  width: min(520px, 100%); max-height: 88vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-pop);
}
.modal__head {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.9rem 1.1rem; border-bottom: 1px solid var(--border);
}
.modal__title { flex: 1; min-width: 0; font-size: 0.95rem; font-weight: 600; }
.modal__body { padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.7rem; }
.modal__body .panel__row { font-size: 0.82rem; color: var(--ink-2); }
.modal__body input[type=text], .modal__body input[type=number] {
  background: var(--bg); border: 1px solid var(--border-2); border-radius: 7px;
  padding: 0.4rem 0.6rem; font: inherit; font-size: 0.82rem; color: var(--ink); outline: none;
}
.modal__body input:focus { border-color: var(--ink-3); }
.modal__foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 0.45rem;
  padding: 0.8rem 1.1rem; border-top: 1px solid var(--border);
}

/* ---------- account / devices ---------- */

.acct { display: flex; align-items: center; gap: 0.15rem; }
.acct:empty { display: none; }
.acct__btn { position: relative; font-size: 0.8rem; padding: 0.45rem 0.65rem; }
.acct__badge {
  margin-left: 0.35rem; min-width: 17px; height: 17px; padding: 0 0.3rem;
  border-radius: 999px; background: var(--warn); color: #fff;
  font-size: 0.66rem; font-weight: 600; display: inline-grid; place-items: center;
}
.devs { display: flex; flex-direction: column; gap: 0.45rem; }
.adm__h { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ink-3); margin-top: 0.4rem; }
.dev {
  display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: 9px; padding: 0.6rem 0.75rem;
}
.dev--pending { border-color: var(--warn); background: var(--warn-soft); }
.dev--refused { opacity: 0.6; }
.dev__main { flex: 1; min-width: 180px; }
.dev__t { font-size: 0.84rem; display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; }
.dev__s { font-size: 0.74rem; color: var(--ink-3); }
.dev__ctl { display: flex; gap: 0.35rem; flex-wrap: wrap; }

/* ---------- misc ---------- */

.empty { display: flex; flex-direction: column; align-items: center; gap: 0.85rem; color: var(--ink-3); text-align: center; padding: 4.5rem 1rem; }
.empty p { margin: 0; line-height: 1.6; }
.spinner {
  width: 22px; height: 22px; border: 2px solid var(--border-2); border-top-color: var(--ink-2);
  border-radius: 999px; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: 1.4rem; transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  font-size: 0.82rem; padding: 0.6rem 1rem; border-radius: 8px;
  box-shadow: var(--shadow-pop); z-index: 50; max-width: 90vw;
}

@media (max-width: 620px) {
  .topbar__inner { padding: 0.7rem 1rem; }
  .search input { width: 110px; }
  .page { padding: 1.3rem 1rem 3.5rem; }
  .watch__top { padding: 0.95rem; gap: 0.85rem; }
  .watch__cover { width: 60px; }
  .books { grid-template-columns: repeat(2, 1fr); gap: 1.3rem 0.9rem; }
  .tabs { gap: 1.1rem; }
  .stat__sub { display: none; }
  .item { flex-wrap: wrap; }
  .item__ctl { width: 100%; padding-left: 42px; }
  .flabel { min-width: 0; }
  .modal { padding: 0.6rem; align-items: flex-end; }
  .modal__box { max-height: 92vh; }
}
