:root {
  --paper: #f3efe6;
  --card: #fffdf8;
  --ink: #241c16;
  --muted: #6d6258;
  --line: #e3d9cc;
  --seal: #6e3428;
  --seal-dark: #54261d;
  --ok: #e7f0e4;
  --control-h: 48px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 17px/1.5 "Segoe UI", sans-serif;
}
.wrap { width: min(920px, calc(100% - 32px)); margin: 0 auto; }
.site-header { border-bottom: 1px solid var(--line); background: #f7f3eb; }
.site-header .wrap { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 18px 0; }
.mark { margin: 0; letter-spacing: 0.08em; text-transform: uppercase; font-size: 13px; color: var(--seal); }
nav { display: flex; flex-wrap: wrap; gap: 14px; }
nav a { color: var(--ink); text-decoration: none; }
nav a:hover { color: var(--seal); }
main { padding: 32px 0 64px; }
.site-footer { border-top: 1px solid var(--line); padding: 18px 0 28px; }
.site-footer a { color: var(--muted); font-size: 14px; }
h1 { font-family: Palatino, "Palatino Linotype", Georgia, serif; font-weight: 500; font-size: 40px; line-height: 1.15; margin: 0 0 12px; }
h2 { font-family: Palatino, "Palatino Linotype", Georgia, serif; font-weight: 500; font-size: 26px; margin: 28px 0 10px; }
p { margin: 0 0 12px; }
.lead { font-size: 19px; max-width: 38em; }
.muted { color: var(--muted); }
a { color: var(--seal-dark); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin: 16px 0; }
.flash { background: var(--ok); border-radius: 10px; padding: 10px 14px; }
.flash.error { background: #fdecea; color: #c62828; }
.errors { color: #c62828; margin: 0 0 12px; }
form .row { margin: 0 0 14px; }
label { display: block; font-size: 14px; margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], select {
  width: min(420px, 100%);
  height: var(--control-h);
  padding: 0 12px;
  border: 1px solid #d5cbbd;
  border-radius: 8px;
  background: white;
  font: inherit;
}
button, .button, .filters a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--control-h);
  min-height: var(--control-h);
  background: var(--seal);
  color: white;
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  font: inherit;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}
button.secondary, a.secondary { background: transparent; color: var(--ink); border: 1px solid #d5cbbd; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
.rights { width: 100%; }
.rights select { width: 100%; }
.file-list { display: grid; gap: 16px; }
.file-card img { width: 100%; height: auto; border-radius: 8px; background: #ece6dc; }
.password-once { font-family: Consolas, monospace; font-size: 20px; letter-spacing: 0.04em; }
.check { display: flex; gap: 8px; align-items: center; }
.check input { width: auto; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; }
.filters a { color: var(--ink); border: 1px solid var(--line); background: var(--card); }
.filters a.on { background: var(--seal); color: white; border-color: var(--seal); }
.page-tools { display: flex; flex-direction: column; align-items: stretch; gap: 16px; margin: 16px 0 20px; }
.page-tools .name-find { width: min(640px, 100%); }
.pages { display: grid; gap: 18px; }
.pages figure { margin: 0; }
.pages figcaption { margin-top: 8px; color: var(--muted); font-size: 14px; }
input[type="file"] {
  height: var(--control-h);
  padding: 8px 12px;
  border: 1px solid #d5cbbd;
  border-radius: 8px;
  background: white;
  font: inherit;
}
.upload-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.upload-row .row { margin: 0; }
.upload-original { margin: 16px 0; }
.upload-original input[type="file"] { width: min(520px, 100%); }
textarea {
  width: 100%;
  min-height: 140px;
  padding: 9px 10px;
  border: 1px solid #d5cbbd;
  border-radius: 8px;
  background: white;
  font: inherit;
}
.wrap.wide { width: min(1180px, calc(100% - 32px)); }
.doc-side { margin-top: 8px; }
.pair-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 8px; }
.pair-files, .pair-zoom { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pair-tools button {
  width: 42px;
  height: 42px;
  min-height: 0;
  padding: 0;
  border-radius: 10px;
  background: #fff;
  color: #1a2332;
  border: 1px solid #d5dbe3;
  box-shadow: 0 1px 4px rgba(20, 30, 50, 0.16);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.pair-view {
  overflow: auto;
  height: min(72vh, 760px);
  margin: 8px 0 16px;
  background: #e6e0d4;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.pair-sizer { position: relative; }
.pair-stage {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 16px;
  transform-origin: 0 0;
}
.pair-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.pair-original figure { margin: 0 0 12px; background: #fff; }
.pair-original img { width: 100%; height: auto; display: block; }
.pair-original figcaption { padding: 6px 8px 8px; color: var(--muted); font-size: 13px; }
.sheet {
  background: #fff;
  min-height: 100%;
  padding: 28px 26px 36px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  color: #1c1c1c;
  font: 15px/1.45 Palatino, Georgia, serif;
}
.sheet h2 { font-size: 22px; margin: 0 0 8px; }
.sheet h3 { font-size: 16px; margin: 18px 0 8px; }
.sheet-date { margin: 0 0 8px; }
.sheet-text { white-space: pre-wrap; }
.sheet.sheet-form {
  display: flex;
  flex-direction: column;
  width: 100%;
  aspect-ratio: var(--form-w) / var(--form-h);
  height: auto;
  overflow: hidden;
  box-sizing: border-box;
  padding: 0;
  font: 7px/1.15 "Segoe UI", sans-serif;
}
.form-page {
  flex: 1 1 auto;
  min-height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  border: 1px solid #1a1a1a;
}
.form-lines { text-align: center; padding: 0.45em 0.6em 0.2em; }
.form-lines p { margin: 0; }
.form-page > .form-lines:not(:first-child) {
  text-align: left;
  font-weight: 650;
  border-top: 1px solid #1a1a1a;
  padding: 0.35em 0.55em 0.05em;
}
.form-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid #1a1a1a;
  flex: 1 1 auto;
}
.form-fields:has(> :only-child) { grid-template-columns: 1fr; }
.form-fields p {
  margin: 0;
  padding: 0.35em 0.55em 0.45em;
  border-left: 1px solid #1a1a1a;
}
.form-fields p:first-child { border-left: 0; }
.form-label { display: block; font-size: 0.82em; color: #333; }
.sheet.sheet-form { position: relative; background: var(--paper, #fdfae1); }
.form-copy { position: absolute; inset: 0; container-type: size; }
.form-copy-paper { width: 100%; height: 100%; display: block; object-fit: fill; }
.form-place {
  position: absolute;
  margin: 0;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  overflow: hidden;
  background: var(--paper, #fdfae1);
  color: #1a1a1a;
  line-height: 1.05;
}
.form-place span { display: block; width: 100%; min-width: 0; }
.form-place-print { font-weight: 400; font-family: Palatino, "Palatino Linotype", Georgia, serif; }
.form-place-hand, .form-place-type { font-weight: 400; font-family: "Courier New", Courier, monospace; color: #222; }
.form-bold { font-weight: 700; }
.form-size-num { font-size: calc(var(--fs) * 0.1cqh); }
.form-place-hand span, .form-place-type span { white-space: nowrap; }
.form-place.form-wrap { align-items: flex-start; line-height: 1.22; }
.form-wrap span { white-space: normal; }
.form-size-title { font-size: 3.15cqh; letter-spacing: 0.01em; }
.form-size-sub { font-size: 1.9cqh; }
.form-size-body { font-size: 1.45cqh; }
.form-size-small { font-size: 1.2cqh; }
.form-place-type.form-size-body, .form-place-hand.form-size-body { font-size: 1.15cqh; }
.form-align-center { justify-content: center; }
.form-align-center span { text-align: center; }
.form-align-right { justify-content: flex-end; }
.form-align-right span { text-align: right; }
.form-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.form-grid th, .form-grid td {
  border: 1px solid #222;
  padding: 0.08em 0.15em;
  vertical-align: top;
  overflow-wrap: anywhere;
  font-weight: 400;
  text-align: left;
}
.form-grid th { font-size: 0.86em; background: #f4f1ea; }
.date-form { margin-bottom: 8px; }
.date-parts { display: flex; flex-wrap: nowrap; gap: 10px; align-items: end; }
.date-parts .row { margin: 0; }
.date-parts input, .date-parts select { width: 9.5rem; height: var(--control-h); min-height: var(--control-h); }
.date-parts button { white-space: nowrap; }
.form-sheet { width: 100%; border-collapse: collapse; background: white; font: 13px/1.35 "Segoe UI", sans-serif; }
.form-sheet th, .form-sheet td { border: 1px solid #b7ab9e; padding: 4px 6px; vertical-align: top; }
.form-sheet th { background: #f3efe6; font-size: 12px; color: var(--ink); }
.suggestion { padding: 12px 0; border-top: 1px solid var(--line); }
.suggestion-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.accepted { background: var(--ok); border-radius: 10px; padding: 10px 12px; }
.rejected { color: var(--muted); }
.find { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin: 0; }
.find input { width: min(320px, 100%); }
.row-actions { text-align: right; white-space: nowrap; vertical-align: middle; }
td.row-actions { padding-right: 0; }
.row-actions .button, .row-actions button { margin-left: 8px; }
th.row-actions, td.row-actions { width: 1%; }
.stitok-stav { min-height: 1.4em; margin: 0 0 12px; }
button:disabled { opacity: 0.45; cursor: default; }
[hidden] { display: none !important; }
.name-find { margin: 8px 0 4px; }
.search-field { position: relative; width: min(640px, 100%); }
.search-field input {
  width: 100%;
  height: 48px;
  padding: 10px 46px 10px 14px;
  font-size: 18px;
}
button.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  width: 28px;
  height: 28px;
  min-height: 0;
  margin: 0;
  padding: 0;
  transform: translateY(-50%);
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #c62828;
  font-size: 28px;
  line-height: 1;
  box-shadow: none;
}
.table-wrap { overflow-x: auto; }
.index-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; }
.index-people { grid-column: 1 / -1; }
.person-pick { max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; background: white; }
.person-pick .check { margin: 6px 0; font-size: 20px; line-height: 1.35; }
.chosen-names { min-height: 1.4em; margin: 8px 0; font-size: 17px; }
.name-list { max-height: 240px; overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin: 8px 0 16px; }
.name-list a { display: block; padding: 6px 12px; text-decoration: none; color: var(--ink); }
.name-list a.on, .name-list a:hover { background: var(--ok); }
.tree-viewport {
  position: relative;
  height: min(72vh, 680px);
  min-height: 420px;
  overflow: clip;
  background: #eef2f6;
  border: 1px solid #d5dee8;
  border-radius: 14px;
  margin-top: 8px;
  touch-action: none;
  cursor: grab;
  user-select: none;
}
.tree-viewport.dragging { cursor: grabbing; }
.tree-stage { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.tree-tools {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
}
.tree-tools button {
  width: 42px;
  height: 42px;
  min-height: 0;
  padding: 0;
  border-radius: 10px;
  background: #fff;
  color: #1a2332;
  border: 1px solid #d5dbe3;
  box-shadow: 0 1px 4px rgba(20, 30, 50, 0.16);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.tree-tools button:hover { background: #f4f7fb; }
.tree-menu {
  position: fixed;
  z-index: 40;
  min-width: 220px;
  padding: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(36, 28, 22, 0.16);
}
.tree-menu-name { margin: 0; padding: 8px 12px 10px; font-weight: 600; }
.tree-menu a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
}
.tree-menu a:hover { background: var(--ok); }
.name-row { display: flex; gap: 10px; align-items: center; margin: 0 0 10px; }
.name-row select { width: 14rem; flex: 0 0 14rem; }
.name-row input { flex: 1 1 auto; width: auto; }
.person-choice label { display: flex; gap: 8px; align-items: center; }
.person-choice input { width: auto; }
.tree-line { stroke: #9aa8b8; stroke-width: 1.5; }
.tree-box { stroke-width: 1.5; }
.tree-box.m { fill: #d7e9f8; stroke: #2a6fbb; }
.tree-box.f { fill: #f8d3e2; stroke: #c73b6e; }
.tree-box.u { fill: #f3efe6; stroke: #b7ab9e; }
.tree-box.on { stroke: var(--seal); stroke-width: 3; }
.tree-person.inlaw { opacity: 0.78; }
.tree-name { font: 600 13px "Segoe UI", sans-serif; fill: #1a2332; }
.tree-name.inlaw { fill: #4e463f; }
.tree-years { font: 12px "Segoe UI", sans-serif; fill: #3e5168; }
.tree-ribbon { fill: #141414; }
.tree-ribbon-fold { fill: none; stroke: #6a6a6a; stroke-width: 1; }
.person-card h3 { font-family: Palatino, Georgia, serif; font-weight: 500; font-size: 22px; margin: 18px 0 8px; }
@media (max-width: 860px) {
  .doc-layout { grid-template-columns: 1fr; }
  .doc-side { position: static; }
  .index-grid { grid-template-columns: 1fr; }
}
