:root {
  --bg: #f6f2ea;
  --panel: #fffdf8;
  --panel-2: #f1ece1;
  --ink: #1f2a37;
  --ink-2: #4b5563;
  --muted: #8a8577;
  --line: #e2dbcc;
  --line-2: #d3cab6;
  --primary: #243b53;
  --primary-ink: #f8f4ea;
  --accent: #8c2f39;
  --new: #9aa0a6;
  --draft: #c9861a;
  --draft-bg: #fbf1dc;
  --edited: #2f6db5;
  --edited-bg: #e6eef9;
  --approved: #2f7d4f;
  --approved-bg: #e3f2e8;
  --red: #b42318;
  --red-bg: #fde8e6;
  --yellow-bg: #fff5d6;
  --focus: #f2b84b;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(31, 42, 55, .06), 0 4px 16px rgba(31, 42, 55, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15191f; --panel: #1c2128; --panel-2: #232a33; --ink: #e8e4da; --ink-2: #b8b3a7; --muted: #8b8778;
    --line: #2d3540; --line-2: #3a4450; --primary: #d9c7a0; --primary-ink: #15191f; --accent: #e08a93;
    --draft-bg: #3a2f17; --edited-bg: #1b2c44; --approved-bg: #183325; --red-bg: #3d1b18; --yellow-bg: #3a3317;
    --draft: #e3a540; --edited: #6aa2e6; --approved: #5cc08a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; color: var(--muted); }

/* ---------- Viršutinė juosta ---------- */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 54px; background: var(--primary); color: var(--primary-ink); }
.brand { font: 600 18px/1 var(--serif); letter-spacing: .2px; text-decoration: none; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand .mark { width: 28px; height: 28px; border-radius: 7px; background: var(--primary-ink); color: var(--primary); display: grid; place-items: center; font-size: 16px; }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.nav a { text-decoration: none; padding: 7px 12px; border-radius: 7px; opacity: .82; white-space: nowrap; font-size: 14px; }
.nav a:hover { opacity: 1; background: rgba(255,255,255,.08); }
.nav a.on { opacity: 1; background: rgba(255,255,255,.14); }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; white-space: nowrap; }
.who button { background: transparent; border: 1px solid rgba(255,255,255,.25); color: inherit; border-radius: 7px; padding: 4px 10px; cursor: pointer; }
@media (prefers-color-scheme: dark) { .nav a:hover, .nav a.on { background: rgba(0,0,0,.12); } .who button { border-color: rgba(0,0,0,.25); } }

main.page { max-width: 1180px; margin: 0 auto; padding: 28px 20px 80px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; margin: 0 0 6px; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt { margin-top: 18px; }

/* ---------- Mygtukai ir laukai ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--panel); border-radius: 8px; padding: 7px 13px; cursor: pointer; text-decoration: none; white-space: nowrap; font-size: 14px; }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { filter: brightness(1.12); }
.btn.ok { background: var(--approved); border-color: var(--approved); color: #fff; }
.btn.danger { color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { padding: 4px 9px; font-size: 13px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: default; }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 4px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=number], input:not([type]), select, textarea {
  width: 100%; border: 1px solid var(--line-2); background: var(--panel); border-radius: 8px; padding: 8px 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 35%, transparent); }
textarea { resize: vertical; min-height: 90px; line-height: 1.45; }
textarea.code { font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; min-height: 320px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }

/* ---------- Kortelės ir lentelės ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.book { display: block; text-decoration: none; transition: transform .08s; }
.book:hover { transform: translateY(-1px); border-color: var(--line-2); }
.book h3 { font-size: 18px; margin-bottom: 2px; }
.book .meta { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px; padding: 8px 10px; border-bottom: 1px solid var(--line-2); }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:hover td { background: color-mix(in srgb, var(--panel-2) 50%, transparent); }
table.t td.wrap { white-space: normal; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-2); margin: 10px 0 18px; }
.tabs a { padding: 8px 14px; text-decoration: none; border-bottom: 2px solid transparent; color: var(--ink-2); margin-bottom: -1px; }
.tabs a.on { border-color: var(--primary); color: var(--ink); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; border: 1px dashed var(--line-2); border-radius: var(--radius); }

/* ---------- Progresas ---------- */
.prog { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--panel-2); }
.prog i { display: block; height: 100%; }
.prog .a { background: var(--approved); } .prog .e { background: var(--edited); } .prog .d { background: var(--draft); }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.legend b { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; letter-spacing: .2px; }
.chip.new { background: var(--panel-2); color: var(--muted); }
.chip.draft { background: var(--draft-bg); color: var(--draft); }
.chip.edited { background: var(--edited-bg); color: var(--edited); }
.chip.approved { background: var(--approved-bg); color: var(--approved); }
.chip.job { background: var(--edited-bg); color: var(--edited); }
.chip.fail { background: var(--red-bg); color: var(--red); }

/* ---------- Modalai, pranešimai ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 24, 30, .45); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: var(--panel); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.3); width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 22px 24px; }
.modal.wide { width: min(900px, 100%); }
.modal h2 { margin-bottom: 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
#toast div { background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 9px; box-shadow: var(--shadow); font-size: 14px; max-width: 90vw; }
#toast div.err { background: var(--red); color: #fff; }
.drop { border: 2px dashed var(--line-2); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--ink-2); cursor: pointer; background: var(--panel); }
.drop.over { border-color: var(--primary); background: var(--panel-2); }

/* ---------- Prisijungimas ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: min(400px, 100%); padding: 28px; }
.auth h1 { text-align: center; margin-bottom: 4px; }
.auth .sub { text-align: center; }

/* ---------- Redaktorius ---------- */
.ed-top { position: sticky; top: 54px; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line-2); }
.ed-top .in { max-width: 1500px; margin: 0 auto; padding: 10px 20px; display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.ed-title { min-width: 0; }
.ed-title .crumb { font-size: 12.5px; color: var(--muted); text-decoration: none; }
.ed-title h1 { font-size: 20px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.ed-top .prog { width: 160px; }
.seg-filter { display: flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg-filter button { border: 0; background: var(--panel); padding: 5px 10px; font-size: 13px; cursor: pointer; border-right: 1px solid var(--line); }
.seg-filter button:last-child { border-right: 0; }
.seg-filter button.on { background: var(--primary); color: var(--primary-ink); }
.jobbar { width: 100%; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.jobbar .prog { flex: 1; max-width: 360px; }
.ed { max-width: 1500px; margin: 0 auto; padding: 16px 20px 120px; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; }
@media (max-width: 1100px) { .ed { grid-template-columns: 1fr; } .side { position: static !important; max-height: none !important; } .ed-title h1 { max-width: 80vw; } }
.segs { display: flex; flex-direction: column; gap: 6px; }
.seg { display: grid; grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1fr); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.seg.focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 30%, transparent); }
.seg .num { font-size: 11.5px; color: var(--muted); padding: 12px 0 0 0; text-align: center; border-right: 1px solid var(--line); position: relative; }
.seg .num::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; border-radius: 10px 0 0 10px; background: var(--new); }
.seg.st-draft .num::after { background: var(--draft); }
.seg.st-edited .num::after { background: var(--edited); }
.seg.st-approved .num::after { background: var(--approved); }
.src, .tgt { font: 16.5px/1.6 var(--serif); padding: 10px 14px; min-width: 0; overflow-wrap: anywhere; }
.src { border-right: 1px solid var(--line); color: var(--ink); }
.seg.k-h1 .src, .seg.k-h1 .tgt-text { font-size: 22px; font-weight: 600; }
.seg.k-h2 .src, .seg.k-h2 .tgt-text { font-size: 19px; font-weight: 600; }
.seg.k-h3 .src, .seg.k-h3 .tgt-text, .seg.k-h4 .src, .seg.k-h4 .tgt-text { font-size: 17px; font-weight: 600; }
.seg.k-blockquote .src, .seg.k-blockquote .tgt-text { font-size: 15.5px; padding-left: 14px; border-left: 3px solid var(--line-2); }
.seg.k-footnote .src, .seg.k-footnote .tgt-text { font-size: 14px; }
.seg.k-li .src::before { content: "• "; color: var(--muted); }
.kind { font: 600 10.5px/1 var(--sans); text-transform: uppercase; letter-spacing: .5px; color: var(--muted); display: block; margin-bottom: 4px; }
.gl { border-bottom: 2px dotted var(--accent); cursor: help; }
.tgt { display: flex; flex-direction: column; gap: 6px; }
.tgt-text { outline: none; min-height: 1.6em; border-radius: 6px; padding: 2px 4px; margin: -2px -4px; }
.tgt-text:empty::before { content: attr(data-ph); color: var(--muted); font-style: italic; }
.tgt-text:focus { background: color-mix(in srgb, var(--focus) 9%, transparent); }
.seg-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font: 12.5px/1.3 var(--sans); }
.seg-foot .saved { color: var(--muted); }
.seg-foot .btn.sm { padding: 3px 8px; font-size: 12.5px; }
.flag { font: 13px/1.45 var(--sans); border-radius: 8px; padding: 7px 10px; background: var(--yellow-bg); }
.flag.red { background: var(--red-bg); }
.flag.grey { background: var(--panel-2); }
.flag .fl-h { font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--ink-2); }
.flag .q { font-family: var(--serif); text-decoration: line-through; text-decoration-color: var(--red); }
.flag .s { font-family: var(--serif); font-weight: 600; }
.flag .fl-a { margin-top: 5px; display: flex; gap: 6px; }
.note-box textarea { min-height: 54px; font-size: 13.5px; }
.side { position: sticky; top: 130px; max-height: calc(100vh - 150px); overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.side .card { padding: 14px 16px; }
.side h3 { font: 600 12.5px/1 var(--sans); text-transform: uppercase; letter-spacing: .5px; color: var(--ink-2); margin-bottom: 10px; }
.tm-item { border-top: 1px solid var(--line); padding: 9px 0; font-size: 13.5px; }
.tm-item:first-of-type { border-top: 0; padding-top: 0; }
.tm-item .pct { font-weight: 700; font-size: 12px; padding: 1px 6px; border-radius: 5px; background: var(--approved-bg); color: var(--approved); }
.tm-item .pct.mid { background: var(--draft-bg); color: var(--draft); }
.tm-item .en { color: var(--ink-2); margin: 4px 0 2px; }
.tm-item .lt { font-family: var(--serif); font-size: 14.5px; }
.tm-item mark { background: color-mix(in srgb, var(--focus) 45%, transparent); color: inherit; border-radius: 3px; }
.gl-item { padding: 5px 0; font-size: 14px; border-top: 1px solid var(--line); }
.gl-item:first-of-type { border-top: 0; }
.gl-item b { font-family: var(--serif); }
.hist-item { font-size: 13px; border-top: 1px solid var(--line); padding: 7px 0; }
.hist-item .lt { font-family: var(--serif); font-size: 14px; margin: 3px 0; }
.kbd { font: 11px/1 ui-monospace, monospace; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; padding: 1px 4px; background: var(--panel); }
.menu { position: relative; display: inline-block; }
.menu .pop { position: absolute; right: 0; top: calc(100% + 4px); background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); min-width: 260px; padding: 6px; z-index: 40; display: none; }
.menu.open .pop { display: block; }
.menu .pop button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 14px; }
.menu .pop button:hover { background: var(--panel-2); }
.menu .pop button small { display: block; color: var(--muted); font-size: 12px; }
@media (max-width: 760px) {
  .seg { grid-template-columns: 26px minmax(0, 1fr); }
  .src { border-right: 0; border-bottom: 1px solid var(--line); grid-column: 2; }
  .tgt { grid-column: 2; }
  .seg .num { grid-row: span 2; }
  .who span { display: none; }
  .top { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 6px 10px; }
  .nav { order: 3; flex-basis: 100%; }
  .ed-top { position: static; }
  main.page { padding: 18px 12px 60px; }
  .ed { padding: 10px 8px 80px; }
}
