:root {
  --bg: #f7f7f5;
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #d8d5cd;
  --male: #2f6fb0;
  --female: #b03a72;
  --unknown: #8a8f98;
  --root: #1f9d8a;
  --panel: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 16px;
  background: #23303f;
  color: #f2f2f2;
  flex-wrap: wrap;
}

.brand { font-weight: 700; font-size: 18px; letter-spacing: 0.5px; }

.control { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.control label { display: flex; align-items: center; gap: 6px; }

.toolbar select,
.toolbar input[type="text"],
.toolbar input[type="search"],
.toolbar input:not([type]) {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid #3d4c5e;
  background: #18222d;
  color: #f2f2f2;
  font-size: 13px;
}

#search { min-width: 240px; }

.toolbar button {
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid #3d4c5e;
  background: #2f6fb0;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
}
.toolbar button:hover { background: #3a82cc; }

.status { margin-left: auto; color: #a9b4c0; }

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

.canvas { position: relative; flex: 1; min-width: 0; }
#tree { width: 100%; height: 100%; display: block; cursor: grab; }
#tree:active { cursor: grabbing; }

.node rect {
  fill: #fff;
  stroke: var(--line);
  stroke-width: 1.5;
  rx: 8;
}
.node.male rect { stroke: var(--male); }
.node.female rect { stroke: var(--female); }
.node.unknown rect { stroke: var(--unknown); }
.node.root rect { stroke: var(--root); stroke-width: 3; fill: #ecfaf7; }
.node { cursor: pointer; }
.node .surname { font-size: 13px; font-weight: 700; fill: var(--ink); }
.node .given { font-size: 12px; fill: #4b5563; }
.node .years { font-size: 11px; fill: var(--muted); }
.node .cross { font-size: 11px; fill: var(--muted); }

.link-child { fill: none; stroke: #b9b3a6; stroke-width: 1.4; }
.link-spouse { stroke: #c9a24a; stroke-width: 2.5; }

.minimap {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 220px;
  height: 150px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
}
#minimap { width: 100%; height: 100%; display: block; }
.minimap .mm-node { fill: #b9c2cc; }
.minimap .mm-node.root { fill: var(--root); }
.minimap .mm-view { fill: rgba(47, 111, 176, 0.18); stroke: #2f6fb0; stroke-width: 1; }

.panel {
  width: 360px;
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
  padding: 16px;
}
.panel-empty { color: var(--muted); text-align: center; margin-top: 40px; }
.panel h2 { margin: 0 0 2px; font-size: 18px; }
.panel .lifespan { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.panel h3 { font-size: 13px; text-transform: uppercase; color: var(--muted); margin: 18px 0 6px; letter-spacing: 0.4px; }
.panel table { width: 100%; border-collapse: collapse; font-size: 13px; }
.panel td { padding: 4px 0; vertical-align: top; }
.panel td:first-child { color: var(--muted); width: 42%; }
.panel .chip { display: inline-block; padding: 2px 8px; margin: 2px 4px 2px 0; border-radius: 12px; background: #eef1f4; font-size: 12px; cursor: pointer; }
.panel .chip:hover { background: #dde5ec; }
.panel .event { border-left: 3px solid var(--line); padding: 4px 0 4px 8px; margin-bottom: 6px; font-size: 13px; }
.panel .event .tag { font-weight: 600; }
.panel .note { font-size: 13px; white-space: pre-wrap; background: #f6f6f3; padding: 8px; border-radius: 6px; }
.panel .btn-card { margin-top: 12px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: #23303f;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 50;
  max-width: 70vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #a12b2b; }

.edit { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 4px; }
.edit label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 2px; }
.edit input, .edit select {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}
.edit button { align-self: flex-start; }
.panel .event { position: relative; padding-right: 20px; }
.panel .del {
  position: absolute;
  right: 0;
  top: 0;
  border: none;
  background: transparent;
  color: #b03a72;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.panel .btn {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #eef1f4;
  cursor: pointer;
  font-size: 13px;
}
.panel .btn:hover { background: #dde5ec; }

.media-item {
  display: flex;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
  margin-bottom: 6px;
  position: relative;
  padding-right: 20px;
}
.media-item img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 4px;
  background: #eee;
}
.media-item .meta { font-size: 12px; overflow-wrap: anywhere; }
.media-item .meta a { color: #2f6fb0; }
.media-item .media-link {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: #2f6fb0;
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
}
.media-item .media-link:hover { color: #1d4e82; }
.media-item .missing { color: #a12b2b; font-size: 11px; }
.media-item .del-media {
  position: absolute;
  right: 4px;
  top: 2px;
  border: none;
  background: transparent;
  color: #b03a72;
  cursor: pointer;
  font-size: 15px;
}

.nav-btn { cursor: pointer; }
.node-menu-btn { cursor: pointer; font-size: 16px; fill: #9aa3ad; font-weight: 700; }
.node-menu-btn:hover { fill: #1f9d8a; }

.node-menu {
  position: absolute;
  z-index: 20;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  padding: 4px;
  min-width: 132px;
}
.node-menu.hidden { display: none; }
.node-menu button {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
  font-family: inherit;
}
.node-menu button:hover { background: #eef1f4; }
.node-menu button b { color: var(--muted); font-weight: 600; }

.panel .chip .unlink { margin-left: 5px; color: #b03a72; cursor: pointer; font-weight: 700; }
.panel .chip .unlink:hover { color: #7d1947; }
.panel .add-rel {
  border: none;
  background: transparent;
  color: #1f9d8a;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 2px;
}
.panel .add-rel:hover { color: #146b5f; }
.rel-cell { position: relative; }
.rel-picker { margin-top: 4px; }
.rel-picker.hidden { display: none; }
.rel-picker .rel-input {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}
.rel-results { margin-top: 4px; }
.rel-results .rel-result {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: none;
  background: #f4f6f7;
  border-radius: 6px;
  padding: 5px 8px;
  margin-bottom: 3px;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.rel-results .rel-result:hover { background: #e6ebee; }
.rel-results .rel-result span { color: var(--muted); }

.panel .note { position: relative; padding-right: 18px; }
.panel .del-field {
  position: absolute;
  right: 0;
  top: 0;
  border: none;
  background: transparent;
  color: #b03a72;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.edit textarea {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  min-height: 48px;
  resize: vertical;
}

.panel-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.panel-tab {
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.panel-tab.active { background: #23303f; color: #fff; border-color: #23303f; }

.catalog-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.catalog-tab {
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.catalog-tab.active { background: #2f6fb0; color: #fff; border-color: #2f6fb0; }

.doc-list { display: flex; flex-direction: column; }
.doc-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink);
  text-decoration: none;
}
.doc-item:hover { background: #eef1f4; }
.doc-item.dir { color: var(--muted); font-weight: 600; }
.doc-item .doc-meta { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.doc-title { font-weight: 600; }
.doc-body { font-size: 12px; white-space: pre-wrap; font-family: ui-monospace, monospace; line-height: 1.5; }
.muted { color: var(--muted); font-size: 12px; }

.panel { width: var(--panel-w, 360px); }
.panel-resize {
  flex: 0 0 6px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s;
}
.panel-resize:hover, .panel-resize.dragging { background: #d9d5cd; }

.doc-md { font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.doc-md h1 { font-size: 17px; margin: 8px 0; }
.doc-md h2 { font-size: 15px; margin: 12px 0 6px; }
.doc-md h3 { font-size: 13px; text-transform: none; color: var(--ink); letter-spacing: 0; margin: 12px 0 4px; }
.doc-md p { margin: 6px 0; }
.doc-md ul, .doc-md ol { margin: 6px 0; padding-left: 20px; }
.doc-md pre { background: #f6f6f3; padding: 8px; border-radius: 6px; overflow: auto; font-size: 12px; }
.doc-md code { background: #f0f0ed; padding: 1px 4px; border-radius: 4px; font-size: 12px; }
.doc-md table { border-collapse: collapse; font-size: 12px; margin: 8px 0; }
.doc-md th, .doc-md td { border: 1px solid var(--line); padding: 3px 6px; }
.doc-md blockquote { margin: 6px 0; padding-left: 10px; border-left: 3px solid var(--line); color: var(--muted); }
.doc-md a { color: #2f6fb0; }

.doc-search {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  margin-bottom: 8px;
}
.doc-actions { display: flex; gap: 6px; margin-bottom: 8px; }

.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.panel-head h2 { flex: 1; }
.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  font-size: 15px;
  cursor: pointer;
  color: var(--muted);
  flex: 0 0 auto;
}
.icon-btn:hover { background: #eef1f4; color: var(--ink); }
.icon-btn.active { background: #1f9d8a; color: #fff; border-color: #1f9d8a; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 26, 34, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  z-index: 100;
}
.modal.hidden { display: none; }
.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 18px 20px;
  width: 340px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-box h3 { margin: 0 0 4px; }
.modal-box label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.modal-box input, .modal-box select {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.btn.primary { background: #1f9d8a; color: #fff; border-color: #1f9d8a; }
.btn.primary:hover { background: #188a79; }

.media-box {
  width: min(94vw, 1000px);
  /* вписываемся в экран: не 12vh отступ + 90vh высота, иначе низ уходит за край */
  height: min(94vh, 900px);
  padding: 12px 14px;
  gap: 8px;
}
.media-view .doc-frame { width: 100%; height: 100%; border: 0; background: #fff; }
/* медиа-модалка открывается почти от верха и полностью помещается по высоте */
#media-modal {
  padding-top: 3vh;
  padding-bottom: 3vh;
  align-items: flex-start;
}
.media-head { display: flex; align-items: center; gap: 10px; }
.media-head-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.media-head-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #eef1f4;
  color: var(--ink);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.media-head-actions .btn:hover { background: #dde5ec; }
.media-head-actions .btn[data-act="close-media"] {
  padding: 4px 10px;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
}
.media-view {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: #f4f6f8;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.media-view img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.media-view iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.media-view video, .media-view audio { max-width: 100%; }
.media-view .doc {
  align-self: stretch;
  background: #fff;
  padding: 18px 22px;
  font-size: 14px;
  line-height: 1.5;
  width: 100%;
}
.media-view .doc h1, .media-view .doc h2, .media-view .doc h3 { margin: 16px 0 6px; }
.media-view .doc pre { background: #f2f4f6; padding: 10px; border-radius: 6px; overflow-x: auto; }
.media-view .doc code { background: #f2f4f6; padding: 1px 4px; border-radius: 4px; }
.media-view .doc table { border-collapse: collapse; }
.media-view .doc th, .media-view .doc td { border: 1px solid var(--line); padding: 4px 8px; }
.media-view .fallback { color: var(--muted); text-align: center; padding: 20px; }

.toolbar button,
.toolbar select {
  height: 30px;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
}
.toolbar input[type="range"] { height: 30px; }

.hidden { display: none !important; }
.date-row { display: flex; gap: 6px; align-items: center; }
.date-row .ev-date, .date-row .mar-date { flex: 1; }
.date-row .ev-cal { padding: 4px 8px; }
.ev-head { position: relative; }
.ev-edit {
  position: absolute;
  right: 16px;
  top: -2px;
  border: none;
  background: transparent;
  color: #2f6fb0;
  cursor: pointer;
  font-size: 13px;
}
.ev-edit:hover { color: #1a4a7a; }
.marriage-title { margin: 10px 0 4px; font-size: 13px; color: var(--muted); font-weight: 600; }

.icon-btn { width: auto; padding: 0 10px; font-size: 13px; }

.edit-actions { display: flex; gap: 6px; }
.edit-actions .btn { font-size: 12px; padding: 4px 10px; }
.icon-btn { border-radius: 8px; height: 28px; }

.date-row { position: relative; }
.ev-date-pick {
  position: absolute;
  right: 8px;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: 0;
  padding: 0;
  pointer-events: none;
}

.user-chip { font-size: 12px; color: #cfd8e3; }

.dir-btn {
  padding: 4px 12px;
  border: 1px solid #3d4c5e;
  background: #18222d;
  color: #cfd8e3;
  border-radius: 14px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  height: 30px;
}
.dir-btn.active { background: #2f6fb0; color: #fff; border-color: #2f6fb0; }

.adm-row { display: flex; gap: 6px; margin-bottom: 4px; align-items: center; }
.adm-row input, .adm-row select {
  flex: 1;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
}
.adm-row .del-row { flex: 0 0 auto; padding: 3px 8px; }

.toolbar .dir-btn {
  background: #18222d;
  color: #cfd8e3;
  border: 1px solid #3d4c5e;
}
.toolbar .dir-btn.active {
  background: #2f6fb0;
  color: #fff;
  border-color: #2f6fb0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
#back-btn:disabled { opacity: 0.4; cursor: default; }

.head-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

/* экран до входа */
body.logged-out .toolbar, body.logged-out .layout { display: none; }
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, #2b3a4a 0%, #1a232e 70%);
  z-index: 200;
}
.login-screen.hidden { display: none; }
.login-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 32px; }
.login-brand { font-size: 44px; font-weight: 800; color: #f2f6fa; letter-spacing: 1px; }
.login-sub { color: #a9b4c0; font-size: 15px; margin-bottom: 8px; }
.login-hint { color: #7d8895; font-size: 12px; max-width: 320px; }

/* ── мобильная вёрстка ────────────────────────────────────────────── */
.panel-toggle, .panel-close { display: none; }
.panel-backdrop { display: none; }

@media (max-width: 900px), (max-height: 520px) {
  .panel-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    font-size: 18px;
    border: 1px solid #3d4c5e;
    background: #18222d;
    color: #f2f2f2;
    border-radius: 8px;
    cursor: pointer;
  }
  .panel-close {
    display: inline-flex;
    margin-left: auto;
    border: none;
    background: transparent;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: var(--muted);
    flex: 0 0 auto;
  }
  /* 4 таба + крестик не влезают в ширину панели: разрешаем перенос строк,
     иначе .panel-close с margin-left:auto выдавливается за пределы панели */
  .panel-tabs { flex-wrap: wrap; gap: 4px; row-gap: 6px; }
  .panel-tab { padding: 4px 8px; font-size: 12px; }

  .toolbar { gap: 8px; padding: 6px 10px; }
  .brand { font-size: 16px; }
  #search { min-width: 0; flex: 1 1 140px; }
  .toolbar .control { font-size: 12px; }
  .status { margin-left: 0; width: 100%; text-align: right; }

  .panel-resize { display: none; }
  /* строки админки (6 полей) не влезают в ширину панели: 2 колонки вместо overflow */
  .adm-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; margin-bottom: 8px; }
  .adm-row input, .adm-row select { min-width: 0; width: 100%; }
  .adm-row .del-row { grid-column: 1 / -1; justify-self: end; align-self: center; }
  .panel {
    position: fixed;
    top: var(--toolbar-h, 46px);
    right: 0;
    bottom: 0;
    width: min(94vw, 440px);
    max-width: 94vw;
    transform: translateX(102%);
    transition: transform 0.22s ease;
    z-index: 60;
    box-shadow: -8px 0 28px rgba(0, 0, 0, 0.28);
    padding-top: 10px;
  }
  body.panel-open .panel { transform: translateX(0); }
  body.panel-open .panel-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 20, 27, 0.4);
    z-index: 55;
  }
  .canvas { min-width: 100%; }
}

/* верхняя панель: гамбургер сворачивает доп. элементы (мобильный) */
.toolbar .toolbar-toggle { display: none; }
.toolbar-controls { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; flex: 1 1 auto; }
@media (max-width: 900px), (max-height: 520px) {
  .toolbar .toolbar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    font-size: 18px;
    border: 1px solid #3d4c5e;
    background: #18222d;
    color: #f2f2f2;
    border-radius: 8px;
    cursor: pointer;
    flex: 0 0 auto;
  }
  .toolbar-controls { display: none; }
  body.toolbar-open .toolbar-controls {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100%;
    padding-top: 8px;
  }
  .toolbar-controls .status { margin-left: 0; text-align: left; }
}

@media (max-width: 900px), (max-height: 520px) {
  .minimap { width: 108px; height: 78px; right: 8px; bottom: 8px; border-radius: 6px; }

  body.toolbar-open .toolbar-controls { gap: 12px; }
  body.toolbar-open .toolbar-controls .control {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: 100%;
  }
  body.toolbar-open .toolbar-controls .control > label { font-size: 12px; color: #a9b4c0; }
  body.toolbar-open .toolbar-controls button {
    width: 100%;
    justify-content: center;
    height: 34px;
  }
  body.toolbar-open .toolbar-controls input[type="range"] { width: 100%; }
  #back-btn::after { content: "\00a0Назад"; }
  .toolbar-controls .status { width: 100%; text-align: left; }
}

@media (max-width: 900px), (max-height: 520px) {
  /* тулбар перекрывает холст и не меняет область отрисовки */
  .toolbar { position: fixed; top: 0; left: 0; right: 0; z-index: 70; }
  .layout { padding-top: var(--toolbar-h, 56px); }
}

@media (max-width: 900px), (max-height: 520px) {
  /* выпадающее меню компактной ширины */
  body.toolbar-open .toolbar-controls {
    position: absolute;
    top: 100%;
    left: 8px;
    right: auto;
    width: min(86vw, 320px);
    max-height: 76vh;
    overflow: auto;
    background: #23303f;
    border: 1px solid #3d4c5e;
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.38);
    gap: 12px;
  }
  body.toolbar-open .toolbar-controls button { width: 100%; }
}

.commit-list { display: flex; flex-direction: column; }
.commit-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid #f0efeb;
}
.commit-item:hover { background: #eef1f4; }
.commit-when { font-size: 11px; color: var(--muted); }
.commit-subj {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.commit-box { width: min(92vw, 560px); max-height: 80vh; overflow-y: auto; }
.commit-box h3 { margin: 0 0 6px; }
.commit-box h4 { margin: 12px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; }
.commit-meta { font-size: 13px; color: #4b5563; }
.commit-sha { font-family: ui-monospace, monospace; font-size: 11px; color: var(--muted); margin: 6px 0; }
.commit-raw { background: #f6f6f3; padding: 8px; border-radius: 6px; font-size: 12px; white-space: pre-wrap; }
.commit-file { font-size: 12px; padding: 2px 0; overflow-wrap: anywhere; }
.commit-file .cs { display: inline-block; min-width: 18px; color: var(--muted); font-family: ui-monospace, monospace; }

.commit-box details summary { cursor: pointer; color: #2f6fb0; font-size: 13px; margin: 10px 0 4px; }
.commit-diff {
  background: #f6f6f3;
  padding: 8px;
  border-radius: 6px;
  font-size: 11px;
  white-space: pre;
  overflow: auto;
  max-height: 42vh;
}
