:root {
  --bg: #f5efe2;
  --bg-soft: #fbf8f2;
  --surface: #fffdfa;
  --text: #1f312c;
  --muted: #64746f;
  --line: #ddd4c6;
  --primary: #0f7c6d;
  --primary-strong: #095f54;
  --accent: #c7743f;
  --danger: #b34b3f;
  --shadow: 0 16px 40px rgba(27, 39, 35, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Be Vietnam Pro", sans-serif;
  background: var(--bg);
  color: var(--text);
}

body.modal-open {
  overflow: hidden;
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1100px 600px at -10% -10%, rgba(15, 124, 109, 0.14), transparent 60%),
    radial-gradient(900px 500px at 120% 0%, rgba(199, 116, 63, 0.12), transparent 60%),
    linear-gradient(180deg, #f7f1e6 0%, #f4eedf 100%);
}

.app {
  /* width: min(1380px, 96vw); */
  margin: 20px 20px 30px;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: "Noto Serif Display", serif;
}

h2 {
  font-size: clamp(1rem, 1.7vw, 1.2rem);
}

.hero {
  position: relative;
  display: flex;
  justify-content: flex-start;
  gap: 16px;
  align-items: flex-start;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: linear-gradient(140deg, #fff6e8 0%, #eef7f1 65%);
  padding: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  right: -100px;
  top: -130px;
  background: rgba(15, 124, 109, 0.12);
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--primary-strong);
  font-weight: 700;
}

h1 {
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  letter-spacing: 0.02em;
}

.hero-text {
  margin: 8px 0 0;
  max-width: min(920px, 100%);
  color: var(--muted);
  line-height: 1.6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.public-genealogy-title {
  margin: 11px 0 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: min(100%, 620px);
  border: 2px solid rgba(15, 124, 109, 0.42);
  border-radius: 14px;
  background: linear-gradient(145deg, #e5f8f1 0%, #d2efe6 100%);
  color: #063f37;
  font-size: clamp(1.08rem, 1.8vw, 1.36rem);
  font-weight: 900;
  line-height: 1.35;
  padding: 10px 14px;
  box-shadow: 0 14px 28px rgba(15, 124, 109, 0.2);
  letter-spacing: 0.01em;
  word-break: break-word;
}

.public-genealogy-title::before {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid rgba(6, 63, 55, 0.28);
  background-color: #dff2ea;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23063f37' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 1 0-7l1.5-1.5a5 5 0 0 1 7 7L17 13'/%3E%3Cpath d='M14 11a5 5 0 0 1 0 7L12.5 19.5a5 5 0 0 1-7-7L7 11'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px 12px;
  flex: 0 0 auto;
}

.hero-intro {
  position: relative;
  z-index: 1;
  min-width: 0;
  flex: 1;
  max-width: min(680px, 100%);
}

.hero-corner-controls {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hero-language-corner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #d4dbc8;
  border-radius: 999px;
  background: rgba(255, 252, 245, 0.94);
  padding: 4px 7px;
}

.hero-language-icon {
  width: 14px;
  height: 14px;
  stroke: #5f706a;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hero-language-corner select {
  border: 1px solid #d8dece;
  border-radius: 999px;
  padding: 4px 8px;
  background: #ffffff;
  color: var(--text);
  font-family: inherit;
  font-size: 0.74rem;
  min-width: 104px;
}

.hero-language-corner select:focus {
  outline: 2px solid rgba(15, 124, 109, 0.28);
  border-color: rgba(15, 124, 109, 0.36);
}

.hero-actions {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: auto;
  max-width: min(680px, 100%);
  margin-top: 18px;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.hero-actions > * {
  flex: 0 0 auto;
}

.hero-actions .genealogy-switcher {
  width: min(600px, 100%);
  min-width: 460px;
}

.hero-quick-actions {
  display: flex;
  align-items: stretch;
  flex-wrap: nowrap;
  gap: 4px;
  width: auto;
  border: 1px solid #e4dccd;
  border-radius: 12px;
  background: rgba(255, 250, 241, 0.92);
  padding: 4px;
}

.genealogy-switcher .hero-quick-actions {
  width: 100%;
  min-width: 0;
  margin-top: 2px;
}

.hero-quick-actions .import-mode,
.hero-quick-actions .button {
  width: auto;
  min-width: fit-content;
  flex: 0 0 auto;
}

.genealogy-switcher .hero-quick-actions .import-mode.import-mode-compact {
  flex: 1 1 auto;
}

.hero-quick-actions .import-mode.import-mode-compact {
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  padding: 4px 6px;
  border-radius: 8px;
  min-height: 30px;
  margin: 0;
  border-color: #e2dacb;
  background: #fffdf8;
}

.compact-mode-icon {
  width: 14px;
  height: 14px;
  stroke: #5f706a;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.hero-quick-actions .import-mode.import-mode-compact select {
  width: 112px;
  padding: 4px 6px;
  border-radius: 8px;
  font-size: 0.72rem;
  max-width: none;
}

.hero-quick-actions .compact-data-action {
  min-height: 30px;
  border-radius: 8px;
  width: auto;
  min-width: fit-content;
  padding: 5px 8px;
  font-size: 0.73rem;
  gap: 4px;
  box-shadow: none;
}

.hero-quick-actions .compact-data-action .compact-action-text {
  display: inline;
}

.hero-quick-actions .compact-data-action#btnExport {
  border: 1px solid var(--line);
  background: #f6efe2;
  color: var(--text);
}

.hero-quick-actions .compact-data-action#btnExport:hover {
  transform: none;
  box-shadow: none;
  background: #efe6d5;
}

.compact-action-icon {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.top-menu-tabs {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffaf1;
  box-shadow: 0 8px 22px rgba(30, 43, 38, 0.08);
}

.top-tab-btn {
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 7px 12px;
  cursor: pointer;
  text-decoration: none;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.top-tab-btn:hover {
  background: #f2f7f3;
  color: var(--text);
}

.top-tab-btn.active {
  border-color: #cbe2dc;
  background: #ecf8f4;
  color: var(--primary-strong);
}

.top-tab-btn:focus-visible {
  outline: 2px solid rgba(15, 124, 109, 0.3);
  outline-offset: 1px;
}

.auth-box {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7fbf9;
  padding: 8px 10px;
  min-width: 280px;
}

.auth-box.auth-box-compact {
  display: block;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 0;
}

.auth-menu-trigger {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid #d4dbc8;
  background: rgba(255, 252, 245, 0.94);
  color: #5f706a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.auth-menu-trigger:hover {
  background: #f4efe4;
}

.auth-menu-trigger:active {
  transform: translateY(1px);
}

.auth-menu-trigger:focus-visible {
  outline: 2px solid rgba(15, 124, 109, 0.3);
  outline-offset: 1px;
}

.auth-menu-icon {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.auth-box.auth-box-compact.open .auth-menu-trigger {
  border-color: #b9d3cb;
  background: #ecf8f4;
  color: var(--primary-strong);
}

.auth-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 260px;
  max-width: min(86vw, 340px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7fbf9;
  box-shadow: 0 14px 28px rgba(25, 36, 32, 0.16);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-dropdown-menu .auth-status {
  max-width: 100%;
  min-height: 0;
}

.auth-dropdown-menu .auth-actions {
  width: 100%;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.auth-dropdown-menu .auth-actions .button {
  flex: 1 1 112px;
}

.auth-status {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  max-width: 240px;
  min-height: 2.2em;
  line-height: 1.35;
}

.auth-status.privileged {
  color: var(--primary-strong);
  font-weight: 700;
}

.auth-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.genealogy-switcher {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f9fbff;
  padding: 8px 10px;
  min-width: 320px;
}

.genealogy-switcher[hidden] {
  display: none;
}

.genealogy-switcher-select {
  margin: 0;
}

.genealogy-switcher-select select {
  min-width: 0;
}

.genealogy-switcher-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.genealogy-switcher-actions .button {
  flex: 1 1 132px;
}

.genealogy-link-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "label input button";
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.genealogy-link-head {
  grid-area: label;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.genealogy-link-label {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.genealogy-link-mode-select {
  min-width: 94px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  font-family: inherit;
  font-size: 0.72rem;
  color: var(--text);
  padding: 0 8px;
}

.genealogy-link-mode-select:focus {
  outline: 2px solid rgba(15, 124, 109, 0.28);
  border-color: rgba(15, 124, 109, 0.36);
}

.genealogy-link-input {
  grid-area: input;
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 9px;
  font-family: inherit;
  font-size: 0.76rem;
  color: var(--text);
  background: #ffffff;
}

.genealogy-link-input:focus {
  outline: 2px solid rgba(15, 124, 109, 0.28);
  border-color: rgba(15, 124, 109, 0.36);
}

.genealogy-link-actions {
  grid-area: button;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.copy-link-icon-button {
  grid-area: button;
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  border-radius: 10px;
}

.facebook-story-button {
  border-color: #cfdbef;
  background: linear-gradient(180deg, #eff5ff 0%, #e8f0ff 100%);
  color: #1a4ea0;
}

.facebook-story-button:hover {
  border-color: #b7c8e8;
  background: linear-gradient(180deg, #e7f0ff 0%, #dce8ff 100%);
}

.copy-link-icon {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.facebook-story-icon {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.genealogy-passphrase-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "label input actions";
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.genealogy-passphrase-actions {
  grid-area: actions;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.passphrase-toggle-button {
  min-width: 58px;
  height: 34px;
  border-radius: 10px;
  padding: 0 10px;
  font-size: 0.74rem;
}

.genealogy-passphrase-input.has-passphrase {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  letter-spacing: 0.01em;
}

.genealogy-passphrase-input.is-unavailable {
  color: var(--muted);
}

.genealogy-meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.35;
}

.genealogy-meta.empty {
  display: block;
}

.genealogy-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid #e2dbce;
  border-radius: 999px;
  background: #fffaf1;
  padding: 3px 8px;
}

.genealogy-meta-key {
  color: #7a857f;
}

.genealogy-meta-value {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #2e3f39;
  font-weight: 700;
}

.genealogy-meta-item.security {
  border-color: #cce3db;
  background: #edf8f4;
}

.genealogy-share-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.genealogy-share-section[hidden] {
  display: none;
}

.genealogy-share-card {
  width: min(960px, 96vw);
  max-height: min(88vh, 760px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.genealogy-share-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.genealogy-share-topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.genealogy-share-topbar h3 {
  margin: 0;
  font-size: 0.92rem;
  color: #2a3b35;
}

.genealogy-share-hint {
  margin: 0;
  font-size: 0.74rem;
}

.genealogy-share-form-grid {
  display: grid;
  grid-template-columns: 1.35fr 0.9fr auto;
  gap: 6px;
  align-items: end;
}

.genealogy-share-form-actions {
  display: flex;
  justify-content: flex-end;
}

.genealogy-share-table-wrap {
  border: 1px solid #e1e9f0;
  border-radius: 8px;
  background: #ffffff;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 180px;
}

.genealogy-share-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 500px;
}

.genealogy-share-table th,
.genealogy-share-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #edf1f4;
  font-size: 0.75rem;
  text-align: left;
  color: #304039;
}

.genealogy-share-table th {
  font-size: 0.72rem;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: #74847e;
  background: #fbfdff;
}

.genealogy-share-table td code {
  font-size: 0.7rem;
}

.genealogy-share-row-actions {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.genealogy-share-empty {
  margin: 8px;
  font-size: 0.74rem;
}

.genealogy-story-modal {
  z-index: 35;
}

.genealogy-story-card {
  width: min(1040px, 96vw);
  max-height: min(90vh, 820px);
  border-color: #d9e2e7;
  background:
    radial-gradient(800px 400px at 0% -15%, rgba(30, 122, 172, 0.08), transparent 60%),
    radial-gradient(560px 360px at 112% 0%, rgba(27, 134, 112, 0.08), transparent 64%),
    #fffdf9;
  gap: 12px;
}

.genealogy-story-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.genealogy-story-topbar h3 {
  margin: 0;
  font-size: 0.96rem;
  color: #203b37;
}

.genealogy-story-hint {
  margin: 0;
  font-size: 0.78rem;
}

.genealogy-story-content {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.genealogy-story-preview-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  min-height: 340px;
  border-radius: 16px;
  border: 1px solid #cfdbe6;
  background:
    radial-gradient(120% 90% at 0% 0%, rgba(67, 126, 198, 0.26), transparent 65%),
    radial-gradient(90% 80% at 100% 100%, rgba(54, 148, 118, 0.28), transparent 64%),
    linear-gradient(165deg, #123048 0%, #1f475f 40%, #1e5d53 100%);
  overflow: hidden;
  box-shadow: 0 16px 26px rgba(22, 42, 51, 0.24);
}

.genealogy-story-preview-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.genealogy-story-preview-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(246, 251, 255, 0.92);
  font-size: 0.86rem;
  font-weight: 700;
  text-align: center;
  padding: 18px;
}

.genealogy-story-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.genealogy-story-controls .field {
  margin: 0;
}

.genealogy-story-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.genealogy-story-actions #btnShareGenealogyStoryNow {
  grid-column: span 2;
}

.genealogy-story-actions .button {
  width: 100%;
}

.activity-panel .panel-title-row {
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.activity-panel-actions {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.activity-count {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid #d8e4de;
  background: #f5faf7;
  color: #2f6558;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.activity-intro {
  margin: 0 0 10px;
  font-size: 0.8rem;
}

.activity-table-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #fffdfa 0%, #fffaf0 100%);
  overflow: auto;
  max-height: 430px;
}

.activity-table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
  table-layout: fixed;
}

.activity-table th:nth-child(1) {
  width: 170px;
}

.activity-table th:nth-child(2) {
  width: 240px;
}

.activity-table th:nth-child(3) {
  width: 160px;
}

.activity-table th,
.activity-table td {
  padding: 10px 11px;
  border-bottom: 1px solid #ece4d6;
  text-align: left;
  font-size: 0.8rem;
  color: #2f3f38;
  vertical-align: top;
}

.activity-table th {
  font-size: 0.76rem;
  color: #6c7f76;
  background: #fff8ee;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  position: sticky;
  top: 0;
  z-index: 1;
}

.activity-row {
  transition: background-color 160ms ease;
}

.activity-row:hover {
  background: rgba(241, 248, 244, 0.72);
}

.activity-time {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: #4f5f58;
}

.activity-actor {
  min-width: 0;
}

.activity-actor-main {
  font-weight: 600;
  color: #20352f;
  word-break: break-word;
}

.activity-actor-sub {
  margin-top: 3px;
  font-size: 0.73rem;
  color: #688178;
  word-break: break-word;
}

.activity-action {
  white-space: nowrap;
}

.activity-action-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid #d8e4de;
  background: #f3f8f6;
  color: #2f6558;
}

.activity-action-chip.is-member {
  border-color: #d7e5de;
  background: #eef8f4;
  color: #1a6a5a;
}

.activity-action-chip.is-import {
  border-color: #ebdfc8;
  background: #fff5e3;
  color: #8a5d1d;
}

.activity-action-chip.is-share {
  border-color: #dfd7ee;
  background: #f3eefb;
  color: #5f4b90;
}

.activity-action-chip.is-create {
  border-color: #d3ebd9;
  background: #e8f7eb;
  color: #317245;
}

.activity-action-chip.is-generic {
  border-color: #dfe6e2;
  background: #f5f8f7;
  color: #4f635c;
}

.activity-detail {
  color: #43564f;
  line-height: 1.45;
  word-break: break-word;
}

.activity-detail.is-empty {
  color: #8b998f;
}

.activity-state-cell {
  text-align: center;
  color: #667a72;
  font-weight: 600;
}

.genealogy-meta-security-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  font-size: 0.64rem;
  line-height: 1;
  background: #dff1ea;
  color: #0e6a5c;
}

.genealogy-meta-security-icon.is-plain {
  background: #f1ece1;
  color: #776448;
}

.user-profile-modal {
  position: fixed;
  inset: 0;
  z-index: 32;
  display: grid;
  place-items: center;
  padding: 18px;
}

.user-profile-modal[hidden] {
  display: none;
}

.user-profile-overlay {
  position: absolute;
  inset: 0;
  background: rgba(27, 39, 35, 0.42);
  backdrop-filter: blur(2px);
}

.user-profile-card {
  position: relative;
  z-index: 1;
  width: min(840px, 94vw);
  max-height: min(88vh, 720px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fffdfa;
  box-shadow: 0 24px 44px rgba(27, 39, 35, 0.24);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.image-preview-modal {
  z-index: 36;
}

.image-preview-card {
  position: relative;
  z-index: 1;
  width: min(980px, 96vw);
  max-height: min(92vh, 860px);
  border-radius: 14px;
  border: 1px solid #2a3230;
  background: #111717;
  box-shadow: 0 28px 52px rgba(10, 16, 15, 0.48);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.image-preview-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #24302d;
  background: linear-gradient(180deg, #1a2322 0%, #121919 100%);
}

.image-preview-topbar h3 {
  margin: 0;
  color: #f0f5f3;
  font-family: "Be Vietnam Pro", sans-serif;
  font-size: 0.9rem;
  line-height: 1.3;
}

.button.image-preview-close {
  border-color: #3d4f4b;
  color: #eff5f2;
}

.button.image-preview-close:hover {
  border-color: #68867f;
}

.image-preview-body {
  padding: 12px;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top, rgba(57, 70, 67, 0.2) 0%, rgba(16, 22, 21, 0.1) 54%, rgba(11, 15, 14, 0) 100%);
}

.image-preview-body img {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 110px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  background: #0e1413;
}

.user-profile-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.user-profile-topbar h3 {
  font-family: "Be Vietnam Pro", sans-serif;
  font-size: 0.94rem;
}

.user-profile-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.user-profile-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-profile-head img {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid #d7e5e1;
  background: #f2f8f5;
}

.user-profile-head-meta {
  min-width: 0;
}

.user-profile-head-meta strong {
  display: block;
  font-size: 0.88rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-profile-head-meta small {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}

.user-profile-meta {
  border: 1px solid #ece5d7;
  border-radius: 10px;
  background: #faf7ef;
  padding: 9px;
}

.user-profile-meta p {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-profile-meta p + p {
  margin-top: 6px;
}

.user-profile-meta span {
  font-size: 0.72rem;
  color: var(--muted);
}

.user-profile-meta strong {
  font-size: 0.82rem;
  color: var(--text);
  word-break: break-word;
}

.user-profile-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(255, 253, 250, 0) 0%, rgba(255, 253, 250, 0.95) 34%, #fffdfa 100%);
  padding-top: 6px;
}

.user-profile-actions .button {
  min-width: 108px;
}

.permission-manager {
  border: 1px solid #e6dece;
  border-radius: 12px;
  background: #fffaf1;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.permission-manager-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.permission-manager-topbar h4 {
  margin: 0;
  font-family: "Be Vietnam Pro", sans-serif;
  font-size: 0.86rem;
}

.permission-grant-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.permission-grant-grid .field {
  margin: 0;
}

.permission-grant-grid .field span {
  font-size: 0.72rem;
  color: var(--muted);
}

.permission-grant-actions {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
}

.permission-list-wrap {
  border: 1px solid #e4dece;
  border-radius: 10px;
  background: #fffef9;
  max-height: 220px;
  overflow: auto;
}

.permission-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
}

.permission-table th,
.permission-table td {
  padding: 7px 8px;
  border-bottom: 1px solid #efe8da;
  text-align: left;
  font-size: 0.76rem;
  vertical-align: middle;
}

.permission-table th {
  position: sticky;
  top: 0;
  background: #fdf7ec;
  z-index: 1;
}

.permission-table td code {
  font-size: 0.72rem;
}

.permission-row-actions {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.permission-role-select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 6px;
  font-size: 0.76rem;
  background: #ffffff;
}

.permission-email-cell {
  max-width: 180px;
  word-break: break-word;
}

.permission-bootstrap-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 6px;
  background: #eaf4ef;
  color: var(--primary-strong);
  font-size: 0.67rem;
  font-weight: 700;
  margin-left: 4px;
}

.permission-empty {
  margin: 0;
  padding: 10px;
  font-size: 0.76rem;
}

.import-mode {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffaf0;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.import-mode select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 9px;
  font-family: inherit;
  color: var(--text);
  background: #ffffff;
  min-width: 182px;
}

.import-mode select:focus {
  outline: 2px solid rgba(15, 124, 109, 0.28);
  border-color: rgba(15, 124, 109, 0.36);
}

.button {
  border: none;
  border-radius: 12px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 600;
  font-family: inherit;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
  box-shadow: 0 8px 18px rgba(15, 124, 109, 0.24);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(15, 124, 109, 0.3);
}

.button:active {
  transform: translateY(0);
}

.button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.button.disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  pointer-events: none;
}

.button.secondary {
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(199, 116, 63, 0.26);
}

.button.ghost {
  background: #f6efe2;
  color: var(--text);
  box-shadow: none;
  border: 1px solid var(--line);
}

.button.small {
  padding: 8px 11px;
  font-size: 0.85rem;
}

.button.tiny {
  padding: 6px 10px;
  font-size: 0.82rem;
}

.button.danger {
  background: var(--danger);
  box-shadow: 0 8px 18px rgba(179, 75, 63, 0.3);
}

.layout {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 10px 26px rgba(25, 36, 32, 0.08);
  padding: 16px;
  animation: rise 420ms ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stats-panel {
  grid-column: span 12;
}

.analytics-panel {
  grid-column: span 12;
}

.guide-panel {
  grid-column: span 12;
  background:
    radial-gradient(440px 190px at 0% 0%, rgba(15, 124, 109, 0.08), transparent 64%),
    radial-gradient(320px 180px at 100% 100%, rgba(199, 116, 63, 0.08), transparent 66%),
    var(--surface);
}

.guide-intro {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.guide-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 10px;
  counter-reset: guide-step;
}

.guide-list li {
  position: relative;
  border: 1px solid #dfe7e2;
  border-radius: 12px;
  background: linear-gradient(160deg, #ffffff 0%, #f5faf7 100%);
  padding: 10px 12px 10px 42px;
  line-height: 1.45;
  font-size: 0.86rem;
}

.guide-list li::before {
  counter-increment: guide-step;
  content: counter(guide-step);
  position: absolute;
  left: 12px;
  top: 10px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #e8f4ef;
  color: var(--primary-strong);
  display: grid;
  place-items: center;
  font-size: 0.76rem;
  font-weight: 700;
}

.tree-panel {
  grid-column: span 8;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(460px 230px at 8% 0%, rgba(15, 124, 109, 0.08), transparent 60%),
    radial-gradient(380px 220px at 96% 8%, rgba(199, 116, 63, 0.09), transparent 62%),
    var(--surface);
}

.tree-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34) 0%, rgba(255, 255, 255, 0) 100%);
}

.tree-panel .panel-title-row {
  position: relative;
  z-index: 1;
}

#treeTitle {
  color: #173b33;
  font-weight: 700;
}

.profile-panel {
  grid-column: span 4;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-panel {
  grid-column: span 12;
}

.relation-panel {
  grid-column: span 12;
}

.activity-panel {
  grid-column: span 12;
}

.contact-panel {
  grid-column: span 12;
}

.contact-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(240px, 0.9fr);
  gap: 12px;
}

.contact-form {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #fffef9 0%, #f7f3ea 100%);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.contact-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.contact-form-grid .field {
  margin: 0;
}

.contact-form-grid textarea {
  min-height: 88px;
  resize: vertical;
}

.contact-form-grid .field.span-2 {
  grid-column: span 2;
}

.contact-form h3 {
  margin: 0;
  font-size: 0.9rem;
  color: #2a3b35;
}

.contact-info-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #f7fcfa 0%, #eef6f2 100%);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.contact-info-card h3 {
  margin: 0;
  font-size: 0.9rem;
  color: #2a3b35;
}

.contact-info-card p {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.contact-info-card span {
  font-size: 0.78rem;
  color: var(--muted);
}

.contact-info-card strong {
  font-size: 0.88rem;
  color: var(--text);
  word-break: break-word;
}

.contact-info-card a {
  color: var(--primary-strong);
  text-decoration: none;
}

.contact-info-card a:hover {
  text-decoration: underline;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  background: #e9f4f1;
  color: var(--primary-strong);
  font-weight: 700;
}

.subheading {
  margin: 12px 0 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 700;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(165deg, #fffefb 0%, #f5f7f2 100%);
  padding: 12px;
}

.stat-card p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.48rem;
}

.advanced-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.advanced-stat-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(160deg, #fffefb 0%, #f4f8f5 100%);
  padding: 11px;
  min-height: 94px;
}

.advanced-stat-card p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.advanced-stat-card strong {
  margin-top: 6px;
  display: block;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--text);
  word-break: break-word;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border-radius: 999px;
  border: 1px solid #c9d8d3;
  background: #f2faf8;
  color: var(--primary-strong);
  font-weight: 600;
  font-size: 0.82rem;
  padding: 6px 10px;
  cursor: pointer;
}

.chip:hover {
  background: #e6f4f0;
}

.control-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(140px, 1fr) minmax(240px, 1.25fr) minmax(280px, 1.45fr);
  gap: 10px;
  align-items: end;
}

.control-row > * {
  min-width: 0;
}

.tree-tools {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

.tree-depth-box {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 30px auto;
  align-items: center;
  gap: 6px;
  border: 1px solid #e5ddcf;
  border-radius: 12px;
  background: linear-gradient(180deg, #fffdf7 0%, #f6f1e6 100%);
  padding: 4px 6px;
  min-width: 0;
  width: 100%;
}

.tree-depth-btn {
  width: 30px;
  min-width: 30px;
  height: 30px;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  font-weight: 700;
  border-radius: 9px;
}

.tree-depth-pill {
  min-width: 38px;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid #d5dfd8;
  background: #f2faf6;
  color: var(--primary-strong);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.tree-range {
  --range-fill: 50%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-width: 0;
  height: 8px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #d7dccc;
  background: linear-gradient(
    90deg,
    #2f9f8f 0%,
    #2f9f8f var(--range-fill),
    #e8e2d6 var(--range-fill),
    #e8e2d6 100%
  );
  margin: 0;
  cursor: pointer;
}

.tree-range:focus-visible {
  outline: 2px solid rgba(15, 124, 109, 0.34);
  outline-offset: 1px;
}

.tree-range:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tree-range::-webkit-slider-runnable-track {
  height: 8px;
  background: transparent;
  border: none;
}

.tree-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -5px;
  border-radius: 50%;
  border: 2px solid #228577;
  background: #ffffff;
  box-shadow: 0 1px 5px rgba(24, 52, 44, 0.26);
}

.tree-range::-moz-range-track {
  height: 8px;
  border: none;
  background: transparent;
}

.tree-range::-moz-range-progress {
  height: 8px;
  border-radius: 999px;
  background: #2f9f8f;
}

.tree-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #228577;
  background: #ffffff;
  box-shadow: 0 1px 5px rgba(24, 52, 44, 0.26);
}

.tree-zoom-range {
  width: 100%;
  min-width: 0;
}

.tree-zoom-box {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid #e4dccd;
  border-radius: 12px;
  background: linear-gradient(180deg, #fffdf7 0%, #f6f1e6 100%);
  padding: 5px 7px;
  width: 100%;
  min-width: 0;
}

.tree-zoom-controls {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto 30px;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.tree-zoom-btn {
  width: 30px;
  min-width: 30px;
  height: 30px;
  padding: 0;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
  border-radius: 9px;
}

.tree-zoom-reset {
  min-width: 62px;
  padding-inline: 8px;
  border-radius: 9px;
  font-variant-numeric: tabular-nums;
  border-color: #d5dfd8;
  background: #f2faf6;
  color: var(--primary-strong);
  font-size: 0.78rem;
  font-weight: 700;
}

.tree-search-row {
  margin-top: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.tree-search-field {
  margin: 0;
}

.tree-search-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.tree-search-input-wrap {
  position: relative;
}

.tree-search-controls input {
  background: #fffcf5;
}

.tree-search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 9;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdfa;
  box-shadow: 0 10px 22px rgba(27, 39, 35, 0.16);
}

.tree-search-option {
  width: 100%;
  border: none;
  border-bottom: 1px solid #eee7d9;
  background: transparent;
  text-align: left;
  cursor: pointer;
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tree-search-option:last-child {
  border-bottom: none;
}

.tree-search-option:hover {
  background: #f3faf7;
}

.tree-search-option.active {
  background: #e9f7f2;
}

.tree-search-option strong {
  font-size: 0.84rem;
  color: var(--text);
}

.tree-search-option small {
  font-size: 0.75rem;
  color: var(--muted);
}

.tree-search-empty {
  padding: 10px 11px;
  font-size: 0.82rem;
  color: var(--muted);
}

.tree-search-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.86rem;
  color: var(--muted);
}

.field.compact {
  font-size: 0.82rem;
}

.field.action-field {
  justify-content: flex-end;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  font-family: inherit;
  background: #fffdfa;
  color: var(--text);
}

.field select[multiple] {
  min-height: 110px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid rgba(15, 124, 109, 0.28);
  border-color: rgba(15, 124, 109, 0.36);
}

.field.span-2 {
  grid-column: span 2;
}

.role-switch-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.role-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #faf8f2;
  padding: 8px 10px;
  font-size: 0.82rem;
  color: var(--text);
  cursor: pointer;
}

.role-switch input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

#treeDepthValue {
  font-variant-numeric: tabular-nums;
}

#treeViewport {
  position: relative;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  min-height: 260px;
  max-height: 540px;
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(249, 244, 233, 0.9) 0%, rgba(247, 251, 248, 0.9) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
  cursor: grab;
  touch-action: none;
  overscroll-behavior: contain;
  -webkit-tap-highlight-color: transparent;
}

#treeViewport.is-panning {
  cursor: grabbing;
  user-select: none;
}

#treeViewport.is-panning * {
  cursor: grabbing !important;
}

#treeViewport::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(transparent 95%, rgba(18, 88, 80, 0.06) 96%),
    linear-gradient(90deg, transparent 95%, rgba(18, 88, 80, 0.05) 96%);
  background-size: 38px 38px;
  opacity: 0.3;
  z-index: 0;
}

#treeViewport::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(12px 10px at 6% 16%, rgba(112, 160, 108, 0.17), transparent 70%),
    radial-gradient(12px 10px at 15% 8%, rgba(112, 160, 108, 0.14), transparent 72%),
    radial-gradient(11px 9px at 74% 14%, rgba(112, 160, 108, 0.14), transparent 74%),
    radial-gradient(11px 9px at 84% 10%, rgba(112, 160, 108, 0.18), transparent 72%),
    radial-gradient(12px 10px at 95% 18%, rgba(112, 160, 108, 0.14), transparent 76%);
  opacity: 0.55;
  z-index: 0;
}

.tree-floating-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 0;
  z-index: 3;
}

.tree-icon-btn {
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  border-radius: 10px;
  box-shadow: none;
  border: 1px solid rgba(158, 170, 166, 0.5);
  background: rgba(255, 253, 250, 0.92);
}

.tree-icon-btn:hover {
  background: #f3ede1;
}

.tree-icon-svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tree-icon-btn:disabled .tree-icon-svg {
  opacity: 0.55;
}

.tree-icon-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#treeScene {
  position: relative;
  min-width: 100%;
  min-height: 100%;
  z-index: 1;
  touch-action: none;
}

#treeCanvas {
  position: absolute;
  top: 0;
  left: 0;
  min-width: 100%;
  width: max-content;
  padding: 24px 16px 30px;
  transform-origin: top left;
  will-change: transform;
  touch-action: none;
}

#treeLines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

#treeLevels {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 44px;
  touch-action: none;
}

#treeLevels.is-centered {
  justify-content: center;
}

.tree-row {
  min-width: max-content;
  display: flex;
  justify-content: center;
  gap: 12px;
}

.tree-node {
  position: relative;
  min-width: 178px;
  max-width: 196px;
  border-radius: 14px;
  border: 1px solid #d5ddd9;
  background:
    linear-gradient(180deg, #ffffff 0%, #f8fcfb 100%);
  padding: 10px 11px;
  text-align: left;
  cursor: pointer;
  transition: transform 170ms ease, box-shadow 170ms ease, border 170ms ease, background 170ms ease;
  box-shadow: 0 6px 14px rgba(27, 39, 35, 0.07);
  animation: treeNodeReveal 380ms ease both;
  animation-delay: var(--node-delay, 0ms);
  overflow: hidden;
  touch-action: none;
}

.tree-node::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(77, 121, 84, 0.2) 0%, rgba(53, 96, 73, 0.06) 100%);
}

.tree-node::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 7px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #9ac27f 0%, #6d9d6a 70%, #4b7e53 100%);
  opacity: 0.54;
}

.tree-node > * {
  position: relative;
  z-index: 1;
}

.tree-node-photo {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  margin: 0 auto 8px;
  border: 1px solid #d6dfd9;
  background: linear-gradient(180deg, #f8fcfa 0%, #edf5f1 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

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

.tree-node-photo.fallback {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #3e6e63;
  background: radial-gradient(circle at 30% 20%, #ffffff 0%, #e4f0eb 70%, #d6e7df 100%);
}

.tree-node:hover {
  transform: translateY(-3px) scale(1.01);
  box-shadow: 0 12px 22px rgba(27, 39, 35, 0.14);
}

.tree-node.active {
  border-color: rgba(15, 124, 109, 0.74);
  box-shadow: 0 12px 24px rgba(15, 124, 109, 0.24);
  background: linear-gradient(180deg, #ffffff 0%, #eef9f6 100%);
}

.tree-node.match {
  border-color: rgba(199, 116, 63, 0.48);
  box-shadow: 0 9px 18px rgba(199, 116, 63, 0.16);
}

.tree-node.match-current {
  border-color: rgba(199, 116, 63, 0.9);
  box-shadow: 0 0 0 3px rgba(199, 116, 63, 0.16), 0 12px 24px rgba(199, 116, 63, 0.3);
  animation: treeMatchPulse 1.5s ease-in-out infinite;
}

.tree-node strong {
  display: block;
  font-size: 0.93rem;
}

.tree-node p {
  margin: 4px 0 0;
  font-size: 0.79rem;
  color: var(--muted);
}

.node-status {
  margin-top: 7px;
  display: inline-block;
  font-size: 0.72rem;
  border-radius: 999px;
  padding: 3px 8px;
  background: #edf7f3;
  color: var(--primary-strong);
}

.node-status.deceased {
  background: #f8ece8;
  color: #9a4f45;
}

.node-role {
  margin-top: 6px;
  display: inline-block;
  font-size: 0.69rem;
  border-radius: 999px;
  padding: 3px 8px;
  font-weight: 700;
}

.node-role-row {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.node-role-row .node-role {
  margin-top: 0;
}

.node-role.patriarch {
  background: #f7efe0;
  color: #8b5a1f;
}

.node-role.eldest-son {
  background: #e9f5f2;
  color: #0b6457;
}

.node-role.eldest-grandson {
  background: #f0ecfb;
  color: #5a3f92;
}

.tree-line-path {
  stroke: url(#treeBranchGradient);
  stroke-opacity: 0.94;
  stroke-dasharray: var(--line-len, 160);
  stroke-dashoffset: var(--line-len, 160);
  animation: treeLineReveal 560ms ease forwards;
  animation-delay: var(--line-delay, 0ms);
}

.tree-leaf-dot {
  fill: #78ad78;
  opacity: 0;
  transform-origin: center;
  animation: treeLeafPop 420ms ease forwards;
  animation-delay: var(--leaf-delay, 140ms);
}

.tree-branch-bud {
  fill: #b2cd8d;
  opacity: 0;
  animation: treeBudFade 440ms ease forwards;
  animation-delay: var(--leaf-delay, 200ms);
}

@keyframes treeNodeReveal {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes treeLineReveal {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes treeMatchPulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(199, 116, 63, 0.16), 0 12px 24px rgba(199, 116, 63, 0.3);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(199, 116, 63, 0.24), 0 13px 26px rgba(199, 116, 63, 0.36);
  }
}

@keyframes treeLeafPop {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  65% {
    opacity: 0.95;
    transform: scale(1.15);
  }
  100% {
    opacity: 0.88;
    transform: scale(1);
  }
}

@keyframes treeBudFade {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  100% {
    opacity: 0.68;
    transform: scale(1);
  }
}

#treePanel:fullscreen {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 14px;
  border-radius: 0;
  border: none;
  box-shadow: none;
  display: flex;
  flex-direction: column;
}

#treePanel:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 14px;
  border-radius: 0;
  border: none;
  box-shadow: none;
  display: flex;
  flex-direction: column;
}

#treePanel:fullscreen #treeViewport {
  flex: 1;
  min-height: 0;
  max-height: none;
}

#treePanel:-webkit-full-screen #treeViewport {
  flex: 1;
  min-height: 0;
  max-height: none;
}

#treePanel:fullscreen .control-row {
  grid-template-columns: repeat(3, minmax(180px, 1fr)) auto;
}

#treePanel:-webkit-full-screen .control-row {
  grid-template-columns: repeat(3, minmax(180px, 1fr)) auto;
}

#treePanel:fullscreen .tree-search-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

#treePanel:-webkit-full-screen .tree-search-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.empty-state {
  border-radius: 14px;
  border: 1px dashed #ccbfa7;
  background: #faf5ea;
  padding: 14px;
  color: #7b6f5c;
  font-size: 0.92rem;
}

.empty-state p {
  margin: 0;
}

#btnCreateFirstMember {
  margin-top: 10px;
}

.profile-quick-create {
  margin-top: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(120px, 0.8fr) auto;
  gap: 8px;
  align-items: end;
  border: 1px solid #e2d7c3;
  border-radius: 12px;
  background: linear-gradient(180deg, #fffdf8 0%, #f7f2e8 100%);
  padding: 10px;
}

.profile-quick-create-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.muted {
  color: var(--muted);
  margin: 5px 0 10px;
}

.role-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.76rem;
  font-weight: 700;
}

.role-badge.patriarch {
  background: #f7efe0;
  color: #8b5a1f;
}

.role-badge.eldest-son {
  background: #e9f5f2;
  color: #0b6457;
}

.role-badge.eldest-grandson {
  background: #f0ecfb;
  color: #5a3f92;
}

.profile-overview-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.profile-header-main {
  min-width: 0;
  flex: 1;
}

.profile-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.button.profile-delete-trigger {
  background: linear-gradient(180deg, #c85a4a 0%, #ab4337 100%);
  color: #ffffff;
  /* border: 1px solid #9b3f35; */
  /* box-shadow: 0 8px 18px rgba(179, 75, 63, 0.34); */
}

.button.profile-delete-trigger:hover {
  /* background: linear-gradient(180deg, #d06656 0%, #b24b3d 100%); */
  color: #ffffff;
  /* box-shadow: 0 10px 20px rgba(179, 75, 63, 0.42); */
}

.button.profile-delete-trigger:focus-visible {
  /* outline: 2px solid rgba(179, 75, 63, 0.34); */
  /* outline-offset: 1px; */
}

.button.profile-delete-trigger:disabled {
  background: #e8d9d5;
  color: #8e7770;
  border-color: #d8c4bf;
  box-shadow: none;
}

.profile-edit-trigger {
  flex: 0 0 auto;
  white-space: nowrap;
}

#profileName {
  font-size: 1.06rem;
  line-height: 1.35;
}

.profile-overview-stack .muted {
  margin: 0;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.kv-item {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fdfbf5 0%, #f9f5ea 100%);
  border-radius: 9px;
  padding: 7px 8px;
}

.kv-item p {
  margin: 0;
  font-size: 0.67rem;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.kv-item strong {
  margin-top: 3px;
  display: block;
  font-size: 0.82rem;
  line-height: 1.34;
}

.kv-link {
  color: var(--primary-strong);
  text-decoration: none;
  word-break: break-all;
}

.kv-link:hover {
  text-decoration: underline;
}

.kv-item-media-compact {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.profile-media-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 82px));
  gap: 8px;
  justify-content: flex-start;
}

.profile-media-slot {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  align-items: flex-start;
}

.profile-media-slot-label {
  font-size: 0.67rem;
  color: #6d7a73;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.profile-media-thumb {
  width: 82px;
  height: 82px;
  border: 1px solid #d5cab6;
  border-radius: 8px;
  background: linear-gradient(160deg, #f4eee2 0%, #eae2d4 100%);
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  display: block;
}

.profile-media-thumb:hover {
  border-color: #bba882;
}

.profile-media-thumb:focus-visible {
  outline: 2px solid rgba(15, 124, 109, 0.3);
  outline-offset: 1px;
}

.profile-media-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-media-empty {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  border: 1px dashed #d9ceba;
  border-radius: 8px;
  background: #faf5ea;
  color: #7f8d85;
  font-size: 0.7rem;
  line-height: 1.2;
  padding: 6px;
  text-align: center;
  word-break: break-word;
}

.kv-item.editing {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: linear-gradient(180deg, #fffdf8 0%, #f7f2e6 100%);
}

.profile-inline-input,
.profile-inline-select,
.profile-inline-textarea {
  width: 100%;
  border: 1px solid #d8d2c4;
  border-radius: 8px;
  padding: 6px 7px;
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--text);
  background: #fffdfa;
}

.profile-inline-textarea {
  resize: vertical;
  min-height: 54px;
}

.profile-inline-input:focus,
.profile-inline-select:focus,
.profile-inline-textarea:focus {
  outline: 2px solid rgba(15, 124, 109, 0.28);
  border-color: rgba(15, 124, 109, 0.36);
}

.profile-inline-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #d8d2c4;
  border-radius: 8px;
  padding: 6px 7px;
  background: #fffdfa;
  width: fit-content;
  font-size: 0.78rem;
  color: var(--text);
}

.profile-inline-check input {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
}

.relation-columns {
  margin-top: 4px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.relation-card {
  border: 1px solid #e2d9c8;
  border-radius: 10px;
  background: linear-gradient(180deg, #fefcf8 0%, #f8f4ea 100%);
  padding: 7px 8px;
  min-height: 74px;
}

.relation-columns h4 {
  margin: 0 0 5px;
  font-size: 0.76rem;
  color: #68726b;
  font-family: "Be Vietnam Pro", sans-serif;
  font-weight: 700;
}

.tag-list {
  min-height: 28px;
  max-height: 92px;
  overflow: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-content: flex-start;
}

.tag-list.editing {
  max-height: none;
  overflow: visible;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.relation-inline-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  width: 100%;
}

.relation-inline-item {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}

.relation-inline-label {
  font-size: 0.73rem;
  color: #6d746f;
  font-weight: 600;
}

.relation-inline-multi {
  min-height: 82px;
}

.tag-btn {
  border: 1px solid #d2e0dc;
  background: #eff8f5;
  color: var(--primary-strong);
  border-radius: 999px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 600;
}

.tag-btn:hover {
  background: #e0f2ec;
}

.tag-empty {
  color: var(--muted);
  font-size: 0.75rem;
}

.profile-actions {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.profile-manage-section {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed #d9cebb;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inline-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 0;
}

.inline-title-row h3 {
  margin: 0;
  font-family: "Be Vietnam Pro", sans-serif;
  font-size: 0.94rem;
}

.badge.subtle {
  background: #f5eee1;
  color: #7a6955;
}

.profile-form-grid {
  gap: 8px;
}

.profile-manage-section .field {
  font-size: 0.8rem;
}

.profile-manage-section .field input,
.profile-manage-section .field select,
.profile-manage-section .field textarea {
  padding: 8px 9px;
  border-radius: 9px;
}

.profile-manage-section .role-switch {
  padding: 6px 8px;
  font-size: 0.77rem;
}

.profile-manage-section .actions {
  margin-top: 0;
}

.search-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.table-wrap {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 730px;
}

thead th {
  background: #f6f2e8;
  text-align: left;
  font-size: 0.8rem;
  color: #6d6a61;
  font-weight: 700;
  padding: 10px;
}

tbody td {
  padding: 9px 10px;
  border-top: 1px solid #eee8dd;
  font-size: 0.88rem;
}

tbody tr {
  transition: background 120ms ease;
}

tbody tr:hover {
  background: #f7fbf8;
}

tbody tr.selected {
  background: #ecf8f4;
}

.status-pill {
  border-radius: 999px;
  font-size: 0.74rem;
  padding: 4px 8px;
  font-weight: 700;
}

.status-pill.alive {
  background: #e6f3ee;
  color: #106351;
}

.status-pill.deceased {
  background: #f4e8e4;
  color: #8f473e;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.actions {
  grid-column: span 2;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 2px;
}

.relation-tools {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.relation-tools .field {
  min-width: 240px;
  flex: 1;
}

.relation-result {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fcfaf5;
  min-height: 68px;
  line-height: 1.55;
}

.relation-path {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.relation-name {
  font-weight: 700;
  color: var(--text);
}

.relation-arrow {
  font-size: 0.82rem;
  color: var(--primary-strong);
  padding: 3px 8px;
  background: #eaf5f2;
  border-radius: 999px;
}

.footer {
  margin-top: 12px;
  padding: 12px;
  text-align: center;
  color: #72695c;
  font-size: 0.82rem;
}

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateY(15px);
  bottom: 22px;
  border-radius: 10px;
  padding: 10px 14px;
  background: #1f312c;
  color: #ffffff;
  font-size: 0.88rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1320px) {
  .profile-panel .relation-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profile-panel .relation-card:last-child {
    grid-column: span 2;
  }
}

@media (max-width: 1140px) {
  .tree-panel,
  .profile-panel,
  .search-panel {
    grid-column: span 12;
  }

  .control-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .tree-tools {
    grid-column: span 2;
    justify-content: flex-start;
  }

  .tree-zoom-box {
    max-width: 520px;
  }

  .stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .advanced-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .contact-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 800px) {
  .hero {
    flex-direction: column;
    padding: 18px;
  }

  .public-genealogy-title {
    width: 100%;
    max-width: 100%;
    font-size: 1.06rem;
    padding: 9px 11px;
  }

  .hero-corner-controls {
    position: static;
    width: 100%;
    align-self: flex-end;
    justify-content: flex-end;
    margin-bottom: 4px;
  }

  .hero-actions {
    width: 100%;
    display: flex;
    margin-top: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .top-menu-tabs {
    width: 100%;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 5px;
    padding: 5px 4px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .top-menu-tabs::-webkit-scrollbar {
    display: none;
  }

  .top-tab-btn {
    width: auto;
    flex: 0 0 auto;
    min-height: 38px;
    min-width: 104px;
    padding: 7px 10px;
    white-space: nowrap;
    scroll-snap-align: start;
  }

  .import-mode {
    width: 100%;
    justify-content: space-between;
  }

  .hero-quick-actions .import-mode.import-mode-compact {
    width: auto;
    justify-content: flex-start;
  }

  .hero-quick-actions .compact-data-action {
    width: auto;
    min-width: fit-content;
    padding: 5px 8px;
  }

  .hero-quick-actions .compact-data-action .compact-action-text {
    display: inline;
  }

  .auth-dropdown-menu {
    min-width: 230px;
  }

  .genealogy-switcher {
    width: min(560px, 100%);
    min-width: 320px;
  }

  .genealogy-switcher-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .genealogy-switcher-actions .button {
    width: 100%;
    min-width: 0;
  }

  .genealogy-link-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "label label"
      "input button";
    align-items: stretch;
  }

  .genealogy-link-head {
    justify-content: space-between;
    width: 100%;
  }

  .genealogy-link-mode-select {
    min-width: 120px;
  }

  .genealogy-link-actions {
    align-self: stretch;
  }

  .genealogy-passphrase-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "label label"
      "input actions";
    align-items: stretch;
  }

  .genealogy-link-input {
    font-size: 0.8rem;
  }

  .genealogy-story-content {
    grid-template-columns: 1fr;
  }

  .genealogy-story-preview-frame {
    max-width: min(460px, 100%);
    margin: 0 auto;
  }

  .genealogy-story-actions {
    grid-template-columns: 1fr;
  }

  .genealogy-story-actions #btnShareGenealogyStoryNow {
    grid-column: auto;
  }

  .genealogy-share-form-grid {
    grid-template-columns: 1fr;
  }

  .genealogy-share-form-actions {
    justify-content: stretch;
  }

  .genealogy-share-form-actions .button {
    width: 100%;
  }

  .contact-form-grid {
    grid-template-columns: 1fr;
  }

  .contact-form-grid .field.span-2 {
    grid-column: span 1;
  }

  .auth-status {
    max-width: 100%;
  }

  .auth-actions {
    width: 100%;
    justify-content: stretch;
  }

  .auth-actions .button {
    flex: 1;
  }

  .user-profile-modal {
    padding: 12px;
  }

  .user-profile-card {
    width: 100%;
    max-height: 90vh;
    padding: 10px;
  }

  .user-profile-form-grid {
    grid-template-columns: 1fr;
  }

  .permission-grant-grid {
    grid-template-columns: 1fr;
  }

  .permission-grant-actions {
    justify-content: stretch;
  }

  .permission-grant-actions .button {
    width: 100%;
  }

  .permission-table {
    min-width: 560px;
  }

  .activity-intro {
    margin-bottom: 8px;
  }

  .activity-panel-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .activity-table-wrap {
    max-height: none;
    overflow: visible;
    border-radius: 10px;
  }

  .activity-table {
    min-width: 0;
    display: block;
  }

  .activity-table thead {
    display: none;
  }

  .activity-table tbody {
    display: grid;
    gap: 8px;
  }

  .activity-table tr {
    display: block;
    border: 1px solid #e6ddd0;
    border-radius: 11px;
    background: #fffefc;
    padding: 7px 9px;
  }

  .activity-table td {
    display: block;
    border-bottom: none;
    padding: 3px 0;
  }

  .activity-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    text-transform: uppercase;
    color: #6b7d75;
  }

  .activity-state-cell {
    text-align: left;
    padding: 4px 0;
  }

  .activity-state-cell::before {
    display: none;
  }

  .user-profile-actions {
    flex-wrap: wrap;
    position: static;
    background: transparent;
    padding-top: 0;
  }

  .user-profile-actions .button {
    width: 100%;
    min-width: 0;
  }

  .control-row {
    grid-template-columns: 1fr;
  }

  .tree-tools {
    justify-content: flex-start;
    gap: 6px;
    width: 100%;
  }

  .tree-depth-box {
    width: 100%;
    min-width: 0;
    grid-template-columns: 30px minmax(0, 1fr) 30px auto;
  }

  .tree-zoom-box {
    width: 100%;
  }

  .tree-zoom-controls {
    width: 100%;
    grid-template-columns: 30px minmax(0, 1fr) auto 30px;
  }

  .tree-zoom-reset {
    min-width: 56px;
  }

  .tree-range,
  .tree-zoom-range {
    width: 100%;
    min-width: 0;
  }

  .tree-floating-actions {
    justify-content: flex-end;
    gap: 5px;
    margin-top: 7px;
  }

  .tree-icon-btn {
    width: 30px;
    height: 30px;
    min-width: 30px;
  }

  .tree-icon-svg {
    width: 15px;
    height: 15px;
  }

  .tree-search-row {
    grid-template-columns: 1fr;
  }

  .tree-search-controls {
    grid-template-columns: 1fr;
  }

  .tree-search-input-wrap {
    width: 100%;
  }

  .tree-search-controls .button {
    width: 100%;
  }

  .tree-search-hint {
    text-align: left;
    white-space: normal;
  }

  .profile-header-row {
    flex-direction: column;
    align-items: stretch;
  }

  .profile-header-actions {
    align-self: flex-end;
  }

  .profile-quick-create {
    grid-template-columns: 1fr;
  }

  .profile-quick-create-actions {
    justify-content: stretch;
  }

  .profile-quick-create-actions .button {
    flex: 1;
  }

  .profile-edit-trigger {
    align-self: auto;
  }

  .kv-grid,
  .relation-columns,
  .search-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .kv-item-media-compact {
    grid-column: span 1;
  }

  .profile-panel .relation-card:last-child {
    grid-column: span 1;
  }

  .field.span-2,
  .actions {
    grid-column: span 1;
  }

  .actions {
    justify-content: stretch;
    flex-wrap: wrap;
  }

  .actions .button {
    width: 100%;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .stats-panel {
    padding: 12px;
  }

  .stats-panel .panel-title-row {
    margin-bottom: 8px;
    gap: 7px;
    align-items: flex-start;
  }

  .stats-panel .panel-title-row h2 {
    font-size: 1rem;
    line-height: 1.25;
  }

  .stats-panel .badge {
    padding: 4px 8px;
    font-size: 0.68rem;
  }

  .stats-panel .subheading {
    margin: 8px 0 6px;
    font-size: 0.8rem;
  }

  .stat-card {
    border-radius: 11px;
    padding: 8px 9px;
  }

  .stat-card p {
    font-size: 0.74rem;
    line-height: 1.28;
  }

  .stat-card strong {
    margin-top: 5px;
    font-size: 1.16rem;
    line-height: 1.1;
  }

  .chip-row {
    gap: 6px;
  }

  .chip {
    font-size: 0.74rem;
    padding: 5px 8px;
  }

  .advanced-stat-grid {
    grid-template-columns: 1fr;
  }

  .guide-list {
    grid-template-columns: 1fr;
  }

  .relation-tools .field {
    min-width: 100%;
  }
}

@media (max-width: 520px) {
  .top-menu-tabs {
    gap: 4px;
    padding: 4px 3px;
  }

  .profile-media-grid {
    grid-template-columns: repeat(2, minmax(0, 76px));
    gap: 7px;
  }

  .profile-media-thumb,
  .profile-media-empty {
    width: 76px;
    height: 76px;
  }

  .image-preview-topbar {
    padding: 8px 10px;
  }

  .image-preview-body {
    padding: 8px;
  }

  .top-tab-btn {
    min-width: 92px;
    font-size: 0.81rem;
    min-height: 36px;
    padding: 7px 9px;
  }

  .stats-panel {
    padding: 10px;
  }

  .stat-grid {
    gap: 6px;
  }

  .stat-card {
    padding: 7px 8px;
  }

  .stat-card p {
    font-size: 0.7rem;
  }

  .stat-card strong {
    font-size: 1.04rem;
    margin-top: 4px;
  }

  .stats-panel .badge {
    font-size: 0.65rem;
    padding: 3px 7px;
  }

  .chip {
    font-size: 0.72rem;
    padding: 4px 7px;
  }
}
