:root {
  --bg: #f4efe8;
  --panel: #ffffff;
  --primary: #4a312a;
  --primary-soft: #e6d7cb;
  --secondary: #7a5f55;
  --text: #2b201d;
  --line: #d1c0b5;
  --alert: #7a1f1f;
  --muted: #6f5d56;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.topbar {
  padding: 16px 22px;
  background: var(--primary);
  color: #fff;
  border-bottom: 1px solid #2f1d19;
}

.topbar-main {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(360px, 560px) auto;
  align-items: center;
  gap: 16px;
}

.topbar-brand {
  min-width: 0;
}

.topbar-logo {
  display: block;
  width: auto;
  height: 44px;
  max-width: 100%;
}

.topbar h1 {
  margin: 0 0 4px;
  font-family: Literata, Georgia, serif;
  font-size: 25px;
  font-weight: 600;
}

.topbar p {
  margin: 0;
  font-size: 13px;
  color: #f0e8e4;
}

.topbar-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-width: 0;
}

.topbar-actions {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.topbar-search input,
.search-filters-menu input,
.search-filters-menu select {
  background: #fff;
  color: var(--text);
}

#personSearchInput {
  flex: 1;
  min-width: 0;
  height: 38px;
  border: 1px solid #d7c8bd;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 13px;
}

#personSearchInput::placeholder {
  color: #7e6a62;
}

#personSearchInput:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 2px rgba(230, 215, 203, 0.6);
}

.icon-btn {
  border: 1px solid #d7c8bd;
  background: #fff;
  color: var(--primary);
  border-radius: 8px;
  min-width: 38px;
  height: 38px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.icon-btn.active {
  background: var(--primary-soft);
  border-color: #cbb4a5;
}

.icon-btn:focus-visible {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 2px rgba(230, 215, 203, 0.7);
}

.search-filters-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: 280px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 10px 6px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
}

.search-filters-menu label {
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--secondary);
}

.topbar-results {
  position: absolute;
  top: 50px;
  left: 0;
  right: 0;
  z-index: 19;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  max-height: 280px;
}

.quick-nav-btn {
  flex: 0 0 auto;
}

.language-toggle-btn {
  flex: 0 0 auto;
  min-width: 52px;
  font-weight: 600;
}

.generation-quick-select {
  height: 38px;
  min-width: 108px;
  border: 1px solid #d7c8bd;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 12px;
  background: #fff;
  color: var(--text);
}

.generation-quick-select:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.quick-results {
  top: calc(100% + 8px);
  left: auto;
  right: 0;
  width: min(360px, 92vw);
}

.quick-results li:last-child {
  margin-bottom: 0;
}

.legend-popup {
  position: fixed;
  inset: 0;
  background: rgba(29, 20, 16, 0.5);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.legend-card {
  position: relative;
  width: min(740px, 100%);
  max-height: 80vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 14px;
}

.legend-card h3 {
  margin-top: 0;
  color: var(--secondary);
}

.legend-close {
  position: absolute;
  top: 10px;
  right: 10px;
}

.quick-action-card {
  width: min(460px, 100%);
}

.quick-action-form {
  display: grid;
  gap: 8px;
}

.quick-action-buttons {
  justify-content: flex-end;
}

/* Generation Modal */
.generation-modal-card {
  width: min(500px, 100%);
}

.generation-buttons-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 8px;
  padding: 12px 0;
}

.generation-buttons-container button {
  padding: 10px;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  color: var(--text);
}

.generation-buttons-container button:hover {
  border-color: var(--secondary);
  background: var(--primary);
  color: #fff;
}

.generation-buttons-container button.active {
  background: var(--secondary);
  border-color: var(--secondary);
  color: #fff;
}

.generation-btn {
  padding: 10px;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  color: var(--text);
}

.generation-btn:hover {
  border-color: var(--secondary);
  background: var(--primary);
  color: #fff;
}

.generation-btn.active {
  background: var(--secondary);
  border-color: var(--secondary);
  color: #fff;
}

/* Settings Modal */
.settings-modal-card {
  width: min(600px, 100%);
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}

.settings-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--line);
  margin: 0 -14px 14px -14px;
  padding: 0 14px;
  margin-bottom: 12px;
}

.settings-tab-btn {
  background: none;
  border: none;
  padding: 12px 16px;
  cursor: pointer;
  color: var(--secondary);
  font-weight: 500;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.settings-tab-btn:hover {
  color: var(--primary);
}

.settings-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.settings-content {
  flex: 1;
  overflow-y: auto;
  padding-right: 8px;
}

.settings-tab-content {
  display: none;
}

.settings-tab-content.active {
  display: block;
}

.settings-tab-content h4 {
  margin-top: 0;
  margin-bottom: 12px;
  color: var(--secondary);
}

.settings-option {
  margin-bottom: 12px;
}

.settings-option label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--secondary);
}

.settings-option select {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
}

.social-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.social-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  color: var(--secondary);
  transition: all 0.2s ease;
}

.social-link:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  transform: translateY(-2px);
}

.social-link i {
  font-size: 24px;
  margin-bottom: 6px;
}

.social-link span {
  font-size: 12px;
  font-weight: 500;
}

.hidden {
  display: none !important;
}

.layout {
  display: grid;
  grid-template-columns: 350px 1fr 340px;
  gap: 14px;
  padding: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}

.controls,
.details {
  max-height: calc(100vh - 110px);
  overflow-y: auto;
}

.controls h2,
.viewer h2,
.details h2 {
  margin: 0 0 10px;
  font-size: 19px;
  font-family: Literata, Georgia, serif;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.controls h3,
.details h3 {
  font-size: 14px;
  margin: 16px 0 8px;
  color: var(--secondary);
}

.required-config {
  border: 1px solid #dcc7b8;
  border-radius: 10px;
  padding: 12px;
  background: #fbf6f2;
}

.required-config h3 {
  margin-top: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.required-tip {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #6f4f44;
}

.cfg-group {
  border: 1px solid #e3d5ca;
  border-radius: 10px;
  margin-top: 10px;
  background: #fff;
}

.cfg-group > summary {
  list-style: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary);
  padding: 11px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cfg-group > summary::-webkit-details-marker {
  display: none;
}

.cfg-group > summary::after {
  content: "▾";
  font-size: 12px;
  color: var(--muted);
}

.cfg-group[open] > summary::after {
  transform: rotate(180deg);
}

.cfg-group > section {
  padding: 2px 12px 12px;
  border-top: 1px solid #eee2d9;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  font-weight: 500;
  gap: 4px;
  margin-bottom: 9px;
}

label.inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

label.disabled {
  opacity: 0.6;
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea,
select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  background: #fff;
  color: var(--text);
}

textarea {
  min-height: 84px;
  resize: vertical;
}

.field-help {
  margin: 4px 0 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

hr {
  border: 0;
  border-top: 1px solid #e6d9cf;
  margin: 10px 0;
}

.weights-editor {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.terminal-people-list {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.terminal-person-row {
  border: 1px solid #e5d7cc;
  border-radius: 8px;
  background: #fdfbf9;
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.terminal-person-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.terminal-person-remove {
  align-self: center;
  min-width: 32px;
  width: 32px;
  height: 32px;
  padding: 0;
}

.weight-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid #e5d7cc;
  border-radius: 8px;
  padding: 8px;
  background: #fdfbf9;
  font-size: 12px;
}

.weight-row input[type="range"] {
  width: 100%;
}

.weight-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.weight-name {
  color: var(--text);
  font-size: 12px;
}

.weight-rarity {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid #d9c7bb;
  color: var(--secondary);
  background: #f5ebe3;
}

.weight-rarity[data-tone="off"] {
  background: #f4f0ed;
  color: #80726b;
}

.weight-rarity[data-tone="rare"] {
  background: #efe6f8;
  color: #6c4f95;
}

.weight-rarity[data-tone="mid"] {
  background: #ecf1fa;
  color: #536b92;
}

.weight-rarity[data-tone="common"] {
  background: #e7f3ea;
  color: #476f52;
}

.weight-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.weight-row .value {
  min-width: 28px;
  text-align: left;
  color: var(--secondary);
}

.weight-row .value.percent {
  font-weight: 600;
}

.world-files-grid {
  display: grid;
  gap: 8px;
  margin: 8px 0 10px;
}

.world-file-card {
  border: 1px solid #e5d7cc;
  border-radius: 8px;
  padding: 8px;
  background: #fdfbf9;
}

.world-file-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.world-file-head strong {
  font-size: 12px;
  color: var(--text);
}

.file-chip {
  font-size: 10px;
  color: var(--muted);
  border: 1px solid #dccdc2;
  background: #f8f2ed;
  padding: 2px 6px;
  border-radius: 999px;
}

.file-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.file-actions button {
  flex: 1;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
}

.file-actions .file-reset-btn {
  flex: 0 0 34px;
  width: 34px;
  min-width: 34px;
  min-height: 32px;
  padding: 0;
  gap: 0;
}

.genetics-source-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 150px;
  font-size: 11px;
  color: var(--secondary);
}

.genetics-source-inline select {
  min-height: 32px;
  width: 100%;
  font-size: 12px;
}

.buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  padding: 8px 11px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

button.secondary {
  background: #fff;
  color: var(--primary);
}

button:hover {
  opacity: 0.9;
}

.tree {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-height: 640px;
  max-height: calc(100vh - 150px);
  overflow: auto;
}

.tree.hidden {
  display: none;
}

.viewer-help {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
}

.search-results {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 180px;
  overflow-y: auto;
}

.search-result-item {
  margin-bottom: 6px;
}

.search-result-btn {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 7px 9px;
  text-align: left;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.search-result-btn span {
  color: var(--muted);
  font-size: 11px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  padding: 14px;
}

.empty-state.hidden {
  display: none;
}

.tree-links {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.tree-nodes {
  padding: 16px 18px 26px;
  min-width: 960px;
}

.family-unit {
  border-left: 2px solid #e8dbd1;
  padding-left: 16px;
  margin-bottom: 20px;
}

.family-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.family-add-btn {
  margin-left: auto;
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  flex: 0 0 24px;
  border-radius: 50%;
  aspect-ratio: 1 / 1;
  padding: 0;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.generation-pill {
  font-size: 11px;
  color: #fff;
  background: var(--secondary);
  border-radius: 999px;
  padding: 3px 8px;
  letter-spacing: 0.04em;
}

.family-label {
  font-size: 12px;
  color: var(--muted);
}

.person-node {
  width: 262px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  min-height: 0;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.person-node.selected {
  border-color: var(--primary);
  background: #f8f0eb;
}

.person-node.related-parent,
.person-node.related-child,
.person-node.related-sibling {
  border-color: #8b7062;
}

.node-avatar {
  width: 64px;
  height: 64px;
  min-height: 64px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, #efe3d8, #d9c2b1);
  border: 1px solid #cbb3a4;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6f5d56;
  flex-shrink: 0;
}

.node-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.node-avatar .placeholder-icon {
  font-size: 18px;
  line-height: 1;
}

.node-main {
  min-width: 0;
  padding-top: 1px;
  padding-bottom: 2px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.node-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}

.node-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.favorite-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--secondary);
  padding: 0;
  border-radius: 50%;
  font-size: 11px;
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  flex: 0 0 24px;
  aspect-ratio: 1 / 1;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.favorite-btn.active {
  color: #7b5a3d;
  border-color: #cbb3a4;
  background: #f3ece5;
}

.generation-focus-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}

.generation-person-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 10px;
}

.generation-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.generation-chip {
  font-size: 11px;
  color: #fff;
  background: var(--secondary);
  border-radius: 999px;
  padding: 3px 8px;
  letter-spacing: 0.03em;
}

.generation-relations {
  display: grid;
  gap: 8px;
}

.generation-relation-block {
  border-top: 1px solid #ecdfd5;
  padding-top: 8px;
}

.generation-relation-title {
  margin: 0 0 6px;
  font-size: 11px;
  color: var(--muted);
}

.generation-relation-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.generation-relation-row .person-node {
  width: 100%;
}

.couple-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.couple-link {
  min-width: 36px;
  text-align: center;
  color: var(--secondary);
  font-size: 12px;
}

.children-wrap {
  margin-top: 10px;
  border-top: 1px solid #e4d6cc;
  padding-top: 10px;
}

.lover-wrap {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #e0d1c6;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lover-row .couple-link {
  min-width: 96px;
  text-align: left;
}

.children-title {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
}

.children-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.child-cell {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.descendants-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.descendant-branch {
  border: 1px solid #e2d3c8;
  border-radius: 8px;
  padding: 8px;
  background: #fcfaf8;
}

.descendant-title {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--secondary);
  font-weight: 600;
}

.descendants {
  margin-top: 8px;
  padding-left: 12px;
  border-left: 1px dashed #dac8bc;
}

.node-symbols {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 0;
  margin-bottom: 3px;
}

.symbol-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #f5ece5;
  color: var(--secondary);
  font-size: 10px;
}

.symbol-icon.principal {
  background: #ead8ca;
  color: #5f3d2f;
}

.symbol-icon.bastardo {
  background: #f2e1e1;
  color: var(--alert);
}

.symbol-icon.amante {
  background: #efe5dc;
  color: #8a5f4b;
}

.node-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-years {
  margin-top: 5px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  line-height: 1.25;
}

.ordinal-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid #cbb3a4;
  background: #f3ece5;
  color: #6a4e43;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.expand-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--secondary);
  padding: 0;
  border-radius: 50%;
  font-size: 11px;
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  flex: 0 0 24px;
  aspect-ratio: 1 / 1;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.expand-btn.hidden {
  display: none;
}

.person-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  font-size: 12px;
  line-height: 1.55;
}

.person-details.empty {
  color: var(--muted);
}

.person-details .title {
  margin: 0 0 7px;
  font-size: 14px;
  font-weight: 600;
}

.person-details .line {
  margin: 0 0 4px;
}

.detail-item-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.detail-flute {
  font-size: 16px;
  line-height: 1;
}

.details-subgroup {
  border: 1px solid #e7d9cf;
  border-radius: 6px;
  margin-top: 8px;
  background: #fff;
}

.details-subgroup > summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--secondary);
  padding: 7px 9px;
}

.details-subgroup > p.line {
  padding: 0 9px 8px;
}

.death-log {
  margin: 0;
  padding-left: 0;
  list-style: none;
  font-size: 12px;
  max-height: 260px;
  overflow-y: auto;
}

.death-log li {
  margin-bottom: 7px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.death-year {
  font-weight: 600;
}

.mini-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 18px;
  padding: 2px 5px;
  border-radius: 999px;
  background: #f6eee7;
  color: var(--secondary);
  font-size: 10px;
  line-height: 1;
}

.mini-badge.noble {
  background: #ead9cc;
  color: #5f3d2f;
}

.mini-badge.common {
  background: #f3ece5;
}

.mini-badge.bastard {
  background: #f2e1e1;
  color: var(--alert);
}

.mini-badge.incest {
  background: #e8e0f3;
  color: #6b4f93;
}

.mini-badge.path-military { color: #4f5d75; }
.mini-badge.path-religious { color: #7a5f55; }
.mini-badge.path-democratic { color: #5f6f52; }
.mini-badge.path-common { color: #6f5d56; }
.mini-badge.path-noble { color: #7b5a3d; }

.icon-inline {
  color: var(--secondary);
  width: 14px;
  text-align: center;
}

.gender-male {
  color: #5d4037;
}

.gender-female {
  color: #7d4f5f;
}

.death-icon {
  color: var(--alert);
}

.bastard-icon {
  color: #8b5c4a;
}

.death-cause {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

@media (max-width: 1300px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .topbar-main {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .topbar-search {
    max-width: 100%;
    min-width: 0;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .topbar-results {
    right: 0;
  }

  .search-filters-menu {
    right: 0;
  }

  .terminal-person-fields {
    grid-template-columns: 1fr;
  }

  .controls,
  .details,
  .viewer {
    max-height: unset;
  }
}
