:root {
  --bg: #f1f5f9; --card: #ffffff; --text: #0f172a; --muted: #64748b;
  --primary: #1e3a8a; --accent: #2563eb; --border: #e2e8f0;
}
body.dark-mode {
  --bg: #0f172a; --card: #1e293b; --text: #f8fafc; --muted: #94a3b8;
  --primary: #60a5fa; --accent: #3b82f6; --border: #334155;
}
* { box-sizing: border-box; font-family: 'Segoe UI', system-ui, sans-serif; }
body { margin: 0; background: var(--bg); color: var(--text); padding-bottom: 90px; transition: background 0.2s, color 0.2s; }

/* Safe-Area Top Header (Fixes Android Status Bar Overlap) */
.app-bar {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  color: #fff; padding: max(28px, env(safe-area-inset-top)) 16px 26px;
  text-align: center; border-bottom-left-radius: 22px; border-bottom-right-radius: 22px;
}
.app-bar h1 { margin: 4px 0 0; font-size: 1.3rem; }
.app-bar p { margin: 4px 0 0; font-size: 0.82rem; color: #cbd5e1; }

/* User Profile Pill */
.user-bar { display: flex; justify-content: flex-end; max-width: 580px; margin: 0 auto 8px; position: relative; }
.user-pill { display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,0.16); padding: 4px 12px 4px 6px; border-radius: 30px; cursor: pointer; border: 1px solid rgba(255,255,255,0.25); color: #fff; font-size: 0.82rem; font-weight: 600; }
.avatar-img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; background: #3b82f6; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.75rem; color: #fff; }
.user-menu { position: absolute; top: 38px; right: 0; background: #fff; color: #0f172a; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.22); border: 1px solid #e2e8f0; width: 195px; z-index: 60; overflow: hidden; text-align: left; }
.user-menu div { padding: 11px 14px; font-size: 0.85rem; font-weight: 600; cursor: pointer; border-bottom: 1px solid #f1f5f9; }
.user-menu div.danger { color: #dc2626; border-bottom: none; }

.container { max-width: 580px; margin: -14px auto 0; padding: 0 14px; }
.card { background: var(--card); padding: 20px; border-radius: 16px; box-shadow: 0 6px 20px rgba(15,23,42,0.07); border: 1px solid var(--border); }

/* 2-Column Play Store Style Tile Grid */
.tile-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 12px; }
.tile {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 16px 12px; text-align: center; cursor: pointer;
  box-shadow: 0 4px 12px rgba(15,23,42,0.05); transition: transform 0.12s, border-color 0.12s;
}
.tile:active { transform: scale(0.97); }
.tile-icon {
  width: 48px; height: 48px; border-radius: 50%; margin: 0 auto 10px;
  display: flex; align-items: center; justify-content: center; font-size: 1.45rem;
  background: #eff6ff; border: 1px solid #bfdbfe;
}
.tile-title { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.tile-sub { font-size: 0.78rem; color: var(--muted); margin-top: 3px; font-weight: 600; }

/* Solution & Quiz Utility Toolbar */
.util-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
  background: var(--card); padding: 8px 10px; border-radius: 12px;
  border: 1px solid var(--border); margin-bottom: 12px; flex-wrap: wrap;
}
.util-btn {
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 0.8rem; font-weight: 700; cursor: pointer;
}
.option-btn {
  width: 100%; padding: 13px 14px; border-radius: 10px; background: var(--bg);
  color: var(--text); border: 1.5px solid var(--border); text-align: left;
  margin-top: 10px; cursor: pointer; font-weight: 500;
}
.option-btn.correct { background: #dcfce7 !important; border-color: #16a34a !important; color: #14532d !important; font-weight: 700; }
.option-btn.wrong { background: #fee2e2 !important; border-color: #dc2626 !important; color: #7f1d1d !important; font-weight: 700; }

/* Bottom PREV / BOOKMARK / NEXT + Question Palette */
.nav-controls { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; margin-top: 16px; }
.palette-strip {
  display: flex; gap: 6px; overflow-x: auto; padding: 10px 4px; margin-top: 12px;
  border-top: 1px solid var(--border);
}
.pal-dot {
  min-width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-weight: 700; font-size: 0.82rem;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.pal-dot.active { border: 2px solid #2563eb; }
.pal-dot.ok { background: #22c55e; color: #fff; border-color: #16a34a; }
.pal-dot.bad { background: #ef4444; color: #fff; border-color: #dc2626; }
.pal-dot.skip { background: #eab308; color: #fff; border-color: #ca8a04; }

/* Diagnostic Solution & Kindle Sepia Reader */
.diag-box { background: #fefce8; border-left: 4px solid #eab308; color: #1e293b; padding: 14px; border-radius: 10px; margin-top: 14px; font-size: 0.9rem; line-height: 1.5; }
.kindle-modal {
  position: fixed; inset: 0; background: rgba(15,23,42,0.75); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.kindle-page {
  background: #fbf0d9; color: #3b2f2f; max-width: 540px; width: 100%; max-height: 85vh;
  overflow-y: auto; border-radius: 14px; padding: 22px; box-shadow: 0 20px 40px rgba(0,0,0,0.4);
  font-family: Georgia, 'Times New Roman', serif; border: 2px solid #d6c3a5;
}
.kindle-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #d6c3a5; padding-bottom: 8px; margin-bottom: 12px; font-family: system-ui, sans-serif; }
.visual-3d-box { background: #0f172a; color: #e2e8f0; border-radius: 12px; padding: 14px; margin-top: 12px; text-align: center; }

/* Standard Inputs & Buttons */
.text-input, select { width: 100%; padding: 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--card); color: var(--text); font-size: 0.95rem; margin-top: 6px; }
.btn-primary { width: 100%; padding: 13px; border-radius: 12px; border: none; background: #2563eb; color: #fff; font-size: 0.96rem; font-weight: 700; cursor: pointer; margin-top: 12px; }
.btn-secondary { width: 100%; padding: 11px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg); color: var(--text); font-weight: 600; cursor: pointer; margin-top: 8px; }
.badge { display: inline-block; padding: 5px 12px; border-radius: 20px; font-weight: 700; font-size: 0.8rem; background: #dbeafe; color: #1e40af; }
.slider-group { background: var(--bg); border: 1px solid var(--border); padding: 10px 12px; border-radius: 12px; margin-bottom: 10px; }
.slider-header { display: flex; justify-content: space-between; font-weight: 600; font-size: 0.86rem; }
.passage-box { background: var(--bg); border: 1px solid var(--border); border-left: 4px solid #2563eb; padding: 12px; border-radius: 8px; font-size: 0.9rem; line-height: 1.55; margin-bottom: 12px; max-height: 170px; overflow-y: auto; }
.review-item { background: var(--card); border: 1px solid var(--border); border-left: 4px solid #ef4444; padding: 14px; border-radius: 12px; margin-top: 12px; font-size: 0.88rem; line-height: 1.5; }
.review-item.skipped { border-left-color: #eab308; }
.hidden { display: none !important; }
