/* ═══════════════════════════════════════════════════
   Nagish-style Accessibility Panel
   ─────────────────────────────────────────────────── */

#nagish-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100009;
}
#nagish-overlay.open { display: block; }

#nagish-panel {
  display: none;
  position: fixed;
  left: 72px;
  top: 50%;
  transform: translateY(-50%);
  width: 324px;
  max-height: min(88vh, 680px);
  overflow-y: auto;
  overflow-x: hidden;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 50px rgba(0,0,0,0.38);
  z-index: 100010;
  font-family: 'Segoe UI', Arial, 'Helvetica Neue', sans-serif;
  direction: rtl;
  color: #222;
  scroll-behavior: smooth;
}
#nagish-panel.open { display: block; }

#nagish-panel::-webkit-scrollbar { width: 4px; }
#nagish-panel::-webkit-scrollbar-track { background: #f0f0f0; }
#nagish-panel::-webkit-scrollbar-thumb { background: #bbb; border-radius: 2px; }

/* ─── Header ─────────────────────────────────────── */
.nagish-header {
  background: #6c3fc5;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 16px 16px 0 0;
  position: sticky;
  top: 0;
  z-index: 2;
}
.nagish-header-left  { display: flex; align-items: center; }
.nagish-header-center { flex: 1; display: flex; justify-content: center; }
.nagish-header-right { display: flex; align-items: center; gap: 4px; }

/* Cursor visibility: keep a standard arrow on the purple header area.
   Some custom cursor modes become low-contrast on dark/purple backgrounds,
   making the pointer feel "missing". */
#nagish-panel .nagish-header,
#nagish-panel .nagish-lang-pill,
#nagish-panel .nagish-lang-menu,
#nagish-panel .nagish-icon-btn {
  cursor: auto !important;
}

.nagish-icon-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  padding: 0;
  transition: background 0.15s;
  flex-shrink: 0;
}
.nagish-icon-btn:hover { background: rgba(255,255,255,0.22); }
.nagish-icon-btn svg  { display: block; }

/* ─── Language pill (button) ──────────────────────── */
.nagish-lang-pill {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 20px;
  color: #fff;
  font-size: 12.5px;
  padding: 3px 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
  outline: none;
}
.nagish-lang-pill:hover,
.nagish-lang-pill.lang-open {
  background: rgba(255,255,255,0.30);
  border-color: rgba(255,255,255,0.6);
}
.nagish-lang-chevron {
  flex-shrink: 0;
  transition: transform 0.2s;
  margin-inline-start: 1px;
}
.nagish-lang-pill.lang-open .nagish-lang-chevron {
  transform: rotate(180deg);
}

/* ─── Language dropdown menu ─────────────────────── */
.nagish-lang-menu {
  display: none;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 12px;
  background: #f5f0ff;
  border-bottom: 1px solid #e0d6f5;
  position: sticky;
  top: 82px;        /* header (~56px) + title-bar (~28px) */
  z-index: 3;
}
.nagish-lang-menu.open {
  display: flex;
}
.nagish-lang-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid #d1c4ee;
  background: #fff;
  color: #3d2070;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap;
  line-height: 1;
}
.nagish-lang-item:hover {
  background: #ede5fa;
  border-color: #6c3fc5;
}
.nagish-lang-item:active {
  transform: scale(0.95);
}
.nagish-lang-emoji {
  font-size: 14px;
  line-height: 1;
}
.nagish-lang-label {
  font-size: 12px;
}
.nagish-flag {
  width: 20px;
  height: 13px;
  border-radius: 2px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 13'%3E%3Crect width='20' height='13' fill='white'/%3E%3Crect width='20' height='2' y='1' fill='%230038b8'/%3E%3Crect width='20' height='2' y='10' fill='%230038b8'/%3E%3Cpolygon points='10,4 12.3,8 7.7,8' fill='%230038b8'/%3E%3Cpolygon points='10,9 12.3,5 7.7,5' fill='%230038b8'/%3E%3C/svg%3E") no-repeat center/cover;
  flex-shrink: 0;
}

/* ─── Title bar ──────────────────────────────────── */
.nagish-title-bar {
  background: #6c3fc5;
  padding: 0 14px 13px;
  display: flex;
  justify-content: center;
}
.nagish-title-pill {
  border: 2px solid #fff;
  border-radius: 22px;
  color: #fff;
  font-size: 15.5px;
  font-weight: 700;
  padding: 5px 38px;
  letter-spacing: 0.4px;
}

/* ─── Feature grid ───────────────────────────────── */
.nagish-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  padding: 10px;
  background: #efefef;
}
.nagish-feat-btn {
  background: #fff;
  border: 1.5px solid #e2e2e2;
  border-radius: 10px;
  padding: 13px 6px 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s, box-shadow 0.14s;
  font-family: inherit;
  min-height: 86px;
}
.nagish-feat-btn:hover {
  border-color: #6c3fc5;
  background: #f5f0ff;
}
.nagish-feat-btn.active {
  border-color: #6c3fc5;
  background: #ede5fa;
  box-shadow: 0 0 0 2px rgba(108,63,197,.18);
}
.nagish-feat-icon {
  color: #6c3fc5;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nagish-feat-icon svg { width: 30px; height: 30px; display: block; }
.nagish-feat-label {
  font-size: 10.5px;
  color: #333;
  text-align: center;
  line-height: 1.3;
  font-weight: 500;
}
.nagish-feat-btn.active .nagish-feat-label { color: #6c3fc5; font-weight: 600; }

/* ─── Sections (color / cursor / font) ──────────── */
.nagish-section {
  background: #fff;
  margin: 7px 10px;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  overflow: hidden;
}
.nagish-section-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  gap: 8px;
}
.nagish-section-hd:hover { background: #f7f7f7; }
.nagish-sec-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #6c3fc5;
  margin-bottom: 1px;
}
.nagish-sec-sub { font-size: 11px; color: #666; }
.nagish-sec-icon { color: #6c3fc5; flex-shrink: 0; }
.nagish-sec-body {
  display: none;
  padding: 0 12px 12px;
}
.nagish-section.open .nagish-sec-body { display: block; }

/* Tabs */
.nagish-tabs { display: flex; gap: 4px; margin-bottom: 9px; }
.nagish-tab {
  flex: 1;
  background: none;
  border: 1.5px solid #ddd;
  border-radius: 20px;
  padding: 4px 4px;
  font-size: 10.5px;
  cursor: pointer;
  color: #555;
  font-family: inherit;
  transition: all 0.13s;
  white-space: nowrap;
}
.nagish-tab.active {
  background: #6c3fc5;
  border-color: #6c3fc5;
  color: #fff;
  font-weight: 600;
}

/* Color slider */
.nagish-rainbow-wrap {
  height: 22px;
  border-radius: 11px;
  overflow: hidden;
  background: linear-gradient(to left,
    hsl(0,100%,50%), hsl(30,100%,50%), hsl(60,100%,50%),
    hsl(120,100%,50%), hsl(180,100%,50%), hsl(240,100%,50%),
    hsl(300,100%,50%), hsl(360,100%,50%));
  margin-bottom: 10px;
}
.nagish-color-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  outline: none;
  cursor: pointer;
}
.nagish-color-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(0,0,0,.4);
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
  cursor: pointer;
  margin-top: -2px;
}
.nagish-reset-colors-btn {
  background: none;
  border: 1.5px solid #ccc;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 11.5px;
  color: #6c3fc5;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: inherit;
  transition: border-color 0.14s;
}
.nagish-reset-colors-btn:hover { border-color: #6c3fc5; }

/* Cursor buttons */
.nagish-cursor-row { display: flex; gap: 6px; margin-top: 8px; }
.nagish-cursor-btn {
  flex: 1;
  background: none;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  padding: 8px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.13s;
  color: #333;
}
.nagish-cursor-btn:hover  { border-color: #6c3fc5; color: #6c3fc5; }
.nagish-cursor-btn.active { background: #6c3fc5; border-color: #6c3fc5; color: #fff; }

/* Font slider */
.nagish-font-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  background: #f5f5f5;
  border: 1.5px solid #e0e0e0;
  border-radius: 10px;
  padding: 8px 12px;
}
.nagish-font-step {
  background: #6c3fc5;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: inherit;
  padding: 0;
  transition: background 0.13s;
}
.nagish-font-step:hover { background: #5430a0; }
.nagish-font-track {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  background: #ccc;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
.nagish-font-track::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #6c3fc5;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,.2);
}

/* ─── Reset all button ───────────────────────────── */
.nagish-reset-all-btn {
  display: block;
  width: calc(100% - 20px);
  margin: 8px 10px;
  background: #6c3fc5;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.14s;
  letter-spacing: 0.3px;
}
.nagish-reset-all-btn:hover { background: #5430a0; }

/* ─── Footer ─────────────────────────────────────── */
.nagish-footer {
  text-align: center;
  font-size: 11.5px;
  color: #999;
  padding: 7px 8px 10px;
  border-top: 1px solid #eee;
  background: #fff;
  direction: ltr;
}

/* ─── Global feature styles ──────────────────────── */
body.nagish-kbd-focus *:focus {
  outline: 3px solid #6c3fc5 !important;
  outline-offset: 2px !important;
}
body.nagish-high-contrast { filter: contrast(2); }
body.nagish-reading-view p,
body.nagish-reading-view li {
  line-height: 2 !important;
  max-width: 65ch !important;
}

/* ─── Mobile ─────────────────────────────────────── */
@media (max-width: 520px) {
  #nagish-panel {
    left: 6px;
    right: 6px;
    width: auto;
    top: 8px;
    transform: none;
    max-height: calc(100dvh - 16px);
    border-radius: 12px;
  }
}
