: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; text-align: center; }
.page-head { position: relative; display: flex; align-items: center; justify-content: flex-end; min-height: 48px; margin: 0 0 16px; }
.page-head h1 { position: absolute; left: 0; right: 0; margin: 0; padding: 0 150px; text-align: center; pointer-events: none; }
.page-head .page-back { position: relative; z-index: 1; }
button.text-link { height: auto; min-height: 0; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--seal); text-decoration: underline; }
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"], input[type="number"], 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: 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: 8px 0 16px; }
.pair-files, .pair-zoom, .pair-aside { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pair-aside { justify-content: flex-end; }
.reread { margin: 0; }
.reread button { margin: 0; white-space: nowrap; }
.doc-tabs {
  display: flex;
  width: 100%;
  gap: 8px;
  align-items: flex-end;
  margin: 0;
  padding: 10px 10px 0;
  background: var(--seal);
  border-radius: 14px 14px 0 0;
}
.doc-tabs button {
  flex: 1 1 0;
  height: auto;
  min-height: 46px;
  margin: 0;
  padding: 8px 16px;
  border: 0;
  border-radius: 12px 12px 0 0;
  background: #8d5346;
  color: #fffdf8;
  box-shadow: none;
}
.doc-tabs button.on {
  background: var(--card);
  color: var(--ink);
}
.doc-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 14px 14px;
  padding: 18px 20px;
  margin: 0 0 16px;
}
.index-code { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 12px; }
.index-code p, .index-code form { margin: 0; }
.index-code form { flex: 0 0 auto; }
.index-save { display: flex; justify-content: flex-end; margin-top: 8px; }
.person-dialog {
  width: min(920px, calc(100vw - 32px));
  max-height: min(860px, calc(100vh - 48px));
  margin: auto;
  border: 0;
  border-radius: 16px;
  padding: 16px 16px 8px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 18px 50px rgba(36, 28, 22, 0.28);
}
.person-dialog::backdrop { background: rgba(36, 28, 22, 0.45); }
.person-dialog-head { display: flex; justify-content: flex-end; margin: 0 0 8px; }
.person-dialog-head form, .person-dialog-head button { margin: 0; }
.person-dialog-head button { height: auto; min-height: 40px; }
.person-dialog .doc-panel { max-height: min(58vh, 560px); overflow: auto; }
.person-sheet > h2 { margin: 0 0 12px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.timeline-text { flex: 1 1 auto; min-width: 0; }
.timeline li .doc-open, .timeline li .event-open { flex: 0 0 auto; margin: 0; }
.timeline-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.panel-bar { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin: 0 0 12px; }
.person-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 28px; max-width: 820px; }
.person-fields .row { display: flex; align-items: center; gap: 10px; margin: 0; }
.person-fields label { flex: 0 0 8.5rem; margin: 0; }
.person-fields input[type="text"] { width: auto; flex: 1 1 auto; height: 36px; }
.person-fields + h2 { margin-top: 16px; }
@media (max-width: 720px) {
  .person-fields { grid-template-columns: 1fr; }
}
.name-list { list-style: none; margin: 0 0 12px; padding: 0; }
.name-list li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.name-kind { flex: 0 0 11rem; color: var(--muted); }
.name-value { min-width: 0; }
.name-list .name-remove { margin-left: auto; }
.event-dialog[open], .name-dialog[open] { width: min(560px, calc(100vw - 32px)); }
.event-actions { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin: 8px 0 0; }
.event-actions-start { justify-self: start; }
.event-actions-center { justify-self: center; }
.event-actions-end { justify-self: end; }
.link-dialog[open] { width: min(560px, calc(100vw - 32px)); }
.link-list { display: flex; flex-direction: column; gap: 8px; max-height: min(50vh, 420px); overflow: auto; }
.link-list button { justify-content: flex-start; height: auto; min-height: 48px; white-space: normal; text-align: left; }
.link-list button.on { background: var(--seal); color: white; border-color: var(--seal); }
.event-dialog .event-pair { display: flex; gap: 12px; align-items: end; }
.event-dialog .event-pair .row { flex: 1 1 0; min-width: 0; margin: 0 0 14px; }
.name-dialog select, .name-dialog input[type="text"], .event-dialog .row > input[type="text"] { width: min(320px, 100%); }
.event-dialog .event-pair .row > input[type="text"], .event-dialog #event-note { width: 100%; }
.event-dialog .date-parts .row > input[type="text"], .event-dialog .date-parts select { width: 9.5rem; }
.event-edit { margin: 8px 0 0; }
.pair-zoom 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-back {
  position: absolute;
  box-sizing: border-box;
  background: var(--paper, #fdfae1);
  z-index: 1;
}
.form-place {
  position: absolute;
  margin: 0;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  overflow: visible;
  background: transparent;
  color: #1a1a1a;
  line-height: 1;
  z-index: 2;
}
.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; }
.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 .event-name input { width: 16rem; }
.event-assign { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 10px 0 0; }
.event-assign-list {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: auto 26ch minmax(8rem, 14rem) minmax(0, 1fr);
  column-gap: 1.5rem;
  row-gap: 4px;
  align-items: baseline;
}
.event-assign-list .muted, .event-person { grid-column: 1 / -1; margin: 0; }
.event-person { color: var(--muted); font-size: 14px; }
.event-choice {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: baseline;
  margin: 0;
}
.event-choice input { width: auto; height: auto; min-height: 0; margin: 0; }
.event-choice .event-date { white-space: nowrap; }
.event-assign > button { flex: 0 0 auto; }
.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; }
.row-actions form { display: inline; margin: 0; }
th.row-actions, td.row-actions { width: 1%; }
.stitok-stav { min-height: 1.4em; margin: 0 0 12px; }
[data-stitok] { touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.print-dialog:not([open]) { display: none; }
.print-dialog[open] { width: min(420px, calc(100vw - 32px)); border: 0; border-radius: 16px; padding: 16px 18px 18px; background: var(--card); color: var(--ink); }
.print-dialog::backdrop { background: rgba(36, 28, 22, 0.45); }
.print-dialog h2 { margin: 0 0 14px; font-size: 22px; text-align: center; }
.print-choices { display: flex; flex-direction: column; gap: 10px; }
.print-choices button { width: 100%; }
.print-dialog .muted { margin: 12px 0 0; }
.print-dialog input[type="number"] { width: 100%; text-align: center; font-size: 22px; }
button:disabled { opacity: 0.45; cursor: default; }
[hidden] { display: none !important; }
.name-find { margin: 8px 0 4px; width: 100%; }
.search-field { position: relative; width: 100%; }
.subline { display: block; margin-top: 4px; color: var(--muted); font-size: 15px; line-height: 1.35; }
.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-maiden { font: 12px "Segoe UI", sans-serif; fill: #3e5168; }
.tree-maiden.inlaw { fill: #4e463f; }
.tree-years { font: 12px "Segoe UI", sans-serif; fill: #3e5168; }
.tree-more-badge { fill: #fffdf8; stroke: #6e3428; stroke-width: 1.4; }
.tree-more-node { fill: #6e3428; }
.tree-more-branch { fill: none; stroke: #6e3428; stroke-width: 1.15; stroke-linecap: round; stroke-linejoin: round; }
.tree-detail { cursor: pointer; }
.tree-detail-badge { fill: #fffdf8; stroke: #6e3428; stroke-width: 1.4; }
.tree-detail-card { fill: none; stroke: #6e3428; stroke-width: 1.2; }
.tree-detail-mark { fill: #6e3428; }
.tree-detail-lines { fill: none; stroke: #6e3428; stroke-width: 1.1; stroke-linecap: round; }
.tree-ribbon { fill: #141414; }
.tree-ribbon-fold { fill: none; stroke: #6a6a6a; stroke-width: 1; }
.tree-medal-ring { fill: none; stroke: #6e3428; stroke-width: 1.4; }
.person-head { display: flex; align-items: center; gap: 14px; }
.person-head h2 { margin: 0; }
.person-medal { position: relative; width: 88px; height: 88px; border-radius: 50%; overflow: hidden; flex: 0 0 88px; border: 1.5px solid #6e3428; background: #efe8dc; }
.person-medal img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; }
.medal-editor { margin: 0 0 16px; }
.medal-stage { position: relative; width: 220px; height: 220px; margin: 8px 0 12px; border-radius: 50%; overflow: hidden; border: 2px solid #6e3428; background: #fff; touch-action: none; cursor: grab; }
.medal-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.medal-stage img { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; }
.medal-zoom { display: flex; flex-wrap: wrap; gap: 8px; }
.crop-dialog:not([open]) { display: none; }
.crop-dialog[open] { display: flex; flex-direction: column; width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 24px); overflow: hidden; border: 0; border-radius: 16px; padding: 18px 18px 16px; background: var(--card); color: var(--ink); }
.crop-dialog::backdrop { background: rgba(36, 28, 22, 0.45); }
.crop-dialog p { margin: 0 0 12px; }
.crop-stage { position: relative; width: 100%; max-height: calc(100vh - 190px); margin: 0 auto; background: #fff; overflow: hidden; touch-action: none; }
.crop-layer { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; mix-blend-mode: multiply; pointer-events: none; }
.crop-box { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(36, 28, 22, 0.55); cursor: move; touch-action: none; }
.crop-box i { position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; background: #fff; border: 2px solid #6e3428; border-radius: 3px; }
.crop-box i[data-handle="nw"] { left: 0; top: 0; cursor: nwse-resize; }
.crop-box i[data-handle="n"] { left: 50%; top: 0; cursor: ns-resize; }
.crop-box i[data-handle="ne"] { left: 100%; top: 0; cursor: nesw-resize; }
.crop-box i[data-handle="e"] { left: 100%; top: 50%; cursor: ew-resize; }
.crop-box i[data-handle="se"] { left: 100%; top: 100%; cursor: nwse-resize; }
.crop-box i[data-handle="s"] { left: 50%; top: 100%; cursor: ns-resize; }
.crop-box i[data-handle="sw"] { left: 0; top: 100%; cursor: nesw-resize; }
.crop-box i[data-handle="w"] { left: 0; top: 50%; cursor: ew-resize; }
.import-list { max-height: min(62vh, 640px); overflow: auto; margin: 0 0 12px; }
.import-person { margin: 0 0 14px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.import-person h2 { margin: 0 0 8px; font-size: 1.05rem; }
.import-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 12px; }
.import-choice label { display: block; margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.import-actions { display: flex; justify-content: flex-end; gap: 8px; }
.crop-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.crop-actions form { margin: 0; }
.reading-dialog[open] { width: min(520px, calc(100vw - 32px)); }
.look-switch { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.look-switch label { margin: 0; cursor: pointer; }
.look-switch input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.look-switch span {
  display: inline-flex;
  align-items: center;
  height: 48px;
  padding: 0 16px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}
.look-switch label:has(input:checked) span { background: var(--seal); color: #fffdf8; border-color: var(--seal); }
.look:has(.look-switch) .look-pane { display: none; }
.look:has(input[value="original"]:checked) .look-original,
.look:has(input[value="prepis"]:checked) .look-prepis,
.look:has(input[value="preklad"]:checked) .look-preklad { display: block; }
.look-page { margin: 0 0 12px; background: #fff; }
.look-page img { width: 100%; height: auto; display: block; }
.look-page figcaption { padding: 6px 8px 8px; color: var(--muted); font-size: 13px; }
.look .sheet { margin: 0 0 12px; }
.person-doc { margin: 0 0 22px; }
.person-doc h3 { margin: 0 0 4px; }
.person-doc + .person-doc { border-top: 1px solid var(--line); padding-top: 18px; }
.view-dialog:not([open]) { display: none; }
.view-dialog[open] { display: flex; flex-direction: column; width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 24px); border: 0; border-radius: 16px; padding: 16px; background: var(--card); color: var(--ink); }
.view-dialog::backdrop { background: rgba(36, 28, 22, 0.45); }
.view-dialog-head { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin: 0 0 12px; }
.view-dialog-head button { margin: 0; }
.photo-nav { display: flex; gap: 8px; margin-right: auto; }
.photo-nav button { width: 48px; padding: 0; font-size: 28px; }
.photo-dialog[open] { width: min(920px, calc(100vw - 32px)); height: min(760px, calc(100vh - 24px)); }
.photo-frame { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; background: #efe8dc; border-radius: 12px; overflow: hidden; }
.photo-frame img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.photo-caption { margin: 10px 0 0; min-height: 1.3em; text-align: center; color: var(--muted); }
#doc-modal-body { overflow: auto; min-height: 0; }
.photo-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.photo-card { display: flex; flex-direction: column; gap: 8px; }
button.photo-tile { display: flex; flex-direction: column; width: 100%; height: 248px; min-height: 248px; margin: 0; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); box-shadow: none; }
.photo-tile-frame { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; background: #efe8dc; border-radius: 8px; overflow: hidden; }
.photo-tile-frame img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.photo-tile-date { flex: 0 0 32px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; }
@media (max-width: 860px) {
  .doc-layout { grid-template-columns: 1fr; }
  .doc-side { position: static; }
  .index-grid { grid-template-columns: 1fr; }
  .tree-viewport {
    height: min(46vh, 420px);
    min-height: 0;
  }
}
