.tm-page {
  min-height: 100vh;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tm-wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 1.2rem;
}

.tm-hero {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  margin-top: -0.35rem;
  margin-bottom: 1.45rem;
}

.tm-hero h1 {
  margin: 0;
  font-size: clamp(1.55rem, 3.5vw, 2.2rem);
}

.tm-hero p {
  margin: 0.45rem 0 0;
}

.tm-controls {
  display: grid;
  grid-template-columns: minmax(320px, 2fr) minmax(190px, 1fr) minmax(190px, 1fr);
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.tm-controls input,
.tm-controls select {
  width: 100%;
  box-sizing: border-box;
  border-radius: 8px;
  border: 1px solid rgba(128, 83, 39, 0.28);
  background: #fffdf8;
  padding: 0.58rem 0.65rem;
}

.tm-controls #tm-search {
  border-radius: 10px;
  padding: 0.74rem 0.86rem;
  border-color: rgba(128, 83, 39, 0.26);
  box-shadow: none;
  font-size: 1rem;
}

.tm-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.tm-stat {
  background: rgba(255, 251, 236, 0.7);
  border: 1px solid rgba(128, 83, 39, 0.2);
  padding: 0.85rem;
  text-align: center;
}

.tm-stat strong {
  display: block;
  font-size: 1.55rem;
  line-height: 1;
}

.tm-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.tm-panel {
  background: rgba(255, 251, 236, 0.7);
  border: 1px solid rgba(128, 83, 39, 0.2);
}

.tm-people-panel {
  display: none;
  padding: 0.9rem;
}

.tm-people-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.75rem;
}

.tm-people-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.tm-people-head p {
  margin: 0.22rem 0 0;
  font-size: 0.9rem;
  color: rgba(62, 38, 17, 0.82);
}

.tm-people-cap {
  border: 1px solid rgba(128, 83, 39, 0.24);
  border-radius: 999px;
  padding: 0.28rem 0.62rem;
  font-size: 0.78rem;
  background: rgba(255, 252, 242, 0.82);
  color: #7f3f1f;
}

.tm-people-wrap {
  display: grid;
  gap: 0.55rem;
  max-height: calc((4.9rem * 5) + (0.55rem * 4));
  overflow: auto;
  padding-right: 0.15rem;
}

.tm-person-card {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.8rem;
  align-items: start;
  padding: 0.85rem 0.9rem;
  border: 1px solid rgba(128, 83, 39, 0.15);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 252, 0.95), rgba(248, 238, 214, 0.84));
  text-align: left;
  cursor: pointer;
}

.tm-person-card:hover,
.tm-person-card:focus-visible {
  border-color: rgba(128, 83, 39, 0.3);
  transform: translateY(-1px);
}

.tm-person-card.active {
  border-color: rgba(151, 97, 46, 0.45);
  box-shadow: 0 12px 24px rgba(113, 75, 34, 0.11);
  background: linear-gradient(180deg, rgba(255, 249, 234, 0.98), rgba(237, 215, 170, 0.82));
}

.tm-person-main {
  min-width: 0;
}

.tm-person-main strong {
  display: block;
  font-size: 1rem;
  color: #4f2d10;
}

.tm-person-meta {
  display: block;
  margin-top: 0.28rem;
  font-size: 0.82rem;
  color: rgba(62, 38, 17, 0.78);
  line-height: 1.45;
}

.tm-person-generation {
  border-radius: 999px;
  border: 1px solid rgba(128, 83, 39, 0.2);
  padding: 0.28rem 0.58rem;
  font-size: 0.78rem;
  background: rgba(255, 253, 246, 0.95);
  color: #7f3f1f;
  white-space: nowrap;
}

.tm-empty {
  padding: 1rem;
  border-radius: 12px;
  background: rgba(255, 252, 244, 0.76);
  border: 1px dashed rgba(128, 83, 39, 0.24);
}

.tm-detail {
  padding: 0.9rem;
}

.tm-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(340px, 1.08fr);
  gap: 1rem;
  align-items: start;
}

.tm-detail-main,
.tm-detail-tree {
  min-width: 0;
}

.tm-detail-main {
  padding-right: 0.95rem;
  border-right: 1px solid rgba(128, 83, 39, 0.18);
}

.tm-detail-tree {
  padding-left: 0.15rem;
}

.tm-detail-tree .tm-tree {
  margin-top: 0;
  height: 100%;
  padding: 0.8rem;
  background: linear-gradient(180deg, rgba(255, 254, 249, 0.96), rgba(245, 235, 210, 0.78));
}

.tm-detail-head {
  display: grid;
  grid-template-columns: 124px 1fr;
  gap: 0.8rem;
  align-items: start;
}

.tm-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
}

.tm-title-row h2 {
  margin: 0;
}

.tm-title-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 0 0 auto;
}

.tm-propose-edit,
.tm-add-child-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  border: 1px solid rgba(128, 83, 39, 0.26);
  background: linear-gradient(180deg, rgba(255, 253, 247, 0.98), rgba(244, 229, 195, 0.92));
  color: #7f3f1f;
  font-size: 1rem;
  text-decoration: none;
  box-shadow: 0 8px 18px rgba(92, 61, 26, 0.08);
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.tm-propose-edit:hover,
.tm-propose-edit:focus-visible,
.tm-add-child-trigger:hover,
.tm-add-child-trigger:focus-visible {
  color: #9d4f2a;
  border-color: rgba(128, 83, 39, 0.38);
  transform: translateY(-1px);
}

.tm-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(38, 24, 10, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}

.tm-modal-backdrop[hidden] {
  display: none;
}

.tm-modal {
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  background: #fffdf8;
  border-radius: 14px;
  border: 1px solid rgba(128, 83, 39, 0.25);
  box-shadow: 0 24px 48px rgba(40, 24, 8, 0.28);
  padding: 1.1rem 1.2rem 1.3rem;
}

.tm-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.35rem;
}

.tm-modal-head h2 {
  margin: 0;
}

.tm-modal-close {
  flex: 0 0 auto;
  width: 2.1rem;
  height: 2.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(128, 83, 39, 0.26);
  background: rgba(255, 252, 244, 0.9);
  color: #7f3f1f;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.tm-modal-close:hover,
.tm-modal-close:focus-visible {
  color: #9d4f2a;
  border-color: rgba(128, 83, 39, 0.4);
}

.tm-modal-sub {
  margin: 0 0 0.9rem;
  font-size: 0.88rem;
  color: rgba(62, 38, 17, 0.82);
}

.tm-footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  position: relative;
}

.tm-admin-lock {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 1.9rem;
  height: 1.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(128, 83, 39, 0.24);
  background: rgba(255, 252, 244, 0.5);
  color: rgba(127, 63, 31, 0.75);
  font-size: 0.9rem;
  cursor: pointer;
  opacity: 0.7;
}

.tm-admin-lock:hover,
.tm-admin-lock:focus-visible {
  transform: translateY(-50%);
}

.tm-admin-lock:focus-visible {
  opacity: 1;
  border-color: rgba(128, 83, 39, 0.4);
}

.tm-admin-login[hidden] {
  display: none;
}

.tm-admin-login {
  display: grid;
  gap: 0.7rem;
  max-width: 320px;
}

.tm-admin-pending-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.7rem;
}

.tm-admin-pending-head h3 {
  margin: 0;
}

.tm-admin-pending-list {
  display: grid;
  gap: 0.7rem;
}

.tm-pending-card {
  border: 1px solid rgba(128, 83, 39, 0.2);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  background: rgba(255, 252, 244, 0.75);
}

.tm-pending-card header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}

.tm-pending-date {
  font-size: 0.78rem;
  color: rgba(62, 38, 17, 0.7);
  white-space: nowrap;
}

.tm-pending-changes {
  margin: 0 0 0.45rem;
  padding-left: 1.1rem;
  font-size: 0.88rem;
}

.tm-pending-changes li {
  margin-bottom: 0.15rem;
}

.tm-pending-meta {
  margin: 0 0 0.6rem;
  font-size: 0.82rem;
  color: rgba(62, 38, 17, 0.78);
}

.tm-photo,
.tm-photo-fallback {
  width: 124px;
  height: 124px;
  border-radius: 10px;
  border: 1px solid rgba(128, 83, 39, 0.22);
  object-fit: cover;
  background: #f5ebd0;
}

.tm-photo-fallback {
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #70431d;
}

.tm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.4rem 0;
}

.tm-chip {
  border: 1px solid rgba(128, 83, 39, 0.3);
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  font-size: 0.8rem;
  background: rgba(255, 252, 242, 0.85);
}

.tm-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.tm-card {
  border: 1px solid rgba(128, 83, 39, 0.2);
  padding: 0.6rem;
  background: rgba(255, 252, 244, 0.72);
}

.tm-card h3 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
}

.tm-description-text {
  margin: 1.5rem 0 0;
  padding-top: 1.2rem;
  border-top: 1px solid rgba(128, 83, 39, 0.3);
  font-size: 0.94rem;
  line-height: 1.55;
  color: rgba(62, 38, 17, 0.88);
  white-space: pre-line;
}

.tm-tree {
  margin-top: 0.8rem;
  border: 1px solid rgba(128, 83, 39, 0.2);
  background: rgba(255, 252, 244, 0.72);
  padding: 0.6rem;
}

.tm-tree h3 {
  margin: 0 0 0.55rem;
}

.tm-tree-list {
  display: grid;
  gap: 0.5rem;
}

.tm-tree-node {
  position: relative;
  border-left: 3px solid rgba(128, 83, 39, 0.35);
  padding: 0.5rem 0.65rem 0.5rem 0.85rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(248, 235, 205, 0.68));
}

.tm-tree-node::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 0.95rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9d6331;
  border: 2px solid #f7ecd2;
}

.tm-tree-node-center {
  border-left-color: rgba(95, 128, 39, 0.42);
  background: linear-gradient(180deg, rgba(251, 255, 243, 0.92), rgba(233, 243, 207, 0.75));
}

.tm-tree-node-center::before {
  background: #6d8a2d;
}

.tm-tree-node-descendant {
  border-left-color: rgba(62, 116, 85, 0.34);
  background: linear-gradient(180deg, rgba(245, 255, 252, 0.94), rgba(220, 240, 231, 0.76));
}

.tm-tree-node-descendant::before {
  background: #3b7d58;
}

.tm-tree-node strong {
  display: inline-block;
  min-width: 7.2rem;
}

.tm-tree-meta {
  font-size: 0.84rem;
  color: rgba(62, 38, 17, 0.9);
  margin-top: 0.18rem;
}

.tm-person-link {
  border: none;
  background: transparent;
  color: #7f3f1f;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  margin: 0;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
}

.tm-person-link:hover,
.tm-person-link:focus-visible {
  color: #a14d27;
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  outline: none;
}

.tm-list {
  margin: 0;
  padding-left: 1rem;
}

.tm-list li { margin-bottom: 0.2rem; }

.tm-add-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}

.tm-field {
  display: grid;
  gap: 0.35rem;
  padding: 0.7rem;
  border: 1px solid rgba(128, 83, 39, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 252, 0.72);
}

.tm-field span {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(96, 59, 26, 0.92);
}

.tm-field input[readonly] {
  background: rgba(246, 240, 223, 0.92);
  color: rgba(78, 49, 22, 0.8);
}

.tm-field-inline {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
}

.tm-field-inline input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  flex: 0 0 auto;
}

.tm-field-inline span {
  text-transform: none;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0;
}

.tm-add-grid input,
.tm-add-grid select,
.tm-add-grid textarea {
  width: 100%;
  box-sizing: border-box;
  border-radius: 8px;
  border: 1px solid rgba(128, 83, 39, 0.28);
  background: #fffdf8;
  padding: 0.62rem 0.7rem;
}

.tm-add-grid .full {
  grid-column: 1 / -1;
}

.tm-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.15rem;
  flex-wrap: wrap;
}

.tm-add-note {
  margin: 0;
  padding: 0.7rem 0.8rem;
  border-left: 3px solid rgba(128, 83, 39, 0.28);
  background: rgba(255, 252, 244, 0.84);
  font-size: 0.9rem;
  color: rgba(62, 38, 17, 0.84);
}

.tm-post-block {
  margin-top: 0.4rem;
}

.tm-post-meta {
  margin-top: 0.45rem;
  padding: 0.5rem 0.65rem;
  border-left: 3px solid rgba(128, 83, 39, 0.3);
  background: rgba(255, 252, 244, 0.72);
}

.tm-post-meta p {
  margin: 0.18rem 0;
}

@media (max-width: 1100px) {
  .tm-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tm-controls #tm-search {
    grid-column: 1 / -1;
  }

  .tm-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tm-layout {
    grid-template-columns: 1fr;
  }

  .tm-table-wrap {
    max-height: 48vh;
  }
}

@media (max-width: 700px) {
  .tm-controls {
    grid-template-columns: 1fr 1fr;
  }

  .tm-controls #tm-search {
    grid-column: 1 / -1;
  }

  .tm-detail-head {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .tm-detail-layout {
    grid-template-columns: 1fr;
  }

  .tm-detail-main {
    padding-right: 0;
    border-right: none;
  }

  .tm-detail-tree {
    padding-left: 0;
  }

  .tm-title-row {
    width: 100%;
    align-items: center;
  }

  .tm-cols {
    grid-template-columns: 1fr;
  }

  .tm-add-grid {
    grid-template-columns: 1fr;
  }
}
