/* ─────────────────────────────────────────────────────────
   NearLibrary — navy + gold design system (matches logo)
   The --violet-* names are kept but remapped to a navy scale
   so every component inherits the brand colours automatically.
   ───────────────────────────────────────────────────────── */
:root {
  /* navy scale (light → deep) */
  --violet-50:  #eef3f8;
  --violet-100: #dbe6f1;
  --violet-300: #9fb6d0;
  --violet-400: #5c7fa6;
  --violet-500: #2f5e8f;
  --violet-600: #1e3a5f;
  --violet-700: #13273e;

  /* gold accent (from the logo ribbon) */
  --gold:        #c2a15c;
  --gold-strong: #a5842f;
  --gold-soft:   #f4edd9;

  --gray-50:  #faf8f2;
  --gray-100: #f3eee2;
  --gray-200: #e7e0cf;
  --gray-300: #d6ccb6;
  --gray-400: #a99f89;
  --gray-500: #6b6455;
  --gray-600: #4b463b;
  --gray-700: #35322a;
  --gray-800: #24211b;
  --gray-900: #171511;

  --brand: var(--violet-600);
  --brand-strong: var(--violet-700);
  --grad: linear-gradient(135deg, #26496f, #13273e);

  --bg: #f9f5ec;
  --surface: #ffffff;
  --ink: #13273e;
  --muted: #6b6455;
  --line: #e7e0cf;
  --danger: #c0392b;
  --ok: #1f8a5b;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(20, 41, 63, .07), 0 1px 3px rgba(20, 41, 63, .09);
  --shadow-lg: 0 24px 60px -12px rgba(20, 41, 63, .35);
  --ring: 0 0 0 4px rgba(30, 58, 95, .16);
}



* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Inter", "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ── Auth / login ─────────────────────────────── */
.auth {
  position: relative;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  overflow: hidden;
  background:
    radial-gradient(1000px 500px at 15% -10%, var(--violet-100), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, #dbe6f1, transparent 55%),
    var(--gray-100);
}


/* Floating gradient orbs */
.auth__bg { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(46px);
  opacity: .55;
  animation: float 16s ease-in-out infinite;
}
.orb--1 { width: 320px; height: 320px; left: -80px; top: -60px;
  background: radial-gradient(circle, var(--violet-400), transparent 70%); }
.orb--2 { width: 260px; height: 260px; right: -60px; top: 30%;
  background: radial-gradient(circle, var(--violet-500), transparent 70%); animation-delay: -5s; }
.orb--3 { width: 300px; height: 300px; left: 20%; bottom: -120px;
  background: radial-gradient(circle, var(--gray-400), transparent 70%); animation-delay: -9s; opacity: .35; }

@keyframes float {
  0%, 100% { transform: translateY(0) translateX(0); }
  50% { transform: translateY(-26px) translateX(16px); }
}

.auth__card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 410px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  border-radius: 24px;
  padding: 34px 30px;
  box-shadow: var(--shadow-lg);
  animation: rise .5s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.brand { text-align: center; margin-bottom: 22px; }
.brand__logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 60px; height: 60px; border-radius: 18px;
  background: var(--grad); color: #fff;
  box-shadow: 0 10px 24px -6px rgba(30, 58, 95, .6);
}
.brand__name {
  margin: 14px 0 4px; font-size: 23px; font-weight: 700; letter-spacing: -.02em;
}
.brand__tag { margin: 0; color: var(--muted); font-size: 14px; }

.g-signin { display: flex; justify-content: center; margin: 6px 0 2px; min-height: 44px; }

.divider {
  display: flex; align-items: center; text-align: center;
  color: var(--muted); font-size: 12px; margin: 20px 0;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}
.divider span { padding: 0 12px; }

.form { display: flex; flex-direction: column; gap: 15px; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field__label {
  font-size: 12.5px; font-weight: 600; color: var(--gray-600);
  text-transform: uppercase; letter-spacing: .04em;
}


.field__control { position: relative; display: flex; align-items: center; }
.field__icon {
  position: absolute; left: 14px; color: var(--gray-400); pointer-events: none;
}
.field__control input { padding-left: 42px; }

input[type="email"], input[type="text"] {
  width: 100%;
  padding: 14px 15px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 16px;
  color: var(--ink);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--gray-400); }
input:focus {
  border-color: var(--violet-400);
  box-shadow: var(--ring);
}

.otp-input {
  letter-spacing: 14px;
  text-indent: 14px;
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ── Buttons ──────────────────────────────────── */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .06s, box-shadow .18s, background .18s, opacity .18s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn--primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 12px 24px -10px rgba(30, 58, 95, .7);
}
.btn--primary:hover:not(:disabled) {
  box-shadow: 0 16px 30px -10px rgba(30, 58, 95, .85);
}

.btn--ghost {
  background: var(--violet-50);
  color: var(--brand-strong);
  border: 1px solid var(--violet-100);
}
.btn--ghost:hover:not(:disabled) { background: var(--violet-100); }


.btn--pill {
  padding: 8px 14px; font-size: 13px; border-radius: 999px;
  background: rgba(255, 255, 255, .18); color: #fff;
  backdrop-filter: blur(6px);
}
.btn--pill:hover { background: rgba(255, 255, 255, .28); }

/* Spinner shown while a form is submitting (.is-loading on the button) */
.btn__spinner {
  display: none;
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.btn.is-loading .btn__spinner { display: inline-block; }
.btn.is-loading .btn__label { opacity: .85; }
@keyframes spin { to { transform: rotate(360deg); } }

.linkbtn {
  background: none; border: none; color: var(--brand);
  font-weight: 600; cursor: pointer; font-size: 13px; padding: 4px;
}
.linkbtn:hover { color: var(--brand-strong); text-decoration: underline; }
.linkbtn--center { align-self: center; }
.linkbtn:disabled { color: var(--gray-400); cursor: not-allowed; text-decoration: none; }

.otp-note { font-size: 13.5px; color: var(--muted); margin: 0 0 2px; line-height: 1.5; }

.msg { min-height: 18px; font-size: 13px; text-align: center; margin: 14px 0 0; }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--ok); }

.footer { position: relative; z-index: 1; color: var(--muted); font-size: 12px; }

/* ── App shell ────────────────────────────────── */
.app { min-height: 100dvh; background: var(--bg); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: var(--grad);
  color: #fff;
  position: sticky; top: 0; z-index: 10;
  box-shadow: 0 8px 24px -12px rgba(20, 41, 63, .6);
}
.topbar__brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; }
.topbar__logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 10px;
  background: rgba(255, 255, 255, .18);
}
.topbar__user { display: flex; align-items: center; gap: 12px; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  object-fit: cover;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .25); color: #fff; font-weight: 700;
  border: 1.5px solid rgba(255, 255, 255, .5);
}

.content { max-width: 780px; margin: 0 auto; padding: 24px 18px 48px; }

.hero { margin-bottom: 8px; }
.hero__eyebrow {
  margin: 0 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--violet-500);
}
.hero h1 { margin: 0 0 6px; font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.hero__sub { margin: 0; font-size: 14px; }

.chip {
  display: inline-block; margin-left: 4px;
  padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--violet-50); color: var(--brand-strong); border: 1px solid var(--violet-100);
}


.cards {
  display: grid; gap: 16px; margin-top: 24px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 40px -20px rgba(20, 41, 63, .5);
  border-color: var(--violet-300);
}
.card--accent { border-color: var(--violet-300); background:
  linear-gradient(180deg, color-mix(in srgb, var(--violet-50) 70%, var(--surface)), var(--surface)); }

.card__icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 12px; font-size: 22px;
  margin-bottom: 12px;
}
.card__icon--blue  { background: #dbe6f1; }
.card__icon--green { background: #dcfce7; }
.card__icon--amber { background: #fef3c7; }
.card h3 { margin: 0 0 6px; font-size: 16px; font-weight: 700; }
.card p { margin: 0; font-size: 14px; line-height: 1.5; }
.card__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.card__actions .btn { margin: 0; }

@media (prefers-reduced-motion: reduce) {
  *, .orb, .auth__card { animation: none !important; transition: none !important; }
}

/* ─────────────────────────────────────────────────────────
   Work tracker module
   ───────────────────────────────────────────────────────── */
.content--wide { max-width: 900px; }

.rolebadge {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,.2); color: #fff;
}
.rolebadge--sm { background: var(--violet-100); color: var(--brand-strong); }

.flash {
  padding: 11px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 12px;
  border: 1px solid var(--line); background: var(--surface);
}
.flash--success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.flash--error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

.hintbar {
  background: var(--violet-50); border: 1px solid var(--violet-100);
  color: var(--brand-strong); border-radius: 12px; padding: 12px 14px;
  font-size: 14px; margin-bottom: 16px;
}


.board-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.board-head h1 { margin: 2px 0 4px; font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.board-head__actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-form { margin: 0; }

.select-sm, .select {
  padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); font-size: 14px; outline: none;
}
.select-sm:focus, .select:focus { border-color: var(--violet-400); box-shadow: var(--ring); }

/* ── Filter tabs ── */
.filtertabs {
  display: flex; gap: 6px; flex-wrap: wrap; margin: 20px 0 16px;
  padding-bottom: 4px;
}
.filtertab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 999px; text-decoration: none;
  font-size: 13.5px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--line); background: var(--surface);
  transition: all .15s;
}
.filtertab:hover { border-color: var(--violet-300); color: var(--brand-strong); }
.filtertab.is-active { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 8px 18px -8px rgba(30,58,95,.7); }
.filtertab .cnt {
  font-size: 11px; background: rgba(0,0,0,.06); padding: 1px 7px; border-radius: 999px;
}
.filtertab.is-active .cnt { background: rgba(255,255,255,.25); }

/* ── Task card ── */
.tasklist { display: flex; flex-direction: column; gap: 14px; }
.tcard {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px 20px; box-shadow: var(--shadow-sm);
  transition: box-shadow .18s, border-color .18s;
}
.tcard:hover { box-shadow: 0 16px 36px -20px rgba(20,41,63,.4); }
.tcard--overdue { border-color: #fca5a5; box-shadow: 0 0 0 1px #fecaca inset; }
.tcard--done { opacity: .72; }
.tcard--done .tcard__title { text-decoration: line-through; color: var(--muted); }

.tcard__top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tcard__title { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.tcard__spacer { flex: 1; }
.tcard__actions { display: flex; gap: 6px; }

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--gray-600);
  text-decoration: none; font-size: 14px; transition: all .15s;
}
.iconbtn:hover { border-color: var(--violet-300); color: var(--brand); }
.iconbtn--danger:hover { border-color: #fca5a5; color: #dc2626; background: #fef2f2; }

/* pills */
.pill { font-size: 12px; font-weight: 700; padding: 3px 11px; border-radius: 999px; white-space: nowrap; }
.pill--low { background: #eef2ff; color: #4338ca; }
.pill--medium { background: var(--violet-50); color: var(--brand-strong); }
.pill--high { background: #fff7ed; color: #c2410c; }
.pill--overdue { background: #fef2f2; color: #dc2626; }
.pill--done { background: #ecfdf5; color: #059669; }

/* meta row */
.tcard__meta { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 12px 0 4px; }
.meta { font-size: 13px; color: var(--gray-600); display: inline-flex; align-items: center; gap: 5px; }

.meta--timer b { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--brand-strong); }
.meta--tag { background: var(--gray-100); padding: 2px 9px; border-radius: 999px; color: var(--gray-600); font-weight: 600; }


/* checkboxes */
.tcheck { position: relative; display: inline-flex; cursor: pointer; }
.tcheck input { position: absolute; opacity: 0; width: 0; height: 0; }
.tcheck span {
  width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--gray-300);
  display: inline-block; transition: all .15s; background: var(--surface);
}
.tcheck--sm span { width: 19px; height: 19px; border-radius: 6px; }
.tcheck input:checked + span {
  background: #16a34a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center/14px no-repeat;
  border-color: #16a34a;
}
.tcheck input:disabled + span { opacity: .5; cursor: default; }

/* subtasks */
.subs { list-style: none; margin: 12px 0 4px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sub { display: flex; align-items: center; gap: 10px; font-size: 14.5px; }
.sub--done .sub__title { text-decoration: line-through; color: var(--muted); }
.sub__mark { color: #16a34a; font-weight: 700; }

/* footer */
.tcard__foot {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line);
}
.startbtn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 16px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 13.5px;
  border: 1.5px solid #86efac; background: #f0fdf4; color: #15803d; transition: all .15s;
}
.startbtn:hover { background: #dcfce7; }
.startbtn.is-running { border-color: var(--violet-400); background: var(--violet-50); color: var(--brand-strong); }
.startbtn__icon { font-size: 11px; }

.statustabs { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.statustab {
  background: none; border: none; cursor: pointer; padding: 6px 10px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--muted); transition: all .12s;
}
.statustab:hover:not(:disabled) { background: var(--gray-100); color: var(--ink); }
.statustab.is-active { background: var(--violet-100); color: var(--brand-strong); }
.statustab:disabled { cursor: default; }

.tcard__comments { margin-left: auto; text-decoration: none; }

/* empty state */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty__icon { font-size: 46px; }
.empty h3 { margin: 12px 0 6px; color: var(--ink); }

/* ── Forms (task create/edit) ── */
.formcard, .detailcard {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 26px; box-shadow: var(--shadow-sm); margin-top: 18px;
}
.tform { display: flex; flex-direction: column; gap: 16px; }
.tform .field { display: flex; flex-direction: column; gap: 7px; }
.tform label.field__label { text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 700; color: var(--ink); }
.tform .opt { color: var(--muted); font-weight: 500; }
.tform input, .tform select, .tform textarea {
  width: 100%; padding: 12px 14px; font-size: 15px; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface);
  outline: none; transition: border-color .15s, box-shadow .15s; font-family: inherit;
}
.tform input:focus, .tform select:focus, .tform textarea:focus {
  border-color: var(--violet-400); box-shadow: var(--ring);
}
.tform textarea { resize: vertical; }
.field__err { color: var(--danger); font-size: 12.5px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 560px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.btn--soft { background: var(--gray-100); color: var(--gray-700); }
.btn--soft:hover { background: var(--gray-200); }


/* ── Modal ── */
.modal { position: fixed; inset: 0; z-index: 100; display: none; }
.modal.open { display: block; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(17,24,39,.55); backdrop-filter: blur(3px); }
.modal__panel {
  position: relative; z-index: 1; margin: 5vh auto; max-width: 640px; width: calc(100% - 32px);
  max-height: 90vh; overflow: auto; background: var(--surface); border-radius: 20px;
  padding: 24px; box-shadow: var(--shadow-lg); animation: rise .25s ease both;
}
.modal__panel--sm { max-width: 460px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal__head h2 { margin: 0; font-size: 20px; font-weight: 800; }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ── Detail / comments ── */
.detail__title { margin: 0; font-size: 22px; font-weight: 800; }
.detail__h { margin: 22px 0 10px; font-size: 15px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.comments { display: flex; flex-direction: column; gap: 12px; }
.comment { background: var(--gray-50); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }

.comment__head { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 4px; }
.comment p { margin: 0; font-size: 14.5px; }
.comment-form { display: flex; gap: 10px; margin-top: 14px; align-items: flex-end; }
.comment-form textarea {
  flex: 1; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); font-family: inherit; font-size: 14.5px; resize: vertical; outline: none;
}
.comment-form textarea:focus { border-color: var(--violet-400); box-shadow: var(--ring); }

/* ── Install-to-home-screen banner ── */
.install-bar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 200; width: calc(100% - 28px); max-width: 460px;
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 16px;
  padding: 12px 14px; box-shadow: var(--shadow-lg);
  animation: rise .3s ease both;
}
.install-bar__icon { font-size: 24px; }
.install-bar__txt { flex: 1; font-size: 13.5px; line-height: 1.35; }
.install-bar__txt small { color: var(--muted); }
.install-bar .install-bar__go { padding: 9px 16px; font-size: 14px; }
.install-bar__x {
  background: none; border: none; color: var(--muted);
  font-size: 15px; cursor: pointer; padding: 4px 6px; border-radius: 8px;
}
.install-bar__x:hover { background: var(--gray-100); color: var(--ink); }


/* ── Brand logo image (Near Library) ── */
.brand__logo--img {
  width: auto; height: 132px; max-width: 100%;
  border-radius: 18px; background: transparent; box-shadow: none;
  object-fit: contain;
}
.topbar__logo--img {
  width: 34px; height: 34px; padding: 0; overflow: hidden;
  background: #fff; border: 1.5px solid rgba(255,255,255,.6);
  object-fit: cover;
}

/* ── Gold accents (from logo ribbon) ── */
.hero__eyebrow { color: var(--gold-strong); }
.chip { background: var(--gold-soft); color: var(--gold-strong); border-color: #e7d9b0; }
.rolebadge--sm { background: var(--gold-soft); color: var(--gold-strong); }
.filtertab.is-active { position: relative; }
.linkbtn { color: var(--brand); }
.linkbtn:hover { color: var(--gold-strong); }
.pill--high { background: var(--gold-soft); color: var(--gold-strong); }
.card__icon--blue { background: var(--gold-soft); }
/* thin gold rule under the login logo */
.brand__logo--img { border-bottom: 3px solid var(--gold); border-radius: 4px; padding-bottom: 8px; }


/* ─────────────────────────────────────────────────────────
   Home dashboard
   ───────────────────────────────────────────────────────── */
.stats {
  display: grid; gap: 12px; margin: 22px 0 6px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.stat {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 16px 18px; text-decoration: none;
  box-shadow: var(--shadow-sm); transition: transform .16s, box-shadow .16s, border-color .16s;
  border-left: 4px solid var(--violet-600);
}
a.stat:hover { transform: translateY(-3px); box-shadow: 0 16px 34px -20px rgba(20,41,63,.5); }
.stat__num { font-size: 30px; font-weight: 800; letter-spacing: -.02em; color: var(--ink); line-height: 1; }
.stat__num small { font-size: 15px; font-weight: 700; color: var(--muted); margin-left: 2px; }
.stat__label { font-size: 12.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat--gold { border-left-color: var(--gold); }
.stat--gold .stat__num { color: var(--gold-strong); }
.stat--danger { border-left-color: var(--danger); }
.stat--danger .stat__num { color: var(--danger); }
.stat--ok { border-left-color: var(--ok); }
.stat--ok .stat__num { color: var(--ok); }

/* Quick actions */
.quick { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 4px; }
.quick__btn {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 11px 16px; border-radius: 12px; cursor: pointer; text-decoration: none;
  font-size: 14px; font-weight: 600; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  transition: transform .12s, border-color .15s, background .15s;
}
.quick__btn:hover { transform: translateY(-2px); border-color: var(--violet-300); }
.quick__btn--primary { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 12px 24px -12px rgba(20,41,63,.7); }
.quick__ic { font-size: 17px; }

/* Panels */
.panel { margin-top: 26px; }
.panel__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel__head h2 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -.01em; }

/* Mini task list */
.minilist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-sm); }
.minirow { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-top: 1px solid var(--line); }
.minirow:first-child { border-top: none; }
.minirow__main { flex: 1; text-decoration: none; min-width: 0; }
.minirow__title { display: block; font-size: 15px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.minirow__meta { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.minirow:hover { background: var(--gray-50); }

.card--soft { background: var(--gray-50); }
.soon {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  background: var(--gold-soft); color: var(--gold-strong); padding: 2px 7px; border-radius: 999px; vertical-align: middle;
}
.empty--sm { padding: 26px 16px; }
.empty--sm .empty__icon { font-size: 32px; }

/* ─────────────────────────────────────────────────────────
   Brand wordmark — "Near Library" in gold (matches logo)
   ───────────────────────────────────────────────────────── */
.wordmark {
  display: inline-flex; flex-direction: column; justify-content: center;
  line-height: 1.05; text-decoration: none;
}
.wordmark__name {
  font-family: "Playfair Display", "Georgia", "Times New Roman", serif;
  font-size: 20px; font-weight: 700; letter-spacing: .10em; text-transform: uppercase;
  background: linear-gradient(100deg, #e8cf92 0%, #c2a15c 45%, #f0dfae 70%, #c2a15c 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: var(--gold);
  text-shadow: 0 1px 0 rgba(0,0,0,.18);
  white-space: nowrap;
}
.wordmark__name .wm-thin { font-weight: 400; }
.wordmark__tag {
  font-size: 8.5px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase;
  color: rgba(255,255,255,.62); margin-top: 3px; white-space: nowrap;
}
/* On light surfaces (if ever used outside the navy bar) */
.wordmark--ink .wordmark__tag { color: var(--muted); }

@media (max-width: 480px) {
  .wordmark__name { font-size: 17px; letter-spacing: .07em; }
  .wordmark__tag { font-size: 7.5px; letter-spacing: .16em; }
}

/* Large wordmark on the login card */
.wordmark__name--lg {
  display: block; margin: 14px 0 0; font-size: 30px; letter-spacing: .12em;
  font-family: "Playfair Display", "Georgia", serif; font-weight: 700; text-transform: uppercase;
  background: linear-gradient(100deg, #b8933f 0%, #c2a15c 40%, #e8cf92 60%, #a5842f 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
/* Divider rule with the tagline, echoing the logo lockup */
.brand__rule {
  display: flex; align-items: center; gap: 10px; margin: 10px 0 0;
  color: var(--muted); font-size: 9.5px; font-weight: 600;
  letter-spacing: .2em; text-transform: uppercase;
}
.brand__rule::before, .brand__rule::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
/* Gold ring on the small logo badge in the top bar */
.topbar__logo--img { border-color: rgba(226, 200, 140, .85); box-shadow: 0 0 0 1px rgba(0,0,0,.12); }
.brand__rule span { flex: 0 0 auto; }
/* logo on login already contains the wordmark — drop the extra gold underline */
.brand__logo--img { border-bottom: none; padding-bottom: 0; }

/* ─────────────────────────────────────────────────────────
   Time-per-book / topic bars
   ───────────────────────────────────────────────────────── */
.timecard {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 6px 18px 14px; box-shadow: var(--shadow-sm);
}
.bookrow { padding: 14px 0; border-top: 1px solid var(--line); }
.bookrow:first-child { border-top: none; }
.bookrow__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.bookrow__name { font-size: 15px; font-weight: 700; color: var(--ink); }
.bookrow__time {
  font-size: 14px; font-weight: 800; color: var(--brand-strong);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* the horizontal bar */
.bar {
  position: relative; height: 10px; border-radius: 999px;
  background: var(--gray-100); overflow: hidden;
}
.bar--sm { height: 7px; flex: 1; }
.bar__fill {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #2f5e8f, #13273e);
  transition: width .5s cubic-bezier(.2,.8,.2,1);
  min-width: 3px;
}
.bar__fill--gold { background: linear-gradient(90deg, #e8cf92, #c2a15c); }


/* topics nested under a book */
.topiclist { list-style: none; margin: 10px 0 0; padding: 0 0 0 14px; display: flex; flex-direction: column; gap: 8px;
  border-left: 2px dashed var(--line); }
.topicrow { display: flex; align-items: center; gap: 10px; }
.topicrow__name { font-size: 13px; color: var(--gray-600); flex: 0 0 34%; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topicrow__time { font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--gold-strong);
  flex: 0 0 auto; font-weight: 700; }
@media (max-width: 520px) { .topicrow__name { flex-basis: 42%; } }

/* pulsing dot when a timer is running */
.livedot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: #16a34a; margin-left: 6px; vertical-align: middle;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.8); } }

/* stack the two "…or add new" inputs under their select */
.tform .field select + input { margin-top: 8px; font-size: 14px; }

/* ─────────────────────────────────────────────────────────
   Icons — Font Awesome + native picker visibility
   ───────────────────────────────────────────────────────── */

/* The browser's built-in date/time picker button renders as a dark glyph,
   which disappears on dark backgrounds. Invert it so it stays visible. */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  opacity: .75;
  cursor: pointer;
  padding: 3px;
  border-radius: 5px;
  transition: opacity .15s, background .15s;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
  background: rgba(194, 161, 92, .22);
}


/* Font Awesome sizing/colour inside the app */
.fa-solid, .fa-regular, .fa-brands { line-height: 1; }
.ico { width: 1.05em; text-align: center; }
.ico--gold { color: var(--gold); }
.ico--brand { color: var(--brand); }
.ico--muted { color: var(--muted); }

/* Icons sitting inside form labels */
.tform label.field__label .ico { margin-right: 6px; color: var(--gold-strong); }


/* Meta row + buttons use FA now — give them a consistent muted tone */
.meta .ico { color: var(--gray-400); margin-right: 2px; }
.meta--timer .ico { color: var(--brand); }

.quick__ic .ico, .quick__ic { color: inherit; }

/* ─────────────────────────────────────────────────────────
   Date / time / number fields — our own visible gold icon
   The browser's native picker glyph is made transparent but is
   stretched over the icon area so clicking it still opens the picker.
   ───────────────────────────────────────────────────────── */
.infield { position: relative; display: block; }
.infield input { width: 100%; padding-right: 42px !important; }

.infield__ico {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--gold-strong); font-size: 15px; pointer-events: none; z-index: 1;
}

.infield:focus-within .infield__ico { color: var(--brand); }


/* Invisible but clickable native picker button covering the icon zone */
.infield input[type="date"]::-webkit-calendar-picker-indicator,
.infield input[type="time"]::-webkit-calendar-picker-indicator {
  position: absolute; right: 0; top: 0;
  width: 46px; height: 100%;
  margin: 0; padding: 0;
  opacity: 0;               /* hide the dark, unreadable default glyph */
  cursor: pointer;
  z-index: 2;
  filter: none;
}
/* Firefox / others that don't support the pseudo-element still show the icon;
   the input itself remains clickable. */
.infield input[type="date"], .infield input[type="time"] { color-scheme: light; }


/* Number field: drop the tiny spinners so the icon has room */
.infield input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.infield input[type="number"]::-webkit-outer-spin-button,
.infield input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ─────────────────────────────────────────────────────────
   Topic checkboxes / µs timer / estimate bar / session log
   ───────────────────────────────────────────────────────── */
.topicbox {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 12px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); max-height: 190px; overflow-y: auto;
}
.topicchk {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--gray-50);
  font-size: 13.5px; font-weight: 600; color: var(--gray-700);
  transition: all .14s; user-select: none;
}

.topicchk:hover { border-color: var(--gold); }
.topicchk input { accent-color: var(--gold-strong); width: 15px; height: 15px; cursor: pointer; margin: 0; }
.topicchk:has(input:checked) {
  background: var(--gold-soft); border-color: var(--gold); color: var(--gold-strong);
}

.topicbox__empty { font-size: 13px; margin: 4px; }

/* microsecond digits, rendered smaller after the milliseconds */
.mu { font-size: .68em; opacity: .65; margin-left: 1px; letter-spacing: 0; }
.meta--timer b { font-variant-numeric: tabular-nums; }

/* elapsed-vs-estimate bar on the task card */
.estrow { display: flex; align-items: center; gap: 10px; margin: 10px 0 2px; }
.estrow__label { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.estrow__pct {
  font-size: 12.5px; font-weight: 800; color: var(--brand);
  font-variant-numeric: tabular-nums; min-width: 42px; text-align: right;
}
.estrow__pct.is-over { color: var(--danger); }
.bar__fill--over { background: linear-gradient(90deg, #f0a24a, #c0392b) !important; }

/* work-session log table */
.logtable {
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  background: var(--surface); font-size: 13.5px;
}
.logtable__head, .logrow, .logtable__foot {
  display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 8px;
  padding: 10px 14px; align-items: center;
}
.logtable__head {
  background: var(--gray-50); font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
}

.logrow { border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.logrow--live { background: rgba(22, 163, 74, .07); }
.logtable__foot {
  border-top: 1px solid var(--line); background: var(--gray-50);
  grid-template-columns: 1fr auto; font-weight: 700;
}

.ta-r { text-align: right; }
.logtable__empty { font-size: 14px; padding: 14px 0; }
@media (max-width: 560px) {
  .logtable__head, .logrow { grid-template-columns: 1.3fr .8fr .8fr .9fr; font-size: 12px; padding: 9px 10px; }
}

/* ─────────────────────────────────────────────────────────
   Contrast fixes — navy text is unreadable on the dark theme
   ───────────────────────────────────────────────────────── */

/* Make the running timer the most legible thing on the card */
.meta--timer b {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13.5px; font-weight: 700; letter-spacing: .2px;
  color: var(--brand-strong);
  background: var(--gray-100);
  padding: 3px 9px; border-radius: 7px;
  border: 1px solid var(--line);
}
.mu { font-size: .72em; opacity: .8; }



/* Compact Start/Stop chip that sits in the meta row beside the tags */
.startbtn--sm {
  padding: 4px 12px; font-size: 12.5px; border-width: 1.5px;
  margin-left: 4px; line-height: 1.4;
}
.startbtn--sm .startbtn__icon { font-size: 9.5px; }

/* Running state reads as "Stop" — red, so it's obvious it will halt */
.startbtn.is-running {
  border-color: #f5b5b5; background: #fdf0f0; color: #b93b32;
}
.startbtn.is-running:hover { background: #fbe3e3; }



/* ─────────────────────────────────────────────────────────
   Task card footer — readable status control on mobile
   ───────────────────────────────────────────────────────── */
.st-short { display: none; }

/* Desktop: keep tabs on one line, never wrap into a ragged block */
.statustabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.statustabs::-webkit-scrollbar { display: none; }
.statustab { white-space: nowrap; flex: 0 0 auto; }

@media (max-width: 640px) {
  /* Stack the footer: actions on one row, status strip on its own row */
  .tcard__foot {
    flex-direction: column; align-items: stretch; gap: 12px;
  }
  .tcard__foot .startbtn { align-self: flex-start; }

  /* Row 1: Start + comments side by side */
  .tcard__foot { position: relative; }
  .tcard__comments { position: absolute; top: 14px; right: 0; margin: 0; }

  /* Row 2: a proper segmented control that scrolls horizontally */
  .statustabs {
    display: flex; gap: 6px; width: 100%;
    padding: 4px; border-radius: 12px;
    background: var(--gray-100);
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  
  .statustab {
    flex: 1 0 auto; scroll-snap-align: start;
    padding: 9px 12px; font-size: 13px; border-radius: 9px;
    text-align: center;
  }
  .statustab.is-active {
    background: var(--surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
    color: var(--brand-strong);
  }
  

  /* Use the compact wording so all five fit comfortably */
  .st-long { display: none; }
  .st-short { display: inline; }

  /* Tighter meta row on phones */
  .tcard { padding: 16px; }
  .tcard__meta { gap: 7px 10px; }
  .estrow__label { font-size: 12px; }
}

/* ─────────────────────────────────────────────────────────
   Board + top bar — mobile layout
   ───────────────────────────────────────────────────────── */

/* Filter tabs: one scrollable row, never a ragged multi-line block */
.filtertabs {
  flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity;
  padding-bottom: 6px;
}
.filtertabs::-webkit-scrollbar { display: none; }
.filtertab { flex: 0 0 auto; scroll-snap-align: start; white-space: nowrap; }

@media (max-width: 640px) {
  /* ── Top bar: keep it to a single tidy line ── */
  .topbar { padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); gap: 8px; }
  .topbar__brand { gap: 8px; min-width: 0; }
  .topbar__logo--img { width: 30px; height: 30px; flex: 0 0 auto; }
  .wordmark__name { font-size: 15px; letter-spacing: .06em; }
  .wordmark__tag { font-size: 7px; letter-spacing: .14em; }
  .topbar__user { gap: 8px; flex: 0 0 auto; }
  .rolebadge { display: none; }              /* role is implied by the page */
  .avatar { width: 30px; height: 30px; font-size: 13px; }
  .btn--pill { padding: 8px 10px; }
  .pill-txt { display: none; }               /* icon-only Sign out */
  .btn--pill i { font-size: 14px; }

  /* ── Board header ── */
  .content { padding: 16px 14px 40px; }
  .board-head { flex-direction: column; align-items: stretch; gap: 14px; }
  .board-head h1 { font-size: 20px; line-height: 1.25; }
  .hero__eyebrow { font-size: 10.5px; letter-spacing: .1em; }
  .board-head .muted { font-size: 13px; }

  /* Actions: equal-width buttons on one row */
  .board-head__actions { display: flex; gap: 8px; }
  .board-head__actions .btn { flex: 1 1 0; padding: 12px 10px; font-size: 14px; justify-content: center; }
  .board-head__actions .inline-form { flex: 1 1 100%; }
  .board-head__actions .select-sm { width: 100%; }

  /* ── Filter tabs: compact wording + tighter chips ── */
  .filtertabs { gap: 6px; margin: 16px 0 12px; }
  .filtertab { padding: 8px 12px; font-size: 13px; }
  .filtertab .cnt { font-size: 10.5px; padding: 1px 6px; }

  /* ── Time panel ── */
  .panel__head h2 { font-size: 15px; }
  .timecard { padding: 4px 14px 12px; }
  .bookrow__name { font-size: 14px; }
  .hintbar { font-size: 13px; padding: 10px 12px; }
}

/* Very narrow phones — hide the tagline so the name never truncates */
@media (max-width: 380px) {
  .wordmark__tag { display: none; }
  .wordmark__name { font-size: 14px; }
}

/* ─────────────────────────────────────────────────────────
   Account dropdown + profile page
   ───────────────────────────────────────────────────────── */
.topbar a, .topbar .btn { text-decoration: none; }   /* kill the stray underline */

.usermenu { position: relative; flex: 0 0 auto; }
.usermenu__btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 999px; padding: 4px 10px 4px 4px; cursor: pointer;
  transition: background .15s;
}
.usermenu__btn:hover { background: rgba(255, 255, 255, .24); }
.usermenu__caret { color: rgba(255, 255, 255, .8); font-size: 11px; }

.usermenu__panel {
  position: absolute; right: 0; top: calc(100% + 10px);
  width: 268px; z-index: 60;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-lg); overflow: hidden;
  display: none; animation: rise .16s ease both;
}
.usermenu__panel.open { display: block; }

.usermenu__head {
  display: flex; gap: 12px; align-items: center;
  padding: 16px; border-bottom: 1px solid var(--line);
  background: var(--gray-50);
}

.usermenu__id { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.usermenu__id b { font-size: 14.5px; }
.usermenu__mail {
  font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 165px;
}
.usermenu__id .rolebadge--sm { align-self: flex-start; font-size: 10px; padding: 2px 8px; }

.usermenu__item {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 16px; font-size: 14px; font-weight: 600;
  color: var(--ink); border-top: 1px solid transparent;
  transition: background .13s;
}
.usermenu__item:hover { background: var(--gray-50); }

.usermenu__item .ico { color: var(--muted); width: 1.1em; }
.usermenu__item--danger { color: var(--danger); border-top: 1px solid var(--line); }
.usermenu__item--danger .ico { color: var(--danger); }

.avatar--lg { width: 44px; height: 44px; font-size: 17px; }
.avatar--xl { width: 78px; height: 78px; font-size: 30px; border-width: 2px; }

/* profile header */
.profilehead {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 22px; margin-top: 18px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow-sm);
}
.profilehead .avatar { background: var(--grad); color: #fff; border-color: var(--gold); }
.profilehead__id { min-width: 0; }
.profilehead__id h1 { margin: 0 0 4px; font-size: 22px; font-weight: 800; }
.profilehead__id p { margin: 0 0 6px; font-size: 13.5px; word-break: break-word; }

.tform input:disabled {
  background: var(--gray-100); color: var(--muted); cursor: not-allowed;
}


@media (max-width: 640px) {
  .usermenu__panel { width: min(280px, calc(100vw - 24px)); }
  .usermenu__btn { padding: 3px 8px 3px 3px; }
  .profilehead { gap: 14px; padding: 18px; }
  .avatar--xl { width: 62px; height: 62px; font-size: 24px; }
  .profilehead__id h1 { font-size: 19px; }
}

/* ─────────────────────────────────────────────────────────
   Dark mode: invert the gray ramp.
   The warm --gray-50/100/200 are cream tones used as hover and
   card backgrounds. Left un-inverted they paint a light panel
   under light text, making content unreadable on hover. Flipping
   the ramp fixes every component that uses it, in one place.
   ───────────────────────────────────────────────────────── */



/* ─────────────────────────────────────────────────────────
   Books catalog map
   ───────────────────────────────────────────────────────── */
.catalog {
  display: grid; gap: 16px; margin-top: 20px;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}
.bookcard {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 20px; box-shadow: var(--shadow-sm);
  transition: border-color .18s, box-shadow .18s;
}
.bookcard:hover { border-color: var(--gold); box-shadow: 0 18px 40px -24px rgba(20,41,63,.55); }
.bookcard__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.bookcard__title { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.bookcard__spine {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; flex: 0 0 auto;
  background: var(--grad); color: var(--gold); font-size: 17px;
}
.bookcard__title h2 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.bookcard__title p { margin: 2px 0 0; font-size: 12.5px; }
.bookcard__total { text-align: right; white-space: nowrap; }
.bookcard__total b {
  display: block; font-size: 17px; font-weight: 800; color: var(--brand-strong);
  font-variant-numeric: tabular-nums;
}
.bookcard__total span { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }


.bookstats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin: 14px 0 12px; text-align: center;
}
.bookstat {
  padding: 9px 4px; border-radius: 10px;
  background: var(--gray-50); border: 1px solid var(--line);
}
.bookstat b {
  display: block; font-size: 14px; font-weight: 800; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.bookstat span {
  font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
}
.bookstat--gold { border-color: var(--gold); }
.bookstat--gold b { color: var(--gold-strong); }


.chapterlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.chapterrow { display: flex; align-items: center; gap: 10px; }
.chapterrow__name {
  flex: 0 0 40%; min-width: 0; font-size: 13px; color: var(--gray-700);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chapterrow__time {
  font-size: 12px; font-variant-numeric: tabular-nums; color: var(--gold-strong);
  flex: 0 0 auto; font-weight: 700; min-width: 56px; text-align: right;
}
.chapterrow--idle { opacity: .5; }
.chapterrow--idle .chapterrow__time { color: var(--muted); }
.chapterlist__empty { font-size: 13px; margin: 6px 0 0; }

/* two-column layout: form + catalog sidebar (desktop only) */
.formlayout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.formlayout .formcard { margin-top: 18px; }
.catalogside {
  margin-top: 18px; position: sticky; top: 84px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 18px; box-shadow: var(--shadow-sm);
  max-height: calc(100vh - 110px); overflow-y: auto;
}
.catalogside__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.catalogside__head h2 { margin: 0; font-size: 15px; font-weight: 800; }
.catalogside__body { display: flex; flex-direction: column; gap: 16px; }
.sidebook { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.sidebook:last-child { border-bottom: none; padding-bottom: 0; }
.sidebook__head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.sidebook__name { font-size: 13.5px; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebook__time { font-size: 12.5px; font-weight: 800; color: var(--brand-strong); font-variant-numeric: tabular-nums; }

.sidebook__meta { margin: 7px 0 8px; font-size: 11.5px; color: var(--muted); }
.sidechapters { list-style: none; margin: 0; padding: 0 0 0 10px; border-left: 2px dashed var(--line);
  display: flex; flex-direction: column; gap: 5px; }
.sidechapters li { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.sidechapters li span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--gray-600); }
.sidechapters li b { color: var(--gold-strong); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.sidechapters li.is-idle { opacity: .5; }
.sidechapters li.is-more { color: var(--muted); font-style: italic; }

/* Below desktop the sidebar drops under the form */
@media (max-width: 900px) {
  .formlayout { grid-template-columns: 1fr; }
  .catalogside { position: static; max-height: none; }
}
@media (max-width: 640px) {
  .catalog { grid-template-columns: 1fr; }
  .bookstats { grid-template-columns: repeat(2, 1fr); }
  .chapterrow__name { flex-basis: 46%; }
}

/* book card header actions */
.bookcard__right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.bookcard__right .tcard__actions { gap: 5px; }
.bookcard__right form { margin: 0; line-height: 0; }
@media (max-width: 480px) {
  .bookcard__head { flex-direction: column; align-items: stretch; gap: 10px; }
  .bookcard__right { justify-content: space-between; }
  .bookcard__total { text-align: left; }
}

/* ─────────────────────────────────────────────────────────
   Book → chapter picker on the task form
   ───────────────────────────────────────────────────────── */
.chapterpick {
  border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); overflow: hidden;
}
.chapterpick__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; background: var(--gray-50);
  border-bottom: 1px solid var(--line); min-height: 40px;
}
.chapterpick__book {
  font-size: 13px; font-weight: 700; color: var(--ink);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chapterpick__tools { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.chapterpick__count {
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line);
  padding: 2px 9px; border-radius: 999px; white-space: nowrap;
}
.chapterpick__tools .linkbtn { font-size: 12px; padding: 2px 4px; }

/* the checkbox area itself */
.chapterpick .topicbox {
  border: none; border-radius: 0; background: transparent;
  padding: 12px; max-height: 200px;
}
.topicbox--empty { align-items: center; justify-content: center; min-height: 96px; }
.topicbox__empty {
  width: 100%; text-align: center; font-size: 13px; margin: 6px 0;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.topicbox__empty i { opacity: .7; }

/* chapter chips read as a tidy list once a book is chosen */
.topicchk { transition: background .14s, border-color .14s, color .14s, transform .1s; }
.topicchk:active { transform: scale(.97); }
.topicchk:has(input:checked) { box-shadow: 0 2px 8px -3px rgba(194, 161, 92, .6); }


@media (max-width: 480px) {
  .chapterpick__bar { flex-wrap: wrap; gap: 6px; }
  .chapterpick__tools { width: 100%; justify-content: flex-end; }
}

/* Explore cards are real links now */
.card--link {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); cursor: pointer;
}
.card--link h3 {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.card__go { font-size: 12px; color: var(--muted); transition: transform .18s, color .18s; }
.card--link:hover { border-color: var(--gold); }
.card--link:hover .card__go { transform: translateX(4px); color: var(--gold-strong); }


/* ─────────────────────────────────────────────────────────
   Theme switcher in the account menu
   ───────────────────────────────────────────────────────── */
.usermenu__theme {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 16px; border-bottom: 1px solid var(--line);
}
.usermenu__themelabel { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.usermenu__themelabel .ico { color: var(--muted); margin-right: 3px; }

.themeswitch {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--gray-100); border-radius: 999px;
}
.themeswitch__btn {
  border: none; background: none; cursor: pointer;
  width: 30px; height: 26px; border-radius: 999px;
  font-size: 12.5px; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.themeswitch__btn:hover { color: var(--ink); }
.themeswitch__btn.is-active {
  background: var(--surface); color: var(--brand-strong);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .16);
}

/* Profile stats: keep all three tiles on a single row at every width */
.stats--row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats--row .stat { min-width: 0; }
@media (max-width: 560px) {
  .stats--row { gap: 8px; }
  .stats--row .stat { padding: 13px 12px; border-left-width: 3px; }
  .stats--row .stat__num { font-size: 23px; }
  .stats--row .stat__num small { font-size: 12px; }
  .stats--row .stat__label { font-size: 10px; letter-spacing: .03em; }
}
@media (max-width: 380px) {
  .stats--row .stat { padding: 11px 9px; }
  .stats--row .stat__num { font-size: 19px; }
  .stats--row .stat__label { font-size: 9px; }
}

/* ─────────────────────────────────────────────────────────
   Fixes
   ───────────────────────────────────────────────────────── */

/* 1. The email field's leading icon was overlapping the placeholder.
      `input[type="email"] { padding: 14px 15px }` is declared after
      `.field__control input { padding-left: 42px }` with equal specificity,
      so the shorthand reset the left padding. Re-assert it with a
      higher-specificity selector. */
.field__control input[type="email"],
.field__control input[type="text"],
.field__control input[type="tel"] {
  padding-left: 44px;
}
.field__icon { z-index: 1; }

/* 2. The install banner was centred with translateX(-50%), but the `rise`
      animation also sets `transform` (with fill-mode `both`), wiping the
      centring — so the bar sat off-screen to the right. Centre it with
      auto margins instead, and animate only opacity/offset. */
.install-bar {
  left: 14px;
  right: 14px;
  margin: 0 auto;
  width: auto;
  transform: none;
  animation: install-rise .28s ease both;
}
@keyframes install-rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.install-bar__txt { min-width: 0; }
.install-bar__txt small { display: block; }

@media (max-width: 420px) {
  .install-bar { gap: 10px; padding: 11px 12px; bottom: 12px; }
  .install-bar__icon { font-size: 20px; }
  .install-bar__txt { font-size: 12.5px; }
  .install-bar .install-bar__go { padding: 8px 13px; font-size: 13px; }
}
