:root{
  --bg:#fafafa;
  --surface:#ffffff;
  --text:#111827;
  --muted:#6b7280;
  --rule:#d1d5db;
  --accent:#2563eb;

  --paneHeaderH: 44px;
  --headerH: 58px;

  /* JS sets --vh for iOS; fallback to 1vh */
  --vh: 1vh;
}

*{ box-sizing:border-box; }
html,body{ height:100%; margin:0; }

body{
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* --- iOS: prevent whole-page scroll/bounce --- */
html, body{
  height: 100%;
  overflow: hidden;
}

body{
  position: fixed;     /* critical for iOS */
  inset: 0;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  touch-action: manipulation;
}

/* Ensure panes scroll internally */
.paneBible,
.paneNotes{
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* Safe areas */
.appHeader{
  padding-top: calc(12px + env(safe-area-inset-top));
}
.main{
  padding-bottom: env(safe-area-inset-bottom);
}

/* Header */
.appHeader{
  position: relative;
  height: var(--headerH);
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}

.headerRow{
  display:flex;
  align-items:flex-start;
  justify-content: space-between;
  gap: 12px;
}

.brand{
  display: flex;
  align-items: center;
  gap: 10px;
}

.brandIcon{
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.brandText{
  display: flex;
  flex-direction: column;
}

.brandTitle{
  font-weight: 800;
  letter-spacing: .2px;
  line-height: 1.1;
}

.brandTag{
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
}

/* Hamburger menu panel */
.menuPanel{
  position: absolute;
  top: 54px;
  right: 16px;
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(0,0,0,.14);
  padding: 6px;
  z-index: 50;
}

.menuItem{
  width: 100%;
  text-align: left;
  padding: 10px 10px;
  border: 0;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}

.menuItem:hover{
  background: rgba(37,99,235,.08);
}

/* Pane frames */
.pane{ overflow: hidden; background: var(--surface); }

/* Pane title rows */
.paneTitleRow{
  height: var(--paneHeaderH);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid var(--rule);
}

.paneTitle{
  padding: 12px 14px;
  border-bottom: 1px solid var(--rule);
  font-weight: 700;
}

.paneTitleRow .paneTitle{
  padding:0;
  border:0;
}

/* Translation name on the right */
.versionLabel{
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52%;
  text-align: right;
}

/* Modal base */
.modal{ position: fixed; inset: 0; z-index: 100; }

.modalBackdrop{
  position:absolute; inset:0;
  background: rgba(0,0,0,.35);
}

/* Settings modal */
.modalCard{
  position: relative;
  max-width: 520px;
  margin: 14vh auto 0;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 18px;
  box-shadow: 0 12px 28px rgba(0,0,0,.18);
  overflow: hidden;
}

.modalHeader{
  display:flex;
  justify-content: space-between;
  align-items:center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--rule);
}

.modalTitle{ font-weight: 800; }
.modalBody{ padding: 14px; }

.settingRow{
  display:flex;
  justify-content: space-between;
  align-items:center;
  gap: 14px;
}

.settingLabel{ font-weight: 700; margin-bottom: 2px; }
.settingHelp{ color: var(--muted); font-size: 13px; line-height: 1.4; }
.settingHint{ margin-top: 10px; color: var(--muted); font-size: 13px; line-height: 1.4; }

/* Switch */
.switch{ position: relative; display:inline-block; width: 50px; height: 28px; }
.switch input{ opacity:0; width:0; height:0; }

.slider{
  position:absolute; cursor:pointer;
  inset:0;
  background: #e5e7eb;
  transition: .2s;
  border-radius: 999px;
  border:1px solid var(--rule);
}

.slider:before{
  position:absolute; content:"";
  height: 22px; width: 22px;
  left: 3px; top: 2px;
  background: white;
  transition: .2s;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.06);
}

.switch input:checked + .slider{
  background: color-mix(in oklab, var(--accent) 18%, #e5e7eb);
  border-color: color-mix(in oklab, var(--accent) 30%, var(--rule));
}

.switch input:checked + .slider:before{
  transform: translateX(22px);
}

/* Logos-like nav modal */
.navCard{
  position: relative;
  width: min(860px, calc(100vw - 20px));
  height: min(620px, calc(100vh - 80px));
  margin: 50px auto 0;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 18px;
  box-shadow: 0 14px 34px rgba(0,0,0,.20);
  overflow: hidden;
  display:flex;
  flex-direction: column;
}

.navHeader{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 12px;
  border-bottom: 1px solid var(--rule);
}

.navTitle{
  font-weight: 800;
  flex: 1;
  text-align:center;
}

.navBody{
  padding: 10px;
  overflow: hidden;
  flex: 1;
}

.navSection{
  height: 100%;
  overflow: auto;
  padding: 4px;
}

.navSubTitle{
  color: var(--muted);
  font-size: 13px;
  margin: 2px 0 10px;
  text-align:center;
}

/* Book grid */
.navGrid{
  display:grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 900px){
  .navGrid{ grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

@media (max-width: 520px){
  .navCard{ height: calc(100vh - 40px); margin-top: 20px; }
  .navGrid{ grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; }
}

.navBtn{
  border: 1px solid var(--rule);
  background: var(--surface);
  border-radius: 12px;
  padding: 10px 6px;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  text-align:center;
  user-select:none;
}

.navBtn:hover{
  border-color: var(--accent);
  background: rgba(37,99,235,.06);
}

.navBtn:active{
  transform: translateY(1px);
}

/* Chapter grid tighter */
.navGrid.chapters{
  grid-template-columns: repeat(8, minmax(0, 1fr));
}
@media (max-width: 900px){
  .navGrid.chapters{ grid-template-columns: repeat(7, minmax(0, 1fr)); }
}
@media (max-width: 520px){
  .navGrid.chapters{ grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
