/* ════════════════════════════════════════════════
   MedInterp — Arabic Medical Interpretation Prep
   Shared Stylesheet
   ════════════════════════════════════════════════ */

/* Arabic font — loaded async via <link> in HTML to avoid render-blocking */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 230px;
  --bg: #f5f4f0;
  --surface: #ffffff;
  --border: #d3d1c7;
  --border-light: #e8e5de;
  --text: #1a1a18;
  --muted: #888780;
  --label: #5f5e5a;

  --sidebar-bg: #18181a;
  --sidebar-text: #c2c0bb;
  --sidebar-muted: rgba(255,255,255,0.55);
  --sidebar-hover: rgba(255,255,255,0.07);
  --sidebar-active-bg: rgba(255,255,255,0.12);
  --sidebar-active-txt: #ffffff;
  --sidebar-divider: rgba(255,255,255,0.08);

  --blue: #185FA5;
  --blue-light: #E6F1FB;
  --teal: #0F6E56;
  --teal-light: #E1F5EE;
  --amber: #854F0B;
  --amber-light: #FAEEDA;
  --red: #B91C1C;
  --red-light: #FEE2E2;
  --purple: #534AB7;
  --purple-light: #EEEDFE;

  --ar-font: 'Noto Sans Arabic', 'Arabic Typesetting', 'Traditional Arabic', sans-serif;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  overflow: hidden;
}

/* ── Layout ── */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 50;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 16px;
  text-decoration: none;
  border-bottom: 1px solid var(--sidebar-divider);
  flex-shrink: 0;
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: var(--blue);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  font-family: serif;
  color: #ff4444;
  font-variation-settings: normal;
}

.brand-text { display: flex; flex-direction: column; }
.brand-title { font-size: 13px; font-weight: 700; color: #fff; line-height: 1.2; }
.brand-sub   { font-size: 10.5px; color: var(--sidebar-muted); line-height: 1.2; }

/* Search */
.sidebar-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--sidebar-divider);
  position: relative;
  flex-shrink: 0;
}

.search-wrap { position: relative; }

.search-input {
  width: 100%;
  padding: 7px 10px 7px 28px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  color: #fff;
  font-size: 12.5px;
  outline: none;
  transition: border-color .15s, background .15s;
}

.search-input::placeholder { color: rgba(255,255,255,0.3); }
.search-input:focus { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.25); }

.search-ico {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255,255,255,0.3);
  font-size: 13px;
  pointer-events: none;
}

.search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  max-height: 280px;
  overflow-y: auto;
  z-index: 200;
}

.search-item {
  display: block;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border-light);
  transition: background .1s;
}

.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--bg); }
.search-item-page { font-size: 11px; color: var(--blue); font-weight: 600; margin-bottom: 1px; }
.search-item-term { color: var(--text); }
.search-empty { padding: 12px 14px; font-size: 13px; color: var(--muted); }

.search-section-label {
  padding: 6px 14px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  background: var(--sidebar-bg);
  position: sticky;
  top: 0;
}

.search-loading {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.7;
  font-size: 10px;
}

.search-term-item { display: block; }
.search-term-en   { font-size: 13px; color: var(--text); font-weight: 500; }
.search-term-ar   { font-size: 13px; color: var(--text); margin-top: 1px; }
.search-term-source {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0 16px;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }

.nav-section {
  padding: 14px 14px 5px;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--sidebar-muted);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background .12s, color .12s;
}

.nav-link:hover { background: var(--sidebar-hover); color: #fff; }

.nav-link.active {
  background: var(--sidebar-active-bg);
  border-left-color: #4a90d9;
  color: var(--sidebar-active-txt);
  font-weight: 500;
}

.nav-link.master-link { color: #fde68a; }
.nav-link.master-link:hover { background: rgba(253,230,138,.1); color: #fef3c7; }
.nav-link.master-link.active { border-left-color: #fde68a; background: rgba(253,230,138,.1); }

.nav-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  flex-shrink: 0;
}

.nav-link.active .nav-dot { background: #4a90d9; }
.nav-link.master-link .nav-dot { background: rgba(253,230,138,.4); }
.nav-link.master-link.active .nav-dot { background: #fde68a; }

/* ── Main area ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
}

/* Page header */
.page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  flex-shrink: 0;
}

.page-title-row {
  padding: 18px 0 14px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.page-title { font-size: 20px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* Tabs */
.tabs-wrap {
  position: relative;
}
.tabs-wrap::after {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 40px;
  background: linear-gradient(to right, transparent, var(--surface));
  pointer-events: none;
  z-index: 1;
}
.tabs {
  display: flex;
  gap: 2px;
  padding-top: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-wrap: nowrap;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 10px 14px 12px;
  min-height: 44px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--label);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  white-space: nowrap;
  outline: none;
  transition: color .12s, border-color .12s;
}

.tab:hover { color: var(--blue); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ── Focus indicators (keyboard navigation) ── */
.tab:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
  border-radius: 4px;
}
.nav-link:focus-visible,
.hamburger:focus-visible {
  outline: 2px solid #4a90d9;
  outline-offset: 3px;
  border-radius: 4px;
}
.search-input:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 0;
}
a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Scrollable content */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 40px;
  max-width: 1080px;
}

.page-content::-webkit-scrollbar { width: 5px; }
.page-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Tab panels */
.panel { display: none; }
.panel.active { display: block; }

/* ── Copy row ── */
tr.copyable { cursor: pointer; transition: background .15s; }
tr.copyable:hover td { background: #f0f4ff; }
tr.copied td {
  background: #d1fae5 !important;
  transition: background .15s;
}

/* ── Tables ── */
.tbl {
  width: auto;
  min-width: 320px;
  max-width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 20px;
  font-size: 14px;
}

.tbl th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  background: #f1efe8;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.tbl th.ar { text-align: right; }

.tbl td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
  line-height: 1.6;
}

.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: #faf9f6; }

.tbl td.en { color: var(--text); font-weight: 450; padding-right: 32px; }

.tbl td.ar {
  text-align: right;
  direction: rtl;
  font-size: 16px;
  line-height: 1.9;
  color: #1d1a0e;
  font-family: var(--ar-font);
  width: 50%;
}

/* ── Section headings ── */
.sec-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 20px 0 8px;
}

.sec-label:first-child { margin-top: 0; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.card-title { font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.card-sub   { font-size: 12px; color: var(--muted); margin-bottom: 12px; }

/* ── Red flags ── */
.flag-list { display: flex; flex-direction: column; gap: 8px; }

.flag-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--red-light);
  border: 1px solid #fca5a5;
  border-left: 4px solid #ef4444;
  border-radius: 8px;
  padding: 12px 14px;
}

.flag-icon { font-size: 15px; flex-shrink: 0; margin-top: 1px; }

.flag-item.critical {
  border-left-color: #dc2626;
  background: #fee2e2;
  border-color: #fca5a5;
}

.flag-item.urgent {
  border-left-color: #d97706;
  background: #fef3c7;
  border-color: #fcd34d;
}

.flag-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #7f1d1d;
  margin-bottom: 6px;
}

.flag-item.urgent .flag-title { color: #78350f; }

.flag-en {
  font-size: 13px;
  color: #7f1d1d;
  margin-bottom: 4px;
  line-height: 1.5;
}

.flag-item.urgent .flag-en { color: #78350f; }

.flag-ar {
  font-size: 15px;
  direction: rtl;
  text-align: right;
  color: #991b1b;
  font-family: var(--ar-font);
  display: block;
  line-height: 1.85;
  margin-top: 4px;
}

.flag-item.urgent .flag-ar { color: #92400e; }

.interpreter-note {
  font-size: 12.5px;
  color: #78350f;
  background: var(--amber-light);
  border-left: 3px solid var(--amber);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
  line-height: 1.6;
}

.flag-body .en {
  font-size: 13.5px;
  font-weight: 600;
  color: #7f1d1d;
  margin-bottom: 4px;
}

.flag-body .ar {
  font-size: 15px;
  direction: rtl;
  text-align: right;
  color: #991b1b;
  font-family: var(--ar-font);
  display: block;
}

/* ── Dialogue ── */
.dialogue { display: flex; flex-direction: column; gap: 14px; }

.dl-turn { display: flex; flex-direction: column; gap: 4px; }

.dl-role {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 4px;
  display: block;
}

.role-p  { color: var(--blue); }
.role-pt { color: var(--teal); }
.role-i  { color: var(--amber); }

.dl-en {
  font-size: 13.5px;
  color: var(--label);
  margin-bottom: 2px;
}

.dl-ar {
  font-size: 16px;
  direction: rtl;
  text-align: right;
  color: var(--text);
  font-family: var(--ar-font);
  background: #f5f4f0;
  padding: 8px 12px;
  border-radius: 6px;
  line-height: 1.85;
  display: block;
}

.dl-note {
  font-size: 11.5px;
  color: var(--amber);
  background: var(--amber-light);
  border-radius: 5px;
  padding: 4px 9px;
  display: inline-block;
  margin-top: 2px;
}

/* Dialogue table layout */
.dialogue-note {
  font-size: 12.5px;
  color: var(--muted);
  background: #f5f4ef;
  padding: 8px 14px;
  border-radius: 7px;
  margin-bottom: 14px;
  border-left: 3px solid var(--border);
}

.tbl td.en .dl-role { margin-bottom: 4px; }

.interp-row td {
  background: var(--amber-light);
  font-size: 12.5px;
  color: #7a4f00;
  padding: 10px 14px;
}

.interp-row td .interp-ar {
  direction: rtl;
  text-align: right;
  font-family: var(--ar-font);
  font-size: 14px;
  line-height: 1.8;
  margin-top: 6px;
  color: #7a4f00;
}

/* ── Conditions grid ── */
.conditions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 20px;
}

.cond-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 13px;
}

.cond-en { font-size: 13.5px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.cond-ar {
  font-size: 15px;
  direction: rtl;
  text-align: right;
  color: var(--blue);
  font-family: var(--ar-font);
  line-height: 1.8;
}

/* ── Procedure / treatment list ── */
.proc-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
}

.proc-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
}

.proc-item:last-child { border-bottom: none; }

.proc-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--blue);
  flex-shrink: 0;
  margin-top: 6px;
}

.proc-en { font-size: 13.5px; font-weight: 500; color: var(--text); flex: 1; }
.proc-ar {
  font-size: 15px;
  direction: rtl;
  text-align: right;
  color: var(--blue);
  font-family: var(--ar-font);
  flex: 1;
  line-height: 1.8;
}

/* ── Doc / Insurance ── */
.doc-tbl {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.doc-tbl th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  background: #f1efe8;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.doc-tbl th:last-child { text-align: right; }

.doc-tbl td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
  font-size: 13.5px;
}

.doc-tbl tr:last-child td { border-bottom: none; }
.doc-tbl tr:hover td { background: #faf9f6; }

.doc-tbl td.term { font-weight: 600; color: var(--text); width: 35%; }
.doc-tbl td.def  { color: var(--label); font-size: 12.5px; width: 30%; }
.doc-tbl td.ar   {
  text-align: right;
  direction: rtl;
  font-size: 15px;
  color: var(--blue);
  font-family: var(--ar-font);
  width: 35%;
  line-height: 1.85;
}

/* ── Glossary ── */
/* ── Glossary tables ── */
.table-glossary {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  font-size: 13.5px;
  margin-bottom: 20px;
  table-layout: auto;
}

.table-glossary th {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted);
  background: #f1efe8; padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.table-glossary th.ar { text-align: right; }

.table-glossary td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
  line-height: 1.6;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
}

.table-glossary tr:last-child td { border-bottom: none; }
.table-glossary tr:hover td { background: #faf9f6; }

.table-glossary td.en,
.table-glossary td.term {
  width: 25%;
  font-weight: 600;
  color: var(--blue);
}

.table-glossary td.ar {
  width: 25%;
  text-align: right;
  direction: rtl;
  font-size: 15.5px;
  color: var(--text);
  font-family: var(--ar-font);
  line-height: 1.9;
}

/* ── Badges ── */
.badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 20px;
  display: inline-block;
}

.b-teal   { background: var(--teal-light);   color: var(--teal); }
.b-blue   { background: var(--blue-light);   color: var(--blue); }
.b-red    { background: var(--red-light);    color: var(--red); }
.b-amber  { background: var(--amber-light);  color: var(--amber); }
.b-purple { background: var(--purple-light); color: var(--purple); }

/* ── Home page ── */
.home-hero {
  background: linear-gradient(135deg, #18181a 0%, #1c2b44 100%);
  color: #fff;
  padding: 36px 28px;
  margin: -24px -28px 24px;
  border-radius: 0 0 14px 14px;
}

.hero-title { font-size: 28px; font-weight: 800; line-height: 1.2; margin-bottom: 6px; }
.hero-sub   { font-size: 14px; opacity: .6; margin-bottom: 16px; }
.hero-badges { display: flex; flex-wrap: wrap; gap: 6px; }

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.home-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: box-shadow .15s, border-color .15s, transform .12s;
}

.home-card:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,.07);
  border-color: #b8b5ad;
  transform: translateY(-1px);
}

.home-card.master-card {
  background: linear-gradient(135deg, #fefce8, #fef9c3);
  border: 1px solid #fbbf24;
  border-radius: 10px;
  padding: 14px 16px;
  display: block;
  margin-bottom: 20px;
  transition: box-shadow .15s, border-color .15s;
}

.home-card.master-card:hover {
  box-shadow: 0 3px 10px rgba(0,0,0,.07);
  border-color: #f59e0b;
}

.master-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  margin-bottom: 0;
}

.master-card-link:hover { text-decoration: none; }

.master-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #fde68a;
}

.master-quick-label {
  font-size: 10.5px;
  font-weight: 700;
  color: #92400e;
  margin-right: 2px;
  white-space: nowrap;
}

.master-pill {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
  background: #fde68a;
  border: 1px solid #fbbf24;
  color: #78350f;
  text-decoration: none;
  transition: background .15s;
}

.master-pill:hover { background: #fbbf24; }

.hc-icon { font-size: 24px; margin-bottom: 8px; }

.hc-title { font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.hc-desc  { font-size: 12px; color: var(--muted); line-height: 1.5; }

.master-card .hc-title { font-size: 15px; font-weight: 700; color: #78350f; margin-bottom: 4px; }
.master-card .hc-desc  { font-size: 12.5px; color: #a16207; line-height: 1.5; }

.home-section-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .09em; color: var(--muted);
  margin: 24px 0 10px;
}

/* ── Note / info box ── */
.note {
  background: var(--blue-light);
  border: 1px solid #bfdbfe;
  border-left: 4px solid var(--blue);
  border-radius: 7px;
  padding: 11px 14px;
  font-size: 13px;
  color: #1e3a8a;
  margin-bottom: 16px;
  line-height: 1.55;
}

/* ── Master page hero ── */
.master-hero {
  background: linear-gradient(135deg, #78350f 0%, #92400e 100%);
  color: #fff;
  padding: 36px 28px;
  margin: -24px -28px 24px;
  border-radius: 0 0 14px 14px;
}

/* Utility */
.divider { border: none; border-top: 1px solid var(--border-light); margin: 20px 0; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.table-medical {
  width: auto;
  min-width: 320px;
  max-width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 15px;
}

/* make columns controlled and closer */
.table-medical th,
.table-medical td {
  padding: 6px 12px;
}

/* English column */
.table-medical th:first-child,
.table-medical td:first-child {
  text-align: left;
  padding-right: 32px;
}

/* Arabic column */
.table-medical th:last-child,
.table-medical td:last-child {
  text-align: right;
  direction: rtl;
}

/* optional styling */
.table-medical th {
  background-color: #f5f5f5;
  font-weight: 600;
  border-bottom: 1px solid #ddd;
}

.table-medical td {
  border-bottom: 1px solid #eee;
}

/* ══════════════════════════════════════════════════
   Mobile Responsive  ≤ 768px
   ══════════════════════════════════════════════════ */

/* ── Overlay & hamburger elements (desktop: hidden) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.50);
  z-index: 149;
}
.sidebar-overlay.visible { display: block; }

.mobile-topbar { display: none; }

.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 14px 11px;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

.mobile-brand {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -.01em;
}

.mobile-home-btn {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  white-space: nowrap;
}

.bottom-home-link {
  text-align: center;
  padding: 32px 16px 24px;
  border-top: 1px solid var(--gray-200);
  margin-top: 24px;
}

.bottom-home-link a {
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  padding: 8px 20px;
  border: 1px solid var(--primary);
  border-radius: 8px;
}

.bottom-home-link a:hover {
  background: var(--primary);
  color: #fff;
}

/* ─── Vocab card grid ─── */
.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.vocab-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.12s;
}

.vocab-card:hover { background: #faf9f6; }
.vocab-card.copied { background: var(--teal-light); }

.vocab-en {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.vocab-ar {
  font-size: 15px;
  color: var(--blue);
  font-family: var(--ar-font);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 600px) {
  .vocab-grid {
    grid-template-columns: 1fr;
  }
}

/* ─── Prev / Next specialty nav ─── */
.prev-next-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 20px 0 4px;
  margin-top: 16px;
  border-top: 1px solid var(--border-light);
}

.prev-next-btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
  text-decoration: none;
  background: var(--surface);
  transition: background 0.15s, border-color 0.15s;
  min-height: 38px;
}

.prev-next-btn:hover {
  background: var(--blue-light);
  border-color: var(--blue);
}

.prev-next-btn.disabled {
  visibility: hidden;
  pointer-events: none;
}

@media (max-width: 768px) {

  /* ── Scrolling model: let the whole page scroll ── */
  html, body {
    overflow: auto;
    height: auto;
  }

  body.sidebar-open { overflow: hidden; }

  .app {
    display: block;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  /* ── Sidebar: hidden off-screen, slides in ── */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 150;
  }
  .sidebar.open { transform: translateX(0); }

  /* ── Main: full width, natural height ── */
  .main {
    margin-left: 0;
    height: auto;
    min-height: 100vh;
    overflow: visible;
    display: block;
  }

  /* ── Mobile top bar ── */
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
  }

  /* ── Page header & content ── */
  .page-header  { padding: 0 14px; }
  .page-title   { font-size: 17px; }
  .page-title-row { padding: 14px 0 10px; }
  .page-content {
    overflow: visible;
    height: auto;
    padding: 16px 14px 48px;
  }

  /* ── Heroes ── */
  .home-hero   { padding: 24px 14px; margin: -16px -14px 20px; }
  .master-hero { padding: 24px 14px; margin: -16px -14px 20px; }
  .hero-title  { font-size: 20px; }

  /* ── Master reference card ── */
  .home-card.master-card { padding: 12px 14px; margin-bottom: 16px; }
  .master-card .hc-title { font-size: 14px; }
  .master-card .hc-desc  { font-size: 12px; }
  .master-pills { gap: 5px; margin-top: 8px; padding-top: 8px; }
  .master-pill  { font-size: 10px; padding: 2px 9px; }

  /* ── Home grid → single column ── */
  .home-grid { grid-template-columns: 1fr; }

  /* ── Conditions grid → single column ── */
  .conditions-grid { grid-template-columns: 1fr; }

  /* ── Tables: allow horizontal scroll ── */
  .tbl,
  .table-glossary,
  .doc-tbl,
  .table-medical {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  /* Keep table cells from collapsing too much */
  .tbl td.en,
  .tbl th    { min-width: 160px; }
  .tbl td.ar { min-width: 160px; }

  /* ── Flag list: tighter on mobile ── */
  .flag-body .en { font-size: 13px; }

  /* ── Proc list: single column ── */
  .proc-list { columns: 1; }

  /* ── Back to top: reposition on mobile ── */
  .back-to-top { bottom: 16px; right: 16px; width: 36px; height: 36px; font-size: 16px; }
}

/* ── Back to top button ── */
.back-to-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s, visibility .2s, transform .2s;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.back-to-top.visible { opacity: 1; visibility: visible; }
.back-to-top:hover   { background: #1454a0; transform: translateY(-2px); }
.back-to-top:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ── Loading spinner ── */
.panel-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 24px;
  color: var(--muted);
  font-size: 13.5px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Error state ── */
.panel-error {
  padding: 32px 24px;
  color: var(--red);
  font-size: 14px;
  background: var(--red-light);
  border-radius: 8px;
  margin: 16px 0;
  text-align: center;
}

/* ── Breadcrumb ── */
.breadcrumb {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 0 0;
}

.breadcrumb a {
  color: var(--blue);
  text-decoration: none;
}

.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { margin: 0 4px; }

/* ── Start here tip on home ── */
.start-here-tip {
  background: var(--blue-light);
  border: 1px solid var(--blue);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 20px;
  font-size: 13.5px;
  color: var(--blue);
  line-height: 1.6;
}

.start-here-tip strong { display: block; margin-bottom: 4px; font-size: 14px; }

/* ── Print styles ── */
@media print {
  .sidebar, .mobile-topbar, .sidebar-overlay,
  .back-to-top, .tabs { display: none !important; }

  .app, .main { display: block !important; }
  .main { margin-left: 0 !important; }

  .page-content {
    overflow: visible !important;
    height: auto !important;
    padding: 0 !important;
  }

  /* Show all tab panels when printing */
  .panel { display: block !important; margin-bottom: 24px; }

  /* Reset table overflow for print */
  .tbl, .table-glossary, .doc-tbl, .table-medical {
    display: table !important;
    width: 100% !important;
    overflow: visible !important;
  }

  /* Strip hero backgrounds */
  .home-hero, .master-hero {
    background: none !important;
    color: var(--text) !important;
    border: 1px solid var(--border);
    margin: 0 0 16px !important;
    padding: 12px !important;
    border-radius: 8px;
  }

  /* Prevent awkward page breaks */
  .flag-item, .cond-item, .proc-item, .tbl tr { break-inside: avoid; }

  a { color: var(--text) !important; text-decoration: none !important; }
}

/* ════════════════════════════════════════
   ACTION BUTTONS — speak + favorite
   ════════════════════════════════════════ */

.term-actions {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  opacity: 0;
  transition: opacity 0.15s;
}
.vocab-card:hover .term-actions,
.cond-item:hover .term-actions,
.proc-item:hover .term-actions,
tr:hover .term-actions {
  opacity: 1;
}
/* Always visible on touch devices */
@media (hover: none) {
  .term-actions { opacity: 1; }
}

.card-actions {
  margin-top: 6px;
  justify-content: flex-end;
}

td.actions-cell {
  white-space: nowrap;
  padding: 6px 8px;
  text-align: right;
  width: 1%;
}

.btn-speak,
.btn-fav {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
  transition: transform 0.15s, background 0.15s;
}
.btn-speak:hover { background: rgba(24,95,165,0.12); transform: scale(1.15); }
.btn-fav:hover   { background: rgba(253,200,48,0.15);  transform: scale(1.15); }
.btn-fav.fav-active { color: #f59e0b; }

@keyframes fav-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.5); }
  100% { transform: scale(1); }
}
.fav-pop { animation: fav-pop 0.35s ease; }

.btn-speak.speaking { animation: pulse-speak 0.6s infinite alternate; }
@keyframes pulse-speak {
  from { opacity: 0.6; }
  to   { opacity: 1; }
}

/* Favorites badge in sidebar */
.fav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--blue);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 0 5px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Recently viewed section in sidebar */
.recent-section { margin-top: 8px; }
.recent-link { font-size: 12.5px; opacity: 0.85; }

/* ════════════════════════════════════════
   PREP MODE BUTTON
   ════════════════════════════════════════ */

.prep-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  margin-left: auto;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.prep-mode-btn:hover  { background: #1570c4; transform: translateY(-1px); }
.prep-mode-btn:active { transform: translateY(0); }

/* ════════════════════════════════════════
   PREP MODE OVERLAY
   ════════════════════════════════════════ */

.prep-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
}

.prep-modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.35);
}

.prep-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  background: var(--sidebar-bg);
  color: #fff;
}
.prep-title    { font-weight: 700; font-size: 14px; flex: 1; color: #fff; }
.prep-progress { font-size: 12px; color: rgba(255,255,255,0.6); }
.prep-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.prep-close:hover { background: rgba(255,255,255,0.12); }

.prep-progress-bar {
  height: 3px;
  background: var(--border-light);
}
.prep-progress-fill {
  height: 3px;
  background: var(--blue);
  transition: width 0.3s ease;
}

.prep-card {
  min-height: 200px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  user-select: none;
  gap: 10px;
  transition: background 0.2s;
}
.prep-card:hover  { background: var(--bg); }
.prep-card:focus  { outline: 2px solid var(--blue); outline-offset: -4px; }

.prep-card-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.prep-card-en {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}
.prep-card-ar {
  font-size: 28px;
  font-weight: 600;
  color: var(--blue);
  font-family: var(--ar-font);
  line-height: 1.4;
  direction: rtl;
}
.prep-flip-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.prep-card-back {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}
.prep-speak {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.prep-speak:hover { background: var(--blue-light); border-color: var(--blue); }

.prep-controls {
  display: flex;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--bg);
}
.prep-btn {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.prep-btn:hover:not(:disabled) { background: var(--blue-light); border-color: var(--blue); color: var(--blue); }
.prep-btn:disabled { opacity: 0.35; cursor: default; }
.prep-next { background: var(--blue); color: #fff; border-color: var(--blue); }
.prep-next:hover:not(:disabled) { background: #1570c4 !important; border-color: #1570c4 !important; color: #fff !important; }

.prep-summary {
  padding: 16px 20px;
  text-align: center;
  color: var(--label);
  font-size: 14px;
  border-top: 1px solid var(--border-light);
}
.prep-summary p { margin-bottom: 10px; }

body.prep-open { overflow: hidden; }

@media (max-width: 480px) {
  .prep-card-en { font-size: 20px; }
  .prep-card-ar { font-size: 22px; }
  .prep-modal   { border-radius: 12px; }
}

/* ════════════════════════════════════════
   FAVORITES PAGE
   ════════════════════════════════════════ */

.favs-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.favs-empty .empty-icon  { font-size: 48px; margin-bottom: 12px; }
.favs-empty p            { font-size: 15px; }

.favs-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.favs-count { font-size: 13px; color: var(--muted); }
.favs-clear {
  margin-left: auto;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: none;
  font-size: 13px;
  cursor: pointer;
  color: var(--label);
  transition: background 0.15s, border-color 0.15s;
}
.favs-clear:hover { background: var(--red-light); border-color: var(--red); color: var(--red); }

.favs-group { margin-bottom: 28px; }
.favs-group-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}

.fav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}
.fav-item:last-child { border-bottom: none; }
.fav-item-en  { flex: 1; font-size: 14px; font-weight: 500; }
.fav-item-ar  { font-size: 16px; color: var(--blue); font-family: var(--ar-font); direction: rtl; lang: ar; }
.fav-item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.fav-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.fav-remove:hover { color: var(--red); background: var(--red-light); }

/* ════════════════════════════════════════
   STUDY MODE BUTTON (specialty pages)
   ════════════════════════════════════════ */

.study-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.study-mode-btn:hover  { background: #0d5e48; transform: translateY(-1px); }
.study-mode-btn:active { transform: translateY(0); }

.study-due-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #f59e0b;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 0 5px;
}
.study-all-done { font-size: 13px; opacity: 0.85; }

/* ════════════════════════════════════════
   STUDY SESSION OVERLAY
   ════════════════════════════════════════ */

.study-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
}

.study-modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.4);
}

.study-hdr {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 20px;
  background: var(--sidebar-bg);
  color: #fff;
}
.study-title   { font-weight: 700; font-size: 14px; flex: 1; color: #fff; }
.study-counter { font-size: 12px; color: rgba(255,255,255,0.55); }
.study-close {
  background: none; border: none;
  color: rgba(255,255,255,0.65);
  font-size: 16px; cursor: pointer;
  padding: 4px 8px; border-radius: 4px;
}
.study-close:hover { background: rgba(255,255,255,0.12); }

.study-pbar {
  height: 3px;
  background: rgba(255,255,255,0.12);
}
.study-pbar-fill {
  height: 3px;
  background: var(--teal);
  transition: width 0.35s ease;
}

/* Card */
.study-card {
  padding: 32px 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  min-height: 190px;
}
.study-card-top { display: flex; gap: 6px; }
.study-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.03em;
}
.badge-new    { background: #dbeafe; color: #1d4ed8; }
.badge-review { background: var(--teal-light); color: var(--teal); }

.study-card-en {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}
.study-divider {
  width: 48px;
  height: 2px;
  background: var(--border);
  border-radius: 1px;
  margin: 4px 0;
}
.study-card-ar {
  font-size: 28px;
  font-weight: 600;
  color: var(--blue);
  font-family: var(--ar-font);
  line-height: 1.4;
  direction: rtl;
}
.study-speak-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.15s;
}
.study-speak-btn:hover { background: var(--blue-light); border-color: var(--blue); }
.study-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: auto;
}

/* Show Answer */
.study-show-wrap {
  padding: 14px 20px 20px;
  display: flex;
  justify-content: center;
}
.study-show-btn {
  padding: 12px 40px;
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.study-show-btn:hover { background: #0d5e48; }

/* Rating buttons */
.study-ratings {
  padding: 4px 16px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--bg);
}
.study-ratings-lbl {
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
  margin: 10px 0 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.study-rating-row { display: flex; gap: 6px; }
.srate {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 6px;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: background 0.12s, transform 0.1s, border-color 0.12s;
}
.srate:active { transform: scale(0.96); }
.srate-lbl { font-size: 13px; font-weight: 700; }
.srate-int { font-size: 11px; font-weight: 400; opacity: 0.75; }

.srate.again { background: #fee2e2; color: #b91c1c; }
.srate.again:hover { background: #fecaca; border-color: #b91c1c; }
.srate.hard  { background: #fff7ed; color: #c2410c; }
.srate.hard:hover  { background: #fed7aa; border-color: #c2410c; }
.srate.good  { background: var(--teal-light); color: var(--teal); }
.srate.good:hover  { background: #a7f3d0; border-color: var(--teal); }
.srate.easy  { background: var(--blue-light); color: var(--blue); }
.srate.easy:hover  { background: #bfdbfe; border-color: var(--blue); }

.study-key-hint {
  text-align: center;
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 10px;
}

/* Done screen */
.study-done {
  padding: 36px 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.study-done-icon  { font-size: 48px; }
.study-done-title { font-size: 22px; font-weight: 700; }
.study-done-sub   { font-size: 14px; color: var(--label); }
.study-next-due   { font-size: 13px; color: var(--muted); }
.study-done-pills { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 4px 0 12px; }

.pill-again, .pill-hard, .pill-good, .pill-easy {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}
.pill-again { background: #fee2e2; color: #b91c1c; }
.pill-hard  { background: #fff7ed; color: #c2410c; }
.pill-good  { background: var(--teal-light); color: var(--teal); }
.pill-easy  { background: var(--blue-light); color: var(--blue); }

.study-btn-primary {
  padding: 12px 32px;
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 8px;
}
.study-btn-primary:hover { background: #0d5e48; }

body.study-open { overflow: hidden; }

@media (max-width: 480px) {
  .study-card-en { font-size: 20px; }
  .study-card-ar { font-size: 22px; }
  .srate-lbl     { font-size: 12px; }
  .study-modal   { border-radius: 12px; }
}

/* ════════════════════════════════════════
   STUDY DASHBOARD (study.html)
   ════════════════════════════════════════ */

.study-dash-empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
}
.study-dash-empty .empty-icon { font-size: 52px; margin-bottom: 12px; }
.study-dash-empty h2 { font-size: 20px; color: var(--text); margin-bottom: 8px; }
.study-dash-empty p  { font-size: 14px; }

.study-dash { max-width: 600px; }

/* Global stat strip */
.study-stat-row {
  display: flex;
  gap: 2px;
  background: var(--border-light);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
}
.study-stat {
  flex: 1;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 8px;
  gap: 2px;
}
.study-stat.due { background: #f0fdf4; }
.ss-num { font-size: 24px; font-weight: 800; color: var(--text); }
.ss-lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.study-stat.due .ss-num { color: var(--teal); }

.study-all-btn {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 28px;
  transition: background 0.15s;
}
.study-all-btn:hover { background: #0d5e48; }

.study-all-caught {
  text-align: center;
  padding: 14px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  font-size: 14px;
  color: var(--teal);
  font-weight: 600;
  margin-bottom: 28px;
}

.study-deck-heading {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 10px;
}

.study-deck-list { display: flex; flex-direction: column; gap: 2px; }
.study-deck-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border-light);
}
.study-deck-info  { flex: 1; min-width: 0; }
.study-deck-name  {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  display: block;
}
.study-deck-name:hover { color: var(--blue); }
.study-deck-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 3px; }
.dstat {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 600;
}
.dstat.total    { background: var(--bg); color: var(--muted); }
.dstat.due      { background: #fef9c3; color: #854d0e; }
.dstat.learning { background: var(--blue-light); color: var(--blue); }
.dstat.mastered { background: #f0fdf4; color: var(--teal); }

.study-deck-btn {
  padding: 7px 14px;
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  flex-shrink: 0;
}
.study-deck-btn:hover { background: #0d5e48; }
.study-deck-done {
  font-size: 13px;
  color: var(--teal);
  font-weight: 600;
  white-space: nowrap;
}

.study-dash-footer {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.study-dash-footer p { font-size: 13px; color: var(--muted); flex: 1; }
.study-clear-btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: none;
  font-size: 13px;
  cursor: pointer;
  color: var(--label);
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.study-clear-btn:hover { background: var(--red-light); border-color: var(--red); color: var(--red); }
