:root {
  --bg: #0f1115;
  --panel: #161922;
  --panel-2: #1d2230;
  --border: #2a3040;
  --text: #e6e9ef;
  --muted: #9aa3b2;
  --accent: #4f8cff;
  --accent-2: #2f6fe0;
  --green: #2faa6a;
  --yellow: #d8a23a;
  --row: #12151d;
  --row-alt: #151926;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.brand { font-weight: 700; letter-spacing: .3px; }
.controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.controls label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }

select, input, button, textarea {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
}
input { min-width: 90px; }
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent-2); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--accent); }

.status { font-size: 12px; color: var(--muted); min-width: 80px; }
.status.err { color: #ff6b6b; }
.status.ok { color: var(--green); }

.layout { flex: 1 1 auto; display: flex; min-height: 0; }

.sidebar {
  width: 300px;
  flex: 0 0 auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
}
.sidebar-head button { padding: 2px 8px; }
.tree { overflow: auto; padding: 6px 0; flex: 1 1 auto; }

.node { user-select: none; }
.node-row {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 10px; cursor: pointer; white-space: nowrap;
  border-radius: 4px;
}
.node-row:hover { background: var(--panel-2); }
.node-row.active { background: var(--accent-2); color: #fff; }
.node-row .twist { width: 12px; color: var(--muted); font-size: 10px; }
.node-row .ic { width: 14px; text-align: center; color: var(--muted); }
.node-row.file .name { font-size: 13px; }
.node-row .miss { color: var(--yellow); font-size: 11px; margin-left: auto; }
.node-row .has { color: var(--green); font-size: 11px; margin-left: auto; }
.children { margin-left: 14px; border-left: 1px solid var(--border); }
.children.collapsed { display: none; }

.editor { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.editor-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--panel);
}
.current-path { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: flex; gap: 4px; }
.tab { padding: 4px 12px; background: transparent; border: 1px solid transparent; }
.tab.active { background: var(--panel-2); border-color: var(--border); }

.panel { flex: 1 1 auto; overflow: auto; min-height: 0; }
.panel.hidden { display: none; }

.grid-head, .grid-row { display: grid; grid-template-columns: 44px 1fr 1fr; }
.grid-head {
  position: sticky; top: 0; z-index: 1;
  background: var(--panel); border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--muted); font-weight: 600;
}
.grid-head > div { padding: 8px 10px; }
.col-num { text-align: right; }

.grid-row { border-bottom: 1px solid var(--border); }
.grid-row:nth-child(odd) { background: var(--row); }
.grid-row:nth-child(even) { background: var(--row-alt); }
.grid-row.changed .cell-tgt { box-shadow: inset 3px 0 0 var(--accent); }

.cell-num { text-align: right; padding: 6px 8px; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.cell-src {
  padding: 6px 10px; white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  color: #cdd6e6; border-right: 1px solid var(--border);
}
.cell-tgt { padding: 2px; }
.cell-tgt textarea {
  width: 100%; min-height: 28px; resize: none; border: 1px solid transparent;
  background: transparent; border-radius: 4px; padding: 5px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  overflow: hidden; line-height: 1.5;
}
.cell-tgt textarea:focus { outline: none; border-color: var(--accent); background: var(--panel-2); }
.src-empty { color: var(--muted); font-style: italic; }

.preview { padding: 20px 28px; max-width: 860px; }
.raw-editor {
  width: 100%; height: 100%; min-height: 400px; border: none; border-radius: 0;
  padding: 16px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; line-height: 1.6; resize: none;
}

/* minimal markdown styling */
.markdown h1 { font-size: 26px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.markdown h2 { font-size: 21px; margin-top: 28px; }
.markdown h3 { font-size: 17px; }
.markdown code { background: var(--panel-2); padding: 2px 5px; border-radius: 4px; font-size: 90%; }
.markdown pre { background: var(--panel-2); padding: 12px; border-radius: 6px; overflow: auto; }
.markdown img { max-width: 100%; border-radius: 6px; }
.markdown a { color: var(--accent); }
.markdown blockquote { border-left: 3px solid var(--border); margin: 0; padding-left: 14px; color: var(--muted); }

.badge { font-size: 11px; padding: 1px 7px; border-radius: 10px; }
.badge.new { background: rgba(216,162,58,.18); color: var(--yellow); }
.badge.exists { background: rgba(47,170,106,.18); color: var(--green); }

/* ---- manifest (block) mode ---- */
.mode-link { font-size: 12px; color: var(--accent); text-decoration: none; margin-left: 8px; }
.doc-row { display: flex; flex-direction: column; gap: 2px; padding: 6px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.doc-row:hover { background: var(--panel-2); }
.doc-row.active { background: var(--accent-2); color: #fff; }
.doc-row .dname { font-size: 12.5px; }
.doc-row .dmeta { font-size: 11px; color: var(--muted); display: flex; gap: 8px; }
.doc-row.active .dmeta { color: #dbe4f5; }
.doc-row .rv { color: var(--yellow); }

.blk { display: grid; grid-template-columns: 40px 1fr 1fr; border-bottom: 1px solid var(--border); }
.blk:nth-child(even) { background: var(--row-alt); }
.blk.nontrans { opacity: .55; }
.blk.stale .b-tgt { box-shadow: inset 3px 0 0 var(--yellow); }
.b-num { padding: 8px; text-align: right; color: var(--muted); font-size: 11px; }
.b-src { padding: 8px 10px; white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; color: #cdd6e6; border-right: 1px solid var(--border); }
.b-tgt { padding: 6px 8px; display: flex; flex-direction: column; gap: 5px; }
.b-tgt textarea { width: 100%; min-height: 30px; resize: vertical; background: var(--panel-2); border: 1px solid var(--border); border-radius: 5px; padding: 6px 8px; color: var(--text); font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
.b-tgt textarea:focus { outline: none; border-color: var(--accent); }
.b-bar { display: flex; align-items: center; gap: 8px; }
.b-bar button { padding: 2px 8px; font-size: 11px; }
.b-type { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.st { font-size: 10px; padding: 1px 7px; border-radius: 9px; font-weight: 600; }
.st.human { background: rgba(47,170,106,.18); color: var(--green); }
.st.model { background: rgba(79,140,255,.18); color: var(--accent); }
.st.untranslated { background: rgba(154,163,178,.18); color: var(--muted); }
.st.stale { background: rgba(216,162,58,.2); color: var(--yellow); }
.st.saved { background: rgba(47,170,106,.14); color: var(--green); }

.chk { font-size: 10px; padding: 1px 6px; border-radius: 9px; font-weight: 600; cursor: help; }
.chk.high { background: rgba(255,107,107,.18); color: #ff8c8c; }
.chk.medium { background: rgba(216,162,58,.18); color: var(--yellow); }
.blk.flagged .b-src { box-shadow: inset 3px 0 0 #ff6b6b; }
.checks-row { display: flex; flex-wrap: wrap; gap: 5px; }

.unaligned-box { margin: 10px; padding: 10px 12px; border: 1px dashed var(--yellow); border-radius: 8px; background: rgba(216,162,58,.06); }
.unaligned-box h4 { margin: 0 0 6px; font-size: 12px; color: var(--yellow); }
.unaligned-item { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: #cdd6e6; padding: 4px 0; border-top: 1px solid var(--border); white-space: pre-wrap; }
