/* ============================================
   GENEALOGY PAGE LAYOUT
   ============================================ */

.genealogy-strip {
  justify-content: space-between;
  align-items: center;
}

.genealogy-page-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}

.genealogy-main {
  display: flex;
  gap: 10px;
  padding: 12px;
  height: calc(100vh - var(--header-height, 100px));
  overflow: hidden;
}

/* ============================================
   COLUMNS — shared
   ============================================ */
.geo-col {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--white);
  min-width: 0;
}

.geo-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--paper-deep);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.geo-col-label {
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.geo-col-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

/* ============================================
   COLUMN 1 — Volume selector
   ============================================ */
.geo-col-select {
  width: 180px;
  flex-shrink: 0;
  transition: width 0.2s ease;
}

.geo-col-select.collapsed {
  width: 36px;
}

.geo-col-select.collapsed .geo-col-label {
  display: none;
}

.geo-col-select.collapsed .geo-col-body {
  display: none;
}

.geo-collapse-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  color: var(--ink-soft);
  padding: 2px 4px;
  line-height: 1;
  flex-shrink: 0;
  border-radius: 3px;
}

.geo-collapse-btn:hover {
  background: var(--line);
  color: var(--ink);
}

.geo-vol-section {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 8px 4px;
}

.geo-vol-item {
  font-family: var(--font-ui-cjk, var(--font-ui));
  font-size: 13px;
  color: var(--ink-soft);
  padding: 7px 10px;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.geo-vol-item:hover {
  background: var(--paper);
  color: var(--ink);
}

.geo-vol-item.active {
  background: rgba(163, 52, 42, 0.08);
  color: var(--seal-red);
  font-weight: 600;
}

/* ============================================
   COLUMN 2 — PDF Viewer
   ============================================ */
.geo-col-pdf {
  flex: 1.2;
}

.geo-pdf-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.geo-nav {
  display: flex;
  align-items: center;
  gap: 5px;
}

.geo-zoom {
  display: flex;
  align-items: center;
  gap: 5px;
}

.geo-nav-btn {
  font-family: var(--font-ui);
  font-size: 12px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  line-height: 1.4;
}

.geo-nav-btn:hover:not(:disabled) {
  background: var(--paper);
  border-color: var(--ink-soft);
}

.geo-nav-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.geo-page-label {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--ink-soft);
  white-space: nowrap;
  min-width: 40px;
  text-align: center;
}

.geo-page-input {
  font-family: var(--font-ui);
  font-size: 12px;
  width: 48px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--white);
  color: var(--ink);
  text-align: center;
}

.geo-page-input:focus {
  outline: none;
  border-color: var(--seal-red-soft);
}

.geo-pdf-frame {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  overflow: auto;
  position: relative;
}

.geo-pdf-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.15s ease;
  transform-origin: center center;
}

.geo-pdf-img.hidden {
  display: none;
}

/* ============================================
   COLUMN 3 — Digital text
   ============================================ */
.geo-col-text {
  flex: 1;
  position: relative;
}

.geo-text-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.geo-entry {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.geo-entry:last-child {
  border-bottom: none;
}

.geo-entry-gen {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  color: var(--seal-red);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
}

.geo-entry-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}

.geo-entry-text {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.8;
}

/* ============================================
   EMPTY / LOADING STATES
   ============================================ */
.geo-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-soft);
}

.geo-empty-icon {
  font-size: 32px;
  margin-bottom: 10px;
}

.geo-empty p {
  font-family: var(--font-ui);
  font-size: 13px;
}

.geo-loading {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink-soft);
  padding: 20px 10px;
  text-align: center;
}

/* ============================================
   DRAFT / EDITING WATERMARK
   ============================================ */
.geo-text-watermark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  overflow: hidden;
  z-index: 5;
}

.geo-text-watermark.hidden {
  display: none;
}

.geo-text-watermark span {
  font-family: var(--font-ui);
  font-size: 52px;
  font-weight: 700;
  color: rgba(163, 52, 42, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  transform: rotate(-28deg);
  white-space: nowrap;
  user-select: none;
}

@media (max-width: 768px) {
  .geo-text-watermark span {
    font-size: 30px;
  }
}

.geo-draft-toggle-btn {
  font-family: var(--font-ui);
  font-size: 11px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--white);
  color: var(--ink-soft);
  cursor: pointer;
}

.geo-draft-toggle-btn:hover {
  background: var(--paper);
}

.geo-draft-toggle-btn.active {
  border-color: var(--seal-red);
  background: rgba(163, 52, 42, 0.08);
  color: var(--seal-red);
  font-weight: 600;
}

.geo-draft-toggle-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.hidden {
  display: none !important;
}

/* ============================================
   TEXT EDITOR (custom, contenteditable-based)
   ============================================ */
.geo-edit-btn {
  font-family: var(--font-ui);
  font-size: 11px;
  padding: 3px 10px;
  border: 1px solid var(--seal-red);
  border-radius: 4px;
  background: var(--white);
  color: var(--seal-red);
  cursor: pointer;
  flex-shrink: 0;
}

.geo-edit-btn:hover {
  background: rgba(163, 52, 42, 0.07);
}

.geo-editor-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.geo-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.geo-editor-toolbar select {
  font-family: var(--font-ui);
  font-size: 12px;
  padding: 3px 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--white);
  color: var(--ink);
}

.geo-tb-btn {
  font-family: var(--font-ui);
  font-size: 12px;
  min-width: 26px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  line-height: 1.4;
}

.geo-tb-btn:hover {
  background: var(--paper);
  border-color: var(--ink-soft);
}

.geo-tb-btn.active {
  background: rgba(163, 52, 42, 0.08);
  border-color: var(--seal-red);
  color: var(--seal-red);
}

.geo-tb-sep {
  width: 1px;
  height: 20px;
  background: var(--line);
  margin: 0 4px;
}

.geo-editor-container {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1.9;
  color: var(--ink);
  outline: none;
}

.geo-editor-container p {
  margin-bottom: 0.6em;
}

.geo-editor-container p:last-child {
  margin-bottom: 0;
}

.geo-editor-container h1 {
  font-size: 1.4em;
  font-weight: 700;
  margin-bottom: 0.5em;
  color: var(--ink);
}

.geo-editor-container h2 {
  font-size: 1.2em;
  font-weight: 600;
  margin-bottom: 0.4em;
  color: var(--ink);
}

.geo-editor-actions {
  display: flex;
  gap: 8px;
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  background: var(--paper);
  flex-shrink: 0;
}

.geo-save-btn {
  font-family: var(--font-ui);
  font-size: 12px;
  padding: 5px 16px;
  border: none;
  border-radius: 4px;
  background: var(--seal-red);
  color: var(--white);
  cursor: pointer;
}

.geo-save-btn:hover {
  opacity: 0.85;
}

.geo-save-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.geo-cancel-btn {
  font-family: var(--font-ui);
  font-size: 12px;
  padding: 5px 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
}

.geo-cancel-btn:hover {
  background: var(--paper);
}

.geo-save-status {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  margin-left: auto;
}

/* ============================================
   RICH TEXT VIEW MODE
   Styles for HTML saved by the custom editor
   ============================================ */
.geo-view-html {
  padding: 14px;
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1.9;
  color: var(--ink);
}

.geo-view-html p {
  margin-bottom: 0.6em;
}

.geo-view-html p:last-child {
  margin-bottom: 0;
}

.geo-view-html h1 {
  font-size: 1.4em;
  font-weight: 700;
  margin-bottom: 0.5em;
  color: var(--ink);
}

.geo-view-html h2 {
  font-size: 1.2em;
  font-weight: 600;
  margin-bottom: 0.4em;
  color: var(--ink);
}

.geo-view-html strong {
  font-weight: 700;
}

.geo-view-html em {
  font-style: italic;
}

.geo-view-html u {
  text-decoration: underline;
}

/* ============================================
   MOBILE
   ============================================ */
@media (max-width: 768px) {
  .genealogy-main {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  .geo-col {
    width: 100% !important;
    height: auto;
  }

  .geo-col-select {
    width: 100% !important;
  }

  .geo-col-select.collapsed {
    width: 100% !important;
  }

  .geo-col-select.collapsed .geo-col-body {
    display: none;
  }

  .geo-col-pdf {
    height: 400px;
  }

  .geo-col-text {
    min-height: 300px;
  }

  .geo-collapse-btn {
    font-size: 13px;
  }
}

.back-link {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  text-decoration: none;
  white-space: nowrap;
}

.back-link:hover {
  color: var(--seal-red);
  text-decoration: underline;
}