/* ===== Design tokens ===== */
:root {
  --bg: #f6f7fb;
  --bg-grad: radial-gradient(1200px 500px at 10% -10%, #e9ecff 0%, transparent 60%), radial-gradient(900px 400px at 100% 0%, #e6f7ef 0%, transparent 55%);
  --surface: #ffffff;
  --surface-2: #f2f4f8;
  --border: #e3e6ee;
  --border-strong: #cfd4df;
  --text: #171a23;
  --text-2: #4b5263;
  --muted: #6b7385;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef0ff;
  --primary-text: #3730a3;
  --ins-bg: #dcf5e6;
  --ins-text: #0f5132;
  --ins-strong: #30a46c;
  --del-bg: #fde2e2;
  --del-text: #8a1c1c;
  --del-strong: #e5484d;
  --warn-bg: #fff4d6;
  --warn-text: #7a4b00;
  --warn-strong: #f5a623;
  --info-bg: #e6f0ff;
  --info-text: #1d4ed8;
  --focus: 0 0 0 3px rgba(79, 70, 229, .25);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 8px 24px -12px rgba(16, 24, 40, .12);
  --shadow-lg: 0 24px 60px -20px rgba(16, 24, 40, .35);
  --radius: 14px;
  --radius-sm: 9px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-doc: "Iowan Old Style", "Charter", "Georgia", "Cambria", "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1016;
    --bg-grad: radial-gradient(1200px 500px at 10% -10%, #1b1e3a 0%, transparent 60%), radial-gradient(900px 400px at 100% 0%, #10261c 0%, transparent 55%);
    --surface: #161922;
    --surface-2: #1d212c;
    --border: #272c39;
    --border-strong: #363c4c;
    --text: #e8eaf0;
    --text-2: #b7bdcb;
    --muted: #8a92a6;
    --primary: #7c74ff;
    --primary-hover: #8f88ff;
    --primary-soft: #23244a;
    --primary-text: #c4c1ff;
    --ins-bg: #123524;
    --ins-text: #8ee2b2;
    --ins-strong: #3dd68c;
    --del-bg: #3b1619;
    --del-text: #ffb1b1;
    --del-strong: #ff6369;
    --warn-bg: #3a2d0c;
    --warn-text: #ffd27a;
    --info-bg: #142546;
    --info-text: #9cc0ff;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
code { font-family: var(--mono); font-size: .9em; }
small { color: var(--muted); font-weight: 400; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 13px; }
.link { color: var(--primary); cursor: pointer; font-weight: 500; }
[hidden] { display: none !important; }

.container { max-width: 1180px; margin: 0 auto; padding: 28px 20px 64px; }
.container.wide { max-width: 1480px; }
.container.narrow { max-width: 720px; }

/* ===== Top bar ===== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { max-width: 1480px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; font-size: 18px; color: var(--text); letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.topnav { display: flex; gap: 4px; flex: 1; }
.topnav a { padding: 6px 12px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.topnav a:hover { background: var(--surface-2); text-decoration: none; }
.topnav a.active { color: var(--text); background: var(--surface-2); }

.user-menu, .more { position: relative; }
.avatar-btn { display: flex; align-items: center; gap: 8px; background: none; border: 1px solid transparent; padding: 4px 8px 4px 4px; border-radius: 999px; color: var(--text); cursor: pointer; font: inherit; }
.avatar-btn:hover { background: var(--surface-2); border-color: var(--border); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--primary), #8b5cf6); }
.user-name { font-weight: 500; }
@media (max-width: 640px) { .user-name { display: none; } }

.dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  padding: 6px; display: none;
}
[data-dropdown].open > .dropdown { display: block; animation: pop .12s ease-out; }
.dropdown-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; display: flex; flex-direction: column; }
.dropdown-head span { color: var(--muted); font-size: 13px; }
.dropdown a, .dropdown button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; border: 0; background: none;
  color: var(--text); font: inherit; font-size: 14px; cursor: pointer;
}
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); text-decoration: none; }
.dropdown .danger { color: var(--del-strong); }
.dropdown form { margin: 0; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ===== Buttons & inputs ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .icon-btn:focus-visible, .tab:focus-visible, .toggle:focus-visible { outline: none; box-shadow: var(--focus); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,.15) inset, 0 4px 14px -6px var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary-soft { background: var(--primary-soft); color: var(--primary-text); }
.btn-primary-soft:hover { filter: brightness(.97); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--del-strong); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.icon-btn {
  width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-size: 16px; line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; flex: 1; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.field-row { display: flex; gap: 12px; }
@media (max-width: 560px) { .field-row { flex-direction: column; gap: 0; } }
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; color: var(--text-2); margin: 8px 0; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--primary); }

/* ===== Cards & misc ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .muted { margin-top: 6px; }
.page-actions { display: flex; gap: 8px; }
.page-actions form { margin: 0; }
.breadcrumb { display: flex; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 14px; flex-wrap: wrap; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--text); }
.section-title { margin: 30px 0 14px; font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; }
.pill { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); }
.pill-accent { background: var(--primary-soft); color: var(--primary-text); }
.party-chip { display: inline-flex; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-size: 13px; font-weight: 500; margin-right: 6px; }
.project-description { margin-top: 10px; color: var(--text-2); max-width: 70ch; }

.alert { padding: 12px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; border: 1px solid transparent; }
.alert-error { background: var(--del-bg); color: var(--del-text); }
.alert-warning { background: var(--warn-bg); color: var(--warn-text); }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.badge-ok { background: var(--ins-bg); color: var(--ins-text); }
.badge-ok::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-error { background: var(--del-bg); color: var(--del-text); }
.badge-info { background: var(--info-bg); color: var(--info-text); }
.badge-mono { font-family: var(--mono); font-weight: 500; font-size: 11.5px; }
.badge-modified { background: var(--warn-bg); color: var(--warn-text); }
.badge-inserted { background: var(--ins-bg); color: var(--ins-text); }
.badge-deleted { background: var(--del-bg); color: var(--del-text); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.dot-del { background: var(--del-strong); }
.dot-ins { background: var(--ins-strong); }

/* Toast */
.toast {
  position: fixed; left: 50%; top: 74px; transform: translateX(-50%); z-index: 50; max-width: min(680px, calc(100vw - 32px));
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg);
  background: var(--surface); border: 1px solid var(--border); font-size: 14px; animation: toast-in .25s ease-out;
}
.auth .toast { top: 20px; }
.toast-success { border-left: 4px solid var(--ins-strong); }
.toast-error { border-left: 4px solid var(--del-strong); }
.toast-warning { border-left: 4px solid var(--warn-strong); }
.toast-close { background: none; border: 0; font-size: 18px; color: var(--muted); cursor: pointer; line-height: 1; padding: 0 2px; }
.toast.hide { opacity: 0; transform: translate(-50%, -8px); transition: .3s; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -10px); } }

/* Modal */
.modal { border: 0; padding: 0; border-radius: 16px; width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.modal::backdrop { background: rgba(15, 18, 30, .45); backdrop-filter: blur(3px); }
.modal[open] { animation: pop .15s ease-out; }
.modal form { padding: 22px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-head .icon-btn { border: 0; font-size: 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* Empty states */
.empty-state { text-align: center; padding: 48px 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-state p { max-width: 52ch; }
.empty-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--del-bg); color: var(--del-strong); font-weight: 800; font-size: 24px; }
.empty-illustration { position: relative; width: 120px; height: 96px; margin-bottom: 8px; }
.sheet { position: absolute; width: 64px; height: 84px; border-radius: 10px; box-shadow: var(--shadow); }
.sheet::before, .sheet::after { content: ""; position: absolute; left: 12px; right: 12px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.75); top: 20px; box-shadow: 0 14px 0 rgba(255,255,255,.75), 0 28px 0 rgba(255,255,255,.55); }
.sheet-a { left: 10px; top: 10px; background: var(--del-strong); transform: rotate(-8deg); }
.sheet-b { right: 10px; top: 0; background: var(--ins-strong); transform: rotate(6deg); }

/* ===== Auth ===== */
.auth-layout { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.auth-aside {
  position: relative; overflow: hidden; padding: 40px 48px; color: #f1f2ff; display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  background: radial-gradient(700px 400px at 0% 0%, #6366f1 0%, transparent 60%), radial-gradient(600px 400px at 100% 100%, #10b981 0%, transparent 60%), #1e1b4b;
}
.brand-light { color: #fff; }
.auth-pitch h2 { font-size: 34px; line-height: 1.15; font-weight: 750; letter-spacing: -.02em; max-width: 16ch; }
.auth-pitch > p { margin-top: 14px; color: rgba(241, 242, 255, .8); max-width: 48ch; font-size: 16px; }
.auth-sample {
  margin-top: 28px; padding: 20px 22px; border-radius: 14px; background: rgba(255,255,255,.96); color: #1f2333;
  font-family: var(--font-doc); font-size: 16px; line-height: 1.7; box-shadow: 0 30px 60px -25px rgba(0,0,0,.6); max-width: 520px;
  transform: rotate(-1deg);
}
.auth-sample p + p { margin-top: 10px; }
.auth-sample del { background: #fde2e2; color: #8a1c1c; }
.auth-sample ins { background: #dcf5e6; color: #0f5132; }
.auth-features { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.auth-features li { padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); font-size: 13px; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: min(420px, 100%); }
.auth-card h1 { margin-bottom: 6px; }
.auth-card > .muted { margin-bottom: 24px; }
.auth-card .btn-block { margin-top: 8px; padding: 11px; }
.auth-switch { margin-top: 18px; text-align: center; font-size: 14px; color: var(--muted); }
@media (max-width: 900px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-aside { padding: 28px 24px; }
  .auth-pitch h2 { font-size: 26px; }
  .auth-sample, .auth-features { display: none; }
}

/* ===== Dashboard ===== */
.search { position: relative; margin-bottom: 20px; max-width: 420px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 38px; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.project-card { display: flex; flex-direction: column; gap: 6px; padding: 18px; color: var(--text); transition: transform .15s, box-shadow .15s, border-color .15s; }
.project-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.project-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.project-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.project-card h3 { font-size: 16px; }
.project-party { color: var(--text-2); font-size: 14px; }
.project-desc { color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.project-meta { margin-top: auto; padding-top: 10px; font-size: 12.5px; color: var(--muted); }

/* ===== Project ===== */
.project-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
@media (max-width: 980px) { .project-layout { grid-template-columns: 1fr; } .project-side { order: -1; } }
.project-side { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 980px) { .project-side { position: static; } }

.dropzone { padding: 0; border: 2px dashed var(--border-strong); background: var(--surface); transition: border-color .15s, background .15s; }
.dropzone.dragging { border-color: var(--primary); background: var(--primary-soft); }
.dropzone-body { display: flex; align-items: center; gap: 16px; padding: 22px; cursor: pointer; }
.dropzone-body strong { display: block; margin-bottom: 2px; }
.dropzone-body .muted { font-size: 13.5px; }
.dropzone-icon { width: 52px; height: 52px; flex: none; border-radius: 14px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.dropzone-details { padding: 0 22px 20px; }
.dropzone-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dropzone-progress { padding: 0 22px 20px; display: flex; gap: 10px; align-items: center; color: var(--text-2); font-size: 14px; }
.file-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; border-radius: 9px; background: var(--surface-2); font-size: 14px; }
.file-list li span:last-child { color: var(--muted); white-space: nowrap; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 21px; top: 10px; bottom: 10px; width: 2px; background: var(--border); }
.timeline-item { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 14px; margin-bottom: 14px; position: relative; }
.timeline-dot {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; z-index: 1;
  font-size: 13px; font-weight: 700; background: var(--surface); border: 2px solid var(--border-strong); color: var(--text-2);
}
.timeline-dot.is-latest { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 0 5px var(--primary-soft); }
.version { padding: 16px 18px; }
.version-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.version-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.version-title h3 { font-size: 16px; overflow-wrap: anywhere; }
.version-actions { display: flex; gap: 6px; align-items: center; }
.version-meta { display: flex; gap: 6px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 6px; }
.version-meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; }
.version-notes { margin-top: 8px; font-size: 14px; color: var(--text-2); padding: 8px 12px; border-left: 3px solid var(--border-strong); background: var(--surface-2); border-radius: 0 8px 8px 0; }
.version-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.version-warning { font-size: 13px; color: var(--warn-text); margin-top: 8px; }
.format { font-size: 11px; font-weight: 800; letter-spacing: .04em; padding: 3px 7px; border-radius: 6px; color: #fff; background: #64748b; }
.format-pdf { background: #e5484d; }
.format-docx, .format-doc { background: #2b6ce6; }
.format-odt { background: #0ea5a4; }
.format-rtf { background: #8b5cf6; }

.compare-panel { padding: 20px; }
.compare-panel h2 { margin-bottom: 16px; }
.compare-panel .field { margin-bottom: 8px; }
.swap-btn {
  display: grid; place-items: center; width: 32px; height: 32px; margin: 0 auto 8px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); cursor: pointer; font-size: 16px;
}
.swap-btn:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.options { margin: 8px 0 14px; font-size: 14px; }
.options summary { cursor: pointer; color: var(--text-2); font-weight: 500; }
.legend { padding: 18px 20px; font-size: 14px; color: var(--text-2); display: flex; flex-direction: column; gap: 8px; }
.legend h3 { color: var(--text); }

/* ===== Diff marks (shared) ===== */
del, ins { text-decoration: none; border-radius: 3px; padding: 0 1px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
del { background: var(--del-bg); color: var(--del-text); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--del-strong) 65%, transparent); text-decoration-thickness: 1.5px; }
ins { background: var(--ins-bg); color: var(--ins-text); }
.legend-del, .legend-ins { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.legend-del { background: var(--del-bg); color: var(--del-text); text-decoration: line-through; }
.legend-ins { background: var(--ins-bg); color: var(--ins-text); }

/* ===== Compare ===== */
.compare-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.compare-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.compare-pick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.compare-pick .swap-btn { margin: 0; }
.version-pick { display: flex; align-items: center; gap: 0; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); overflow: hidden; }
.version-pick > span { padding: 0 10px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; align-self: stretch; display: grid; place-items: center; color: #fff; }
.version-pick-a > span { background: var(--del-strong); }
.version-pick-b > span { background: var(--ins-strong); }
.version-pick select { border: 0; border-radius: 0; max-width: 280px; padding: 9px 10px; }
.version-pick select:focus { box-shadow: none; }
.version-pick:focus-within { box-shadow: var(--focus); border-color: var(--primary); }

.verdict { display: flex; gap: 16px; align-items: center; padding: 18px 20px; border-radius: var(--radius); margin-bottom: 16px; flex-wrap: wrap; border: 1px solid transparent; }
.verdict h2 { font-size: 20px; }
.verdict p { margin-top: 4px; max-width: 80ch; }
.verdict-icon { width: 52px; height: 52px; flex: none; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.verdict-ok { background: var(--ins-bg); color: var(--ins-text); border-color: color-mix(in srgb, var(--ins-strong) 30%, transparent); }
.verdict-ok .verdict-icon { background: var(--ins-strong); }
.verdict-diff { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-sm); }
.verdict-diff .verdict-icon { background: var(--warn-strong); }
.verdict-diff p { color: var(--muted); }
.verdict-text { flex: 1; min-width: 220px; }
.stats { display: flex; gap: 8px; margin: 0; flex-wrap: wrap; }
.stat { padding: 8px 14px; border-radius: 10px; background: var(--surface-2); min-width: 92px; }
.stat dt { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat dd { margin: 2px 0 0; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-ins { background: var(--ins-bg); } .stat-ins dd, .stat-ins dt { color: var(--ins-text); }
.stat-del { background: var(--del-bg); } .stat-del dd, .stat-del dt { color: var(--del-text); }

.compare-toolbar {
  position: sticky; top: 57px; z-index: 20; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 0; margin-bottom: 8px; background: linear-gradient(var(--bg) 75%, transparent);
}
.tabs { display: inline-flex; padding: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.tab { padding: 7px 14px; border-radius: 9px; color: var(--text-2); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.tab:hover { text-decoration: none; color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tab .count { font-size: 11.5px; padding: 1px 7px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-text); }
.nav-changes { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-2); }
.toolbar-right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.toggle { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 700; }
.toggle:hover { text-decoration: none; color: var(--text); }
.toggle.on { background: var(--primary-soft); color: var(--primary-text); border-color: transparent; }

.compare-body { position: relative; padding-right: 22px; }
.minimap { position: absolute; right: 0; top: 0; bottom: 0; width: 10px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); }
.minimap .tick { position: absolute; left: -1px; right: -1px; height: 4px; border: 0; padding: 0; border-radius: 2px; cursor: pointer; transform: translateY(-50%); }
.minimap .tick:hover { height: 8px; }
.tick-modified { background: var(--warn-strong); }
.tick-inserted { background: var(--ins-strong); }
.tick-deleted { background: var(--del-strong); }

.doc-card { overflow: hidden; }
.doc-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--border); background: var(--surface-2); font-size: 13px; font-weight: 600; color: var(--text-2); }
.doc-header > span:first-child { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.doc {
  padding: 28px 36px 40px; white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: var(--font-doc); font-size: 16.5px; line-height: 1.75; color: var(--text); tab-size: 4;
}
@media (max-width: 640px) { .doc { padding: 18px; font-size: 15.5px; } }
.chg { border-radius: 4px; transition: box-shadow .2s; scroll-margin-top: 140px; }
.chg.current { box-shadow: 0 0 0 2px var(--primary); }
.chg.current del, .chg.current ins { filter: saturate(1.6); }
.gap { display: inline-block; width: 6px; height: 1.1em; vertical-align: -0.15em; border-radius: 3px; margin: 0 1px; }
.gap-ins { background: var(--ins-strong); opacity: .7; }
.gap-del { background: var(--del-strong); opacity: .7; }

.side-by-side { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.side-by-side .doc { position: relative; max-height: calc(100vh - 190px); overflow: auto; padding: 22px 26px; font-size: 15.5px; }
@media (max-width: 900px) { .side-by-side { grid-template-columns: 1fr; } 
.side-by-side .doc { position: relative; max-height: 60vh; } }

.change-list { display: flex; flex-direction: column; gap: 12px; }
.change-card { padding: 14px 18px; scroll-margin-top: 140px; transition: box-shadow .2s; }
.change-card.current { box-shadow: 0 0 0 2px var(--primary); }
.change-card header { display: flex; align-items: center; gap: 10px; font-size: 13px; margin-bottom: 10px; flex-wrap: wrap; }
.change-no { font-weight: 800; color: var(--text-2); font-variant-numeric: tabular-nums; }
.change-words { margin-left: auto; display: flex; gap: 6px; font-weight: 700; font-variant-numeric: tabular-nums; }
.change-words .plus { color: var(--ins-strong); }
.change-words .minus { color: var(--del-strong); }
.change-context { font-family: var(--font-doc); font-size: 16px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.change-context .ctx { color: var(--muted); }
.change-card .link { display: inline-block; margin-top: 8px; }
.compare-foot { margin-top: 20px; font-size: 12.5px; }
.print-only { display: none; }


/* ===== Formatted (visual) comparison ===== */
.visual { position: relative; }
.visual-status { padding: 14px 18px; display: flex; gap: 10px; align-items: center; margin-bottom: 12px; color: var(--text-2); }
.visual-ok { background: var(--ins-bg); color: var(--ins-text); border-color: transparent; font-weight: 600; }
.visual-error { background: var(--del-bg); color: var(--del-text); border-color: transparent; }
.vpane { --desk: #e8eaef; background: var(--desk); padding: 20px 12px; overflow: auto; max-height: calc(100vh - 175px); position: relative; }
.vpane-single { max-height: none; overflow: visible; padding: 28px 12px; }
.vpane-hidden { position: absolute; left: -20000px; top: 0; width: 900px; visibility: hidden; max-height: none; }
@media (prefers-color-scheme: dark) { .vpane { --desk: #0b0d12; } }
.visual-side { align-items: start; }

/* Word pages rendered by docx-preview */
.docx-host .docx-wrapper { background: transparent; padding: 0; display: flex; flex-direction: column; align-items: center; }
.docx-host .docx-wrapper > section.docx { margin-bottom: 20px; box-shadow: 0 2px 6px rgba(16, 24, 40, .12), 0 12px 32px -12px rgba(16, 24, 40, .25); color: #000; }
.plain-page { background: #fff; color: #111; max-width: 820px; margin: 0 auto; box-shadow: 0 2px 6px rgba(16, 24, 40, .12); }

/* PDF pages rendered by pdf.js */
.pdf-page { position: relative; margin: 0 auto 20px; background: #fff; box-shadow: 0 2px 6px rgba(16, 24, 40, .12), 0 12px 32px -12px rgba(16, 24, 40, .25); }
.pdf-page canvas { display: block; width: 100%; height: 100%; }
.pdf-overlay { position: absolute; inset: 0; }

/* Marks drawn on the documents (pages are always white, so colours are fixed) */
.vm { cursor: pointer; scroll-margin: 140px; }
span.vm-ins { background: #c6efd6; box-shadow: 0 0 0 1px rgba(48, 164, 108, .45); border-radius: 2px; }
span.vm-del { background: #fbd3d3; box-shadow: 0 0 0 1px rgba(229, 72, 77, .45); border-radius: 2px; text-decoration: line-through; text-decoration-color: #c62828; text-decoration-thickness: 1.5px; }
del.vm-del-inline { background: #fbd3d3; color: #a11d1d; text-decoration: line-through; text-decoration-color: #c62828; text-decoration-thickness: 1.5px; border-radius: 2px; padding: 0 2px; margin: 0 3px 0 0; box-shadow: 0 0 0 1px rgba(229, 72, 77, .35); }
.vm-box { position: absolute; border-radius: 2px; mix-blend-mode: multiply; }
.vm-box.vm-ins { background: rgba(48, 164, 108, .38); }
.vm-box.vm-del { background: rgba(229, 72, 77, .32); }
.vm-box.vm-del::after { content: ""; position: absolute; left: 0; right: 0; top: 52%; height: 1.5px; background: #c62828; }
.vm-caret { display: inline-block; width: 4px; height: 1.15em; vertical-align: -.2em; border-radius: 2px; margin: 0 1px; }
.vm-caret-ins { background: #30a46c; }
.vm-caret-del { background: #e5484d; }
.vm-caret-pdf { position: absolute; display: block; margin: 0; width: 5px; vertical-align: baseline; }
.vm.current { outline: 2.5px solid #4f46e5; outline-offset: 2px; }

.change-bubble {
  position: absolute; z-index: 25; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); font-family: var(--font-doc); font-size: 15px; line-height: 1.55; display: flex; flex-direction: column; gap: 6px;
  max-height: 260px; overflow: auto; animation: pop .15s ease-out;
}
.change-bubble .bubble-head { font-family: var(--font); font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.change-bubble del, .change-bubble ins { display: block; padding: 4px 8px; white-space: pre-wrap; }

/* ===== Print ===== */
@media print {
  @page { margin: 16mm; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .topbar, .no-print, .toast, .compare-toolbar, .minimap { display: none !important; }
  .print-only { display: block; font-size: 10pt; }
  .container { padding: 0; max-width: none; }
  .card, .verdict { box-shadow: none; border-color: #ccc; }
  .compare-body { padding: 0; }
  
.side-by-side .doc { position: relative; max-height: none; overflow: visible; }
  .doc { padding: 12px 0; font-size: 11pt; }
  .doc-header { background: none; }
  del, ins, .verdict, .stat, .badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .chg.current { box-shadow: none; }
}
