@font-face {
  font-family: "LaGaligoSureq";
  src: url("./fonts/LaGaligoSureq-Regular.woff2") format("woff2"),
       url("./fonts/LaGaligoSureq-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  /* This face draws U+1A1E Pallawa as a slash; Noto Sans Buginese has the 3-dot mark. */
  unicode-range: U+0000-1A1D, U+1A1F-10FFFF;
}

@font-face {
  font-family: "LaGaligoScript";
  src: url("./fonts/LaGaligoScript-Regular.woff2") format("woff2"),
       url("./fonts/LaGaligoScript-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0000-1A1D, U+1A1F-10FFFF;
}

@font-face {
  font-family: "Jangang KIT";
  src: url("./fonts/JangangKIT-Regular.woff2") format("woff2"),
       url("./fonts/JangangKIT-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  /* Unicode Makasar block + dotted circle; only fetched when the Jangang-jangang setting is on. */
  unicode-range: U+11EE0-11EF8, U+25CC, U+200B-200D;
}

@font-face {
  font-family: "Noto Sans Buginese";
  src: url("./fonts/NotoSansBuginese-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  unicode-range: U+1A00-1A1F, U+200C, U+200D;
}

:root {
  --ink: #1c140c;
  --muted: #5c4a38;
  --paper: #f4ead6;
  --paper-deep: #ebe0c8;
  --rule: #d4c4a8;
  --accent: #7a3e1d;
  --accent-soft: rgba(122, 62, 29, 0.16);
  --topbar: #2a1c12;
  --topbar-text: #f4ead6;
  --danger-muted: #8a4b2a;
  --highlight: rgba(122, 62, 29, 0.28);
  --vowel: #b86a1a;
  --vowel-inherent: #8d6a3d;
  --shadow: 0 10px 30px rgba(28, 20, 12, 0.18);
  --ui: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --serif: "Source Serif 4", Palatino, "Palatino Linotype", Georgia, serif;
  --lontara: "LaGaligoSureq", "Noto Sans Buginese", "Noto Sans", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --topbar-h: calc(56px + var(--safe-t));
  --tabbar-h: calc(58px + var(--safe-b));
  --font-scale: 1;
  --pane-pad: 12px;
}

body[data-lontara-font="script"] {
  --lontara: "LaGaligoScript", "Noto Sans Buginese", "Noto Sans", sans-serif;
}
body[data-lontara-font="noto"] {
  --lontara: "Noto Sans Buginese", "Noto Sans", sans-serif;
}
body[data-lontara-font="jangang"] {
  --lontara: "Jangang KIT", "Noto Sans Buginese", "Noto Sans", sans-serif;
}
/* Makasar letters are drawn smaller than the Buginese faces at the same size and need a little more air. */
body[data-lontara-font="jangang"] .lontara { line-height: 2.05; }
body[data-lontara-font="jangang"] .lontara .tok { letter-spacing: 0.02em; }

[data-theme="night"] {
  --ink: #f3ead8;
  --muted: #cbbba3;
  --paper: #1a140e;
  --paper-deep: #241c14;
  --rule: #3d3226;
  --accent: #e0a06a;
  --accent-soft: rgba(224, 160, 106, 0.16);
  --topbar: #100c08;
  --topbar-text: #f3ead8;
  --highlight: rgba(224, 160, 106, 0.3);
  --vowel: #e0a06a;
  --vowel-inherent: #c4a07a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  height: 100%;
  height: 100dvh;
  background: var(--topbar);
  color: var(--ink);
  font-family: var(--ui);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.skip-link {
  position: absolute;
  left: 12px;
  top: -40px;
  z-index: 80;
  background: var(--paper);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 8px;
}
.skip-link:focus { top: calc(var(--safe-t) + 8px); }

.icon-btn {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--topbar-text);
}
.icon-btn:hover, .icon-btn:focus-visible, .tab-btn:hover, .tab-btn:focus-visible,
.text-btn:hover, .text-btn:focus-visible, .page-chip:hover, .page-chip:focus-visible {
  outline: none;
  background: rgba(244, 234, 214, 0.12);
}
.icon-btn.tight {
  min-width: 36px;
  min-height: 36px;
  font-size: 16px;
  font-weight: 600;
}
.icon-btn.is-disabled, .icon-btn[disabled] { opacity: 0.35; pointer-events: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  padding: var(--safe-t) var(--safe-r) 0 var(--safe-l);
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px;
  overflow: hidden;
  background: var(--topbar);
  color: var(--topbar-text);
}
.topbar > .icon-btn,
.topbar-actions {
  margin-bottom: 0;
}
.topbar-title {
  min-width: 0;
  text-align: center;
  padding: 2px 4px 2px;
}
.brand {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--topbar-text) 70%, transparent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-chip {
  display: block;
  width: 100%;
  min-height: 28px;
  margin: 0 auto;
  color: var(--topbar-text);
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 8px;
}
.topbar-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 2px;
  padding-right: 2px;
}
.lang-toggle {
  display: inline-flex;
  align-items: stretch;
  flex: 0 0 auto;
  height: 32px;
  padding: 2px;
  margin: 0 2px 0 0;
  border: 1px solid color-mix(in srgb, var(--topbar-text) 28%, transparent);
  border-radius: 999px;
  background: transparent;
  position: relative;
  z-index: 60;
  pointer-events: auto;
}
.lang-toggle button {
  min-width: 28px;
  min-height: 26px;
  padding: 0 7px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: color-mix(in srgb, var(--topbar-text) 72%, transparent);
  font-family: var(--ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.lang-toggle button.is-active {
  background: color-mix(in srgb, var(--topbar-text) 18%, transparent);
  color: var(--topbar-text);
}
.lang-toggle-sheet {
  height: 36px;
  border-color: var(--rule);
  background: var(--paper-deep);
  margin: 4px 0 8px;
}
.lang-toggle-sheet button {
  min-width: 44px;
  min-height: 30px;
  color: var(--muted);
}
.lang-toggle-sheet button.is-active {
  background: var(--accent);
  color: var(--paper);
}

.reader {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--topbar-h) - var(--tabbar-h));
  background: var(--paper);
  overflow: hidden;
}

.scan-pane, .text-pane, .story-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.story-pane { display: none; }
body[data-view="scan"] .text-pane,
body[data-view="text"] .scan-pane,
body[data-view="story"] .scan-pane,
body[data-view="story"] .text-pane { display: none; }
body[data-view="split"] .scan-pane { flex: 0 0 42%; max-height: 48%; }
body[data-view="split"] .text-pane { flex: 1 1 auto; }
body[data-view="scan"] .scan-pane,
body[data-view="text"] .text-pane,
body[data-view="story"] .story-pane { display: flex; flex: 1 1 auto; }

.scan-toolbar, .text-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper-deep);
  flex: 0 0 auto;
}
.text-toolbar {
  padding: 4px 12px;
  min-height: 32px;
}
.text-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
#btn-display-inline { display: none; }
.koreksi-badge {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--topbar-text) 28%, transparent);
  border-radius: 999px;
  background: transparent;
  color: var(--topbar-text);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.koreksi-badge.has-edits {
  border-color: color-mix(in srgb, var(--topbar-text) 70%, transparent);
  background: rgba(244, 234, 214, 0.12);
}
.koreksi-badge span {
  display: inline-block;
  min-width: 1.1em;
  text-align: center;
}
.shelfmark, .text-kicker {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.draft-banner {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--accent);
}
.zoom-controls { display: flex; gap: 2px; color: var(--ink); }
.zoom-controls .icon-btn { color: var(--ink); }

.scan-viewport {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
  touch-action: none;
  background:
    radial-gradient(1200px 400px at 50% 0%, rgba(28, 20, 12, 0.06), transparent 50%),
    var(--paper-deep);
  cursor: grab;
}
.scan-viewport.is-panning { cursor: grabbing; }
.scan-world {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  transform-origin: 0 0;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
}
.scan-world img {
  width: 100%;
  height: auto;
  pointer-events: none;
}
.hotspots { position: absolute; inset: 0; overflow: visible; }
.hotspot {
  position: absolute;
  border-radius: 2px;
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 80%, #1c140c);
  cursor: pointer;
  pointer-events: auto;
}
.hotspot.is-active {
  background: var(--highlight);
  box-shadow: inset 0 0 0 2px var(--accent);
  z-index: 3;
  cursor: move;
}
.hs-h {
  display: none;
  position: absolute;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  touch-action: none;
  pointer-events: auto;
  z-index: 4;
}
.hs-h::after { content: ""; position: absolute; inset: -10px; }
.hotspot.is-active .hs-h { display: block; }
.hs-nw { left: 0; top: 0; cursor: nwse-resize; }
.hs-n { left: 50%; top: 0; cursor: ns-resize; border-radius: 4px; width: 28px; height: 10px; margin: -5px 0 0 -14px; }
.hs-ne { left: 100%; top: 0; cursor: nesw-resize; }
.hs-w { left: 0; top: 50%; cursor: ew-resize; border-radius: 4px; width: 10px; height: 28px; margin: -14px 0 0 -5px; }
.hs-e { left: 100%; top: 50%; cursor: ew-resize; border-radius: 4px; width: 10px; height: 28px; margin: -14px 0 0 -5px; }
.hs-sw { left: 0; top: 100%; cursor: nesw-resize; }
.hs-s { left: 50%; top: 100%; cursor: ns-resize; border-radius: 4px; width: 28px; height: 10px; margin: -5px 0 0 -14px; }
.hs-se { left: 100%; top: 100%; cursor: nwse-resize; }

.attribution {
  flex: 0 0 auto;
  margin: 0;
  padding: 6px 12px calc(8px + var(--safe-b) * 0);
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
  background: var(--paper);
  border-top: 1px solid var(--rule);
}
.attribution a { color: inherit; text-decoration: underline; }

.text-pane { background: var(--paper); }
.text-toolbar .text-btn { color: var(--ink); }
.text-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}
.text-btn.is-active, .text-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff8ef;
}


.line.is-note {
  padding: 8px 10px 10px;
  background: color-mix(in srgb, var(--accent) 6%, var(--paper));
  border-radius: 8px;
  border: 1px dashed color-mix(in srgb, var(--accent) 35%, var(--rule));
}
.line.is-note .line-num {
  color: var(--muted);
  font-style: italic;
  font-weight: 600;
}
.line.is-note .note-latin {
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  margin: 2px 0 6px;
}
.lines {
  list-style: none;
  margin: 0;
  padding: 8px 12px 24px;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  min-height: 0;
}
.line {
  margin: 0;
  padding: 10px 10px 10px 12px;
  border-left: 3px solid transparent;
  border-radius: 0 10px 10px 0;
  scroll-margin: 12px;
}
.line + .line { border-top: 1px dashed color-mix(in srgb, var(--rule) 80%, transparent); }
.line.is-active {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}
.line.is-empty { display: none; }
.line-num {
  display: block;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 2px;
}
.lontara {
  font-family: var(--lontara);
  font-size: calc(1.42em * var(--font-scale));
  line-height: 1.85;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: var(--ink);
}
.latin, .tr-id, .tr-en {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.latin {
  margin-top: 4px;
  font-family: var(--serif);
  font-size: calc(0.98em * var(--font-scale));
  line-height: 1.55;
  color: var(--ink);
}
.tr-id, .tr-en {
  margin-top: 4px;
  font-family: var(--serif);
  font-size: calc(0.92em * var(--font-scale));
  line-height: 1.5;
  color: var(--muted);
}
.tr-en { font-style: italic; }
.tr-id {
  font-style: italic;
  outline: none;
  border-radius: 6px;
  padding: 1px 4px 1px 0;
  min-height: 1.4em;
  overflow-wrap: anywhere;
  word-break: break-word;
  cursor: text;
  -webkit-user-select: text;
  user-select: text;
}
.tr-id:focus {
  color: var(--ink);
  font-style: normal;
  background: var(--paper-deep);
  box-shadow: inset 0 0 0 1.5px var(--accent);
  padding-left: 6px;
}
.tr-id:empty::before {
  content: attr(data-placeholder);
  color: color-mix(in srgb, var(--muted) 65%, var(--paper));
  pointer-events: none;
}
.tr-id.is-edited { color: var(--ink); }
.uncurated {
  font-style: italic;
  color: color-mix(in srgb, var(--muted) 80%, var(--paper));
  font-size: calc(0.86em * var(--font-scale));
}
.lontara, .latin {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.lontara .tok, .latin .tok {
  display: inline-block;
  position: relative;
  margin: 0;
  padding: 0 0.04em;
  border: 0;
  border-radius: 3px;
  background: none;
  color: inherit;
  font: inherit;
  line-height: inherit;
  cursor: pointer;
  vertical-align: baseline;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  max-width: 100%;
}
.lontara .tok.tok-space, .latin .tok.tok-space {
  min-width: 0.45em;
  min-height: 1em;
}
.lontara .tok.has-vowel {
  box-shadow: inset 0 -1.5px 0 color-mix(in srgb, var(--vowel) 65%, transparent);
}
.latin .tok-cons { color: var(--ink); }
.latin .tok-vowel.is-explicit {
  color: var(--vowel);
  font-weight: 600;
}
.latin .tok-vowel.is-inherent {
  color: var(--vowel-inherent);
}
.tok.is-active {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
.tok.is-edited::after {
  content: "";
  position: absolute;
  top: 0.05em;
  right: -0.08em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}
.note-input, .mt-input {
  width: 100%;
  min-height: 88px;
  padding: 8px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.45;
  resize: vertical;
}
.log-list { list-style: none; margin: 0; padding: 0; }
.log-item {
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--paper-deep);
  font-size: 13px;
  line-height: 1.45;
}
.log-item .meta { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.log-item .pair { overflow-wrap: anywhere; word-break: break-word; }
body[data-hide-lontara] .lontara,
body[data-hide-latin] .latin,
body[data-hide-en] .tr-en { display: none; }

.picker-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--paper-deep);
}
.picker-preview .big {
  flex: 0 0 auto;
  font-family: var(--lontara);
  font-size: 3rem;
  line-height: 1;
  color: var(--ink);
}
.picker-preview dl { margin: 0; min-width: 0; }
.picker-preview dt {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.picker-preview dd {
  margin: 0 0 6px;
  font-size: 15px;
  color: var(--ink);
}
.picker-preview dd:last-child { margin-bottom: 0; }
.picker-preview .pv-vowel { color: var(--vowel); font-weight: 600; }
.picker-grid, .vowel-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 14px;
}
.picker-cell, .vowel-cell {
  min-width: 0;
  min-height: 56px;
  padding: 6px 2px 4px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  overflow: visible;
}
.picker-cell .glyph, .vowel-cell .glyph {
  font-family: "Noto Sans Buginese", "LaGaligoSureq", "Noto Sans", sans-serif;
  font-size: 1.3rem;
  line-height: 1.8;
  overflow: visible;
  padding: 2px 0;
}
.picker-cell .lat, .vowel-cell .lat {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.2;
  text-align: center;
}
.vowel-cell { color: var(--vowel); }
.vowel-cell .lat { color: var(--vowel); }
.picker-cell.is-selected, .vowel-cell.is-selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1.5px var(--accent);
  background: var(--accent-soft);
}
.picker-actions, .sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.picker-actions .text-btn, .sheet-actions .text-btn { width: 100%; }
.kamus-glyph {
  font-family: var(--lontara);
  font-size: 2.6rem;
  line-height: 1;
  margin: 0 0 8px;
}
.kamus-note { font-size: 14px; color: var(--muted); line-height: 1.5; }
.loading-line { color: var(--muted); padding: 24px 8px; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  height: var(--tabbar-h);
  padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--topbar);
  color: var(--topbar-text);
  border-top: 1px solid rgba(244, 234, 214, 0.08);
}
.tab-btn {
  min-height: 44px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10px;
  letter-spacing: 0.02em;
  color: color-mix(in srgb, var(--topbar-text) 62%, transparent);
  padding: 6px 2px 4px;
}
.tab-btn span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tab-btn.is-active { color: var(--topbar-text); }

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(16, 10, 6, 0.46);
}
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 60;
  width: min(22rem, 88vw);
  max-width: 100%;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-t);
  padding-bottom: var(--safe-b);
  padding-left: var(--safe-l);
}
.drawer-head, .drawer-foot, .sheet .drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--rule);
}
.drawer-head h2, .sheet h2 {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
}
.drawer .icon-btn, .sheet .icon-btn { color: var(--ink); }
.drawer-body {
  overflow: auto;
  overscroll-behavior: contain;
  padding: 8px 12px 20px;
  flex: 1 1 auto;
  min-height: 0;
}
.drawer-foot {
  border-top: 1px solid var(--rule);
  border-bottom: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.vol-block { margin: 0 0 16px; }
.vol-block h3 {
  margin: 0 0 6px;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.page-link, .vol-soon {
  display: block;
  width: 100%;
  text-align: left;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--rule);
  margin-bottom: 6px;
  background: var(--paper-deep);
  color: var(--ink);
}
.page-link strong, .vol-soon strong { display: block; font-size: 15px; }
.page-link span, .vol-soon span { display: block; font-size: 12px; color: var(--muted); }
.page-link.is-current { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.vol-soon { opacity: 0.72; cursor: default; }

.toc-catalog-lead {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.vol-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}
.vol-chip {
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--rule);
  background: var(--paper-deep);
  text-align: left;
  line-height: 1.2;
  color: var(--ink);
}
.vol-chip strong { display: block; font-size: 13px; }
.vol-chip span { display: block; font-size: 11px; color: var(--muted); }
.vol-chip.is-current { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.page-jump {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  flex-wrap: wrap;
}
.page-jump label { font-size: 13px; color: var(--muted); }
.page-jump input {
  width: 5.5em;
  min-height: 44px;
  padding: 0 8px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--paper-deep);
  color: var(--ink);
  font: inherit;
}
.page-jump-of { font-size: 13px; color: var(--muted); }
.toc-section-title {
  margin: 12px 0 8px;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.scan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 4px;
  margin: 0 0 16px;
}
.scan-grid-btn {
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--paper-deep);
  font-size: 12px;
  color: var(--ink);
}
.scan-grid-btn.is-interactive {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
}
.scan-grid-btn.is-current { box-shadow: inset 0 0 0 1px var(--accent); }

.page-status-badge {
  margin: 0;
  padding: 5px 12px;
  font-size: 11px;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--rule);
  background: var(--accent-soft);
  color: var(--accent);
  flex: 0 0 auto;
}
.page-status-badge.is-awaiting {
  background: color-mix(in srgb, var(--muted) 14%, var(--paper));
  color: var(--muted);
}

.awaiting-panel {
  list-style: none;
  margin: 0;
  padding: 20px 16px 28px;
}
.awaiting-panel h3 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 600;
}
.awaiting-panel p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.5;
}
.awaiting-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.awaiting-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--paper-deep);
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}


.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  max-height: min(86dvh, 640px);
  background: var(--paper);
  color: var(--ink);
  border-radius: 16px 16px 0 0;
  box-shadow: var(--shadow);
  padding-bottom: var(--safe-b);
  display: flex;
  flex-direction: column;
}
.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 4px;
  background: var(--rule);
  margin: 8px auto 0;
}
.sheet-body {
  overflow: auto;
  padding: 4px 16px 20px;
}
fieldset {
  border: 0;
  margin: 0 0 16px;
  padding: 0;
}
legend {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 44px;
  padding: 8px 0;
  font-size: 15px;
}
.toggle input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}
.toggle em {
  display: block;
  font-style: normal;
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
}
.font-row { display: flex; gap: 8px; align-items: center; }
.font-row .text-btn { flex: 1 1 auto; }
.font-row span { min-width: 4.5rem; text-align: center; font-size: 14px; color: var(--muted); }
.sheet-note { font-size: 13px; color: var(--muted); line-height: 1.45; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: #100c08;
  color: #f4ead6;
  display: flex;
  flex-direction: column;
}
.lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(8px + var(--safe-t)) calc(12px + var(--safe-r)) 8px calc(12px + var(--safe-l));
  min-height: 52px;
}
.lightbox-bar p { margin: 0; font-family: var(--serif); }
.lightbox .icon-btn, .lightbox-bar button { color: #f4ead6; min-height: 44px; padding: 0 12px; }
.lightbox-viewport { flex: 1 1 auto; background: #100c08; }


.story-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper-deep);
  flex: 0 0 auto;
}
.story-heading { min-width: 0; }
.story-draft {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
}
.story-lang { display: flex; gap: 6px; flex: 0 0 auto; }
.story-lang .text-btn {
  min-width: 44px;
  min-height: 36px;
  padding: 0 10px;
}
.story-article {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 28px max(22px, var(--safe-l)) 56px max(22px, var(--safe-r));
}
.story-page-label {
  max-width: 38rem;
  margin: 0 auto 1.25rem;
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.story-body {
  max-width: 38rem;
  margin: 0 auto;
  font-family: var(--serif);
  font-size: calc(1.14em * var(--font-scale));
  line-height: 1.8;
  color: var(--ink);
  outline: none;
  border-radius: 10px;
  min-height: 40vh;
  cursor: text;
  -webkit-user-select: text;
  user-select: text;
}
.story-body p { margin: 0 0 1.15em; }
.story-body p:last-child { margin-bottom: 0; }
.story-body:focus {
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 45%, transparent);
  padding: 8px 10px;
}
.story-body:empty::before {
  content: attr(data-placeholder);
  color: color-mix(in srgb, var(--muted) 70%, var(--paper));
  font-style: italic;
}
.story-body.is-edited { /* keep natural text color */ }

@media (min-width: 900px) {
  .topbar { grid-template-columns: 48px minmax(0, 1fr) auto; }
  .reader { flex-direction: row; }
  body[data-view="story"] .reader { flex-direction: column; }
  body[data-view="story"] .story-article { padding-top: 40px; }
  body[data-view="story"] .story-body { font-size: calc(1.2em * var(--font-scale)); }
  body[data-view="split"] .scan-pane,
  body[data-view="split"] .text-pane {
    flex: 1 1 50%;
    max-height: none;
    max-width: 50%;
  }
  body[data-view="split"] .scan-pane { border-right: 1px solid var(--rule); }
  .text-toolbar { padding: 6px 12px; min-height: 44px; }
  #btn-display-inline { display: inline-flex; }
}

@media (max-width: 899px) {
  body[data-view="split"] .attribution { display: none; }
  body[data-view="split"] .text-toolbar {
    padding: 0 12px;
    min-height: 28px;
  }
  body[data-view="split"] .text-kicker { font-size: 10px; }
  .topbar .koreksi-badge { min-height: 28px; font-size: 10px; padding: 0 8px; }
  body[data-view="split"] .line { padding: 6px 8px 6px 10px; }
  body[data-view="split"] .line-num { display: none; }
  body[data-view="split"] .tr-en { display: none; }
  body[data-view="split"] .lontara {
    font-size: calc(1.28em * var(--font-scale));
    line-height: 1.7;
  }
  body[data-view="split"] .latin { margin-top: 2px; }
  body[data-view="split"] .word-col .lontara { line-height: 1.35; }
  body[data-view="split"] .word-col .latin { margin-top: 0; line-height: 1.2; }
  body[data-view="split"] .tr-id { margin-top: 2px; font-size: calc(0.84em * var(--font-scale)); }
}

@media (max-width: 899px) and (orientation: landscape) {
  body[data-view="split"] .reader { flex-direction: row; }
  body[data-view="split"] .scan-pane,
  body[data-view="split"] .text-pane {
    flex: 1 1 50%;
    max-height: none;
  }
  body[data-view="split"] .scan-pane { border-right: 1px solid var(--rule); }
}

@media (min-width: 900px) {
  /* Display controls live in the sheet still, but expose a desktop entry in the text toolbar. */
}


@media (max-width: 480px) {
  .topbar .koreksi-label { display: none; }
  .topbar .lang-toggle { height: 28px; }
  .topbar .lang-toggle button { min-width: 26px; min-height: 22px; padding: 0 6px; font-size: 10px; }
}

/* Picker: live cropped scan of the tapped line */
.picker-sheet {
  max-height: min(96dvh, 920px);
  overflow: hidden;
  padding-bottom: var(--safe-b);
}
.picker-topbar {
  display: flex;
  align-items: stretch;
  gap: 0;
  height: 48px;
  flex: 0 0 48px;
  min-width: 0;
  padding: 0;
  border-bottom: 1px solid var(--rule);
}
.picker-topbar-mid {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  padding: 1px 4px 2px;
}
.picker-topbar-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  flex-wrap: nowrap;
  gap: 2px;
}
.picker-topbar .picker-scan-caption {
  flex: 0 0 auto;
  margin: 0;
  min-width: 0;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0;
  color: var(--ink);
  text-align: center;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.picker-step-prev,
.picker-step-next {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  border: 0;
  border-radius: 0;
  flex: 0 0 auto;
  height: auto;
  min-height: 48px;
  color: var(--ink);
  cursor: pointer;
  line-height: 1;
  font-weight: 800;
  -webkit-tap-highlight-color: transparent;
}
.picker-step-prev {
  width: 46px;
  min-width: 46px;
  font-size: 22px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  border-right: 1px solid var(--rule);
}
.picker-step-next {
  width: 62px;
  min-width: 62px;
  font-size: 28px;
  background: color-mix(in srgb, var(--accent) 32%, transparent);
  border-left: 1px solid var(--rule);
}
.picker-step-prev:disabled,
.picker-step-next:disabled { opacity: 0.34; cursor: default; }
.picker-step-prev:not(:disabled):active,
.picker-step-next:not(:disabled):active { filter: brightness(0.94); }
.picker-topbar .icon-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  flex: 0 0 28px;
}
.picker-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  min-height: 28px;
  min-width: 28px;
  padding: 0 7px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: 650 11px/1 system-ui, sans-serif;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.picker-tool-btn:disabled { opacity: 0.35; cursor: default; }
#picker-slot-delete { font-size: 16px; font-weight: 700; padding: 0; width: 28px; }
#picker-undo {
  width: 28px;
  min-width: 28px;
  padding: 0;
  flex: 0 0 28px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}
.picker-topbar .picker-guides-toggle {
  margin: 0;
  height: 28px;
  min-height: 28px;
  padding: 0 6px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  gap: 3px;
}
@media (max-width: 430px) {
  .picker-step-prev { width: 42px; min-width: 42px; font-size: 20px; }
  .picker-step-next { width: 56px; min-width: 56px; font-size: 26px; }
  .picker-topbar-mid { padding-left: 2px; padding-right: 2px; }
  .picker-topbar .picker-scan-caption { font-size: 10px; }
  .picker-tool-btn, .picker-topbar .picker-guides-toggle { padding-left: 5px; padding-right: 5px; }
}
.picker-scan {
  flex: 0 0 auto;
  padding: 12px 8px 8px;
  overflow-x: hidden;
  overflow-y: visible;
}
.picker-scan-frame {
  --strip-rail: 22px;
  --strip-handle: 16px;
  position: relative;
  display: flex;
  flex-direction: column;
  height: 232px;
  border-radius: 8px;
  overflow: visible;
  background: #1c140c;
  box-shadow: inset 0 0 0 1px var(--rule);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}
.picker-scan-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border-radius: 8px 8px 0 0;
}
.picker-scan-stage canvas,
.picker-scan-frame canvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: calc(100% - var(--strip-handle, 16px));
}
.picker-char-hits {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.pg-char {
  position: absolute;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: auto;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pg-char:focus-visible {
  outline: 2px solid rgba(255, 204, 51, 0.8);
  outline-offset: -2px;
}
.picker-guides {
  position: absolute;
  inset: 0;
  /* Keep guide lines and any chips off the 22px dark syllable rail. */
  bottom: var(--strip-rail, 22px);
  overflow: hidden;
  pointer-events: none;
  z-index: 6;
}
.picker-guides[hidden] { display: none; }
.pg-seam {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 1px solid rgba(120, 200, 255, 0.58);
  pointer-events: none;
  z-index: 1;
}
.picker-syl-rail .pg-rail-seam {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 1px solid rgba(120, 200, 255, 0.42);
  pointer-events: none;
  z-index: 1;
}
.picker-scan-frame.is-guides .pg-rail-seam { display: none; }
.pg-neighbor {
  position: absolute;
  box-sizing: border-box;
  border: 1px dashed rgba(255, 204, 51, 0.42);
  background: rgba(255, 204, 51, 0.05);
  border-radius: 3px;
  pointer-events: none;
  z-index: 1;
}
.pg-gap {
  position: absolute;
  width: 0;
  border-left: 1px dotted rgba(120, 200, 255, 0.75);
}
.pg-redmark {
  position: absolute;
  border: 1.5px solid #ff2d55;
  border-radius: 4px;
  background: rgba(255, 45, 85, 0.12);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5);
}
.pg-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 2px dashed #dc2626;
}
.pg-line.pg-red { border-left-color: #ff2d55; }
.pg-line.pg-est { border-left-style: dotted; border-left-color: rgba(242, 182, 50, 0.85); }
.pg-line.pg-suggest { border-left: 2px dashed #dc2626; }
.pg-line.pg-suggest.pg-red { border-left-color: #b91c1c; }
.pg-line.pg-word {
  width: 0;
  margin-left: 0;
  border-left: none;
  pointer-events: auto;
  cursor: ew-resize;
  touch-action: none;
  z-index: 8;
}
.pg-line.pg-word::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  border-left: 2px dashed #dc2626;
  pointer-events: none;
}
.pg-line.pg-word::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -10px;
  width: 20px;
  pointer-events: auto;
}
.pg-line.pg-word.pg-red::before { border-left-color: #b91c1c; }
.pg-line.pg-word.pg-custom::before,
.pg-line.pg-word.is-custom::before { border-left-style: solid; }
/* Small circular × straddling the top edge of the strip, nudged right of the
   red line so it is not mistaken for the tallest box's top-right handle. */
.pg-remove {
  position: absolute;
  top: 0;
  left: 0;
  transform: translate(5px, -50%);
  width: 18px;
  height: 18px;
  min-width: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #dc2626;
  color: #fff;
  font: 700 12px/18px system-ui, sans-serif;
  text-align: center;
  pointer-events: auto;
  cursor: pointer;
  touch-action: manipulation;
  z-index: 9;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.pg-word.pg-red > .pg-remove { background: #b91c1c; }
.pg-chip {
  position: absolute;
  top: 3px;
  left: 0;
  transform: translateX(-50%);
  pointer-events: auto;
  white-space: nowrap;
  font: 600 10px/1.2 system-ui, sans-serif;
  padding: 2px 6px;
  border-radius: 999px;
  border: 0;
  color: #fff;
  background: #dc2626;
  cursor: pointer;
  opacity: 0.92;
}
.pg-red > .pg-chip { background: #b91c1c; color: #fff; }
.pg-suggest > .pg-chip { display: none; }
.pg-suggest.pg-red > .pg-chip { background: #b91c1c; color: #fff; }
.picker-box {
  position: absolute;
  box-sizing: border-box;
  border: 2.5px solid #ffcc33;
  border-radius: 4px;
  background: rgba(255, 204, 51, 0.10);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
  cursor: move;
  touch-action: none;
  z-index: 7;
}
.picker-box[hidden] { display: none; }
.picker-box.is-custom { border-color: #ff7a1a; background: rgba(255, 122, 26, 0.10); }
.picker-box.is-dragging { box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55); }
.pb-h {
  position: absolute;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #ff7a1a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  touch-action: none;
  z-index: 8;
}
.pb-h::after { content: ""; position: absolute; inset: -10px; }
.pb-nw { left: 0; top: 0; cursor: nwse-resize; }
.pb-n { left: 50%; top: 0; cursor: ns-resize; border-radius: 4px; height: 10px; margin-top: -5px; }
.pb-ne { left: 100%; top: 0; cursor: nesw-resize; }
.pb-w { left: 0; top: 50%; cursor: ew-resize; border-radius: 4px; width: 10px; margin-left: -5px; }
.pb-e { left: 100%; top: 50%; cursor: ew-resize; border-radius: 4px; width: 10px; margin-left: -5px; }
.pb-sw { left: 0; top: 100%; cursor: nesw-resize; }
.pb-s { left: 50%; top: 100%; cursor: ns-resize; border-radius: 4px; height: 10px; margin-top: -5px; }
.pb-se { left: 100%; top: 100%; cursor: nwse-resize; }
.picker-scan-nav { display: none; }
.picker-scan-opts, .picker-scan-tools { display: none; }
/* Zoom lives inside the crop: hidden on touch/mobile, tiny overlay on desktop/web */
.picker-zoom { display: none; }
.picker-zoom button {
  border: 0;
  background: transparent;
  color: inherit;
  font: 600 10px/1 system-ui, sans-serif;
  padding: 4px 6px;
  cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
  .picker-zoom {
    display: inline-flex;
    position: absolute;
    left: 6px;
    bottom: 6px;
    z-index: 6;
    border: 1px solid rgba(255, 255, 255, 0.32);
    border-radius: 999px;
    overflow: hidden;
    flex: 0 0 auto;
    background: rgba(28, 20, 12, 0.48);
    color: #f4ead6;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }
  .picker-zoom button.is-selected { background: rgba(255, 204, 51, 0.88); color: #1c140c; }
}
.picker-slots { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; flex: 0 0 auto; }
.picker-slots button {
  border: 0;
  background: transparent;
  color: inherit;
  font: 700 14px/1 system-ui, sans-serif;
  padding: 5px 9px;
  min-width: 28px;
  cursor: pointer;
}
.picker-slots button:disabled { opacity: 0.35; cursor: default; }
.picker-guides-toggle { font-size: 11px; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; margin-left: auto; }
.picker-guides-toggle input { width: 14px; height: 14px; margin: 0; }
.text-btn.tight { padding: 4px 8px; font-size: 11px; }
.picker-legend, .picker-hint { display: none !important; }
.picker-legend .lg { display: inline-flex; align-items: center; gap: 5px; }
.picker-legend i { display: inline-block; width: 0; height: 12px; }
.lg-word i { border-left: 2px dashed #dc2626; }
.lg-red i { border-left: 2px solid #ff2d55; }
.lg-gap i { border-left: 1px dotted #3c9bd6; }
.picker-hint { margin: 4px 0 0; font-size: 11px; color: var(--muted); }
.picker-ocr {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px 2px;
  min-height: 0;
}
.picker-ocr[hidden] { display: none; }
.picker-ocr.is-busy { opacity: 0.6; }
.picker-ocr .ocr-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.picker-ocr .ocr-engine {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 1px 8px;
  background: color-mix(in srgb, var(--paper) 80%, transparent);
}
.picker-ocr .ocr-engine[data-engine="cnn"] { border-color: color-mix(in srgb, var(--accent) 55%, var(--rule)); }
.picker-ocr .ocr-note { font-size: 11px; color: var(--muted); }
.ocr-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.ocr-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 10px;
  border: 1px solid var(--rule);
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.ocr-chip .glyph { font-family: "Noto Sans Buginese", "LaGaligoSureq", "Noto Sans", sans-serif; font-size: 22px; line-height: 1.6; overflow: visible; }
.ocr-chip .lat { font-size: 12px; font-weight: 600; }
.ocr-chip .pct { font-size: 11px; color: var(--muted); }
.ocr-chip.is-best { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.ocr-chip.is-current { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.ocr-chip.is-special { font-style: italic; }
.ocr-chip.is-info { cursor: default; opacity: 0.92; }

.picker-manual {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--rule);
}
.picker-manual[hidden] { display: none; }
.picker-manual.is-busy { opacity: 0.7; pointer-events: none; }
.ocr-alts {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  width: 100%;
}
.ocr-alt {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px dashed var(--rule);
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.78;
}
.ocr-alt .glyph { font-family: "Noto Sans Buginese", "LaGaligoSureq", "Noto Sans", sans-serif; font-size: 16px; line-height: 1.7; overflow: visible; }
.ocr-alt .lat { font-size: 10px; font-weight: 600; color: var(--muted); }
.picker-manual .ocr-engine {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  opacity: 0.75;
  white-space: nowrap;
}
.manual-head {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 4px 8px;
  min-height: 32px;
  margin-bottom: 4px;
}
.manual-title, .manual-cons-label { display: none; }
.manual-preview { display: inline-flex; align-items: baseline; gap: 5px; min-width: 0; }
.manual-preview .glyph { font-family: "Noto Sans Buginese", "LaGaligoSureq", "Noto Sans", sans-serif; font-size: 20px; line-height: 1.8; overflow: visible; }
.manual-preview .lat { font-size: 12px; font-weight: 600; }
.manual-vowels {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
  margin-bottom: 4px;
}
.manual-vowel, .manual-cons {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0;
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: transparent;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.manual-vowel {
  flex: none;
  flex-direction: column;
  align-items: center;
  gap: 0;
  min-width: 0;
  min-height: 52px;
  padding: 4px 0 2px;
  overflow: visible;
}
.manual-vowel .glyph { font-family: "Noto Sans Buginese", "LaGaligoSureq", "Noto Sans", sans-serif; font-size: 16px; line-height: 1.85; padding: 2px 0; overflow: visible; }
.manual-vowel .lat { font-size: 8px; font-weight: 600; color: var(--muted); line-height: 1.1; }
.manual-vowel.is-selected, .manual-cons.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}
.manual-vowel:disabled, .manual-vowel.is-sample { opacity: 0.5; }
.manual-vowel:disabled { cursor: not-allowed; }
.manual-vowel { position: relative; z-index: 0; }
.manual-vowel[data-hint]::after {
  content: attr(data-hint);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 5px);
  transform: translateX(-50%);
  width: max-content;
  max-width: 160px;
  padding: 4px 7px;
  border-radius: 6px;
  background: rgba(28, 20, 12, 0.92);
  color: #f4ead6;
  font: 600 11px/1.3 system-ui, sans-serif;
  letter-spacing: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  z-index: 30;
  white-space: nowrap;
}
@media (hover: hover) and (pointer: fine) {
  .manual-vowel[data-hint]:hover,
  .manual-vowel[data-hint]:focus-visible { z-index: 8; }
  .manual-vowel[data-hint]:hover::after,
  .manual-vowel[data-hint]:focus-visible::after { opacity: 1; }
}
.manual-cons-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
  max-height: none;
  overflow: visible;
  padding: 0;
}
.manual-cons { flex-direction: column; align-items: center; gap: 0; height: auto; min-height: 54px; min-width: 0; padding: 4px 0 3px; overflow: visible; }
.manual-cons .glyph { font-family: "Noto Sans Buginese", "LaGaligoSureq", "Noto Sans", sans-serif; font-size: 18px; line-height: 1.7; padding: 2px 0 0; overflow: visible; }
.manual-cons .lat { font-size: 9px; font-weight: 600; color: var(--muted); line-height: 1.1; }
.tok.is-current { outline: 2px solid #ff7a1a; outline-offset: 1px; border-radius: 4px; }
.word-div.is-suggested .word-div-bar { opacity: 1; background: transparent; border-left: 2px dashed #3c9bd6; }
.word-div.is-suggested-red .word-div-bar { border-left-color: #ff2d55; }
.picker-scan-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.picker-scan-caption {
  flex: 1 1 auto;
  margin: 0;
  font-size: 13px;
  letter-spacing: 0;
  color: var(--ink);
  text-align: center;
  line-height: 1.2;
}
/* Right-edge tool stack (v44): 40px square buttons above the character box
   and resize handles, kept clear of the 22px syllable rail. */
.picker-edge-stack {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  z-index: 20;
  pointer-events: none;
  max-height: calc(100% - var(--strip-handle, 16px) - 4px);
}
.picker-edge-stack [hidden] { display: none !important; }
.picker-edge-insert,
.picker-edge-add,
.picker-edge-delete {
  position: relative;
  top: auto;
  right: 0;
  bottom: auto;
  left: auto;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  z-index: 20;
  padding: 0;
  border: 0;
  border-radius: 8px 0 0 8px;
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}
.picker-edge-insert {
  background: #d97706;
  cursor: ew-resize;
  touch-action: none;
}
.picker-edge-add { background: #dc2626; }
.picker-edge-add.is-remove { background: #b91c1c; }
.picker-edge-delete { background: #7f1d1d; }
.picker-edge-insert.is-dragging,
.picker-edge-add.is-pressed,
.picker-edge-delete.is-pressed { filter: brightness(1.12); }
.picker-edge-tab {
  position: static;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: 700 22px/40px system-ui, sans-serif;
  text-align: center;
  box-shadow: none;
  pointer-events: none;
}
.picker-edge-preview {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 2px solid #dc2626;
  z-index: 4;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.picker-edge-preview[hidden] { display: none; }
.picker-box-preview {
  position: absolute;
  box-sizing: border-box;
  border: 2.5px solid #ffcc33;
  border-radius: 4px;
  background: rgba(255, 204, 51, 0.16);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  z-index: 5;
}
.picker-box-preview[hidden] { display: none; }

/* Movable word-boundary handles */
.word-div {
  display: inline-flex;
  align-items: stretch;
  justify-content: center;
  width: 0.42em;
  min-height: 1.15em;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  vertical-align: middle;
  cursor: ew-resize;
  touch-action: none;
  position: relative;
  z-index: 1;
  -webkit-tap-highlight-color: transparent;
}
.word-div-bar {
  width: 1px;
  align-self: stretch;
  margin: 0.12em 0;
  background: transparent;
  border-radius: 1px;
  pointer-events: none;
}
.word-div.is-on .word-div-bar {
  width: 1.5px;
  background: color-mix(in srgb, var(--accent) 72%, var(--muted));
}
.word-div.is-off:hover .word-div-bar,
.word-div.is-off:focus-visible .word-div-bar {
  width: 1px;
  background: color-mix(in srgb, var(--muted) 50%, transparent);
}
.word-div.is-target .word-div-bar,
.word-div.is-on:hover .word-div-bar,
.word-div.is-on:focus-visible .word-div-bar {
  width: 2px;
  background: var(--accent);
}
.lontara .word-div { min-height: 1.35em; }
.latin .word-div { min-height: 1.1em; }

.kamus-entry { margin: 0 0 14px; }
.kamus-word {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 2px;
}
.kamus-meta { margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.kamus-gloss { margin: 0 0 6px; font-size: 15px; line-height: 1.5; }
.kamus-note-line { margin: 0 0 8px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.kamus-syl { margin: 0 0 10px; font-size: 12px; color: var(--muted); }

.word-div.is-off {
  width: 0;
  min-width: 0;
  margin: 0;
  overflow: visible;
}
.word-div.is-off::before {
  content: "";
  position: absolute;
  left: -5px;
  right: -5px;
  top: 0;
  bottom: 0;
}
.word-div.is-on {
  width: 0.42em;
  margin: 0 0.06em;
}
.word {
  display: inline;
  margin: 0;
  padding: 0;
  letter-spacing: 0;
  white-space: nowrap;
}

/* Interlinear word columns: Latin sits under its Lontara word; width = the wider of the two. */
.script-line {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  column-gap: 0;
  row-gap: 0.22em;
  max-width: 100%;
}
.word-wrap {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: stretch;
  max-width: 100%;
}
.word-col {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  min-width: 0;
}
.word-col .lontara,
.word-col .latin {
  display: block;
  margin: 0;
  text-align: center;
  overflow-wrap: normal;
  word-break: normal;
  white-space: nowrap;
}
.word-col .latin {
  margin-top: 0.02em;
  line-height: 1.25;
  font-size: calc(0.92em * var(--font-scale));
}
.word-col .lontara {
  line-height: 1.4;
}
.word-col .word {
  display: block;
  text-align: center;
  white-space: nowrap;
}
.word-col-break {
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-start;
  min-width: 0.36em;
}
.word-col-break .lontara,
.word-col-break .latin {
  display: flex;
  align-items: center;
  justify-content: center;
}
.word-col-punct {
  padding: 0 0.04em;
}
.word .tok {
  margin: 0;
  padding: 0;
  letter-spacing: 0;
}
.word.is-karaoke,
.tok.is-karaoke,
.tr-seg.is-karaoke {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: 3px;
}
.tr-seg {
  border-radius: 3px;
  transition: background 120ms ease;
}
.tr-id.is-editing { white-space: pre-wrap; }

.line-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 2px;
}
.line-head .line-num { margin: 0; }
.tts-line-btn,
.tts-page-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 0;
  cursor: pointer;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.tts-line-btn {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-size: 11px;
}
.tts-line-btn.is-playing,
.tts-page-btn.is-playing {
  background: var(--accent);
  color: var(--paper);
}
.tts-page-btn {
  width: 32px;
  min-width: 32px;
  height: 32px;
  margin: 0 2px 0 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--topbar-text) 18%, transparent);
  color: var(--topbar-text);
  font-size: 12px;
  z-index: 61;
  pointer-events: auto;
}
.tts-page-btn .tts-icon-stop,
.tts-line-btn .tts-icon-stop { display: none; }
.tts-page-btn.is-playing .tts-icon-play,
.tts-line-btn.is-playing .tts-icon-play { display: none; }
.tts-page-btn.is-playing .tts-icon-stop,
.tts-line-btn.is-playing .tts-icon-stop { display: inline; }

.font-choice { display: flex; flex-wrap: wrap; gap: 6px; }
.font-choice .text-btn { min-height: 32px; }
.font-choice .text-btn { white-space: nowrap; }
@media (max-width: 480px) {
  /* four typefaces: a compact 2 x 2 grid instead of wrapped, uneven rows */
  .font-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .font-choice .text-btn { min-width: 0; padding-inline: 6px; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
}
#jangang-note { margin: 6px 0 0; font-size: 12.5px; line-height: 1.4; }
#jangang-note[hidden] { display: none; }

@media (max-width: 480px) {
  .word-div.is-on { width: 0.4em; }
  .tts-page-btn { width: 28px; min-width: 28px; height: 28px; }
  .topbar-actions { gap: 0; }
}


/* Status / Contribute — sheet, not a sixth tab */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid rgba(244, 234, 214, 0.28);
  color: var(--topbar-text);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.92;
}
.status-pill svg { flex: 0 0 auto; opacity: 0.9; }
.status-pill[aria-expanded="true"] {
  background: rgba(244, 234, 214, 0.12);
}
.toc-status-link,
.status-sheet-link {
  display: block;
  width: 100%;
  text-align: left;
  min-height: 44px;
  padding: 10px 12px;
  margin: 10px 12px 0;
  width: calc(100% - 24px);
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}
.status-sheet-link { margin: 0 0 14px; width: 100%; }
.toc-status-link strong,
.status-sheet-link strong { display: block; font-size: 15px; }
.toc-status-link span,
.status-sheet-link span { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }

.status-sheet { max-height: min(92dvh, 820px); }
.status-lead {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
}
.status-h {
  margin: 18px 0 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.status-stage,
.status-vol {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  align-items: baseline;
  margin: 0 0 9px;
}
.status-stage-label,
.status-vol-label { font-size: 13px; }
.status-stage-count,
.status-vol-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.status-bar {
  grid-column: 1 / -1;
  height: 7px;
  border-radius: 99px;
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  overflow: hidden;
}
.status-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  width: 0;
}
.status-vol-note { grid-column: 1 / -1; font-size: 11px; color: var(--muted); }
.status-task {
  border: 1px solid var(--rule);
  background: var(--paper-deep);
  border-radius: 10px;
  padding: 8px 10px;
  margin: 0 0 8px;
}
.status-task strong { display: block; font-size: 14px; }
.status-task p { margin: 4px 0 0; font-size: 12px; color: var(--muted); line-height: 1.4; }
.status-task-kind {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 2px;
}

.dropzone {
  border: 1.5px dashed var(--accent);
  border-radius: 12px;
  background: var(--accent-soft);
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  cursor: pointer;
  color: var(--ink);
  font-size: 14px;
}
.dropzone.is-hot { background: var(--paper-deep); }
.dropzone p { margin: 0; }
.upload-error { color: var(--danger-muted); font-size: 13px; margin: 8px 0 0; }
.upload-form { margin-top: 12px; }
.upload-target {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}
.upload-target label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.upload-target input,
.upload-notes textarea {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}
.upload-meta { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.upload-preview {
  max-height: 200px;
  overflow: auto;
  margin: 0 0 10px;
  padding: 0 0 0 1.2em;
  font-family: var(--lontara);
  font-size: 18px;
  line-height: 1.7;
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 8px 10px 8px 2em;
}
.upload-preview li { word-break: break-word; }
.upload-notes { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.contrib-help { margin-bottom: 8px; }
.status-links { word-break: break-all; }

@media (max-width: 480px) {
  .topbar .status-pill-label { display: none; }
  .topbar .status-pill { min-height: 28px; padding: 0 7px; }
}

.status-achieve,
.status-log-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
}
.status-achieve:last-child,
.status-log-item:last-child { border-bottom: 0; }
.status-ts {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}
.status-achieve strong,
.status-log-item strong { display: block; font-size: 14px; font-weight: 600; }
.status-achieve p,
.status-log-note {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.status-log-meta {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.status-log-state { color: var(--accent); }

/* Compact project links (TOC + Status sheet) */
.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 8px 12px 10px;
  font-size: 12px;
  line-height: 1.35;
  border-bottom: 1px solid var(--rule);
}
.project-links-sheet {
  padding: 0 0 12px;
  margin: 0 0 4px;
  border-bottom: 1px solid var(--rule);
}
.project-links a {
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
.project-links a:hover, .project-links a:focus-visible { text-decoration: underline; }

/* BYOK worker panel */
.byok-panel { margin: 4px 0 16px; }
.byok-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 8px;
}
.byok-panel label,
.byok-key-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.byok-panel select,
.byok-panel input[type="text"],
.byok-panel input[type="url"],
.byok-panel input[type="password"],
.byok-panel input[type="number"] {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}
.byok-remember {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 13px;
}
.byok-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.byok-status { font-size: 13px; margin: 0 0 8px; min-height: 1.2em; }
.byok-progress {
  max-height: 160px;
  overflow: auto;
  margin: 0 0 8px;
  padding: 8px 10px 8px 1.6em;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--paper-deep);
  font-size: 12px;
  line-height: 1.45;
}
.byok-preview {
  max-height: 220px;
  overflow: auto;
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--paper-deep);
  font-size: 11px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
@media (max-width: 480px) {
  .byok-row { grid-template-columns: 1fr; }
  .project-links a { white-space: normal; }
}

/* Support / donate card in the Status sheet */
.support-card {
  margin: 0 0 14px;
  padding: 10px 12px 12px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--paper-deep);
}
.support-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 10px;
}
.support-card-head h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
}
.support-cta {
  flex: 0 0 auto;
  text-decoration: none;
  background: var(--accent);
  color: var(--paper) !important;
  border-color: var(--accent);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
}
.support-cta:hover, .support-cta:focus-visible {
  filter: brightness(1.08);
  text-decoration: none;
}
.support-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 14px;
}
.support-grid h4 {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.support-grid ul {
  margin: 0;
  padding: 0 0 0 1.1em;
}
.support-grid li {
  margin: 0 0 5px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink);
}
.support-card .sheet-note { margin: 8px 0 0; }
@media (max-width: 720px) {
  .support-grid { grid-template-columns: 1fr; gap: 10px; }
}

/* Sponsor dedication + credits wall */
.dedication-badge {
  margin: 0;
  padding: 5px 12px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
  background: var(--paper-deep);
  border-bottom: 1px solid var(--rule);
}
.dedication-badge span {
  display: block;
  padding-left: 8px;
  border-left: 2px solid var(--accent);
}
.vol-dedication {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}
.support-tiers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 12px;
  margin: 0 0 8px;
}
.support-tiers h4 {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
}
.support-tiers p {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink);
}
.status-credits, .status-wall, .credits-compact {
  margin: 0 0 14px;
  padding: 10px 12px 12px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--paper-deep);
}
.status-credits {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--paper-deep));
}
.credits-block h2, .wall-block h2, .status-credits h2, .credits-compact h3, .status-wall h2 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
}
.credits-block h3, .wall-block h3, .status-credits h3, .status-wall h3 {
  margin: 12px 0 4px;
  font-size: 13px;
  font-weight: 600;
}
.credits-block p, .wall-block > p, .status-credits p, .credits-compact p, .status-wall > p,
.credits-block li, .status-credits li, .wall-list li {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.45;
}
.credits-honest, .wall-empty-note { color: var(--muted); }
.wall-empty, .wall-founding {
  padding: 10px;
  border-radius: 10px;
  border: 1px dashed var(--accent);
  background: var(--paper);
  margin: 0 0 10px;
}
.wall-list { margin: 0 0 10px; padding: 0 0 0 1.15em; }
.toc-credits-link { margin-top: 8px; }
@media (max-width: 720px) {
  .support-tiers { grid-template-columns: 1fr; }
}

/* First-visit welcome */
.welcome-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(28, 20, 12, 0.55);
}
.welcome-card {
  position: relative;
  max-width: 520px;
  width: 100%;
  padding: 22px 20px 18px;
  border-radius: 16px;
  border: 1px solid var(--rule, #d4c4a8);
  background: var(--paper, #f4ead6);
  color: var(--ink, #1c140c);
  box-shadow: 0 16px 40px rgba(28, 20, 12, 0.28);
}
.welcome-card h2 {
  margin: 0 22px 12px 0;
  font-family: var(--serif, Georgia, serif);
  font-size: 1.35rem;
}
.welcome-card ul {
  margin: 0 0 16px;
  padding: 0 0 0 1.15em;
}
.welcome-card li {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.45;
}
.welcome-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.welcome-primary, .welcome-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}
.welcome-primary {
  background: var(--accent, #7a3e1d);
  color: var(--paper, #f4ead6);
}
.welcome-link {
  border: 1px solid var(--rule, #d4c4a8);
  color: var(--ink, #1c140c);
  background: var(--paper-deep, #ebe0c8);
}
.welcome-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  border: 0;
  background: none;
  color: inherit;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

.picker-type-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}
.picker-type-layer[hidden] { display: none !important; }
.pg-type {
  position: absolute;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(246, 239, 224, 0.90);
  color: #1c140c;
  font-family: var(--lontara);
  font-weight: 400;
  line-height: 1;
  border-radius: 2px;
  overflow: visible;
  white-space: nowrap;
  letter-spacing: 0;
}
.pg-type.is-current {
  background: rgba(246, 239, 224, 0.40);
  color: rgba(28, 20, 12, 0.58);
}
.pg-type.is-pallawa {
  font-family: var(--lontara);
  overflow: visible;
  color: #1c140c;
}
.pg-type.is-pallawa.is-current {
  color: #1c140c;
  background: rgba(246, 239, 224, 0.55);
}
.picker-syl-rail {
  position: relative;
  flex: 0 0 var(--strip-rail, 22px);
  height: var(--strip-rail, 22px);
  pointer-events: none;
  z-index: 3;
  background: #24180f;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
  border-radius: 0 0 8px 8px;
}
.pg-syl {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: 4.8em;
  overflow: hidden;
  text-overflow: ellipsis;
  font: 650 11px/1 var(--ui);
  color: #f6e7c8;
  background: transparent;
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
  text-align: center;
  padding: 0 3px;
  border-radius: 3px;
  z-index: 5;
  -webkit-tap-highlight-color: transparent;
}
.pg-syl.is-with-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  max-width: 6.2em;
  overflow: hidden;
}
.pg-syl-glyph {
  font-family: var(--lontara);
  font-size: 13px;
  font-weight: 400;
  line-height: 1;
  color: #f3e2bc;
  flex: 0 0 auto;
}
.pg-syl-lat {
  font: 650 10px/1 var(--ui);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pg-syl.is-current .pg-syl-glyph,
.pg-syl.is-current .pg-syl-lat { color: inherit; }
.pg-syl.is-pallawa.is-with-glyph {
  font-size: inherit;
  padding: 0 3px;
  gap: 2px;
}
.pg-syl.is-pallawa.is-with-glyph .pg-syl-glyph {
  font-size: 14px;
  font-weight: 400;
}
.pg-syl.is-current {
  color: #1c140c;
  font-weight: 800;
  background: #ffe28a;
}
.pg-syl.is-pallawa {
  font-family: var(--lontara);
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
  padding: 0 6px;
  overflow: visible;
}
.picker-timpa-toggle .timpa-glyph {
  font-family: "LaGaligoSureq", var(--lontara);
  font-size: 15px;
  line-height: 1;
  min-width: 12px;
  text-align: center;
}
@media (max-width: 430px) {
  .picker-guides-toggle > span:not(.timpa-glyph) { display: none; }
  .picker-timpa-toggle { padding-left: 5px; padding-right: 5px; }
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
html[data-await-lang] body { visibility: hidden; }

@media (max-width: 720px) {
  .picker-sheet .sheet-body { display: none !important; }
  .picker-sheet .sheet-handle { display: none; }
  .picker-scan-frame { height: 184px; }
  .manual-cons { height: auto; min-height: 52px; }
  .picker-sheet { max-height: 100dvh; overflow: hidden; }
}
@media (max-width: 720px) and (max-height: 760px) {
  .picker-scan-frame { height: 176px; }
  .manual-cons { height: auto; min-height: 50px; }
  .manual-vowel { min-height: 50px; }
}

/* v40 theatrical Story neural TTS player — compact, theme-aware, no overflow */
.story-player {
  max-width: 38rem;
  margin: 0 auto 1rem;
  min-width: 0;
  width: 100%;
}
.story-pane.has-story-tts #story-body { display: none; }
.story-pane.has-story-tts .story-draft { display: none; }
.story-pane.has-story-tts .story-article { padding-top: 16px; }
.story-neural-player { font-family: var(--serif); color: var(--ink); }
.story-neural-player .snp-toolbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "play role time"
    "scrub scrub scrub";
  align-items: center;
  gap: 6px 8px;
  margin: 0 0 0.85rem;
  padding: 8px 0 10px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  min-width: 0;
  width: 100%;
}
.story-neural-player .snp-play {
  grid-area: play;
  font-family: var(--ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0 12px;
  min-height: 32px;
  min-width: 64px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--paper);
  cursor: pointer;
  white-space: nowrap;
}
.story-neural-player .snp-play:hover { filter: brightness(1.08); }
.story-neural-player .snp-role {
  grid-area: role;
  min-width: 0;
  font-family: var(--ui);
  font-size: 11px;
  font-variant: small-caps;
  letter-spacing: 0.04em;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.story-neural-player .snp-time {
  grid-area: time;
  font-family: var(--ui);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}
.story-neural-player .snp-scrub {
  grid-area: scrub;
  width: 100%;
  min-width: 0;
  height: 28px;
  margin: 0;
  accent-color: var(--accent);
}
.story-neural-player .snp-reader {
  line-height: 1.8;
  font-size: calc(1.14em * var(--font-scale));
  color: var(--ink);
}
.story-neural-player .snp-reader .seg-span { border-radius: 4px; transition: background 0.15s; }
.story-neural-player .snp-reader .seg-span[data-role="scholar"] { opacity: 0.72; font-size: 0.95em; }
.story-neural-player .snp-reader .active-seg { background: #fef9c3; color: #1c1917; }
.story-neural-player .snp-reader .active-word { background: #facc15; border-radius: 3px; color: #1c1917; }
.story-neural-player .snp-reader .seg-span[data-role]:not([data-role="narrator"]):not([data-role="scholar"]) .active-word {
  box-shadow: 0 0 0 1px #b45309;
}
.story-neural-player .snp-reader [id^="w"] { cursor: pointer; }
@media (min-width: 900px) {
  body[data-view="story"] .story-article { padding-top: 28px; }
}

/* v41: word-break handles are off in the reading view unless explicitly enabled */
body:not([data-edit-wordbreaks]) #lines .word-div.is-off {
  display: none !important;
  pointer-events: none !important;
  width: 0 !important;
  min-width: 0 !important;
}
body:not([data-edit-wordbreaks]) #lines .word-div.is-off::before {
  content: none;
  display: none;
}
body:not([data-edit-wordbreaks]) #lines .word-div.is-on {
  pointer-events: none !important;
  cursor: default;
  touch-action: auto;
}
body:not([data-edit-wordbreaks]) #lines .word-div.is-on .word-div-bar,
body:not([data-edit-wordbreaks]) #lines .word-div.is-on:hover .word-div-bar,
body:not([data-edit-wordbreaks]) #lines .word-div.is-on:focus-visible .word-div-bar {
  background: transparent;
}
#btn-wordbreaks {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  min-width: 0;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 480px) {
  .text-kicker { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* v42: compact circular topbar Play, never a tall oval from .icon-btn min-height */
.topbar #btn-tts-page.tts-page-btn,
.topbar .tts-page-btn {
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  max-width: 30px;
  max-height: 30px;
  padding: 0;
  margin: 0 2px 0 0;
  border-radius: 50%;
  flex-shrink: 0;
  box-sizing: border-box;
  line-height: 1;
  font-size: 11px;
  overflow: hidden;
}
.topbar #btn-tts-page .tts-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  line-height: 1;
  font-size: 11px;
}
@media (max-width: 480px) {
  .topbar {
    grid-template-columns: 32px minmax(0, 1fr) auto;
    padding-left: max(2px, var(--safe-l));
    padding-right: max(2px, var(--safe-r));
  }
  .topbar > .icon-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
  }
  .topbar-actions .icon-btn,
  .topbar .status-pill,
  .topbar .koreksi-badge {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    max-height: 30px;
    padding: 0;
    flex-shrink: 0;
  }
  .topbar .koreksi-badge { font-size: 9px; }
  .topbar .lang-toggle { height: 30px; margin-right: 1px; }
  .topbar .lang-toggle button { min-width: 24px; min-height: 24px; padding: 0 5px; font-size: 10px; }
  .topbar .brand { font-size: 9px; letter-spacing: 0.12em; }
  .topbar .page-chip { font-size: 13px; min-height: 22px; }
  .topbar #btn-tts-page.tts-page-btn,
  .topbar .tts-page-btn {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    max-width: 30px;
    max-height: 30px;
  }
}

/* v48 auto-draft pages */
.page-status-badge.is-auto { background: color-mix(in srgb, #e0a100 16%, var(--paper)); color: color-mix(in srgb, #a86f00 80%, var(--muted)); }
.scan-grid-btn.is-auto { border-color: color-mix(in srgb, #e0a100 55%, var(--paper)); background: color-mix(in srgb, #e0a100 8%, var(--paper)); }
.lowconf-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #e0a100; margin-left: 6px; vertical-align: middle; opacity: .8; }

/* Picker: Noto composes Bugis marks (i/u/é/o/pepet) correctly; Sureq clips ka and misfolds some vowels. */
.picker-manual .glyph,
.ocr-alt .glyph,
.picker-preview .big {
  font-family: "Noto Sans Buginese", "LaGaligoSureq", "Noto Sans", sans-serif;
  overflow: visible;
}

/* Compact Contents drawer (one phone screen, no overlapping text) */
#toc-drawer > * { flex-shrink: 0; }
#toc-drawer > .drawer-body { flex: 1 1 auto; min-height: 0; flex-shrink: 1; }
#toc-drawer .drawer-head { align-items: center; padding: 10px 12px 8px; }
#toc-drawer .drawer-head .brand { margin: 0; font-size: 11px; line-height: 1.2; }
#toc-drawer .drawer-head h2 { margin: 0; font-size: 1.1rem; line-height: 1.25; }
.toc-chips {
  display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; overscroll-behavior-x: contain;
  padding: 8px 12px; border-bottom: 1px solid var(--rule); scrollbar-width: none;
}
.toc-chips::-webkit-scrollbar { display: none; }
.toc-chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--rule); background: var(--paper-deep);
  color: var(--ink); font-size: 13px; line-height: 1; white-space: nowrap; text-decoration: none;
}
.toc-chip-main { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
#toc-body .toc-catalog-lead { margin: 2px 0 8px; font-size: 13px; line-height: 1.3; }
#toc-body .vol-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 0 0 10px; }
#toc-body .vol-chip {
  min-height: 40px; padding: 0; text-align: center; font-size: 15px; font-weight: 600; line-height: 1;
}
#toc-body .page-jump { display: flex; flex-wrap: nowrap; align-items: center; gap: 8px; margin: 0 0 10px; }
#toc-body .page-jump-vol { flex: 1 1 auto; min-width: 0; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#toc-body .page-jump input { width: 4.2em; min-height: 40px; flex: 0 0 auto; }
#toc-body .page-jump-go {
  flex: 0 0 auto; min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--paper); font: inherit; font-size: 14px; font-weight: 600;
}
#toc-body .toc-section-title { margin: 8px 0 6px; font-size: 12px; line-height: 1.2; }
#toc-body .ready-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 6px; }
#toc-body .ready-row .page-link {
  display: inline-flex; align-items: center; width: auto; min-height: 34px; margin: 0; padding: 0 12px;
  border-radius: 999px; font-size: 13px; line-height: 1; white-space: nowrap;
  border-color: var(--accent); background: var(--accent-soft);
}
#toc-body .vol-dedication { margin: 0 0 8px; font-size: 12px; line-height: 1.35; }
.toc-foot {
  display: flex; flex-wrap: nowrap; align-items: center; justify-content: flex-start; gap: 8px;
  padding: 8px 12px; font-size: 12px; line-height: 1.3; white-space: nowrap; overflow: hidden;
}
.toc-foot a { color: var(--accent); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
