/* Penerjemah Dokumen: tampilan mengikuti Telaah SLR (web_SLR). */
:root {
  --bg: #eef2f3; --surface: #ffffff; --surface-2: #f5f8f9; --sunk: #e3e9eb;
  --ink: #142229; --ink-2: #44565f; --muted: #74858d; --line: #d3dcdf; --line-2: #e4eaec;
  --accent: #155e7d; --accent-ink: #ffffff; --accent-soft: #dcebf2;
  --ok: #1d7a46; --no: #b3261e; --hl: rgba(250, 204, 21, .45); --hl-cur: rgba(249, 115, 22, .55);
  --shadow: 0 1px 2px rgba(20, 34, 41, .06), 0 4px 16px rgba(20, 34, 41, .05);
  --font-ui: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-doc: "Source Serif 4", Georgia, "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1719; --surface: #162124; --surface-2: #1b282c; --sunk: #0c1315;
    --ink: #e3ecee; --ink-2: #a9bac0; --muted: #7f9399; --line: #2a3a3f; --line-2: #223135;
    --accent: #5fb3d4; --accent-ink: #062029; --accent-soft: #163845;
    --ok: #4cc283; --no: #f2796f; --hl: rgba(250, 204, 21, .3); --hl-cur: rgba(249, 115, 22, .5);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1719; --surface: #162124; --surface-2: #1b282c; --sunk: #0c1315;
  --ink: #e3ecee; --ink-2: #a9bac0; --muted: #7f9399; --line: #2a3a3f; --line-2: #223135;
  --accent: #5fb3d4; --accent-ink: #062029; --accent-soft: #163845;
  --ok: #4cc283; --no: #f2796f; --hl: rgba(250, 204, 21, .3); --hl-cur: rgba(249, 115, 22, .5);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font-ui); display: flex; flex-direction: column; overflow: hidden; }
button, select, input { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
[hidden] { display: none !important; }

/* Bilah atas */
.top { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .55rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 600; font-size: 1rem; color: var(--accent); }
.top-set { display: flex; gap: .8rem; flex: 1; }
.top-set label { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--ink-2); }
.top-act { display: flex; gap: .4rem; }
select, input[type=search] { padding: .3rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }

.btn { padding: .4rem .8rem; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer; font-weight: 500; }
.btn.sm { padding: .25rem .6rem; font-size: .8rem; }
.btn.ghost { background: transparent; color: var(--accent); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--accent); }
.btn.danger { color: var(--no); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; width: 26px; height: 26px; cursor: pointer; line-height: 1; }

/* Tata letak */
.layout { flex: 1; display: flex; min-height: 0; }
.side { width: 290px; flex-shrink: 0; background: var(--surface-2); border-right: 1px solid var(--line); padding: .8rem; display: flex; flex-direction: column; gap: .6rem; overflow-y: auto; }
.drop { display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: 1rem .6rem; border: 2px dashed var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; text-align: center; }
.drop b { color: var(--accent); }
.drop span { font-size: .8rem; color: var(--ink-2); }
.drop small { font-size: .7rem; color: var(--muted); }
.drop.over, body.dragging .drop { border-color: var(--accent); background: var(--accent-soft); }
.side-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; margin-top: .3rem; }
.lib { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.lib li { padding: .5rem .6rem; border-radius: 8px; border: 1px solid transparent; cursor: pointer; background: var(--surface); }
.lib li:hover { border-color: var(--line); }
.lib li.on { border-color: var(--accent); box-shadow: var(--shadow); }
.lib .nm { font-weight: 500; word-break: break-word; font-size: .85rem; line-height: 1.3; }
.lib .st { font-size: .72rem; color: var(--muted); display: flex; align-items: center; gap: .4rem; margin-top: .2rem; }
.lib .st.ok { color: var(--ok); }
.lib .st.err { color: var(--no); }
.chip { font-size: .65rem; text-transform: uppercase; font-weight: 600; padding: 0 .35rem; border-radius: 4px; background: var(--sunk); color: var(--ink-2); }
.mini-bar { height: 3px; background: var(--sunk); border-radius: 2px; margin-top: .3rem; overflow: hidden; }
.mini-bar span { display: block; height: 100%; background: var(--accent); }

/* Panel baca */
.panel { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--surface); }
#docView { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.welcome { max-width: 620px; margin: 3rem auto; padding: 0 16px; color: var(--ink-2); }
.welcome h1 { font-family: var(--font-doc); color: var(--ink); font-size: 1.6rem; font-weight: 600; }
.welcome li { margin: .3rem 0; }
.pa-head { padding: .8rem 1.25rem .4rem; border-bottom: 1px solid var(--line-2); }
.doc-title { font-family: var(--font-doc); font-size: 1.2rem; font-weight: 600; line-height: 1.3; margin: 0 0 .2rem; word-break: break-word; }
.doc-meta { margin: 0; color: var(--ink-2); font-size: .82rem; }
.pa-tools { display: flex; flex-wrap: wrap; gap: .5rem .8rem; align-items: center; padding: .5rem 1.25rem; border-bottom: 1px solid var(--line-2); background: var(--surface-2); }
.seg { display: inline-flex; background: var(--sunk); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: .25rem .6rem; font-size: .8rem; border-radius: 6px; cursor: pointer; color: var(--ink-2); font-weight: 500; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
.find { display: flex; align-items: center; gap: .3rem; }
.find input { width: 190px; }
.find-n { font-size: .75rem; color: var(--muted); min-width: 3.5em; }
.pa-actions { margin-left: auto; display: flex; gap: .4rem; position: relative; }

.doc-content { flex: 1; overflow-y: auto; padding: 1rem 1.25rem 4rem; }
.tr-bar { position: sticky; top: -1rem; z-index: 2; display: flex; align-items: center; flex-wrap: wrap; gap: .4rem .8rem; padding: .45rem .7rem; margin: -.2rem 0 .8rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); font-size: .8rem; color: var(--ink-2); max-width: 80ch; }
.tr-bar .tr-status { flex: 1; min-width: 0; }
.tr-bar .bar { flex-basis: 100%; height: 4px; background: var(--sunk); border-radius: 2px; overflow: hidden; }
.tr-bar .bar span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.tr-bar.err { border-color: var(--no); color: var(--no); }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; text-decoration: underline; font-size: inherit; }

.doc-text { font-family: var(--font-doc); font-size: 1.04rem; line-height: 1.7; max-width: 76ch; }
.sec { margin-bottom: 1.4rem; }
.sec-title { font-family: var(--font-ui); font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; margin: 1.2rem 0 .5rem; padding-bottom: .25rem; border-bottom: 1px solid var(--line-2); }
.blk { margin: .3rem 0 .9rem; }
.blk.title { font-size: 1.35rem; font-weight: 600; line-height: 1.35; }
.blk.h { font-size: 1.12rem; font-weight: 600; margin-top: 1.2rem; }
.blk.li { padding-left: 1.2rem; position: relative; margin-bottom: .4rem; }
.blk.li::before { content: "•"; position: absolute; left: .3rem; color: var(--muted); }
.blk.small { font-size: .9rem; }
.blk.meta { font-family: var(--font-ui); font-size: .75rem; color: var(--muted); margin: .8rem 0 .1rem; }
pre.code { font-size: .85rem; background: var(--surface-2); border: 1px solid var(--line-2); padding: .6rem; border-radius: 6px; overflow-x: auto; }
.u .tr-src, .u .tr-out { display: block; }
.u .tr-src { color: var(--ink-2); font-size: .92em; margin-bottom: .3rem; }
.u .tr-out { padding: .2rem 0 .2rem .7rem; border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); border-radius: 0 6px 6px 0; }
.pending { opacity: .55; }
.tbl-wrap { overflow-x: auto; margin: .5rem 0 1rem; max-width: 100%; }
.tbl { border-collapse: collapse; font-family: var(--font-ui); font-size: .82rem; line-height: 1.45; }
.tbl th, .tbl td { border: 1px solid var(--line); padding: .35rem .5rem; vertical-align: top; text-align: left; min-width: 90px; max-width: 420px; }
.tbl th { background: var(--surface-2); font-weight: 600; position: sticky; top: 0; }
.tbl .u .tr-out { padding: .1rem 0 .1rem .4rem; border-left-width: 2px; }
mark.f { background: var(--hl); color: inherit; border-radius: 2px; }
mark.f.cur { background: var(--hl-cur); }
.pad { padding: 1rem 0; }
.err { color: var(--no); }

.pdf-pages { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.pdf-page { width: 100%; max-width: 900px; background: #fff; box-shadow: var(--shadow); border: 1px solid var(--line); position: relative; }
.pdf-page canvas { display: block; width: 100%; height: auto; }
.pdf-page .pg { position: absolute; top: 4px; right: 8px; font-size: .7rem; color: #74858d; }
.orig-img { max-width: 100%; border: 1px solid var(--line); }

/* Popover & melayang */
.pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 280px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: .8rem; display: flex; flex-direction: column; gap: .5rem; }
.pop h4 { margin: 0; font-size: .85rem; }
.pop label { display: flex; flex-direction: column; gap: .2rem; font-size: .78rem; color: var(--ink-2); }
.pop label.check { flex-direction: row; align-items: center; gap: .4rem; }
.pop-act { display: flex; gap: .4rem; }
.pop p { margin: 0; }
.sel-btn { position: fixed; z-index: 50; box-shadow: var(--shadow); }
.tr-pop { position: fixed; z-index: 60; width: min(380px, calc(100vw - 16px)); max-height: 50vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: .7rem .8rem; }
.tr-pop p { margin: 0 0 .5rem; line-height: 1.55; font-family: var(--font-doc); }
.tr-pop .foot { display: flex; gap: .4rem; justify-content: flex-end; }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 70; background: var(--ink); color: var(--surface); padding: .55rem .9rem; border-radius: 8px; font-size: .85rem; max-width: calc(100vw - 32px); box-shadow: var(--shadow); display: flex; gap: .8rem; align-items: center; }
.toast .link { color: var(--surface); }

@media (max-width: 760px) {
  body { overflow: auto; }
  .layout { flex-direction: column; }
  .side { width: auto; border-right: 0; border-bottom: 1px solid var(--line); max-height: 40vh; }
  .doc-content { padding: 1rem 16px 3rem; }
  .pa-head, .pa-tools { padding-left: 16px; padding-right: 16px; }
  .find input { width: 140px; }
  .pa-actions { margin-left: 0; }
  .pop { left: 0; right: auto; }
}

/* Edit & periksa tata bahasa */
#editBtn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.ed { outline: none; border-radius: 4px; cursor: text; }
.editing .ed { box-shadow: inset 0 -1px 0 var(--line); }
.editing .ed:hover { background: var(--surface-2); }
.editing .ed:focus { background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent); }
.u.flash { animation: flash 1.2s; }
@keyframes flash { from { background: var(--hl-cur); } to { background: transparent; } }
.gram { max-height: 38vh; overflow-y: auto; border-bottom: 1px solid var(--line); background: var(--surface-2); padding: .6rem 1.25rem; }
.gram-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .4rem; font-size: .85rem; }
.gram-head b { flex: 1; }
.gi { background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; padding: .45rem .6rem; margin-bottom: .4rem; font-size: .82rem; }
.gi-ctx { font-family: var(--font-doc); cursor: pointer; }
.gi-ctx mark { background: rgba(239, 68, 68, .22); color: inherit; text-decoration: underline wavy var(--no); }
.gi-msg { color: var(--ink-2); font-size: .75rem; margin: .15rem 0 .3rem; }
.gi-act { display: flex; gap: .3rem; flex-wrap: wrap; }
.gi-act .rep { border: 1px solid var(--ok); color: var(--ok); background: transparent; border-radius: 6px; padding: .05rem .5rem; cursor: pointer; font-size: .8rem; }
.gi-act .rep:hover { background: var(--ok); color: var(--surface); }

/* Dwibahasa berdampingan: kiri asli, kanan terjemahan */
.doc-text.bi { max-width: none; }
.bi-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.5rem; align-items: start; }
.bi-row > div { min-width: 0; }
.bi-l { color: var(--ink-2); }
.bi-r { border-left: 3px solid var(--accent); padding-left: .9rem; }
.bi-head { position: sticky; top: 1.9rem; z-index: 1; background: var(--surface); font-family: var(--font-ui); font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; padding: .35rem 0; border-bottom: 1px solid var(--line-2); margin-bottom: .4rem; }
.bi-head > div:last-child { padding-left: .9rem; border-left: 3px solid transparent; }
.bi .tbl-wrap { margin-top: .2rem; }
.u.syncing { opacity: .5; }
.restore { border: 1px solid var(--line); background: var(--surface); color: var(--accent); border-radius: 4px; font-size: .75rem; line-height: 1; padding: .1rem .3rem; margin-left: .3rem; cursor: pointer; vertical-align: middle; }
label.check.sync { display: flex; align-items: center; gap: .3rem; font-size: .78rem; color: var(--ink-2); }
@media (max-width: 760px) {
  .bi-row { grid-template-columns: 1fr; }
  .bi-r { margin-bottom: .6rem; }
  .bi-head { display: none; }
}

/* Hapus di daftar */
.lib .nm { display: flex; gap: .3rem; align-items: flex-start; }
.lib .nm span { flex: 1; min-width: 0; }
.lib .x { border: 0; background: none; color: var(--muted); font-size: 1.05rem; line-height: 1; cursor: pointer; padding: 0 .2rem; border-radius: 4px; opacity: .55; }
.lib li:hover .x, .lib li.on .x { opacity: 1; }
.lib .x:hover { color: var(--no); background: var(--sunk); }
#quotesBtn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Referensi */
.ref-line { margin-top: .35rem; font-size: .8rem; color: var(--ink-2); line-height: 1.5; }
.ref-line .ref { font-family: var(--font-doc); color: var(--ink); }
.ref-src { color: var(--muted); font-size: .72rem; margin: 0 .3rem; }
.badge { display: inline-block; font-family: var(--font-ui); font-size: .64rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: .05rem .35rem; border-radius: 4px; background: var(--accent-soft); color: var(--accent); vertical-align: 1px; }
.badge.warn { background: rgba(217, 119, 6, .15); color: #b45309; }
.sel-btn { display: flex; gap: .3rem; }

/* Laporan kutipan */
.quotes-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.q-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin: .5rem 0 .3rem; }
.q-list { max-width: 900px; }
.q-group { margin-bottom: 1.6rem; }
.q-ref { font-family: var(--font-doc); padding: .6rem .8rem; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 8px; padding-left: 2.2rem; text-indent: -1.4rem; line-height: 1.55; }
.q-ref-act { text-indent: 0; display: flex; gap: .8rem; margin-top: .3rem; font-family: var(--font-ui); font-size: .78rem; }
.q-card { border-left: 3px solid var(--accent); padding: .4rem 0 .4rem .9rem; margin: .8rem 0 .8rem .6rem; }
.q-card blockquote { margin: 0; font-family: var(--font-doc); font-size: 1rem; line-height: 1.6; }
.q-cite { color: var(--accent); white-space: nowrap; }
.q-meta { font-size: .75rem; color: var(--muted); margin: .25rem 0; }
.q-card details { font-size: .82rem; color: var(--ink-2); }
.q-card details p { font-family: var(--font-doc); margin: .3rem 0; }
.q-note { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: .3rem .5rem; background: var(--surface); font-size: .82rem; resize: vertical; margin: .3rem 0; }
.q-act { display: flex; gap: .35rem; flex-wrap: wrap; }

/* Form referensi */
.modal { position: fixed; inset: 0; z-index: 80; background: rgba(10, 20, 24, .45); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; }
.modal-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; width: min(640px, 100%); padding: 1rem 1.1rem; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-card h3 { margin: 0 0 .7rem; font-size: 1rem; }
.rf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem .8rem; }
.rf-grid label { display: flex; flex-direction: column; gap: .2rem; font-size: .76rem; color: var(--ink-2); }
.rf-grid .span2 { grid-column: span 2; }
.rf-grid input, .rf-grid textarea, .rf-grid select { padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-size: .85rem; }
.rf-preview { margin: .8rem 0; padding: .6rem .7rem; background: var(--surface-2); border-radius: 8px; font-family: var(--font-doc); font-size: .9rem; line-height: 1.55; }
.modal-act { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
@media (max-width: 760px) { .rf-grid { grid-template-columns: 1fr; } .rf-grid .span2 { grid-column: auto; } }
.banner { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; padding: .55rem 1rem; background: rgba(217, 119, 6, .14); color: #92400e; border-bottom: 1px solid rgba(217, 119, 6, .35); font-size: .85rem; }
.banner .link { color: inherit; font-weight: 600; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .banner { color: #fbbf24; } }
:root[data-theme="dark"] .banner { color: #fbbf24; }
