/* ==========================================================================
   Quran Research — 4-Pane Collapsible & Shiftable SPA Styles
   Builds on Corpus.quran.com segment colors & typography from easy-word-by-word
   ========================================================================== */

:root {
  /* Corpus.quran.com segment colors */
  --seg-navy: rgb(19, 1, 184);
  --seg-sky: rgb(42, 112, 194);
  --seg-purple: rgb(129, 38, 192);
  --seg-gold: rgb(156, 128, 12);
  --seg-seagreen: rgb(35, 155, 33);
  --seg-rust: rgb(173, 35, 35);
  --seg-orange: rgb(217, 102, 11);
  --seg-metal: rgb(82, 102, 122);

  /* Theme tokens */
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --surface-hover: #f1f5f9;
  --text-body: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #1d4ed8;
  --primary-soft: #dbeafe;

  /* Yellow highlight frame colors matching user sketch */
  --phrase-yellow-bg: rgba(254, 240, 138, 0.55);
  --phrase-yellow-border: #eab308;
  --word-active-bg: #fef08a;
  --word-active-ring: #ca8a04;
  --clue-highlight-bg: #fef08a;
  --attested-green-bg: #dcfce7;
  --attested-green-border: #16a34a;

  --word-image-slot: 84px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text-body);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  overflow: hidden;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ==========================================================================
   Topbar & Subbar
   ========================================================================== */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-badge {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #fff;
  font-family: "Amiri Quran", "Amiri", serif;
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.brand-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  margin: 0;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.verse-nav-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-field {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}

.nav-field select {
  padding: 0.32rem 0.5rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-body);
  font: inherit;
  font-weight: 500;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.36rem 0.75rem;
  border-radius: 6px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.btn-sm {
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: #1e40af;
}

.btn-outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text-body);
}

.btn-outline:hover {
  background: var(--surface-hover);
}

.btn-auth {
  background: #f8fafc;
  border-color: var(--border-strong);
  color: var(--text-body);
}

.auth-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}

.auth-dot.is-online {
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2);
}

.btn-link {
  border: none;
  background: none;
  color: var(--primary);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.btn-link:hover {
  text-decoration: underline;
}

/* Dropdown */
.dropdown-wrap {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: 260px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
  padding: 0.5rem;
  z-index: 60;
}

.dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.bookmarks-list {
  max-height: 220px;
  overflow-y: auto;
  margin-top: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.bookmark-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.45rem;
  border-radius: 5px;
  font-size: 0.78rem;
  cursor: pointer;
}

.bookmark-item:hover {
  background: var(--surface-hover);
}

/* Subbar */
.subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.3rem 1rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  font-size: 0.76rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.status-banner {
  color: var(--primary);
  font-weight: 600;
}

.status-banner.is-error {
  color: #dc2626;
}

.collapsed-dock {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.dock-label {
  font-weight: 600;
  color: var(--text-muted);
}

.dock-pill {
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.73rem;
  font-weight: 600;
  cursor: pointer;
}

.active-context-pill {
  margin-left: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   4-Pane Workspace Layout (Collapsible, Shiftable, Resizable)
   ========================================================================== */

.workspace {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
  padding: 0.5rem;
  overflow-x: auto;
  overflow-y: hidden;
  min-height: 0;
}

.workspace-pane {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  min-width: 180px;
  min-height: 0;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: box-shadow 0.15s, border-color 0.15s;
}

.workspace-pane.is-dragging {
  opacity: 0.55;
}

.workspace-pane.drag-over-left {
  border-left: 3px solid var(--primary);
}

.workspace-pane.drag-over-right {
  border-right: 3px solid var(--primary);
}

/* Collapsed State */
.workspace-pane.is-collapsed {
  min-width: 42px !important;
  max-width: 42px !important;
  flex: 0 0 42px !important;
  background: var(--surface-subtle);
}

.workspace-pane.is-collapsed .pane-header,
.workspace-pane.is-collapsed .pane-body {
  display: none;
}

.pane-collapsed-rail {
  display: none;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 0.85rem;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
  color: var(--text-body);
}

.pane-collapsed-rail:hover {
  background: #e2e8f0;
}

.workspace-pane.is-collapsed .pane-collapsed-rail {
  display: flex;
}

.rail-expand-icon {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.rail-title {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

/* Splitter between open panes */
.pane-splitter {
  width: 8px;
  flex: 0 0 8px;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  user-select: none;
}

.pane-splitter::after {
  content: "";
  width: 2px;
  height: 36px;
  border-radius: 2px;
  background: var(--border-strong);
  transition: background 0.15s, height 0.15s;
}

.pane-splitter:hover::after,
.pane-splitter.is-active::after {
  background: var(--primary);
  height: 64px;
}

/* Pane Header */
.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.5rem 0.65rem;
  background: var(--surface-subtle);
  border-bottom: 2px solid var(--text-body);
  flex-shrink: 0;
}

.pane-title-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: grab;
  min-width: 0;
}

.pane-title-group:active {
  cursor: grabbing;
}

.drag-grip {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1;
}

.pane-header h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
}

.pane-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.42rem;
  border-radius: 4px;
  background: #e2e8f0;
  color: #334155;
  white-space: nowrap;
}

.pane-controls {
  display: flex;
  align-items: center;
  gap: 0.22rem;
  flex-shrink: 0;
}

.btn-icon {
  width: 25px;
  height: 25px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-body);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.btn-icon:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: #94a3b8;
}

.btn-icon:disabled {
  opacity: 0.35;
  cursor: default;
}

.btn-audio-play {
  background: #eff6ff;
  border-color: #93c5fd;
  color: var(--primary);
}

.btn-audio-play.is-playing {
  background: #fef08a;
  border-color: #ca8a04;
  color: #854d0e;
}

.btn-chip {
  padding: 0.18rem 0.48rem;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-chip.is-active {
  background: #fef9c3;
  border-color: #eab308;
  color: #713f12;
}

/* Pane Body */
.pane-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ==========================================================================
   PANE 1: Ayat (Phrase-wise & Word-by-Word + Audio)
   ========================================================================== */

.ayat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.73rem;
  color: var(--text-muted);
  padding-bottom: 0.35rem;
  border-bottom: 1px dashed var(--border);
}

.hint-mark {
  background: var(--phrase-yellow-bg);
  border: 1px solid var(--phrase-yellow-border);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  font-weight: 600;
}

.verses-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ayah-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem;
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}

.ayah-block.is-active-ayah {
  border-color: #93c5fd;
  background: #f8fafc;
}

.ayah-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.55rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.ayah-ref-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-body);
  cursor: pointer;
}

.ayah-play-mini {
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.ayah-play-mini:hover {
  background: #eff6ff;
  color: var(--primary);
}

/* Phrase Flow Container (RTL) */
.phrases-flow {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.65rem;
  direction: rtl;
  justify-content: flex-start;
  align-items: stretch;
}

.phrase-box {
  display: flex;
  flex-direction: column;
  border: 1.5px solid transparent;
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  background: #f8fafc;
  transition: all 0.15s;
  position: relative;
}

.phrases-flow.phrases-enabled .phrase-box {
  border-color: #cbd5e1;
}

/* Yellow highlighted phrase frame (matching sketch!) */
.phrase-box.is-highlighted-phrase {
  background: var(--phrase-yellow-bg);
  border-color: var(--phrase-yellow-border);
  box-shadow: 0 1px 4px rgba(234, 179, 8, 0.2);
}

.phrase-box.is-active-phrase {
  border-color: #ca8a04;
}

.phrase-words-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.55rem;
  direction: rtl;
  align-items: flex-start;
}

.phrase-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-top: 0.35rem;
  padding-top: 0.25rem;
  border-top: 1px dashed rgba(100, 116, 139, 0.25);
  direction: ltr;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.phrase-meaning-gloss {
  font-style: italic;
  color: #334155;
}

.phrase-highlight-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 4px;
  font-size: 0.66rem;
  padding: 0.08rem 0.35rem;
  cursor: pointer;
  color: var(--text-muted);
}

.phrase-box.is-highlighted-phrase .phrase-highlight-btn {
  background: #fde047;
  border-color: #ca8a04;
  color: #713f12;
  font-weight: 700;
}

/* Individual Word Tile */
.wbw-word-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, background 0.12s, border-color 0.12s;
  min-width: 64px;
  user-select: none;
}

.wbw-word-card:hover {
  background: rgba(255, 255, 255, 0.85);
  border-color: #94a3b8;
}

.wbw-word-card.is-active-word {
  background: var(--word-active-bg);
  border-color: var(--word-active-ring);
  box-shadow: 0 0 0 2px rgba(202, 138, 4, 0.25);
}

.wbw-word-card.is-speaking {
  outline: 2px solid var(--primary);
}

.wbw-arabic-slot {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  direction: rtl;
  gap: 0.25rem;
}

.arabic-word {
  font-family: "Amiri Quran", "Amiri", serif;
  font-size: 1.65rem;
  line-height: 1.35;
  direction: rtl;
  white-space: nowrap;
}

.wbw-translit {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.75rem;
  font-style: italic;
  color: var(--primary);
  margin-top: 0.15rem;
  direction: ltr;
}

.wbw-meaning {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-body);
  text-align: center;
  max-width: 6.5rem;
  line-height: 1.25;
  margin-top: 0.1rem;
  direction: ltr;
}

.wbw-pos-mini {
  font-size: 0.63rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  direction: ltr;
}

/* Corpus POS colors */
.seg-navy { color: var(--seg-navy); }
.seg-sky { color: var(--seg-sky); }
.seg-purple { color: var(--seg-purple); }
.seg-gold { color: var(--seg-gold); }
.seg-seagreen { color: var(--seg-seagreen); }
.seg-rust { color: var(--seg-rust); }
.seg-orange { color: var(--seg-orange); }
.seg-metal { color: var(--seg-metal); }

.ayah-end-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55em;
  height: 1.55em;
  border: 1.5px solid var(--text-body);
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
  margin-right: 0.2rem;
}

/* POS Legend */
.pos-legend {
  margin-top: auto;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.legend-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.7rem;
  font-size: 0.72rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.dot-navy { background: var(--seg-navy); }
.dot-sky { background: var(--seg-sky); }
.dot-purple { background: var(--seg-purple); }
.dot-gold { background: var(--seg-gold); }
.dot-seagreen { background: var(--seg-seagreen); }
.dot-rust { background: var(--seg-rust); }
.dot-orange { background: var(--seg-orange); }
.dot-metal { background: var(--seg-metal); }

/* ==========================================================================
   PANE 2 & 3: Selector Pills (Tafsirs & Translations) + Context Highlights
   ========================================================================== */

.selector-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding-bottom: 0.55rem;
  border-bottom: 1.5px solid var(--text-body);
}

.edition-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.26rem 0.6rem;
  border-radius: 6px;
  border: 1.5px solid var(--text-body);
  background: var(--surface);
  color: var(--text-body);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}

.edition-pill:hover {
  background: var(--surface-hover);
}

/* Shaded pill matching user sketch for active Ibn Kathir / Abdullah Y. Ali */
.edition-pill.is-selected {
  background: #cbd5e1;
  color: #0f172a;
  font-weight: 700;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
}

.edition-lang-tag {
  font-size: 0.62rem;
  padding: 0.05rem 0.28rem;
  border-radius: 3px;
  background: rgba(15, 23, 42, 0.1);
}

.more-editions-select {
  padding: 0.24rem 0.45rem;
  border-radius: 6px;
  border: 1.5px solid var(--text-body);
  background: var(--surface);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.context-clue-bar,
.phrase-meaning-banner {
  background: #fefce8;
  border: 1px solid #fde047;
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  font-size: 0.76rem;
  color: #713f12;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
}

.context-clue-highlight {
  background: var(--clue-highlight-bg);
  color: #0f172a;
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
  border-bottom: 2px solid #ca8a04;
  font-weight: 600;
}

/* Tafsir Cards */
.tafsir-content-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.tafsir-article {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  background: var(--surface);
}

.tafsir-article-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.tafsir-source-title {
  font-weight: 700;
  font-size: 0.84rem;
}

.tafsir-body {
  font-size: 0.86rem;
  line-height: 1.65;
  color: #1e293b;
}

.tafsir-body[dir="rtl"] {
  font-family: "Amiri", serif;
  font-size: 1.08rem;
  line-height: 1.85;
}

.tafsir-body p {
  margin: 0 0 0.65rem;
}

.tafsir-body h1,
.tafsir-body h2,
.tafsir-body h3 {
  font-size: 0.92rem;
  margin: 0.75rem 0 0.35rem;
}

/* Tafsir Translation Project Box */
.tafsir-project-card {
  margin-top: auto;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  padding: 0.65rem;
  background: var(--surface-subtle);
  font-size: 0.76rem;
}

.project-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.project-card-header p {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.suggestions-preview {
  margin-top: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.suggestion-chip {
  font-size: 0.71rem;
  padding: 0.22rem 0.45rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
}

/* Translation Cards */
.translations-stream {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.translation-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  background: var(--surface);
}

.translation-card.is-active-ayah-trans {
  border-color: #eab308;
  background: #fefce8;
}

.translation-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}

.translation-text {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-body);
}

/* ==========================================================================
   PANE 4: Current Word (Stepper, Root, ACON Conjugation Grid & Concordance)
   ========================================================================== */

.word-focus-card {
  border: 1.5px solid var(--text-body);
  border-radius: 8px;
  padding: 0.65rem;
  background: var(--surface-subtle);
  text-align: center;
}

.word-meaning-bracket {
  font-size: 0.82rem;
  font-weight: 700;
  color: #334155;
}

.word-stepper-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  margin: 0.25rem 0;
}

.word-stepper-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-weight: 700;
  cursor: pointer;
}

.word-stepper-btn:hover:not(:disabled) {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.word-focus-arabic {
  font-family: "Amiri Quran", "Amiri", serif;
  font-size: 2.1rem;
  line-height: 1.25;
  cursor: pointer;
  padding: 0.1rem 0.5rem;
  border-radius: 6px;
}

.word-focus-arabic:hover {
  background: var(--phrase-yellow-bg);
}

.word-root-grammar-summary {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.4rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--border);
  text-align: start;
  font-size: 0.78rem;
}

.root-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.root-arabic-letters {
  font-family: "Amiri", serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 0.05rem 0.45rem;
  border-radius: 4px;
}

.grammar-gloss-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
  font-size: 0.75rem;
}

.grammar-gloss-ar {
  font-family: "Amiri", serif;
  font-size: 0.92rem;
  color: #15803d;
  direction: rtl;
  text-align: right;
  margin-top: 0.2rem;
}

/* Grammatical Forms & ACON Section */
.acon-section {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0.6rem;
  background: var(--surface);
}

.acon-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
}

.acon-title {
  font-size: 0.82rem;
  font-weight: 700;
}

.acon-controls {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
  font-size: 0.72rem;
}

.acon-controls select {
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  font-size: 0.72rem;
}

.acon-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.45rem;
  flex-wrap: wrap;
}

.acon-tab {
  padding: 0.2rem 0.48rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
}

.acon-tab.is-active {
  background: var(--text-body);
  color: #fff;
  border-color: var(--text-body);
}

.acon-legend {
  display: flex;
  gap: 0.6rem;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

.legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 3px;
  vertical-align: middle;
}

.swatch-current {
  background: var(--word-active-bg);
  border: 1.5px solid var(--word-active-ring);
}

.swatch-attested {
  background: var(--attested-green-bg);
  border: 1.5px solid var(--attested-green-border);
}

.acon-grid-table {
  width: 100%;
  border-collapse: collapse;
  direction: rtl;
  font-family: "Amiri", serif;
}

.acon-grid-table td {
  border: 1px solid var(--border);
  padding: 0.3rem 0.35rem;
  text-align: center;
  vertical-align: middle;
  position: relative;
  transition: background 0.12s;
}

.acon-cell-clickable {
  cursor: pointer;
}

.acon-cell-clickable:hover {
  background: var(--surface-hover);
}

/* Highlighted cell when attested in Quran */
.acon-grid-table td.is-quran-attested {
  background: var(--attested-green-bg);
  border-color: #86efac;
}

/* Highlighted cell when it is the CURRENT active word form */
.acon-grid-table td.is-current-word-form {
  background: var(--word-active-bg) !important;
  border: 2px solid var(--word-active-ring) !important;
  font-weight: 700;
}

.acon-verb-form {
  font-size: 1.05rem;
  color: var(--text-body);
  display: block;
  line-height: 1.25;
}

.acon-pronoun {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.acon-count-badge {
  display: inline-block;
  font-family: "Inter", sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.04rem 0.28rem;
  border-radius: 999px;
  background: #15803d;
  color: #fff;
  margin-right: 0.2rem;
}

/* Attested Derived Forms / Lemmas strip */
.derived-forms-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px dashed var(--border);
}

.derived-chip {
  font-size: 0.72rem;
  padding: 0.18rem 0.45rem;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: var(--surface-subtle);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.derived-chip.is-active {
  background: var(--word-active-bg);
  border-color: var(--word-active-ring);
  font-weight: 700;
}

/* Usage Elsewhere in Quran (Concordance Jump List) */
.concordance-section {
  border: 1.5px solid var(--text-body);
  border-radius: 8px;
  padding: 0.55rem;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.concordance-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.concordance-title {
  font-size: 0.82rem;
  font-weight: 700;
}

.concordance-list {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding-right: 0.15rem;
}

.concordance-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.38rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-subtle);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.concordance-item:hover {
  background: #eff6ff;
  border-color: #93c5fd;
}

.concordance-item.is-current-occ {
  background: #fefce8;
  border-color: #eab308;
}

.concordance-ref {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

.concordance-snippet {
  font-family: "Amiri", serif;
  font-size: 1.02rem;
  direction: rtl;
  text-align: right;
  flex: 1;
}

.concordance-target-word {
  background: var(--word-active-bg);
  padding: 0 0.25rem;
  border-radius: 3px;
  font-weight: 700;
  color: #854d0e;
}

/* ==========================================================================
   Modals
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-size: 0.95rem;
}

.modal-body {
  padding: 1rem;
}

.modal-desc {
  margin: 0 0 0.85rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.form-field input,
.form-field select,
.form-field textarea {
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  font: inherit;
  font-weight: 400;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.candidate-picks {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
  max-height: 130px;
  overflow-y: auto;
}

.candidate-pick-btn {
  text-align: start;
  padding: 0.35rem 0.5rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  font-size: 0.74rem;
  cursor: pointer;
}

.candidate-pick-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
}
