* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #e0e0e0;
  color: #111;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

body:not(.mobile-live) .admin-panel {
  order: -1;
}

body:not(.mobile-live) .mobile-app {
  order: 0;
  flex: 1;
}

.mobile-app {
  min-height: 0;
}

/* Desktop: admin controls above the preview */
.admin-panel {
  max-width: min(960px, calc(100% - 24px));
  margin: 12px auto 8px;
  padding: 0 12px;
}

.admin-panel-handle {
  display: none;
}

.admin-panel-body {
  display: block;
}

.admin-panel-body[hidden] {
  display: block !important;
}

.admin-panel-summary {
  display: none;
}

.admin-nav {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.admin-nav-section {
  padding: 12px 14px;
  border-bottom: 1px solid #eee;
}

.admin-nav-section:last-child {
  border-bottom: none;
}

.admin-nav-heading {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #888;
}

.admin-nav-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.admin-nav-row--compare {
  align-items: center;
}

.admin-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1 1 140px;
}

.admin-field--day {
  flex: 2 1 180px;
}

.admin-field--device {
  flex: 2 1 200px;
}

.admin-field--file {
  flex: 1 1 160px;
}

.admin-field--compare-view {
  flex: 1 1 180px;
  max-width: 260px;
}

.admin-field-label {
  font-size: 12px;
  color: #666;
}

.admin-field select,
.admin-field input[type="file"] {
  width: 100%;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
  color: #111;
}

.admin-nav-row--split-lang {
  margin-top: 8px;
}

.admin-field--split-lang {
  flex: 1 1 100%;
}

.admin-field--split-lang select {
  width: 100%;
}

.mode-segment {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  background: #f0f0f0;
  border-radius: 10px;
}

@media (min-width: 640px) {
  .mode-segment {
    grid-template-columns: repeat(5, 1fr);
  }
}

.mode-segment-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #444;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.mode-segment-btn:hover {
  background: rgba(255, 255, 255, 0.65);
}

.mode-segment-btn[aria-pressed="true"] {
  background: #fff;
  color: #0d5c63;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.mode-segment-btn[data-mode="english"][aria-pressed="true"] {
  color: #1565c0;
}

.mode-segment-btn[data-mode="korean"][aria-pressed="true"] {
  color: #5c2d91;
}

.mode-segment-btn[data-mode="russian"][aria-pressed="true"] {
  color: #c62828;
}

.mode-segment-btn[data-mode="split"][aria-pressed="true"] {
  color: #006064;
  background: linear-gradient(135deg, #fff 60%, #e0f7fa);
}

.mode-segment-flag {
  font-size: 15px;
  line-height: 1;
}

.admin-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: #333;
  flex: 1 1 auto;
  min-height: 40px;
  user-select: none;
}

.admin-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.admin-toggle-ui {
  flex-shrink: 0;
  width: 42px;
  height: 24px;
  border-radius: 12px;
  background: #ccc;
  position: relative;
  transition: background 0.2s;
}

.admin-toggle-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

.admin-toggle input:checked + .admin-toggle-ui {
  background: #0d5c63;
}

.admin-toggle input:checked + .admin-toggle-ui::after {
  transform: translateX(18px);
}

.admin-nav-section--compare:not(.admin-nav-section--compare-on) .admin-field--compare-view {
  display: none;
}

.device-meta {
  text-align: center;
  font-size: 12px;
  color: #777;
  margin: 8px 0 0;
  padding: 0 4px;
}

/* Bilingual split — same chrome as single mode: header + passage + 2 scroll panes */
.app-single-view[hidden],
.app-split-view[hidden] {
  display: none !important;
}

.app-single-view,
.app-split-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.passage-title--split {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 12px;
  line-height: 1.35;
}

.split-ref-line {
  display: block;
  font-size: 13px;
  font-weight: 500;
}

.split-ref-line--overlay {
  font-size: 11px;
  opacity: 0.92;
}

.split-ref-line--kk::before {
  content: "🇰🇿 ";
}

.split-ref-line--overlay[data-locale="en"]::before {
  content: "🇬🇧 ";
}

.split-ref-line--overlay[data-locale="ko"]::before {
  content: "🇰🇷 ";
}

.split-ref-line--overlay[data-locale="ru"]::before {
  content: "🇷🇺 ";
}

.split-content {
  --split-kk-ratio: 0.5;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.split-lang-pane {
  flex: var(--pane-grow, 1) 1 0;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f7f7f7;
}

.split-lang-pane--kk {
  --pane-grow: var(--split-kk-ratio);
}

.split-lang-pane--overlay {
  --pane-grow: calc(1 - var(--split-kk-ratio));
}

.split-lang-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 14px 14px;
  font-size: 13px;
  line-height: 1.5;
  -webkit-overflow-scrolling: touch;
}

.split-lang-scroll .placeholder {
  margin-top: 12px;
  font-size: 12px;
}

.split-resizer {
  position: relative;
  z-index: 2;
  flex: 0 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: row-resize;
  touch-action: none;
  user-select: none;
  background: #e0e0e0;
  border-top: 1px solid #ccc;
  border-bottom: 1px solid #ccc;
}

.split-resizer:focus-visible {
  outline: 2px solid #4fc3f7;
  outline-offset: -2px;
}

.split-resizer--active,
.split-resizer:hover {
  background: #bdbdbd;
}

.split-resizer-grip {
  width: 28px;
  height: 2px;
  border-radius: 1px;
  background: #888;
}

.device-shell[data-home-bar="true"] .split-lang-pane--overlay .split-lang-scroll {
  padding-bottom: 24px;
}

body.split-mode-active .hint {
  display: none;
}

body.split-mode-active .admin-panel {
  max-width: min(960px, calc(100% - 24px));
}

/* Side-by-side app + live kkitap */
.compare-layout {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 20px;
  padding: 0 12px 16px;
  max-width: 1400px;
  margin: 0 auto;
}

.compare-layout.compare-off .compare-column--bible,
.compare-layout.compare-off-bible .compare-column--bible {
  display: none;
}

.compare-layout.compare-off {
  justify-content: center;
}

.compare-column {
  flex: 0 1 auto;
}

.column-label {
  font-size: 12px;
  font-weight: 600;
  color: #444;
  margin: 0 0 8px;
  text-align: center;
}

.compare-layout.compare-off .compare-column--kkitap {
  display: none;
}

.compare-column--kkitap,
.compare-column--bible {
  min-width: 320px;
  max-width: 420px;
  flex: 1 1 360px;
}

.kkitap-panel,
.bible-panel {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  border: 1px solid #ccc;
}

.kkitap-panel-header,
.bible-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: #0d5c63;
  color: #fff;
}

.kkitap-panel-header .column-label,
.bible-panel-header .column-label {
  color: #fff;
  margin: 0;
  text-align: left;
}

.kkitap-panel-header a,
.bible-panel-header a {
  color: #b2ebf2;
  font-size: 13px;
  text-decoration: none;
}

.kkitap-panel-header a:hover,
.bible-panel-header a:hover {
  text-decoration: underline;
}

.bible-panel-header--youversion {
  background: #5c2d91;
}

.kkitap-url,
.bible-url {
  margin: 0;
  padding: 6px 10px;
  font-size: 10px;
  word-break: break-all;
  background: #f0f0f0;
  color: #555;
  border-bottom: 1px solid #ddd;
}

.kkitap-frame,
.bible-frame {
  display: block;
  width: 100%;
  height: min(852px, 82vh);
  min-height: 500px;
  border: none;
  background: #fff;
}

.bible-frame--split {
  height: min(420px, 38vh);
  min-height: 280px;
}

.kkitap-fallback,
.bible-fallback {
  margin: 0;
  padding: 10px 12px;
  font-size: 12px;
  color: #666;
  background: #fff8e1;
}

@media (max-width: 900px) {
  .compare-layout {
    flex-direction: column;
    align-items: center;
  }

  .compare-column--kkitap,
  .compare-column--bible {
    width: 100%;
    max-width: 420px;
  }

  .kkitap-frame,
  .bible-frame {
    height: 60vh;
    min-height: 400px;
  }
}

.hint {
  text-align: center;
  font-size: 12px;
  color: #666;
  margin: 8px 16px 24px;
}

/* Stage centers device and applies scale from JS */
.device-stage {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 200px;
  padding: 8px 16px 24px;
  overflow: auto;
}

.device-shell {
  position: relative;
  flex-shrink: 0;
  background: #1a1a1a;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 20px 50px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  transform-origin: top center;
  transition: width 0.2s ease, height 0.2s ease, border-radius 0.2s ease;
}

/* Side buttons (iPhone-style) */
.device-shell[data-buttons="iphone"]::before,
.device-shell[data-buttons="iphone"]::after {
  content: "";
  position: absolute;
  background: #2a2a2a;
  border-radius: 2px;
  z-index: 5;
}

.device-shell[data-buttons="iphone"]::before {
  left: -3px;
  top: 120px;
  width: 3px;
  height: 28px;
  box-shadow: 0 40px 0 #2a2a2a, 0 78px 0 #2a2a2a;
}

.device-shell[data-buttons="iphone"]::after {
  right: -3px;
  top: 160px;
  width: 3px;
  height: 56px;
}

.device-screen {
  position: relative;
  overflow: hidden;
  background: #000;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Notch / Dynamic Island / punch-hole */
.device-notch {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  pointer-events: none;
}

.device-notch[data-type="notch"] {
  width: 42%;
  max-width: 160px;
  height: 28px;
  background: #000;
  border-radius: 0 0 18px 18px;
  top: 0;
}

.device-notch[data-type="dynamic-island"] {
  width: 126px;
  height: 37px;
  background: #000;
  border-radius: 20px;
  top: 12px;
}

.device-notch[data-type="punch-hole"] {
  width: 12px;
  height: 12px;
  background: #0a0a0a;
  border-radius: 50%;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: 0 0 0 3px #1a1a1a;
}

.device-notch[data-type="pill"] {
  width: 80px;
  height: 22px;
  background: #111;
  border-radius: 11px;
  top: 10px;
}

.device-home-bar {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 36%;
  max-width: 140px;
  height: 5px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 3px;
  z-index: 30;
  pointer-events: none;
}

.device-shell[data-notch="dynamic-island"] .app-header,
.device-shell[data-notch="notch"] .app-header,
.device-shell[data-notch="punch-hole"] .app-header,
.device-shell[data-notch="pill"] .app-header {
  padding-top: 38px;
}

.device-shell[data-notch="dynamic-island"] .app-header {
  padding-top: 44px;
}

.device-shell[data-home-bar="true"] .app-content {
  padding-bottom: 36px;
}

.app {
  background: #f7f7f7;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Top bar — matches app screenshot */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #0d5c63;
  color: #fff;
  font-size: 15px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(145deg, #4fc3f7, #0d5c63);
  border: 2px solid rgba(255, 255, 255, 0.5);
}

.app-name {
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.header-icon {
  opacity: 0.85;
  font-size: 16px;
}

/* Cyan reference bar */
.passage-title {
  background: #00acc1;
  color: #fff;
  text-align: center;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
}

.app-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 18px 28px;
  font-size: 15px;
  line-height: 1.55;
  -webkit-overflow-scrolling: touch;
}

/* Slightly smaller text on narrow devices */
.device-shell[data-width="360"] .app-content,
.device-shell[data-width="320"] .app-content {
  font-size: 14px;
  padding-left: 14px;
  padding-right: 14px;
}

.placeholder {
  color: #888;
  text-align: center;
  margin-top: 40px;
}

/* Bible passage block */
.btext-block {
  margin-bottom: 0;
}

.btext-block .section-title {
  font-weight: 600;
  margin: 0 0 8px;
  font-size: 15px;
}

.btext-block .passage-subtitle {
  font-style: italic;
  margin: 0 0 12px;
  color: #333;
}

.btext-block p {
  margin: 0 0 10px;
}

.btext-block sup {
  font-size: 0.65em;
  vertical-align: super;
  line-height: 0;
  font-weight: 600;
  color: #0d5c63;
  margin-right: 2px;
}

.btext-block sup small {
  font-size: 1em;
}

.btext-block .chapter-num {
  font-weight: 700;
  font-size: 16px;
  margin: 12px 0 4px;
  display: block;
}

/* Poetic lines: lines after br within same verse group often indent in app */
.btext-block .verse-line {
  margin-bottom: 6px;
}

.btext-block .verse-line.indent {
  padding-left: 1.25em;
}

.divider {
  border: none;
  border-top: 2px solid #4fc3f7;
  margin: 20px 0 16px;
}

/* Devotional / Thought block (below passage in app) */
.thought-block {
  color: #111;
}

.thought-block .day-topic {
  font-weight: 700;
  font-size: 17px;
  margin-bottom: 14px;
}

.thought-block h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 16px 0 8px;
}

.thought-block p {
  margin: 0 0 10px;
}

.thought-block strong {
  font-weight: 700;
}

/* ── Mobile web app (real device / Add to Home Screen) ── */
body.mobile-live {
  background: #f7f7f7;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body.mobile-live .mobile-app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

body.mobile-live .hint,
body.mobile-live .column-label,
body.mobile-live .device-meta,
body.mobile-live .admin-field--device {
  display: none !important;
}

body.mobile-live .compare-layout {
  flex: 1;
  min-height: 0;
  flex-direction: column;
  padding: 0;
  margin: 0;
  max-width: none;
  gap: 0;
}

body.mobile-live .compare-column--app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}

body.mobile-live .device-stage {
  flex: 1;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

body.mobile-live .device-shell {
  width: 100% !important;
  height: 100% !important;
  max-width: none;
  transform: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  box-shadow: none;
  background: transparent;
}

body.mobile-live .device-shell::before,
body.mobile-live .device-shell::after {
  display: none;
}

body.mobile-live .device-notch,
body.mobile-live .device-home-bar {
  display: none !important;
}

body.mobile-live .device-screen {
  border-radius: 0 !important;
  background: #f7f7f7;
}

body.mobile-live .app-header {
  padding: 6px 12px;
  padding-top: max(6px, env(safe-area-inset-top, 0px));
  min-height: 0;
  font-size: 14px;
}

body.mobile-live .logo-icon {
  width: 18px;
  height: 18px;
  border-width: 1.5px;
}

body.mobile-live .app-name {
  font-size: 14px;
}

body.mobile-live .header-right {
  gap: 0;
  font-size: 12px;
}

body.mobile-live .header-icon {
  display: none;
}

body.mobile-live .passage-title {
  padding: 7px 10px;
  font-size: 13px;
  line-height: 1.3;
}

body.mobile-live .passage-title--split {
  gap: 2px;
  padding: 6px 10px;
}

body.mobile-live .split-ref-line {
  font-size: 12px;
}

body.mobile-live .split-ref-line--overlay {
  font-size: 11px;
}

body.mobile-live .app-content,
body.mobile-live .split-lang-scroll {
  padding-bottom: calc(48px + env(safe-area-inset-bottom, 0px));
  -webkit-overflow-scrolling: touch;
}

body.mobile-live .admin-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  max-width: none;
  margin: 0;
  padding: 0;
}

body.mobile-live .admin-panel-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: none;
  border-top: 1px solid #ddd;
  border-radius: 14px 14px 0 0;
  background: #fff;
  color: #333;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  touch-action: manipulation;
  min-height: 40px;
}

body.mobile-live .admin-panel-grab {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: #bbb;
  flex-shrink: 0;
}

body.mobile-live .admin-panel-summary {
  display: block;
  flex: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.mobile-live .admin-panel-body {
  max-height: min(70dvh, 520px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
  border-top: 1px solid #eee;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

body.mobile-live .admin-panel-body[hidden] {
  display: none !important;
}

body.mobile-live .admin-panel--open .admin-panel-handle {
  border-radius: 0;
  box-shadow: none;
}

body.mobile-live .admin-nav {
  border-radius: 0;
  box-shadow: none;
  border: none;
}

body.mobile-live .admin-nav-section {
  padding: 14px 16px;
}

body.mobile-live .admin-field select,
body.mobile-live .admin-field input[type="file"] {
  font-size: 16px;
  min-height: 44px;
}

body.mobile-live .mode-segment-btn {
  min-height: 44px;
}

body.mobile-live .admin-nav-row {
  flex-direction: column;
  align-items: stretch;
}

body.mobile-live .admin-field {
  flex: 1 1 auto;
  width: 100%;
}

body.mobile-live .admin-nav-row--compare {
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

body.mobile-live .admin-field--compare-view {
  max-width: none;
}

body.mobile-live .compare-column--bible {
  display: none;
}

body.mobile-live.admin-bible-on .compare-column--bible {
  display: block;
  flex-shrink: 0;
  width: 100%;
  max-width: none;
  border-top: 1px solid #ccc;
}

body.mobile-live.admin-bible-on .mobile-app {
  position: relative;
  flex: 1;
  min-height: 0;
}

body.mobile-live.admin-bible-on {
  overflow: auto;
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

body.mobile-live.admin-bible-on .bible-frame {
  height: 50dvh;
  min-height: 240px;
}
