/* EYEWAZ web client — plain, high-contrast, large-text design for low vision. */

/* Brand display font. Drop the real file at /app/assets/fonts/GoodDogNew.*
   (see assets/README.md). Until then, a friendly rounded fallback is used. */
@font-face {
  font-family: "GoodDogNew";
  src: url("/app/assets/fonts/GoodDogNew.woff2") format("woff2"),
       url("/app/assets/fonts/GoodDogNew.woff") format("woff"),
       url("/app/assets/fonts/GoodDogNew.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  /* EYEWAZ brand: #7BB2BE blue, #F7F6E9 cream. Darker/lighter shades below are
     derived from the brand blue so text stays legible (WCAG AA) for low vision. */
  --brand-blue: #7BB2BE;   /* brand accent (decorative fills) */
  --brand-cream: #F7F6E9;  /* brand background */
  --bg: #F7F6E9;           /* cream page background */
  --surface: #ffffff;      /* white cards on cream */
  --border: #cdd9d7;       /* soft blue-grey input border */
  --text: #1f2b2e;
  --muted: #5f7176;
  --accent: #7BB2BE;       /* EYEWAZ blue */
  --accent-strong: #2e6675;/* deep blue for buttons/CTAs (white text passes AA) */
  --accent-hover: #224f5b; /* darker still, for hover */
  --accent-soft: #a9cdd4;  /* light blue for highlights/progress */
  --danger: #c0392b;
  --success: #2e7d52;
  --focus: #224f5b;        /* deep-blue keyboard focus ring (visible on cream) */
  --radius: 14px;
  /* Brand display font. "GoodDogNew" first (if its file is ever added at
     assets/fonts/), then a rounded GoodDogNew look-alike from Google Fonts,
     then rounded system fallbacks. */
  --font-brand: "GoodDogNew", "Baloo 2", "Comic Sans MS", "Chalkboard SE",
                ui-rounded, system-ui, sans-serif;
}

* { box-sizing: border-box; }

/* Dark mode — toggled by body.dark */
body.dark {
  --bg: #10211f;
  --surface: #18302f;
  --border: #5a8a92;
  --text: #eef6f4;
  --muted: #aac6c9;
  --accent: #7BB2BE;
  --accent-strong: #3a7080;
  --accent-hover: #4f93a3;
  --focus: #a9cdd4;
}
body.dark .card,
body.dark .reader-controls,
body.dark .social-btn,
body.dark .field input,
body.dark .field select,
body.dark .reader-text,
body.dark .page-text { background: var(--surface); color: var(--text); border-color: #2c3a57; }
body.dark .field input, body.dark .field select, body.dark .reader-text { background: #0e1726; }

/* Reader mode tabs */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  flex: 1; min-height: 52px; padding: 10px; border-radius: 12px;
  border: 2px solid #d4dbe9; background: var(--surface);
  font: inherit; font-weight: 700; font-size: 1.05rem; color: var(--text); cursor: pointer;
}
.tab.is-active { background: var(--accent-strong); color: #fff; border-color: var(--accent-strong); }

/* Inline reader controls */
.reader-controls { display: grid; gap: 14px; }
.rc-row { display: grid; gap: 6px; }
.rc-row label { font-weight: 700; }
.rc-row select {
  width: 100%; padding: 13px; font-size: 1.05rem; border-radius: 8px;
  border: 2px solid var(--border); background: #fff; color: var(--text);
}
.rc-row input[type="range"] { width: 100%; height: 44px; accent-color: var(--accent); }

/* Text reader box */
.reader-text {
  width: 100%; min-height: 220px; padding: 16px; font-size: 1.15rem; line-height: 1.6;
  border: 2px solid var(--border); border-radius: 12px; background: #fff; color: var(--text);
  resize: vertical; font-family: inherit;
}

/* Player bar with big play button */
.player-bar { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 18px 0; }
.play-btn {
  width: 76px; height: 76px; border-radius: 50%; border: none;
  background: var(--accent-strong); color: #fff; font-size: 2rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.play-btn:hover { background: var(--accent-hover); }
.play-btn.playing { background: var(--success); }
.round-btn {
  width: 56px; height: 56px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 1.4rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
  text-decoration: none;
}
.round-btn:hover { background: var(--accent-strong); color: #fff; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 20px;
  line-height: 1.6;
}

/* Big, unmistakable keyboard focus everywhere. */
:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: #ffd166; color: #000; padding: 12px 16px; z-index: 100;
  font-weight: 700;
}
.skip-link:focus { left: 8px; top: 8px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--accent); color: var(--brand-cream);
}
/* Brand lockup: ear/eye mark + GoodDogNew wordmark + tagline */
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 46px; height: 46px; color: var(--brand-cream); flex: none; }
.brand-mark svg, .brand-mark img { width: 100%; height: 100%; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand {
  margin: 0; color: var(--brand-cream);
  font-family: var(--font-brand); font-weight: 700;
  font-size: 2.1rem; letter-spacing: .5px; text-transform: lowercase;
}
.brand-tag {
  margin: 2px 0 0; color: var(--brand-cream); opacity: .85;
  font-size: .62rem; letter-spacing: 2px; text-transform: uppercase;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-actions .link-btn { color: #143b44; font-weight: 700; }
.topbar-actions .link-btn[aria-pressed="false"] { text-decoration: line-through; opacity: .7; }

/* Headings carry the brand font for personality; body stays a legible sans. */
h2, h3, .auth h2 { font-family: var(--font-brand); font-weight: 600; letter-spacing: .3px; }

main { max-width: 640px; margin: 0 auto; padding: 20px 16px 64px; }

h2 { font-size: 1.7rem; margin: 10px 0 6px; }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.15rem; margin: 18px 0 6px; }
.lede { color: var(--muted); margin: 0 0 18px; font-size: 1.05rem; }
.section-title { margin-top: 36px; border-top: 2px solid var(--surface); padding-top: 20px; }

.card {
  background: var(--surface);
  border: 2px solid #d4dbe9;
  border-radius: 12px;
  padding: 22px;
  margin: 0 0 20px;
}

/* Form fields — large targets, strong borders, clear labels. */
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 1.05rem; }
.field input {
  width: 100%;
  padding: 15px;
  font-size: 1.1rem;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: #fff;
  color: var(--text);
}
.field input[aria-invalid="true"] { border-color: var(--danger); border-width: 3px; }

.hint { color: var(--muted); font-size: .95rem; margin: 6px 0 0; }
.optional { color: var(--muted); font-weight: 400; font-size: .9rem; }

.field select {
  width: 100%; padding: 15px; font-size: 1.1rem; border-radius: 8px;
  border: 2px solid var(--border); background: #fff; color: var(--text);
}
.field input[type="range"] { width: 100%; height: 44px; accent-color: var(--accent); }
.field input:disabled { background: var(--surface); color: var(--muted); }
.voice.engine { display: block; }
.voice.engine label { display: block; margin: 8px 0; }

/* Auth screen layout (social-first, like leading apps but higher contrast). */
.auth { max-width: 420px; margin: 0 auto; text-align: center; }
.auth h2 { font-size: 2rem; margin: 18px 0 6px; }
.auth .lede { text-align: center; }
.auth-form { text-align: left; }
.auth-links { margin: 12px 0 0; text-align: center; }
.switch { text-align: center; }

/* Social sign-in buttons — large, clear logos, strong border. */
.social-btn {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 56px; padding: 12px 18px; margin-bottom: 12px;
  background: #fff; color: var(--text);
  border: 2px solid var(--border); border-radius: 999px;
  font-size: 1.1rem; font-weight: 700; cursor: pointer;
}
.social-btn:hover { background: var(--surface); }
.social-btn .social-logo { display: inline-flex; width: 24px; justify-content: center; }
.social-btn > span:last-child { flex: 1; text-align: center; margin-right: 24px; }

.divider {
  display: flex; align-items: center; text-align: center;
  color: var(--muted); margin: 18px 0; font-weight: 700;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 2px; background: #d4dbe9;
}
.divider span { padding: 0 14px; }

/* Password field with show/hide toggle. */
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { padding-right: 84px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  min-height: 40px; padding: 0 12px;
  background: var(--surface); color: var(--accent);
  border: 2px solid #d4dbe9; border-radius: 6px;
  font: inherit; font-weight: 700; cursor: pointer;
}

/* Errors: bold, dark red, with a left bar so they stand out. */
.form-error {
  background: #fdecee;
  color: var(--danger);
  border-left: 6px solid var(--danger);
  padding: 12px 14px;
  border-radius: 6px;
  font-weight: 700;
  margin: 0 0 16px;
}

/* Dev-mode verification code — large and obvious. */
.dev-code {
  background: #fff7e6;
  border: 2px dashed #b45309;
  color: #7a3e00;
  padding: 14px;
  border-radius: 8px;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 3px;
  text-align: center;
  margin-bottom: 16px;
}

.primary-btn {
  width: 100%;
  padding: 16px;
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  background: var(--accent-strong);
  border: 2px solid var(--accent-strong);
  border-radius: 10px;
  cursor: pointer;
  min-height: 56px;
}
.primary-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.primary-btn:disabled { opacity: .6; cursor: progress; }
.primary-btn.ghost { background: #fff; color: var(--accent-strong); border-color: var(--accent-strong); }
.primary-btn.danger { color: var(--danger); border-color: var(--danger); }
.primary-btn.danger:hover { background: var(--danger); color: #fff; }
.primary-btn.ghost:hover { background: var(--surface); }
.primary-btn.speaking { background: var(--success); border-color: var(--success); }

.link-btn {
  background: none; border: none; color: var(--accent);
  font: inherit; font-weight: 700; text-decoration: underline;
  cursor: pointer; padding: 8px; min-height: 44px;
}
.switch { color: var(--muted); margin-top: 14px; }

/* Hero capture button. */
.capture-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; width: 100%; min-height: 180px;
  background: var(--surface); border: 3px dashed var(--accent);
  border-radius: 16px; font-size: 1.3rem; font-weight: 800;
  cursor: pointer; text-align: center; padding: 24px; color: var(--text);
}
.capture-btn:hover { background: #e9eef9; }
.capture-icon { font-size: 3rem; }

#previewWrap { margin-top: 20px; }
#preview { width: 100%; max-height: 320px; object-fit: contain; border-radius: 10px; background: #000; }

.row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin: 16px 0; }
.row .primary-btn { flex: 1; min-width: 190px; }

.voice { border: 2px solid var(--border); border-radius: 8px; padding: 8px 14px; }
.voice legend { padding: 0 6px; font-weight: 700; }
.voice label { margin-right: 16px; display: inline-flex; align-items: center; gap: 6px; }

.status { min-height: 28px; font-weight: 700; margin: 16px 0; font-size: 1.05rem; }
.status.error { color: var(--danger); }
.status.busy { color: var(--accent); }
.status.ok { color: var(--success); }

audio { width: 100%; margin-bottom: 14px; }

.urdu { font-size: 1.7rem; line-height: 2.6rem; }
.eng { color: var(--muted); }

.page-text {
  max-height: 320px; overflow-y: auto;
  background: #fff; border: 2px solid #d4dbe9;
  padding: 14px; border-radius: 8px; line-height: 1.8;
}
.page-text.urdu { font-size: 1.4rem; }
.page-text .speaking-chunk { background: #ffe08a; color: #000; border-radius: 4px; }

.library { list-style: none; padding: 0; margin: 12px 0 0; }
.library li { margin-bottom: 10px; }
.lib-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  background: var(--surface); border: 2px solid #d4dbe9; border-radius: 10px;
  padding: 14px 16px; color: var(--text); font: inherit; cursor: pointer; min-height: 56px;
}
.lib-item:hover { background: #e9eef9; }
.lib-item .lib-ur { font-size: 1.25rem; }
.lib-item .lib-play { font-size: 1.4rem; }

/* ===== EYEWAZ brand refinements (blue/cream identity) ===== */
.topbar { background: var(--accent); }
.tab.is-active { background: var(--accent-strong); border-color: var(--accent-strong); }
.play-btn { background: var(--accent-strong); }
.play-btn:hover { background: var(--accent-hover); }

/* Social sign-in as a centered round-icon row (like the mockup) */
#socialBlock { text-align: center; }
.social-btn {
  position: relative;
  display: inline-flex; width: 60px; height: 60px; min-height: 60px;
  padding: 0; margin: 6px 10px; border-radius: 50%;
  border: 2px solid var(--border); background: #fff;
  align-items: center; justify-content: center;
}
.social-btn:hover { background: var(--surface); }
.social-btn > span:last-child {        /* keep the label for screen readers only */
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); margin: -1px; padding: 0; border: 0; white-space: nowrap;
}
.social-btn .social-logo { width: auto; margin: 0; }

/* Library / My Books cards: play triangle + info + favourite heart */
.lib-item {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  border: 1px solid #e1e7ec; border-radius: var(--radius); background: #fff;
}
.lib-play-icon {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 50%;
  background: var(--accent-strong); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.lib-info { flex: 1; display: flex; flex-direction: column; gap: 3px; text-align: left; min-width: 0; }
.lib-info strong { font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-snippet { color: var(--muted); font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-fav { flex: 0 0 auto; color: var(--accent-strong); font-size: 1.4rem; }

/* Softer, rounder inputs/cards to match */
.field input, .field select, .rc-row select, .reader-text { border-radius: 10px; }
.card, .reader-controls { border-radius: var(--radius); border-color: #e1e7ec; }
body.dark .topbar { background: #102826; }

/* ===== Header/voice toggle polish + responsive ===== */
#ttsToggle, #themeToggle { font-size: 1.35rem; padding: 6px 8px; line-height: 1; }
/* never strike-through the voice icon (looked broken) */
.topbar-actions .link-btn[aria-pressed="false"] { text-decoration: none; opacity: .85; }
.brand { font-size: 1.95rem; letter-spacing: .5px; white-space: nowrap; }

/* Saved-recordings folder chips */
.folder-bar { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 16px; }
.folder-chip {
  padding: 8px 14px; border-radius: 999px; border: 2px solid var(--border);
  background: #fff; color: var(--text); font: inherit; font-weight: 700; cursor: pointer; min-height: 40px;
}
.folder-chip.is-active { background: var(--accent-strong); color: #fff; border-color: var(--accent-strong); }
.folder-chip.folder-del { border-color: var(--danger); color: var(--danger); background: #fff; }
.folder-chip.folder-del:hover { background: var(--danger); color: #fff; }

/* Per-recording "move to folder" dropdown */
.rec-move {
  margin-top: 8px; max-width: 240px; width: 100%;
  padding: 9px 12px; font: inherit; font-size: .95rem;
  border: 2px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); cursor: pointer; min-height: 40px;
}
.rec-move:focus { outline: none; border-color: var(--accent-strong); }
body.dark .rec-move { background: #10211f; }

/* Favourite star on a recording */
.rec-fav { font-size: 1.3rem; line-height: 1; color: var(--muted); flex: 0 0 auto; }
.rec-fav.is-fav { color: #e6a700; border-color: #e6a700; }
.rec-fav:hover { background: var(--accent-strong); color: #fff; }

/* Reminders */
.reminder-form { display: grid; gap: 10px; margin-bottom: 14px; }
.reminder-form input, .reminder-form select {
  padding: 12px 14px; font: inherit; font-size: 1rem;
  border: 2px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); min-height: 48px;
}
.reminder-form input:focus, .reminder-form select:focus { outline: none; border-color: var(--accent-strong); }
.reminder-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.reminder-item {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
}
.reminder-when {
  flex: 0 0 auto; min-width: 92px; font-weight: 800; font-size: 1.05rem; color: var(--accent-strong);
}
.reminder-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.reminder-info strong { overflow: hidden; text-overflow: ellipsis; }
body.dark .reminder-item,
body.dark .reminder-form input,
body.dark .reminder-form select { background: #10211f; }
body.dark .reminder-when { color: var(--accent); }

/* Membership / plan */
.plan-line { color: var(--accent-strong); font-weight: 700; margin: 2px 0 14px; }
body.dark .plan-line { color: var(--accent); }
.upgrade-link { color: var(--accent-strong); font-weight: 800; text-decoration: underline; white-space: nowrap; }
body.dark .upgrade-link { color: var(--accent); }
.plan-grid { display: grid; gap: 14px; grid-template-columns: 1fr; margin: 12px 0; }
@media (min-width: 560px) { .plan-grid { grid-template-columns: repeat(3, 1fr); } }
.plan-card {
  border: 2px solid var(--border); border-radius: var(--radius); padding: 16px;
  background: var(--surface); display: flex; flex-direction: column;
}
.plan-card.is-current { border-color: var(--accent-strong); box-shadow: 0 0 0 3px rgba(46,102,117,.18); }
.plan-card h4 { margin: 0 0 4px; font-family: var(--font-brand); font-size: 1.2rem; }
.plan-price { font-size: 1.6rem; font-weight: 800; margin: 0 0 10px; }
.plan-price small { font-size: .9rem; font-weight: 600; color: var(--muted); }
.plan-feats { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 6px; }
.plan-feats li::before { content: "✓ "; color: var(--accent-strong); font-weight: 800; }
.plan-card .plan-upgrade { margin-top: auto; }
.plan-card .paypal-slot { margin-top: auto; min-height: 46px; }
#cancelSubBtn { max-width: 320px; margin-top: 6px; }
body.dark .plan-card { background: #10211f; }

@media (max-width: 600px) {
  html, body { font-size: 17px; }
  .topbar { padding: 10px 12px; }
  .brand { font-size: 1.15rem; letter-spacing: .5px; }
  .topbar-actions { gap: 2px; }
  .topbar-actions .link-btn { padding: 6px 5px; font-size: .9rem; min-height: 40px; }
  #accountBtn, #logoutBtn { font-size: .85rem; }
  main { padding: 14px 12px 56px; }
  .tabs { flex-wrap: wrap; gap: 6px; }
  .tab { flex: 1 1 28%; min-height: 60px; font-size: .9rem; padding: 8px 4px; min-width: 0; }
  .card, .reader-controls { padding: 16px; }
  .row { gap: 10px; }
  .row .primary-btn { min-width: 140px; }
  .play-btn { width: 64px; height: 64px; }
}
@media (max-width: 380px) {
  .tab { flex: 1 1 45%; }
}

/* ---- Ask Eyewaz assistant ---- */
#assistantCard { border-left: 4px solid var(--accent); }
#asstMicBtn { min-width: 220px; }
#asstMicBtn[aria-pressed="true"] { background: #c0392b; border-color: #c0392b; }
.assistant-log {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 320px; overflow-y: auto; margin: 12px 0;
}
.asst-bubble {
  padding: 10px 14px; border-radius: 14px; line-height: 1.5;
  max-width: 92%; word-wrap: break-word;
}
.asst-user {
  align-self: flex-end; background: var(--accent-strong); color: #fff;
  border-bottom-right-radius: 4px;
}
.asst-assistant {
  align-self: flex-start; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-bottom-left-radius: 4px;
}
body.dark .asst-assistant { border-color: #2c3a57; }
.assistant-typed { display: flex; gap: 10px; margin-top: 12px; }
.assistant-typed input {
  flex: 1; padding: 12px 14px; font-size: 1rem;
  border: 2px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
}
.assistant-typed input:focus { outline: none; border-color: var(--accent); }

/* ============================= My Library view ============================= */
.library-screen { animation: fadeUp .25s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Search */
.lib-search {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 2px solid var(--border);
  border-radius: 999px; padding: 6px 16px; margin-bottom: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.lib-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(123,178,190,.25); }
.lib-search-icon { opacity: .6; font-size: 1.1rem; }
.lib-search input { flex: 1; border: 0; background: transparent; font: inherit; font-size: 1.05rem; color: var(--text); padding: 8px 0; }
.lib-search input:focus { outline: none; }

/* Segmented To-do / Completed */
.seg {
  display: flex; gap: 4px; padding: 5px; margin: 0 auto 16px;
  background: var(--accent-soft); border-radius: 999px; max-width: 420px;
}
.seg-btn {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-weight: 800; letter-spacing: .5px; text-transform: uppercase;
  color: #1c4a55; padding: 10px; border-radius: 999px; min-height: 44px;
  transition: background .2s, color .2s, box-shadow .2s;
}
.seg-btn.is-on { background: #fff; color: var(--accent-strong); box-shadow: 0 2px 8px rgba(0,0,0,.12); }
body.dark .seg-btn { color: #062028; }
body.dark .seg-btn.is-on { background: #10211f; color: var(--accent); }

/* Card list */
.library { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.lib-card-wrap { position: relative; animation: fadeUp .22s ease both; }
.lib-card {
  display: flex; align-items: center; gap: 14px; padding: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  transition: transform .12s ease, box-shadow .15s ease;
}
.lib-card:hover { box-shadow: 0 6px 18px rgba(0,0,0,.10); transform: translateY(-1px); }
body.dark .lib-card { background: #10211f; }

/* Cover with initials + play overlay */
.lib-cover {
  position: relative; flex: 0 0 auto; width: 64px; height: 64px; border-radius: 14px;
  border: 0; cursor: pointer; overflow: hidden;
  background: linear-gradient(135deg, var(--cv), rgba(0,0,0,.18));
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s ease;
}
.lib-cover:active { transform: scale(.94); }
.lib-cover-ini { color: #fff; font-family: var(--font-brand); font-weight: 700; font-size: 1.5rem; text-shadow: 0 1px 3px rgba(0,0,0,.35); }
.lib-cover-play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.5rem; background: rgba(0,0,0,.28); opacity: 0; transition: opacity .15s;
}
.lib-cover:hover .lib-cover-play, .lib-cover:focus-visible .lib-cover-play { opacity: 1; }

.lib-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.lib-line1 { display: flex; align-items: baseline; gap: 8px; }
.lib-title { flex: 1; min-width: 0; font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-meta { flex: 0 0 auto; color: var(--muted); font-size: .85rem; }
.lib-kebab {
  flex: 0 0 auto; border: 0; background: transparent; cursor: pointer;
  color: var(--muted); font-size: 1.4rem; line-height: 1; padding: 2px 6px; border-radius: 8px;
}
.lib-kebab:hover { background: var(--bg); color: var(--text); }
.lib-sub { margin: 0; color: var(--muted); font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-line3 { display: flex; align-items: center; gap: 12px; }
.lib-bar { flex: 1; height: 8px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.lib-bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--accent-strong); transition: width .4s ease; }
.lib-heart {
  flex: 0 0 auto; border: 0; background: transparent; cursor: pointer;
  color: var(--muted); font-size: 1.5rem; line-height: 1; padding: 2px; transition: transform .12s ease, color .15s;
}
.lib-heart:active { transform: scale(1.25); }
.lib-heart.is-fav { color: #e0556b; }

/* Per-card menu */
.lib-menu {
  position: absolute; right: 10px; top: 58px; z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 10px; min-width: 220px;
  display: flex; flex-direction: column; gap: 8px; animation: fadeUp .14s ease both;
}
body.dark .lib-menu { background: #14302e; }
.lib-menu .rec-move { width: 100%; padding: 10px 12px; font: inherit; border: 2px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); min-height: 44px; }
.lib-menu-item { text-align: left; border: 0; background: transparent; cursor: pointer; font: inherit; font-size: 1rem; padding: 10px 12px; border-radius: 10px; color: var(--text); min-height: 44px; }
.lib-menu-item:hover { background: var(--bg); }
.lib-menu-item.danger { color: var(--danger); font-weight: 700; }

.lib-empty { text-align: center; color: var(--muted); margin: 40px 8px; font-size: 1.05rem; line-height: 1.7; }
.newfolder-row { margin: 4px 0 14px; }

/* =============================== Custom icons ============================== */
.ic { width: 24px; height: 24px; flex: none; display: inline-block; vertical-align: middle; }

/* Header icon buttons (voice, theme, account, logout) */
.icon-btn {
  background: transparent; border: 0; cursor: pointer; color: #15454f;
  padding: 8px; border-radius: 12px; min-width: 44px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, transform .1s;
}
.icon-btn .ic { width: 26px; height: 26px; }
.icon-btn:hover { background: rgba(255,255,255,.22); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.is-off { opacity: .75; }
body.dark .icon-btn { color: var(--brand-cream); }

/* Reading-mode tabs: icon above a small label */
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.tab .ic { width: 24px; height: 24px; }
.tab span { font-size: .78rem; font-weight: 700; }

/* =========================== Bottom navigation ============================ */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; align-items: flex-end; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -2px 14px rgba(0,0,0,.08);
}
.bottombar[hidden] { display: none; }   /* [hidden] must beat display:flex */
.bb-btn {
  flex: 1; background: transparent; border: 0; cursor: pointer; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 2px; min-height: 54px; font: inherit; font-size: .72rem; font-weight: 700;
  transition: color .15s, transform .1s;
}
.bb-btn .ic { width: 26px; height: 26px; }
.bb-btn:active { transform: scale(.94); }
.bb-btn.is-on { color: var(--accent-strong); }
body.dark .bb-btn.is-on { color: var(--accent); }
/* Raised central + button */
.bb-add { color: #fff; justify-content: flex-end; }
.bb-add .ic {
  width: 56px; height: 56px; padding: 14px; margin-top: -26px; border-radius: 50%;
  background: var(--accent-strong); color: #fff; box-shadow: 0 6px 16px rgba(46,102,117,.45);
}
.bb-add:active .ic { transform: scale(.94); }

/* Keep page content clear of the fixed bottom bar */
main { padding-bottom: 96px; }

/* Library toolbar + sort */
.lib-toolbar { display: flex; justify-content: flex-end; margin: 0 0 12px; }
.sort-btn {
  border: 2px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 700; font-size: .92rem; cursor: pointer;
  padding: 8px 16px; border-radius: 999px; min-height: 40px; transition: border-color .15s, background .15s;
}
.sort-btn:hover { border-color: var(--accent-strong); }
body.dark .sort-btn { background: #10211f; }

/* Tap-menu (replaces the dropdown) */
.lib-menu-head { font-weight: 800; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .6px; padding: 4px 12px 2px; }
.lib-menu-item.current { color: var(--accent-strong); font-weight: 800; }
.lib-menu-item.accent { color: var(--accent-strong); font-weight: 800; }
.lib-menu-item.back { color: var(--muted); }
body.dark .lib-menu-item.current, body.dark .lib-menu-item.accent { color: var(--accent); }

/* In-button + contextual icons */
.primary-btn .ic, .seg-btn .ic, .sort-btn .ic { width: 22px; height: 22px; vertical-align: -5px; margin-right: 7px; }
.round-btn .ic { width: 24px; height: 24px; }
.play-btn .ic { width: 30px; height: 30px; }
.capture-icon .ic { width: 64px; height: 64px; color: var(--accent-strong); }
.lib-cover-play .ic { width: 26px; height: 26px; color: #fff; }
.lib-search-icon .ic { width: 20px; height: 20px; color: var(--muted); }
.asst-bubble .ic, .reminder-when .ic { vertical-align: -4px; }
/* Mic "listening" state */
#asstMicBtn.is-listening { background: var(--danger); border-color: var(--danger); }
#asstMicBtn.is-listening .ic { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

/* Pakistani dialect picker */
.dialect-list { display: flex; flex-direction: column; gap: 10px; margin: 10px 0 4px; }
.dialect-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border: 2px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); cursor: pointer; font: inherit;
  text-align: left; min-height: 56px; transition: border-color .15s, background .15s, transform .1s;
}
.dialect-item:hover { border-color: var(--accent-strong); }
.dialect-item:active { transform: scale(.99); }
.dialect-item.is-active { border-color: var(--accent-strong); box-shadow: 0 0 0 3px rgba(46,102,117,.18); }
.dialect-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dialect-name { font-weight: 800; font-size: 1.05rem; }
.dialect-region { color: var(--muted); font-size: .9rem; }
.dialect-badge { flex: 0 0 auto; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; padding: 4px 10px; border-radius: 999px; }
.dialect-badge.live { background: var(--accent-soft); color: #143b44; }
.dialect-badge.soon { background: var(--border); color: var(--muted); }
body.dark .dialect-item { background: #10211f; }
body.dark .dialect-badge.live { color: #06222a; }

/* Voice bank (admin) */
.vb-consent { display: flex; align-items: flex-start; gap: 10px; margin: 10px 0 14px; font-size: .98rem; }
.vb-consent input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--accent-strong); }
.vb-list { margin-top: 14px; }
.vb-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }

/* On-the-go dialect chips on the reading screen */
.rc-dialects { display: flex; flex-wrap: wrap; gap: 8px; }
.rc-dialect-chip {
  padding: 8px 14px; border-radius: 999px; border: 2px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 700;
  cursor: pointer; min-height: 40px; transition: border-color .15s, background .15s;
}
.rc-dialect-chip:hover { border-color: var(--accent-strong); }
.rc-dialect-chip.is-active { background: var(--accent-strong); color: #fff; border-color: var(--accent-strong); }
body.dark .rc-dialect-chip { background: #10211f; }

/* ---- Dark mode: make EVERY form control readable (fixes greyed-out fields) ---- */
body.dark { color-scheme: dark; }   /* native date/time/select pickers render dark */
body.dark input,
body.dark select,
body.dark textarea {
  background-color: #10211f !important;
  color: var(--text) !important;
  border-color: var(--border);
}
body.dark input::placeholder,
body.dark textarea::placeholder { color: var(--muted); opacity: 1; }
body.dark option { background-color: #10211f; color: var(--text); }
/* keep the search field transparent inside its pill */
body.dark .lib-search { background: var(--surface); }
body.dark .lib-search input { background-color: transparent !important; }
