:root{
  --bg:#0c0e12;
  --surface:#141821;
  --border:#23293a;
  --text:#e8ecf1;
  --muted:#a9b2c1;
  --accent:#4da3ff;
  --accent-2:#7bd389;
  --danger:#ff6b6b;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --arabic: "Scheherazade New", "Amiri", "Noto Naskh Arabic", "Noto Kufi Arabic", system-ui, sans-serif;
}
/* Force hidden panes to be invisible in all cases */
[hidden] { 
  display: none !important;
}

/* Base */
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:linear-gradient(180deg, #0b0d11 0%, #0f1320 100%);
  color:var(--text);
  font-family:Inter, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height:1.6;
}

.app-header{padding:28px 16px 8px;text-align:center}
h1{margin:0;font-weight:800;letter-spacing:.3px}
.subtitle{color:var(--muted);margin:.25rem 0 1rem}
.container{max-width:1100px;margin:0 auto;padding:12px}

.search-panel{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:14px;
  padding:16px;
  box-shadow:0 8px 24px rgba(0,0,0,.25);
}
.search-group{margin-bottom:14px}
.search-group label{display:block;color:var(--muted);margin-bottom:6px}
.row{display:flex;gap:8px}

.input{
  flex:1; background:#0f1320; color:var(--text);
  border:1px solid var(--border); border-radius:10px; padding:12px 14px;
  outline:none; font-size:16px;
}
.input:focus{border-color:var(--accent); box-shadow:0 0 0 3px rgba(77,163,255,.2)}

/* Buttons (primary and small) */
.btn,
.btn-sm{
  border:1px solid var(--border);
  background:var(--surface);
  color:var(--text);
  cursor:pointer;
  border-radius:10px;
  font-weight:600;
}

.btn{ padding:12px 14px; }

.btn-sm{
  /* bilingual layout */
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:2px;
  line-height:1.15;
  min-width: 110px;
  min-height: 64px;
  text-align:center;
  padding:6px 10px;
  font-size:13px;
}

.btn-sm .ar{
  display:block;
  font-size:14px;
  font-weight:700;
  color: var(--text);     /* Arabic dark */
}

.btn-sm .en{
  display:block;
  font-size:12px;
  font-weight:700;
  color: var(--accent);   /* English blue */
}

.btn:hover, .btn-sm:hover{
  border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(77,163,255,.18);
}

/* Status & results list */
.status{color:var(--muted); margin-top:6px}
.results{margin-top:16px; display:grid; gap:12px}

.result-item{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:14px;
  padding:12px;
}

.result-head{display:flex; align-items:center; justify-content:space-between; gap:10px}

.word-badge{
  font-family:var(--arabic); font-size:22px;
  background:#0f1320; border:1px solid var(--border); border-radius:12px;
  padding:8px 12px;
}

.meta{color:var(--muted); font-size:13px}
.meta { display:flex; flex-direction:column; gap:2px }
.meta .ref { color: var(--text); font-weight:600; }
.meta .gram { color: var(--muted); font-size:12px; }

/* Expansions */
.expansions{margin-top:8px; display:flex; flex-wrap:wrap; gap:6px}
.expansions .chip{
  border:1px solid var(--border); padding:4px 8px; border-radius:999px;
  font-size:12px; background:#0e1528; color:var(--muted);
}

/* Detail section */
.detail-controls{
  display:flex; gap:8px; margin-top:8px;
  flex-wrap: wrap;              /* allow wrapping on small screens */
}
.detail{margin-top:10px; border-top:1px dashed var(--border); padding-top:10px}

.verse-original{
  font-family:var(--arabic); font-size:22px; line-height:2; padding:8px 10px;
  background:#0f1320; border:1px solid var(--border); border-radius:12px;
}
.surah-line{color:var(--muted); margin-top:6px; font-size:13px}

/* Fragmented chips */
.fragmented{
  margin-top:10px; display:flex; flex-wrap:wrap; gap:8px;
}
.fragment-token{
  padding:6px 10px; border:1px solid var(--border); border-radius:10px; background:#0e1424; cursor:pointer;
  font-family:var(--arabic); font-size:18px;
}
.fragment-token:hover{border-color:var(--accent)}

/* High-contrast chips */
.fragmented { 
  background: #0f152a;
  padding: 8px;
  border-radius: 12px;
}
.fragment-token{
  background:#141d39;
  border:1px solid #2a3a68;
  color:#ecf3ff;
  font-size:19px;
  box-shadow: 0 1px 0 rgba(0,0,0,.25);
}
.fragment-token:hover{
  border-color:#4da3ff;
  box-shadow: 0 0 0 3px rgba(77,163,255,.18);
}
.affix { color:#7bb7ff; font-weight:600; }
.noun  { color:#f2f6ff; font-weight:600; }
.verb  { color:#f2f6ff; font-weight:800; }
.other { color:#e6ecff; }

.fragment-token.highlight{
  background:#18234a;
  border-color:#4da3ff;
  box-shadow: 0 0 0 3px rgba(77,163,255,.25);
}

/* WBW + Sahih container */
.wbw,.sahih{
  margin-top:10px;
  padding:10px;
  border:1px solid var(--border);
  border-radius:10px;
  background:#0e1424;
  font-size:15px;
}

/* ---- legacy WBW tokens (kept for backward compatibility) ---- */
.wbw .wbw-word{display:inline-block; margin:0 6px 6px 0}
.wbw .ar{font-family:var(--arabic); font-size:20px}
.wbw .en{color:var(--muted); font-size:13px; display:block}
.wbw .wbw-word.highlight{
  outline: 2px solid var(--accent);
  border-radius: 6px;
  padding: 2px 4px;
}

/* ---- NEW: bracketed WBW pair styling ---- */
.wbw { direction: rtl; }
.wbw-pair{
  display:inline-block;
  margin:0 .35em .35em .35em;
  white-space:nowrap;
  line-height:1.4;
}
.wbw-pair .wbw-ar{
  font-family: var(--arabic);
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
}
.wbw-pair .wbw-en{
  font-weight: 700;
  font-size: .95rem;
  color: var(--accent);
}
/* --- WBW as pill chips (Arabic + English) --- */
.wbw {
  direction: rtl;
}

.wbw.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: #0f152a;           /* same feel as fragmented */
  padding: 8px;
  border-radius: 12px;
}

.wbw .wbw-chip {
  display: inline-flex;
  align-items: center;
  gap: .5em;
  padding: 6px 10px;
  background: #141d39;
  border: 1px solid #2a3a68;
  border-radius: 10px;
  color: #ecf3ff;
  box-shadow: 0 1px 0 rgba(0,0,0,.25);
  line-height: 1.35;
  white-space: nowrap;
}

.wbw .wbw-chip .wbw-ar {
  font-family: var(--arabic);
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
}

.wbw .wbw-chip .sep {
  opacity: .8;                /* the (:) separator */
}

.wbw .wbw-chip .wbw-en {
  font-weight: 700;
  font-size: .95rem;
  color: var(--accent);
}

.wbw .wbw-chip.highlight {
  background:#18234a;
  border-color:#4da3ff;
  box-shadow: 0 0 0 3px rgba(77,163,255,.22);
  border-radius: 10px;
}

/* Sahih footnotes */
.sahih .footnote sup{
  padding:0 4px; cursor:pointer; border-bottom:1px dotted var(--accent);
}
.sahih .note{
  margin-top:8px; padding:8px; border:1px solid var(--border); border-radius:8px; background:#0c1222; color:var(--muted); font-size:13px;
}

/* -------- Token-info (single, clean block) -------- */
.token-info{
  margin-top:8px;
  border:1px solid var(--border);
  border-radius:10px;
  background:#0e1424;
  direction: rtl;
  text-align: right;
  font-size:14px;
}
.ti-box{ padding:10px 12px; }

.ti-row{
  display:flex;
  align-items:flex-start;
  gap:10px;
  padding:6px 0;
  border-bottom:1px dashed var(--border);
}
.ti-row:last-child{ border-bottom:none; }

.ti-label{
  min-width:140px;
  color: var(--muted);
  white-space: nowrap;
}
.ti-val{ color: var(--text); }
.ti-val.ar{ font-family: var(--arabic); font-size: 20px; }
.en-inline{ color: var(--accent); font-weight:700; }

/* NEW: highlight the matched affix/letter in results */
.hl-affix { color: var(--accent); font-weight: 800; }
.status .count { font-weight: 800; color: var(--accent); }
.status .en, .status .ar { font-weight: 700; }


/* === FONT & COLOR CONTROL BLOCK (current defaults preserved) === */

/* === Arabic main verse === */
.verse-original {
  font-size: 22px;         /* current size */
  line-height: 2;
  color: white;            /* current verse color */
  font-weight: bold;
}

/* === Surah name / reference line === */
.surah-line {
  font-size: 15px;         /* current size */
  color: lightgray;        /* current muted text */
  font-weight: 500;
}

/* === Fragmented verse words === */
.fragment-token {
  font-size: 19px;         /* current size */
  color: white;            /* current word color */
  font-weight: bold;
}

/* === Word-by-word (WBW) Arabic part === */
.wbw .wbw-chip .wbw-ar {
  font-size: 1.3rem;      /* current Arabic size */
  font-weight: bold;
  color: white;            /* current Arabic color */
}

/* === Word-by-word (WBW) English part === */
.wbw .wbw-chip .wbw-en {
  font-size: 1.2rem;      /* current English size */
  font-weight: bold;
  color: deepskyblue;      /* current blue accent */
}

/* === Verse English translation (Sahih) === */
.sahih .en {
  font-size: 1.4rem;         /* current size */
  line-height: 1.8;
  color:  dodgerblue;        /* current soft blue tone */
  font-weight: 400;
  font-family: "Inter", system-ui, sans-serif;
}

/* === Token info details (analysis box) === */
.token-info {
  font-size: 14px;         /* current overall size */
  color: white;            /* current normal text */
  font-weight: 500;
}

/* === Arabic value lines inside token info === */
.ti-val.ar {
  font-size: 20px;         /* current Arabic font size */
  color: white;
  font-weight: bold;
  font-family: var(--arabic);
}

/* === English inline labels in token info === */
.en-inline {
  color: dodgerblue;       /* current accent blue */
  font-weight: bold;
}

/* === Footnote tablet button (bigger) === */
.sahih .fn-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:1px solid var(--accent);
  background:rgba(77,163,255,.15);
  border-radius:999px;
  padding:8px 14px;           /* was 6px 12px */
  margin:0 6px;
  font-size:1.15rem;          /* was 1rem */
  line-height:1.1;            /* ensure tall tap target */
  font-weight:800;
  color:var(--accent);
  cursor:pointer;
  transition:all .2s ease;
}
.sahih .fn-btn:hover{
  background:rgba(77,163,255,.25);
  box-shadow:0 0 0 4px rgba(77,163,255,.18);
}
.sahih .fn-btn:focus-visible{
  outline:2px solid var(--accent);
  outline-offset:2px;
}

/* === Footnote note text (bigger & more readable) === */
.sahih .note{
  margin-top:8px;
  padding:10px 12px;           /* a touch more padding */
  border:1px solid var(--border);
  border-radius:8px;
  background:#0c1222;
  color:var(--muted);
  font-size:1rem;              /* was 13px → ~16px */
  line-height:1.7;             /* easier reading */
}

/* === Footnote tablet + note (bright yellow, all devices) === */
.sahih .fn-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffea70;          /* vivid yellow border */
  background: rgba(255, 255, 100, 0.2);
  color: #fffbe0;                     /* bright soft yellow text */
  border-radius: 999px;
  padding: 10px 18px;
  margin: 0 6px;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.15;
  cursor: pointer;
  text-shadow: 0 0 4px rgba(255,255,180,0.6);
  transition: all 0.25s ease;
}

.sahih .fn-btn:hover {
  background: rgba(255, 255, 120, 0.35);
  box-shadow: 0 0 10px rgba(255,255,160,0.3);
}

.sahih .fn-btn:focus-visible {
  outline: 2px solid #fffbe0;
  outline-offset: 2px;
}

.sahih .note {
  margin-top: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0c1222;
  color: #f8f9c4;                     /* light yellow text */
  font-size: 1.05rem;
  line-height: 1.75;
}

/* === Mobile polish (small phones only) === */
@media (max-width: 480px){

  /* stack input + button for search rows */
  .row { 
    flex-direction: column;
    align-items: stretch;
  }
  .row .input { width: 100%; }
  .row .btn { width: 100%; }

  /* result header: stack word badge above meta */
  .result-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .word-badge { font-size: 20px; padding: 6px 10px; }

  /* calmer reading size for Sahih on small screens */
  .sahih .en { 
    font-size: 1.1rem;
    line-height: 1.7;
  }

  /* WBW chips: slightly smaller to reduce wrapping */
  .wbw .wbw-chip .wbw-ar { font-size: 1.05rem; }
  .wbw .wbw-chip .wbw-en { font-size: .9rem; }

  /* compact fragmented tokens a touch */
  .fragment-token { font-size: 17px; padding: 5px 8px; }

  /* make the small bilingual buttons fit better when wrapping */
  .detail-controls .btn-sm {
    min-width: unset;
    flex: 1 1 calc(50% - 8px); /* two per row */
  }

  /* footnote tablet: even larger & brighter on small screens */
  .sahih .fn-btn {
    padding: 12px 20px;
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1.2;
    color: #fffbe0;
    background: rgba(255, 255, 100, 0.3);
    border: 2px solid #ffea70;
    border-radius: 999px;
    text-shadow: 0 0 4px rgba(255,255,180,0.6);
  }

  .sahih .fn-btn:hover {
    background: rgba(255, 255, 130, 0.4);
    box-shadow: 0 0 12px rgba(255,255,160,0.3);
  }

  /* footnote note text: slightly larger on phones */
  .sahih .note {
    font-size: 1.15rem;
    line-height: 1.85;
    color: #fffac2;
  }
}
