/* ============ Shared auth + user area styles ============ */

/* Header auth slot styles live in assets/css/style.css (shared with home + SSR pages) */

/* ---------- Auth / user page shells ---------- */
.auth-shell {
  min-height: calc(100vh - 220px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 18px;
}
.auth-card {
  width: 100%;
  max-width: 460px;
  padding: 34px 32px 30px;
  animation: rise 0.45s ease both;
}
.auth-card.wide { max-width: 980px; }
.auth-title { margin: 0 0 6px; font-size: 1.5rem; font-weight: 800; color: var(--text); }
.auth-sub { margin: 0 0 24px; color: var(--text-mute); font-size: 0.94rem; line-height: 1.6; }
.auth-alt { margin-top: 18px; text-align: center; color: var(--text-mute); font-size: 0.9rem; }
.auth-alt a { color: var(--gold-light); text-decoration: none; font-weight: 600; }
.auth-alt a:hover { text-decoration: underline; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 15px; }
.field > span { font-size: 0.82rem; font-weight: 600; color: var(--text-dim); letter-spacing: 0.3px; }
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 12px 15px;
  border-radius: 12px;
  border: 1px solid rgba(185, 138, 232, 0.25);
  background: rgba(18, 8, 38, 0.65);
  color: var(--text);
  font-family: inherit;
  font-size: 0.96rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--purple, #8b3df6);
  box-shadow: 0 0 0 3px rgba(139, 61, 246, 0.22);
}
.field input::placeholder,
.field textarea::placeholder { color: var(--text-mute); }

.form-error {
  margin: 4px 0 14px;
  padding: 11px 14px;
  border-radius: 10px;
  background: rgba(255, 107, 129, 0.12);
  border: 1px solid rgba(255, 107, 129, 0.35);
  color: #ffc9d1;
  font-size: 0.9rem;
}
.form-info {
  margin: 4px 0 14px;
  padding: 11px 14px;
  border-radius: 10px;
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.35);
  color: #c8f7d8;
  font-size: 0.9rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 24px;
  border-radius: 999px;
  border: none;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.93rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s, box-shadow 0.18s, background 0.18s, opacity 0.18s;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.55; cursor: wait; transform: none; }
.btn-gold {
  color: #241403;
  background: linear-gradient(135deg, #f5d97e, #d4af37);
  box-shadow: 0 6px 20px rgba(212, 175, 55, 0.3);
}
.btn-purple {
  color: #f3ebff;
  background: rgba(139, 61, 246, 0.16);
  border: 1px solid rgba(185, 138, 232, 0.4);
}
.btn-purple:hover { background: rgba(139, 61, 246, 0.28); }
.btn-ghost {
  color: var(--text-dim);
  background: transparent;
  border: 1px solid rgba(185, 138, 232, 0.3);
}
.btn-ghost:hover { color: var(--text); background: rgba(139, 61, 246, 0.1); }
.btn-danger {
  color: #ffdbe1;
  background: rgba(255, 107, 129, 0.14);
  border: 1px solid rgba(255, 107, 129, 0.35);
}
.btn-danger:hover { background: rgba(255, 107, 129, 0.26); }
.btn-sm { padding: 7px 14px; font-size: 0.82rem; }
.btn-block { width: 100%; }

/* ---------- User dashboard layout ---------- */
.user-layout { display: grid; grid-template-columns: 230px 1fr; gap: 22px; align-items: start; }
.user-nav { padding: 18px 12px; position: sticky; top: 86px; }
.user-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 12px;
  color: var(--text-dim);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.94rem;
  transition: background 0.18s, color 0.18s;
}
.user-nav a:hover { color: var(--text); background: rgba(139, 61, 246, 0.1); }
.user-nav a.active { color: var(--gold-light); background: rgba(212, 175, 55, 0.1); }
.user-content { min-width: 0; }
.panel {
  background: rgba(30, 16, 58, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(185, 138, 232, 0.18);
  border-radius: 18px;
  padding: 24px 26px;
  margin-bottom: 20px;
  animation: rise 0.4s ease both;
}
.panel h2 { margin: 0 0 4px; font-size: 1.25rem; font-weight: 800; color: var(--text); }
.panel .panel-sub { margin: 0 0 18px; color: var(--text-mute); font-size: 0.9rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-box {
  padding: 18px 20px;
  border-radius: 16px;
  background: rgba(30, 16, 58, 0.72);
  border: 1px solid rgba(185, 138, 232, 0.18);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-box .num { font-size: 1.6rem; font-weight: 800; color: var(--gold-light); }
.stat-box .lbl { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-mute); }

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.badge-admin { color: #e9dcff; background: rgba(139, 61, 246, 0.2); border: 1px solid rgba(185, 138, 232, 0.5); }
.badge-user { color: #cdb9ec; background: rgba(125, 111, 160, 0.18); border: 1px solid rgba(125, 111, 160, 0.4); }
.badge-ok { color: #c8f7d8; background: rgba(74, 222, 128, 0.13); border: 1px solid rgba(74, 222, 128, 0.4); }
.badge-bad { color: #ffc9d1; background: rgba(255, 107, 129, 0.13); border: 1px solid rgba(255, 107, 129, 0.4); }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-mute);
  padding: 10px 12px;
  border-bottom: 1px solid rgba(185, 138, 232, 0.18);
}
.data-table td { padding: 11px 12px; border-bottom: 1px solid rgba(185, 138, 232, 0.08); font-size: 0.92rem; color: var(--text-dim); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.table-scroll { overflow-x: auto; }

.empty-state { text-align: center; padding: 36px 16px; color: var(--text-mute); }
.empty-state p { margin: 8px 0 16px; }

.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.lib-card {
  background: rgba(18, 8, 38, 0.6);
  border: 1px solid rgba(185, 138, 232, 0.16);
  border-radius: 14px;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s;
  display: flex;
  flex-direction: column;
}
.lib-card:hover { transform: translateY(-3px); border-color: rgba(212, 175, 55, 0.4); }
.lib-card img { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; }
.lib-card .lib-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.lib-card .lib-title { font-size: 0.88rem; font-weight: 700; color: var(--text); line-height: 1.35; }
.lib-card .lib-author { font-size: 0.78rem; color: var(--text-mute); }
.lib-card .lib-actions { margin-top: auto; display: flex; gap: 6px; }
.lib-card .lib-actions .btn { flex: 1; padding: 6px 8px; font-size: 0.74rem; border-radius: 9px; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  max-width: 340px;
  padding: 14px 20px;
  border-radius: 14px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(30, 16, 58, 0.95);
  border: 1px solid rgba(185, 138, 232, 0.4);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  animation: rise 0.25s ease both;
}
.toast.err { border-color: rgba(255, 107, 129, 0.5); color: #ffd3da; }
.toast.ok { border-color: rgba(74, 222, 128, 0.5); }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 860px) {
  .user-layout { grid-template-columns: 1fr; }
  .user-nav { position: static; display: flex; overflow-x: auto; gap: 4px; padding: 10px; }
  .user-nav a { white-space: nowrap; padding: 9px 13px; }
}

/* ---------- sidebar (updated) ---------- */
#userNav { display: flex; flex-direction: column; gap: 4px; }
#userNav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  border-radius: 12px;
  color: #cbbcec;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  transition: background 0.18s, color 0.18s;
}
#userNav a svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; flex-shrink: 0; }
#userNav a:hover { background: rgba(139, 61, 246, 0.14); color: #efe6ff; }
#userNav a.active { background: linear-gradient(135deg, rgba(245, 217, 126, 0.16), rgba(212, 175, 55, 0.1)); color: #f5d97e; border: 1px solid rgba(212, 175, 55, 0.35); }
.usernav-sep { height: 1px; margin: 8px 6px; background: rgba(185, 138, 232, 0.18); }
.usernav-admin { color: #9ecbff !important; }

/* ---------- mobile bottom nav ---------- */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 150;
  display: none;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: rgba(16, 7, 32, 0.97);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(185, 138, 232, 0.25);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px 2px;
  border-radius: 12px;
  text-decoration: none;
  color: #8f7fb5;
  font-size: 0.62rem;
  font-weight: 700;
}
.bottom-nav a svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.bottom-nav a.active { color: #f5d97e; }
.bottom-nav a.active svg { filter: drop-shadow(0 0 6px rgba(212, 175, 55, 0.6)); }

@media (max-width: 900px) {
  .bottom-nav { display: grid; }
  body { padding-bottom: 74px; }
}

/* standalone upload page shell */
.upload-shell {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  animation: rise 0.45s ease both;
}
.upload-shell .panel { padding: 28px 30px; }

/* ---------- dashboard components ---------- */

/* notification badge on sidebar links */
.user-nav a { position: relative; }
.nav-badge {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f5d97e, #d4af37);
  color: #241403;
  font-size: 0.68rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(212, 175, 55, 0.45);
}

/* glass confirmation modal */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 3, 18, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: rise 0.2s ease both;
}
.confirm-overlay.closing { opacity: 0; transition: opacity 0.16s; }
.confirm-box {
  width: 100%;
  max-width: 380px;
  border-radius: 20px;
  padding: 26px 26px 22px;
  text-align: center;
  border: 1px solid rgba(185, 138, 232, 0.35);
}
.confirm-glyph {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #f5d97e;
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid rgba(212, 175, 55, 0.4);
}
.confirm-box h3 { margin: 0 0 6px; font-size: 1.15rem; color: var(--text); }
.confirm-box p { margin: 0 0 18px; color: var(--text-mute); font-size: 0.92rem; line-height: 1.6; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }

/* skeleton shimmer */
.skel {
  height: 74px;
  border-radius: 14px;
  margin-bottom: 12px;
  background: linear-gradient(100deg, rgba(185, 138, 232, 0.08) 35%, rgba(185, 138, 232, 0.2) 50%, rgba(185, 138, 232, 0.08) 65%);
  background-size: 200% 100%;
  animation: skelWave 1.15s ease-in-out infinite;
}
.skel.skel-card { height: 240px; }
@keyframes skelWave {
  from { background-position: 120% 0; }
  to { background-position: -80% 0; }
}

/* empty state star */
.empty-star { animation: starSpin 26s linear infinite; margin-bottom: 6px; }
@keyframes starSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* profile avatar (initials) */
.avatar-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.35rem;
  color: #241403;
  background: conic-gradient(from 210deg, #f5d97e, #b98ae8, #8b3df6, #d4af37, #f5d97e);
  box-shadow: 0 6px 22px rgba(139, 61, 246, 0.4), inset 0 0 0 3px rgba(36, 20, 3, 0.25);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.avatar-circle.sm { width: 44px; height: 44px; font-size: 1rem; }

/* library/favorites toolbar */
.xtoolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.xtoolbar .xsearch {
  flex: 1 1 200px;
  min-width: 160px;
  padding: 11px 16px;
  border-radius: 999px;
  border: 1px solid rgba(185, 138, 232, 0.28);
  background: rgba(18, 8, 38, 0.65);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.xtoolbar .xsearch:focus { border-color: var(--purple, #8b3df6); box-shadow: 0 0 0 3px rgba(139, 61, 246, 0.2); }
.xtoolbar select {
  padding: 11px 14px;
  border-radius: 999px;
  border: 1px solid rgba(185, 138, 232, 0.28);
  background: rgba(18, 8, 38, 0.65);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  cursor: pointer;
}
.view-toggle {
  display: inline-flex;
  border: 1px solid rgba(185, 138, 232, 0.3);
  border-radius: 999px;
  overflow: hidden;
}
.view-toggle button {
  padding: 9px 13px;
  border: none;
  background: transparent;
  color: #8f7fb5;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  transition: background 0.18s, color 0.18s;
}
.view-toggle button.on { background: rgba(139, 61, 246, 0.25); color: #f5d97e; }

/* list view for book grids */
.xgrid.list-view { grid-template-columns: 1fr; }
.xgrid.list-view .xcard { display: grid; grid-template-columns: 84px 1fr auto; align-items: center; }
.xgrid.list-view .xcard-coverwrap { aspect-ratio: auto; height: 118px; border-radius: 14px 0 0 14px; }
.xgrid.list-view .xcard-body { padding: 10px 16px; }
.xgrid.list-view .xcard-actions { flex-direction: column; margin: 0 12px 0 0; }

@media (max-width: 560px) {
  .confirm-box { padding: 22px 18px 18px; }
  .xtoolbar select { flex: 1 1 140px; }
}

/* reading progress bar */
.prog-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(185, 138, 232, 0.14);
  overflow: hidden;
  margin: 8px 0 4px;
}
.prog-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #8b3df6, #d4af37);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
  transition: width 0.5s ease;
}

/* notifications page */
.notif-card { align-items: flex-start; }
.notif-card.unread { border-color: rgba(212, 175, 55, 0.45); background: rgba(42, 22, 78, 0.72); }
.notif-glyph {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: #f5d97e;
  background: rgba(139, 61, 246, 0.16);
  border: 1px solid rgba(185, 138, 232, 0.35);
}
.notif-card.unread .notif-glyph { color: #241403; background: linear-gradient(135deg, #f5d97e, #d4af37); border-color: transparent; }

/* ============ v4: portal home, more sheet, settings prefs, explore selects ============ */
.xselect {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(212,175,55,.25);
  color: #efe6ff;
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  font-size: .88rem;
  cursor: pointer;
}
.xselect option { background: #1d0f3d; color: #efe6ff; }

/* quick action tiles (home) */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 18px;
}
.quick-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 10px;
  border-radius: 14px;
  text-decoration: none;
  font-weight: 600;
  font-size: .92rem;
  transition: transform .18s ease, border-color .18s ease;
}
.quick-tile span { font-size: 1.6rem; }
.quick-tile:hover { transform: translateY(-3px); border-color: rgba(212,175,55,.55); }

/* mini book cards (home previews) */
.mini-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.mini-card {
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
.mini-card img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  border-radius: 8px;
  background: #241247;
}
.mini-card h4 {
  margin: 0;
  font-size: .9rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mini-meta { font-size: .75rem; color: #b9a8d9; }
.mini-card .btn { margin-top: auto; }

/* activity rows */
.act-row { display: flex; gap: 12px; align-items: baseline; padding: 8px 0; }
.act-row p { margin: 0; }
.act-icon { font-size: 1.05rem; }

/* mobile More sheet */
.more-sheet { position: fixed; inset: 0; z-index: 90; }
.more-backdrop { position: absolute; inset: 0; background: rgba(10,5,25,.6); backdrop-filter: blur(3px); }
.more-panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  border-radius: 22px 22px 0 0;
  padding: 14px 18px calc(20px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  animation: sheetUp .22s ease;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.more-grip {
  grid-column: 1 / -1;
  width: 44px; height: 4px;
  border-radius: 2px;
  background: rgba(212,175,55,.4);
  margin: 0 auto 8px;
}
.more-panel a {
  padding: 13px 14px;
  border-radius: 12px;
  text-decoration: none;
  color: #efe6ff;
  background: rgba(255,255,255,.04);
  font-size: .92rem;
}
.more-panel a.on { background: rgba(212,175,55,.16); color: #f5d97e; }
.more-close { grid-column: 1 / -1; margin-top: 6px; }

/* settings preference rows */
.pref-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid rgba(212,175,55,.08);
  cursor: pointer;
}
.pref-row:last-child { border-bottom: none; }
.pref-row small { display: block; color: #9c8cc0; font-size: .78rem; margin-top: 2px; }
.switch { position: relative; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; z-index: 1; }
.switch i {
  display: block;
  width: 46px; height: 26px;
  border-radius: 13px;
  background: rgba(255,255,255,.12);
  position: relative;
  transition: background .18s ease;
}
.switch i::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #cfc3e8;
  transition: transform .18s ease, background .18s ease;
}
.switch input:checked + i { background: rgba(212,175,55,.55); }
.switch input:checked + i::after { transform: translateX(20px); background: #f5d97e; }

.danger-panel { border-color: rgba(220,80,80,.35); }
.danger-panel h2 { color: #ff9b9b; }

/* global pref effects */
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after {
  animation-duration: .001s !important;
  transition-duration: .001s !important;
}
html.compact-cards .xgrid { gap: 10px; }
html.compact-cards .xcard { padding: 8px; }

/* ============ v5: mobile-first polish for user area ============ */
.bottom-nav button {
  background: none;
  border: none;
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px 2px;
  border-radius: 12px;
  color: #8f7fb5;
  font-size: 0.62rem;
  font-weight: 700;
  cursor: pointer;
}
.bottom-nav button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.bottom-nav button.active { color: #f5d97e; }

@media (max-width: 900px) {
  /* sidebar out — bottom tabs + More sheet handle all navigation */
  .user-layout { grid-template-columns: 1fr !important; gap: 14px; }
  .user-nav, #userNav { display: none !important; }

  .auth-shell { margin-top: 14px; }
  .xpage-head { flex-wrap: wrap; gap: 6px; }
  .xpage-title { font-size: 1.35rem; }

  .panel { padding: 18px 16px; border-radius: 16px; }
  .panel h2 { font-size: 1.05rem; }

  /* toolbar stacks: search full row, filters in 2-col grid */
  .xtoolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .xtoolbar .xsearch { grid-column: 1 / -1; }
  .xselect { width: 100%; }

  .quick-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .quick-tile { padding: 14px 8px; font-size: 0.85rem; }
  .quick-tile span { font-size: 1.4rem; }

  .mini-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .mini-card h4 { font-size: 0.82rem; }

  /* toast floats above the tab bar */
  .toast {
    left: 12px; right: 12px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    transform: none;
    text-align: center;
  }

  /* modals fit small screens */
  .confirm-box { width: min(92vw, 420px); padding: 20px 16px; }

  .pref-row { align-items: flex-start; padding: 12px 0; }
}

@media (max-width: 380px) {
  .mini-row { grid-template-columns: 1fr 1fr; }
  .xtoolbar { grid-template-columns: 1fr; }
}
