@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: "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;
}

[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: 48px minmax(0, 1fr) auto;
  align-items: end;
  gap: 4px;
  background: var(--topbar);
  color: var(--topbar-text);
}
.topbar > .icon-btn,
.topbar-actions {
  margin-bottom: 4px;
}
.topbar-title {
  min-width: 0;
  text-align: center;
  padding-bottom: 6px;
}
.brand {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--topbar-text) 70%, transparent);
}
.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;
}
.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; }
.hotspot {
  position: absolute;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px transparent;
}
.hotspot.is-active {
  background: var(--highlight);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.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;
}


.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: 48px;
  padding: 4px 2px;
  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;
}
.picker-cell .glyph, .vowel-cell .glyph {
  font-family: var(--lontara);
  font-size: 1.3rem;
  line-height: 1.15;
}
.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; }

.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"] .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(92dvh, 740px); }
.picker-scan {
  flex: 0 0 auto;
  padding: 0 16px 8px;
}
.picker-scan-frame {
  position: relative;
  height: 88px;
  border-radius: 10px;
  overflow: hidden;
  background: #1c140c;
  box-shadow: inset 0 0 0 1px var(--rule);
}
.picker-scan-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.picker-scan-mark {
  position: absolute;
  top: 5px;
  bottom: 5px;
  width: 22px;
  border-radius: 5px;
  border: 1.5px solid color-mix(in srgb, var(--accent) 85%, white);
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--paper) 35%, transparent);
  pointer-events: none;
}
.picker-scan-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.picker-scan-caption {
  flex: 1 1 auto;
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-align: center;
  line-height: 1.35;
}

/* Movable word-boundary handles */
.word-div {
  display: inline-flex;
  align-items: stretch;
  justify-content: center;
  width: 11px;
  min-height: 1.15em;
  padding: 0;
  margin: 0 -2px;
  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); }

@media (max-width: 480px) {
  .word-div { width: 14px; }
  .picker-scan-frame { height: 80px; }
}
