/* ─── tree module (v10.27) ───────────────────────────────────────── */

.tree-panel .ml-panel-body {
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tree-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--accent2);
  flex-shrink: 0;
}
.tree-tab {
  cursor: pointer;
  text-decoration: none;
  padding: 5px 12px;
  border: 1px solid var(--accent2);
  color: var(--dim);
  font-size: 0.88em;
  border-radius: 2px;
}
.tree-tab:hover { color: var(--fg); }
.tree-tab.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(176,230,176,0.08);
}

.tree-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tree-btn {
  cursor: pointer;
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid var(--accent2);
  color: var(--fg);
  font-size: 0.85em;
  border-radius: 2px;
  font-family: var(--mono, monospace);
}
.tree-btn:hover {
  background: rgba(176,230,176,0.08);
  border-color: var(--accent);
}

/* ─── TIMELINE ─────────────────────────────────────────────────────── */

.tl-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--accent2);
  font-size: 0.85em;
  flex-shrink: 0;
}
.tl-spacer { flex: 1; }

.tl-legend {
  padding: 6px 12px;
  font-size: 0.75em;
  border-bottom: 1px solid rgba(176,230,176,0.1);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.tl-legend-swatch {
  display: inline-block;
  width: 14px;
  height: 8px;
  border-radius: 2px;
  margin: 0 2px;
  vertical-align: middle;
}

/* Scroll container — vertical and horizontal */
.tl-scroll {
  flex: 1;
  overflow: auto;
  position: relative;
  background: rgba(0,0,0,0.2);
}

/* Sticky year axis at top */
.tl-axis {
  position: sticky;
  top: 0;
  height: 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--accent2);
  z-index: 2;
  margin-left: 140px; /* leave room for row labels */
}
.tl-tick {
  position: absolute;
  top: 18px;
  width: 1px;
  height: 10px;
  background: rgba(176,230,176,0.18);
}
.tl-tick-major {
  height: 14px;
  top: 14px;
  background: rgba(176,230,176,0.4);
}
.tl-year-label {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  color: var(--dim);
  font-size: 0.72em;
  white-space: nowrap;
}

/* today vertical line — drawn over both axis and rows */
.tl-today-line {
  position: absolute;
  top: 0;
  width: 1px;
  height: 100%;
  background: rgba(255,200,100,0.5);
  pointer-events: none;
  z-index: 1;
}
.tl-today-line-rows { z-index: 0; }

/* Rows */
.tl-rows {
  position: relative;
  padding-bottom: 20px;
  margin-left: 140px;
}
.tl-row {
  display: flex;
  align-items: stretch;
  height: 32px;
  border-bottom: 1px solid rgba(176,230,176,0.05);
  cursor: pointer;
  position: relative;
}
.tl-row:hover { background: rgba(176,230,176,0.04); }
.tl-row-label {
  position: absolute;
  left: -140px;
  top: 0;
  width: 140px;
  height: 32px;
  padding: 4px 8px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  border-right: 1px solid var(--accent2);
  background: var(--bg);
  z-index: 3;
  font-size: 0.8em;
}
.tl-row-name {
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-row-dates {
  font-size: 0.78em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-row-track {
  position: relative;
  width: 100%;
  height: 32px;
}
.tl-bar {
  position: absolute;
  top: 6px;
  height: 20px;
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  align-items: center;
  padding: 0 6px;
  box-sizing: border-box;
  min-width: 4px;
}
.tl-bar-inner-label {
  color: rgba(0,0,0,0.7);
  font-size: 0.74em;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.2px;
}

/* Status colors */
.tl-bar-alive {
  background: linear-gradient(90deg, rgba(176,230,176,0.85), rgba(176,230,176,0.65));
}
.tl-bar-deceased {
  background: rgba(150,150,150,0.55);
}
.tl-bar-presumed_dead {
  background: repeating-linear-gradient(
    45deg,
    rgba(150,150,150,0.4),
    rgba(150,150,150,0.4) 4px,
    rgba(150,150,150,0.2) 4px,
    rgba(150,150,150,0.2) 8px
  );
}
.tl-bar-alive .tl-bar-inner-label,
.tl-bar-deceased .tl-bar-inner-label,
.tl-bar-presumed_dead .tl-bar-inner-label {
  color: rgba(20,30,20,0.85);
}

/* Legend swatches use the same backgrounds */
.tl-legend-swatch.tl-bar-alive,
.tl-legend-swatch.tl-bar-deceased,
.tl-legend-swatch.tl-bar-presumed_dead {
  /* already covered */
}

/* ─── PEOPLE TAB ───────────────────────────────────────────────────── */

.tree-toolbar {
  margin-bottom: 8px;
}
.tree-toolbar input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  background: transparent;
  border: 1px solid var(--accent2);
  color: var(--fg);
  padding: 6px 10px;
  font-family: var(--mono, monospace);
  font-size: 0.9em;
  border-radius: 2px;
}

.tree-people-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tree-person-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(176,230,176,0.06);
  cursor: pointer;
  border-radius: 2px;
  font-size: 0.92em;
}
.tree-person-row:hover { background: rgba(176,230,176,0.04); }
.tree-person-name { color: var(--fg); flex: 1; }
.tree-person-dates { font-size: 0.82em; }

.tree-status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ─── Mobile ───────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .tree-tabs { padding: 6px 10px; }
  .tree-tab { padding: 4px 8px; font-size: 0.82em; }
  .tl-toolbar { padding: 6px 10px; }
  .tl-legend { font-size: 0.7em; padding: 4px 10px; }
  /* On mobile, narrower label column to give more room for bars */
  .tl-axis { margin-left: 100px; }
  .tl-rows { margin-left: 100px; }
  .tl-row-label {
    left: -100px;
    width: 100px;
    font-size: 0.75em;
    padding: 4px 6px;
  }
  .tl-row { height: 30px; }
  .tl-row-track { height: 30px; }
  .tl-bar { height: 18px; top: 6px; }
}

/* ─── v10.28: person detail view ──────────────────────────────────── */

.tree-loading {
  font-style: italic;
}

.tree-person-detail {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.tree-person-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(176,230,176,0.1);
  flex-shrink: 0;
}
.tree-back-link {
  cursor: pointer;
  color: var(--dim);
  text-decoration: none;
  font-size: 0.88em;
}
.tree-back-link:hover { color: var(--accent); }
.tree-edit-chat {
  font-size: 0.78em;
  color: var(--dim);
  text-decoration: none;
}
.tree-edit-chat:hover { color: var(--accent); }

/* Head: photo + name + dates */
.tree-person-head {
  display: flex;
  gap: 14px;
  padding: 14px;
  border-bottom: 1px solid var(--accent2);
  flex-shrink: 0;
  align-items: flex-start;
}
.tree-person-photo,
.tree-person-photo-placeholder {
  width: 80px;
  height: 80px;
  border-radius: 4px;
  flex-shrink: 0;
  background: rgba(176,230,176,0.05);
  border: 1px solid var(--accent2);
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4em;
  color: var(--dim);
}
.tree-person-head-main {
  flex: 1;
  min-width: 0;
}
.tree-person-name-h {
  margin: 0 0 4px 0;
  color: var(--accent);
  font-size: 1.2em;
  word-break: break-word;
}
.tree-person-dates {
  font-size: 0.9em;
  color: var(--fg);
  margin-bottom: 2px;
}

/* Sub-tabs */
.tree-person-tabs {
  display: flex;
  gap: 3px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--accent2);
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tree-person-tab {
  cursor: pointer;
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid var(--accent2);
  color: var(--dim);
  font-size: 0.82em;
  border-radius: 2px;
  white-space: nowrap;
  flex-shrink: 0;
}
.tree-person-tab:hover { color: var(--fg); }
.tree-person-tab.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(176,230,176,0.08);
}

.tree-person-pane {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  min-height: 0;
}

/* ─── PROFILE TAB ─────────────────────────────────────────────────── */
.tree-profile-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(176,230,176,0.06);
  font-size: 0.92em;
}
.tree-profile-label {
  font-size: 0.85em;
  letter-spacing: 0.4px;
}
.tree-profile-val {
  color: var(--fg);
  word-break: break-word;
}
.tree-profile-bio {
  margin-top: 12px;
}
.tree-profile-bio-text {
  margin-top: 6px;
  padding: 10px 12px;
  background: rgba(176,230,176,0.03);
  border-left: 2px solid var(--accent2);
  font-size: 0.92em;
  line-height: 1.5;
}

.tree-link {
  color: var(--accent);
  text-decoration: none;
}
.tree-link:hover { text-decoration: underline; }

/* ─── PEDIGREE TAB ────────────────────────────────────────────────── */
.tree-pedigree {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.ped-section-h {
  font-size: 0.82em;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--accent2);
}
.ped-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.ped-card {
  width: 110px;
  padding: 8px;
  border: 1px solid var(--accent2);
  border-radius: 3px;
  background: rgba(176,230,176,0.03);
  cursor: pointer;
  text-align: center;
  font-size: 0.85em;
  transition: border-color 0.15s, background 0.15s;
}
.ped-card:hover {
  border-color: var(--accent);
  background: rgba(176,230,176,0.08);
}
.ped-card-self {
  cursor: default;
  border-color: var(--accent);
  background: rgba(176,230,176,0.1);
}
.ped-card-self:hover { background: rgba(176,230,176,0.1); }
.ped-card-photo,
.ped-card-photo-placeholder {
  width: 70px;
  height: 70px;
  margin: 0 auto 6px;
  border-radius: 50%;
  display: block;
  object-fit: cover;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--accent2);
}
.ped-card-photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8em;
  color: var(--dim);
}
.ped-card-name {
  color: var(--fg);
  margin-bottom: 2px;
  word-break: break-word;
  line-height: 1.2;
}
.ped-card-dates {
  font-size: 0.82em;
}

/* ─── LIFE TAB ────────────────────────────────────────────────────── */
.life-section-h {
  font-size: 0.82em;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 14px 0 6px 0;
  padding-bottom: 3px;
  border-bottom: 1px dashed var(--accent2);
}
.life-section-h:first-child { margin-top: 0; }

.life-timeline {
  list-style: none;
  padding: 0;
  margin: 0;
}
.life-tl-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(176,230,176,0.06);
}
.life-tl-date {
  font-size: 0.85em;
  padding-top: 2px;
}
.life-tl-title {
  color: var(--fg);
  font-weight: bold;
  margin-bottom: 4px;
}
.life-tl-detail {
  font-size: 0.92em;
  line-height: 1.5;
  color: var(--fg);
}

.life-tl-attachments,
.life-orphan-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.life-att {
  display: inline-block;
  text-decoration: none;
}
.life-att img {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 3px;
  border: 1px solid var(--accent2);
}
.life-att img:hover { border-color: var(--accent); }
.life-att-file {
  display: inline-block;
  padding: 6px 10px;
  border: 1px solid var(--accent2);
  border-radius: 2px;
  font-size: 0.85em;
  color: var(--fg);
}
.life-att-file:hover { border-color: var(--accent); }

.life-notes {
  padding: 10px 12px;
  background: rgba(176,230,176,0.03);
  border-left: 2px solid var(--accent2);
  font-size: 0.92em;
  line-height: 1.5;
}

/* ─── STORIES TAB ─────────────────────────────────────────────────── */
.tree-stories-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.tree-stories-toolbar .hint { font-size: 0.78em; }
.tree-btn.primary {
  color: var(--accent);
  border-color: var(--accent);
}

.tree-stories-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.tree-story-row {
  padding: 10px 12px;
  border: 1px solid var(--accent2);
  border-radius: 3px;
  margin-bottom: 8px;
  background: rgba(176,230,176,0.02);
}
.tree-story-prompt {
  font-style: italic;
  color: var(--accent);
  font-size: 0.88em;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--accent2);
}
.tree-story-body {
  font-size: 0.92em;
  line-height: 1.5;
  color: var(--fg);
  margin-bottom: 6px;
}
.tree-story-meta {
  font-size: 0.78em;
}

.tree-stories-unanswered {
  margin-top: 16px;
  padding: 8px 12px;
  border: 1px dashed var(--accent2);
  border-radius: 3px;
}
.tree-stories-unanswered summary {
  cursor: pointer;
  font-size: 0.85em;
}
.tree-unanswered-list {
  list-style: disc;
  padding-left: 20px;
  margin: 8px 0 0;
  font-size: 0.88em;
}
.tree-unanswered-list li { padding: 2px 0; }

/* ─── COMMENTS TAB ────────────────────────────────────────────────── */
.tree-comment-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
}
.tree-comment-row {
  padding: 8px 10px;
  border: 1px solid rgba(176,230,176,0.1);
  border-radius: 2px;
  margin-bottom: 6px;
  background: rgba(0,0,0,0.1);
}
.tree-comment-meta {
  font-size: 0.78em;
  margin-bottom: 4px;
}
.tree-comment-body {
  font-size: 0.92em;
  line-height: 1.45;
  word-break: break-word;
}
.tree-comments-add {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--accent2);
  padding-top: 12px;
}
.tree-comments-add textarea {
  width: 100%;
  box-sizing: border-box;
  background: transparent;
  border: 1px solid var(--accent2);
  color: var(--fg);
  padding: 8px;
  font-family: var(--mono, monospace);
  font-size: 0.9em;
  border-radius: 2px;
  resize: vertical;
}
.tree-comments-add textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.tree-comments-add .tree-btn {
  align-self: flex-end;
}

/* ─── Mobile tuning ───────────────────────────────────────────────── */
@media (max-width: 700px) {
  .tree-person-head { padding: 10px; gap: 10px; }
  .tree-person-photo,
  .tree-person-photo-placeholder { width: 64px; height: 64px; font-size: 1.8em; }
  .tree-person-tabs { padding: 4px 10px; gap: 2px; }
  .tree-person-tab { padding: 3px 8px; font-size: 0.76em; }
  .tree-person-pane { padding: 10px; }
  .tree-profile-row {
    grid-template-columns: 90px 1fr;
    font-size: 0.88em;
  }
  .ped-card { width: 88px; padding: 6px; font-size: 0.78em; }
  .ped-card-photo,
  .ped-card-photo-placeholder { width: 56px; height: 56px; }
  .life-tl-row { grid-template-columns: 80px 1fr; gap: 6px; }
  .life-att img { width: 80px; height: 80px; }
}
