:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --text: #20242a;
  --muted: #69717d;
  --subtle: #9198a2;
  --border: #e1e5ea;
  --border-strong: #cfd5dc;
  --primary: #3f6695;
  --primary-dark: #315377;
  --primary-soft: #edf3fa;
  --green: #5e7c69;
  --green-soft: #edf4ef;
  --purple: #72658c;
  --purple-soft: #f1eef7;
  --orange: #9a704d;
  --orange-soft: #f8f1ea;
  --danger: #a34d4d;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
}

/* Full-stack NAS edition */
[hidden] { display: none !important; }

body {
  min-height: 100vh;
}

.fs-main {
  min-height: calc(100vh - 72px);
}

.active-nav {
  color: var(--text) !important;
  font-weight: 650 !important;
}

.logout-form {
  margin: 0;
}

.text-button,
.icon-action,
.danger-action,
.secondary-action {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}

.text-button,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  font-size: 14px;
}

.danger-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-color: #e8c9c9;
  color: #9e3535;
}

.flash-message {
  max-width: 1180px;
  margin: 18px auto 0;
  padding: 12px 16px;
  border: 1px solid #bfd7ca;
  border-radius: 10px;
  background: #f0f8f3;
  color: #255c3d;
  font-size: 14px;
}

.flash-message.error {
  border-color: #ebc8c8;
  background: #fff4f4;
  color: #913333;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 30px;
  background: #f3f5f7;
}

.auth-card {
  width: min(440px, 100%);
  padding: 38px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(33, 44, 55, 0.08);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
}

.auth-brand img {
  width: 46px;
  height: 46px;
  border-radius: 12px;
}

.auth-brand strong,
.auth-brand span {
  display: block;
}

.auth-brand strong { font-size: 18px; }
.auth-brand span { margin-top: 3px; color: var(--muted); font-size: 12px; }

.auth-card h1 { margin: 0 0 8px; font-size: 28px; }
.auth-card > p { margin: 0 0 26px; color: var(--muted); line-height: 1.7; }

.stack-form {
  display: grid;
  gap: 18px;
}

.stack-form label,
.admin-form label {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.stack-form input,
.stack-form select,
.stack-form textarea,
.admin-form input,
.admin-form select,
.admin-form textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 400;
}

.stack-form textarea,
.admin-form textarea {
  min-height: 120px;
  resize: vertical;
}

.auth-submit {
  min-height: 46px;
  border: 0;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 650;
}

.auth-error {
  margin: -6px 0 0 !important;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff1f1;
  color: #963b3b !important;
  font-size: 13px;
}

.auth-success {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #b9d7c2;
  border-radius: 8px;
  color: #1f6840;
  background: #f0f8f2;
  font-size: 14px;
}

.admin-form {
  display: grid;
  gap: 20px;
  padding: 26px;
}

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

.admin-form .field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.admin-form .full-span { grid-column: 1 / -1; }

.admin-form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 6px;
}

.admin-form-actions .primary-action {
  border: 0;
  cursor: pointer;
}

.danger-zone {
  margin-top: 22px;
  padding: 22px;
  border: 1px solid #ebd0d0;
  border-radius: 12px;
  background: #fffafa;
}

.danger-zone h3 { margin: 0 0 8px; color: #852e2e; }
.danger-zone p { margin: 0 0 16px; color: var(--muted); }

.empty-state-full {
  padding: 64px 24px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: #fafbfc;
  text-align: center;
}

.empty-state-full h2 { margin: 0 0 8px; font-size: 20px; }
.empty-state-full p { margin: 0 0 20px; color: var(--muted); }

.record-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.record-meta span {
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.detail-hero-simple {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 30px;
  align-items: start;
  margin-bottom: 24px;
  padding: 28px;
}

.detail-hero-simple img,
.detail-placeholder-large {
  width: 180px;
  aspect-ratio: 4 / 5;
  border-radius: 12px;
  object-fit: cover;
}

.detail-placeholder-large {
  display: grid;
  place-items: center;
  padding: 16px;
  background: #e8edf2;
  color: #52606c;
  text-align: center;
  font-size: 28px;
  font-weight: 650;
}
.detail-placeholder-large > span { max-width: 100%; overflow-wrap: anywhere; line-height: 1.35; }

.detail-hero-simple h1 { margin: 4px 0 10px; font-size: 36px; }
.detail-hero-simple p { color: var(--muted); line-height: 1.8; }

.prose-section {
  margin-bottom: 22px;
  padding: 26px;
}

.prose-section h2 { margin: 0 0 16px; font-size: 20px; }
.prose-section p { margin: 0; color: #3f4952; line-height: 1.9; white-space: pre-wrap; }

.data-list {
  display: grid;
  gap: 0;
}

.data-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(120px, 0.8fr) minmax(180px, 1.4fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 66px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.data-row:last-child { border-bottom: 0; }
.data-row small { color: var(--muted); }
.data-row form { margin: 0; }

.media-file-preview {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #101214;
}

.media-file-preview img,
.media-file-preview video,
.media-file-preview audio {
  display: block;
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
}

.media-file-preview audio { min-height: 80px; background: #fff; }

.upload-progress {
  display: none;
  padding: 14px;
  border-radius: 9px;
  background: #eef5fa;
  color: #31556e;
  font-size: 14px;
}

.upload-progress.active { display: block; }

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

.settings-card { padding: 26px; }
.settings-card h2 { margin: 0 0 10px; font-size: 20px; }
.settings-card p { color: var(--muted); line-height: 1.7; }

.stat-line {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.stat-line:last-child { border-bottom: 0; }

@media (max-width: 760px) {
  .admin-form .field-grid,
  .admin-form .field-grid.three,
  .settings-grid,
  .detail-hero-simple {
    grid-template-columns: 1fr;
  }

  .detail-hero-simple img,
  .detail-placeholder-large {
    width: 130px;
  }

  .data-row {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 16px 0;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); }
body { margin: 0; color: var(--text); background: var(--bg); font-family: var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { color: #fff; background: var(--primary); }
.page-container { width: min(1200px, calc(100% - 48px)); margin-inline: auto; }

/* Shared header and footer */
.site-header { position: sticky; top: 0; z-index: 50; height: 64px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
.header-inner { width: min(1320px, calc(100% - 48px)); height: 100%; display: flex; align-items: center; margin: auto; }
.brand { min-width: 230px; display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 34px; height: 34px; object-fit: cover; border: 1px solid var(--border); border-radius: 7px; }
.brand-name { font-size: 16px; font-weight: 650; letter-spacing: .025em; white-space: nowrap; }
.main-nav { height: 100%; display: flex; align-items: center; justify-content: center; gap: 6px; flex: 1; }
.main-nav a { height: 36px; display: flex; align-items: center; padding: 0 15px; border-radius: 6px; color: #4f5661; font-size: 13px; }
.main-nav a:hover { color: var(--text); background: #f2f4f6; }
.header-actions { min-width: 285px; display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.global-search { height: 34px; display: flex; align-items: center; gap: 7px; padding: 0 9px; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--muted); font-size: 12px; }
.global-search > span:first-child { font-size: 18px; transform: rotate(-15deg); }
.global-search kbd { margin-left: 3px; padding: 2px 5px; border: 1px solid var(--border); border-radius: 4px; color: var(--subtle); background: #f7f8fa; font: 10px var(--font); }
.primary-action { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0 17px; border: 1px solid var(--primary); border-radius: 6px; color: #fff; background: var(--primary); font-size: 13px; font-weight: 550; white-space: nowrap; }
.primary-action:hover { background: var(--primary-dark); }
.primary-action.small { min-height: 34px; padding-inline: 12px; font-size: 12px; }
.user-avatar { width: 34px; height: 34px; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: #eef0f3; font-size: 12px; }
.demo-notice { min-height: 30px; display: flex; align-items: center; justify-content: center; padding: 6px 20px; border-bottom: 1px solid var(--border); color: var(--muted); background: #f3f5f7; font-size: 11px; }
.site-footer { margin-top: 72px; border-top: 1px solid var(--border); background: #fff; }
.footer-inner { width: min(1200px, calc(100% - 48px)); min-height: 100px; display: flex; align-items: center; gap: 60px; margin: auto; color: var(--muted); font-size: 12px; }
.footer-inner > div { display: flex; align-items: baseline; gap: 10px; }
.footer-inner strong { color: var(--text); font-size: 15px; }
.footer-inner > div span { font-size: 11px; }
.footer-inner nav { display: flex; gap: 24px; }
.footer-inner nav a:hover { color: var(--primary); }
.footer-inner > p { margin-left: auto; }

/* Home */
.home-page { padding-top: 44px; }
.welcome-panel { display: flex; align-items: center; justify-content: space-between; gap: 30px; }
.subtle-label, .breadcrumb { color: var(--primary); font-size: 12px; font-weight: 550; }
.welcome-panel h1 { margin: 8px 0 10px; font-size: 34px; line-height: 1.3; letter-spacing: -.02em; }
.welcome-panel p { margin: 0; color: var(--muted); font-size: 15px; }
.home-search { height: 58px; display: flex; align-items: center; gap: 12px; margin-top: 34px; padding: 0 9px 0 17px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: #fff; box-shadow: 0 2px 8px rgba(32,36,42,.04); }
.home-search > span { color: var(--muted); font-size: 24px; transform: rotate(-15deg); }
.home-search input { height: 100%; flex: 1; border: 0; outline: 0; background: transparent; font-size: 14px; }
.home-search button { height: 40px; padding: 0 20px; border: 0; border-radius: 6px; color: #fff; background: var(--primary); font-size: 13px; }
.overview-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-top: 22px; }
.overview-grid > a { position: relative; min-height: 132px; display: grid; grid-template-columns: 42px 1fr; align-content: center; column-gap: 13px; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; transition: border-color .2s, transform .2s; }
.overview-grid > a:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.overview-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 8px; font-size: 14px; font-weight: 650; }
.overview-icon.blue { color: var(--primary); background: var(--primary-soft); }
.overview-icon.green { color: var(--green); background: var(--green-soft); }
.overview-icon.purple { color: var(--purple); background: var(--purple-soft); }
.overview-icon.orange { color: var(--orange); background: var(--orange-soft); }
.overview-grid > a > div:nth-child(2) { display: flex; align-items: baseline; gap: 7px; }
.overview-grid strong { font-size: 25px; }
.overview-grid > a > div:nth-child(2) span { color: #454b54; font-size: 13px; }
.overview-grid p { grid-column: 2; margin: -7px 0 0; color: var(--muted); font-size: 11px; }
.overview-grid > a > i { position: absolute; right: 17px; top: 18px; color: var(--subtle); font-style: normal; }
.home-columns { display: grid; grid-template-columns: minmax(0,1.7fr) minmax(300px,.8fr); gap: 16px; margin-top: 32px; }
.content-card { border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.section-bar { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.section-bar > div:first-child { display: flex; align-items: baseline; gap: 10px; }
.section-bar h2 { margin: 0; font-size: 16px; }
.section-bar span { color: var(--muted); font-size: 11px; }
.section-bar > a, .section-bar > button { padding: 0; border: 0; color: var(--primary); background: transparent; font-size: 12px; }
.featured-event { display: grid; grid-template-columns: 250px 1fr; gap: 20px; padding: 20px; border-bottom: 1px solid var(--border); }
.featured-event img { width: 250px; height: 160px; object-fit: cover; border-radius: 6px; }
.featured-event > div { display: flex; flex-direction: column; align-items: flex-start; }
.category-pill { display: inline-flex; align-items: center; min-height: 22px; padding: 0 8px; border-radius: 4px; color: var(--primary); background: var(--primary-soft); font-size: 10px; font-weight: 550; }
.category-pill.green { color: var(--green); background: var(--green-soft); }
.category-pill.gray { color: #626a75; background: #eff1f3; }
.featured-event h3 { margin: 14px 0 8px; font-size: 19px; }
.featured-event p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.featured-event footer { width: 100%; display: flex; flex-wrap: wrap; gap: 14px; margin-top: auto; color: var(--subtle); font-size: 10px; }
.event-row-list > a { min-height: 70px; display: grid; grid-template-columns: 94px 1fr 20px; align-items: center; gap: 15px; padding: 10px 20px; border-bottom: 1px solid var(--border); }
.event-row-list > a:last-child { border-bottom: 0; }
.event-row-list > a:hover { background: var(--surface-soft); }
.event-row-list time { color: var(--muted); font-size: 11px; }
.event-row-list div { display: flex; flex-direction: column; gap: 6px; }
.event-row-list b { font-size: 13px; }
.event-row-list span { color: var(--muted); font-size: 10px; }
.event-row-list i { color: var(--subtle); font-style: normal; }
.recent-people { overflow: hidden; }
.person-row { min-height: 91px; display: grid; grid-template-columns: 52px 1fr 18px; align-items: center; gap: 13px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.person-row:last-child { border-bottom: 0; }
.person-row:hover { background: var(--surface-soft); }
.person-row img, .person-placeholder { width: 52px; height: 52px; object-fit: cover; border-radius: 50%; }
.person-placeholder { display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); font-size: 14px; font-weight: 600; }
.person-placeholder.green { color: var(--green); background: var(--green-soft); }
.person-placeholder.purple { color: var(--purple); background: var(--purple-soft); }
.person-row > div { display: flex; flex-direction: column; gap: 4px; }
.person-row b { font-size: 13px; }
.person-row span, .person-row small { color: var(--muted); font-size: 10px; }
.person-row small { color: var(--subtle); }
.person-row > i { color: var(--subtle); font-style: normal; }
.quick-timeline, .home-media { margin-top: 16px; }
.timeline-strip { display: grid; grid-template-columns: repeat(5,1fr); padding: 26px 24px 30px; }
.timeline-strip > div { position: relative; min-width: 0; padding-right: 16px; }
.timeline-strip > div::after { content: ""; position: absolute; left: 10px; right: 0; top: 36px; height: 2px; background: var(--border); }
.timeline-strip > div:last-child::after { display: none; }
.timeline-strip time { display: block; height: 18px; color: var(--muted); font-size: 11px; line-height: 18px; }
.timeline-strip i { position: relative; z-index: 2; width: 10px; height: 10px; display: block; margin: 8px 0 14px; border: 2px solid #fff; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.timeline-strip b { display: block; overflow: hidden; margin: 0; font-size: 12px; line-height: 18px; text-overflow: ellipsis; white-space: nowrap; }
.timeline-strip span { display: block; margin-top: 4px; color: var(--subtle); font-size: 9px; line-height: 14px; }
.home-media-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 10px; padding: 18px; }
.home-media-grid a { position: relative; height: 190px; overflow: hidden; border-radius: 6px; }
.home-media-grid img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.home-media-grid a:hover img { transform: scale(1.02); }
.home-media-grid span { position: absolute; inset: auto 0 0; padding: 30px 12px 12px; color: #fff; background: linear-gradient(transparent,rgba(0,0,0,.62)); font-size: 11px; }

/* Shared directory pages */
.directory-page { padding-top: 42px; }
.page-heading { min-height: 116px; display: flex; align-items: flex-start; justify-content: space-between; gap: 30px; padding-bottom: 30px; }
.page-heading h1 { margin: 7px 0 8px; font-size: 32px; letter-spacing: -.02em; }
.page-heading p { max-width: 680px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.directory-toolbar { min-height: 64px; display: flex; align-items: center; gap: 8px; padding: 11px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.search-field { height: 40px; min-width: 290px; display: flex; align-items: center; gap: 8px; flex: 1; padding: 0 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-soft); }
.search-field > span { color: var(--muted); font-size: 19px; transform: rotate(-15deg); }
.search-field input { min-width: 0; height: 100%; flex: 1; border: 0; outline: 0; background: transparent; font-size: 12px; }
.search-field.compact { max-width: 250px; min-width: 180px; }
.filter-button, .segmented button { height: 36px; padding: 0 13px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--muted); font-size: 11px; }
.filter-button:hover, .filter-button.active, .segmented button.active { color: var(--primary); background: var(--primary-soft); }
.directory-toolbar select, .events-searchbar select { height: 40px; padding: 0 34px 0 12px; border: 1px solid var(--border); border-radius: 6px; outline: 0; background: #fff; color: #515862; font-size: 11px; }
.segmented { display: flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: 6px; }
.segmented button { height: 34px; border: 0; }
.directory-summary, .media-count-row { min-height: 60px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; }
.directory-summary > div, .media-count-row > div { display: flex; gap: 3px; }
.directory-summary button, .media-count-row button { min-height: 30px; padding: 0 10px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 11px; }
.directory-summary button.active, .media-count-row button.active { color: var(--primary); background: var(--primary-soft); }
.people-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
.person-card { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; transition: transform .2s, border-color .2s; }
.person-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.person-card-media { width: 100%; height: 255px; }
img.person-card-media { display: block; object-fit: cover; object-position: center 28%; }
.person-card-placeholder { display: grid; place-items: center; color: #52606c; background: #e8edf2; }
.person-card-placeholder > span { max-width: 82%; font-size: clamp(28px, 3.4vw, 46px); font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; text-align: center; }
.person-card-body { padding: 17px 18px; }
.person-card-body h2 { display: inline; margin: 0 8px 0 0; font-size: 17px; }
.person-card-body > span { color: var(--muted); font-size: 11px; }
.person-card-body > p { margin: 9px 0 16px; color: var(--muted); font-size: 11px; }
.person-card-body footer { display: flex; gap: 16px; padding-top: 13px; border-top: 1px solid var(--border); color: var(--subtle); font-size: 10px; }
.load-more { min-width: 150px; height: 40px; display: block; margin: 28px auto 0; border: 1px solid var(--border-strong); border-radius: 6px; background: #fff; color: var(--muted); font-size: 12px; }

/* Event directory */
.events-searchbar { display: flex; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.event-directory-layout { display: grid; grid-template-columns: 220px 1fr; gap: 18px; margin-top: 18px; }
.event-catalog { align-self: start; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.event-catalog h2 { margin: 0 0 12px; font-size: 14px; }
.event-catalog nav { display: flex; flex-direction: column; margin-inline: -8px; }
.event-catalog nav a { min-height: 36px; display: flex; align-items: center; justify-content: space-between; padding: 0 8px; border-radius: 5px; color: var(--muted); font-size: 11px; }
.event-catalog nav a:hover, .event-catalog nav a.active { color: var(--primary); background: var(--primary-soft); }
.event-catalog nav span { color: var(--subtle); }
.event-catalog h3 { margin: 24px 0 10px; padding-top: 18px; border-top: 1px solid var(--border); font-size: 11px; }
.catalog-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.catalog-filters button { height: 28px; padding: 0 9px; border: 1px solid var(--border); border-radius: 5px; background: #fff; color: var(--muted); font-size: 10px; }
.catalog-filters button.active { color: var(--primary); border-color: #b7c9de; background: var(--primary-soft); }
.check-row { display: flex; align-items: center; gap: 7px; margin-top: 9px; color: var(--muted); font-size: 10px; }
.event-results { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.result-summary { min-height: 51px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 11px; }
.result-summary button { border: 0; color: var(--primary); background: transparent; font-size: 11px; }
.event-list-card { min-height: 152px; display: grid; grid-template-columns: 76px 1fr 24px; gap: 18px; padding: 22px 18px; border-bottom: 1px solid var(--border); }
.event-list-card:last-child { border-bottom: 0; }
.event-list-card:hover { background: var(--surface-soft); }
.event-list-card > time { display: flex; flex-direction: column; align-items: center; justify-content: center; align-self: start; width: 66px; height: 66px; border: 1px solid var(--border); border-radius: 7px; background: #fff; }
.event-list-card time b { font-size: 17px; }
.event-list-card time span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.event-list-main > div:first-child { display: flex; align-items: center; gap: 10px; }
.event-list-main h2 { margin: 0; font-size: 16px; }
.event-list-main > p { margin: 12px 0 17px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.event-list-main footer { display: flex; align-items: center; gap: 25px; color: var(--subtle); font-size: 10px; }
.mini-avatars { display: flex; align-items: center; }
.mini-avatars i { width: 24px; height: 24px; display: grid; place-items: center; margin-right: -5px; border: 2px solid #fff; border-radius: 50%; color: var(--primary); background: var(--primary-soft); font-size: 8px; font-style: normal; }
.mini-avatars span { margin-left: 11px; }
.row-arrow { align-self: center; color: var(--subtle); font-style: normal; }
.empty-state { padding: 80px 30px; text-align: center; }
.empty-state b { font-size: 15px; }
.empty-state p { color: var(--muted); font-size: 12px; }

/* Detail pages */
.detail-page { padding-top: 0; }
.breadcrumbs { min-height: 54px; display: flex; align-items: center; gap: 9px; color: var(--subtle); font-size: 10px; }
.breadcrumbs b { color: var(--muted); font-weight: 500; }
.person-detail-header { display: grid; grid-template-columns: 190px 1fr auto; align-items: center; gap: 28px; padding: 30px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.person-detail-header > img { width: 190px; height: 220px; object-fit: cover; border-radius: 7px; }
.title-meta { display: flex; align-items: center; gap: 11px; color: var(--muted); font-size: 10px; }
.status-active { color: var(--green); }
.person-title h1 { margin: 16px 0 7px; font-size: 32px; }
.alt-name { margin: 0; color: var(--muted); font-size: 12px; }
.lead { max-width: 650px; margin: 22px 0 17px; color: #4f5660; font-size: 14px; line-height: 1.8; }
.tag-list { display: flex; gap: 7px; }
.tag-list span { padding: 5px 9px; border-radius: 4px; color: var(--muted); background: #f0f2f4; font-size: 10px; }
.detail-actions { align-self: start; display: flex; gap: 7px; }
.detail-actions button { height: 34px; padding: 0 12px; border: 1px solid var(--border); border-radius: 5px; background: #fff; font-size: 11px; }
.detail-layout { display: grid; grid-template-columns: minmax(0,1fr) 290px; gap: 20px; margin-top: 18px; }
.detail-article { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.inline-toc { min-height: 58px; display: flex; align-items: center; gap: 20px; padding: 0 28px; border-bottom: 1px solid var(--border); background: var(--surface-soft); }
.inline-toc b { font-size: 11px; }
.inline-toc a { color: var(--muted); font-size: 10px; }
.inline-toc a:hover { color: var(--primary); }
.detail-article > section { padding: 32px 36px; border-bottom: 1px solid var(--border); scroll-margin-top: 80px; }
.detail-article > section:last-child { border-bottom: 0; }
.detail-article h2 { margin: 0 0 22px; font-size: 20px; }
.detail-article h3 { margin: 25px 0 10px; font-size: 14px; }
.detail-article > section > p { margin: 0 0 16px; color: #4f5660; font-size: 13px; line-height: 1.9; }
.info-callout { margin-top: 22px; padding: 16px 18px; border-left: 3px solid var(--primary); background: var(--primary-soft); }
.info-callout b { font-size: 11px; }
.info-callout p { margin: 7px 0 0; color: #53667d; font-size: 11px; line-height: 1.7; }
.section-title-row { display: flex; align-items: baseline; justify-content: space-between; }
.section-title-row a { color: var(--primary); font-size: 10px; }
.linked-list { border: 1px solid var(--border); border-radius: 6px; }
.linked-list > a { min-height: 67px; display: grid; grid-template-columns: 90px 1fr 20px; align-items: center; gap: 12px; padding: 0 15px; border-bottom: 1px solid var(--border); }
.linked-list > a:last-child { border-bottom: 0; }
.linked-list > a:hover { background: var(--surface-soft); }
.linked-list time { color: var(--muted); font-size: 10px; }
.linked-list > a > div { display: flex; flex-direction: column; gap: 5px; }
.linked-list b { font-size: 12px; }
.linked-list span { color: var(--muted); font-size: 9px; }
.linked-list i { color: var(--subtle); font-style: normal; }
.relation-cards { display: grid; grid-template-columns: repeat(3,1fr); gap: 9px; }
.relation-cards > div { min-height: 76px; display: flex; align-items: center; gap: 11px; padding: 12px; border: 1px solid var(--border); border-radius: 6px; }
.initial-avatar { width: 36px; height: 36px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: var(--primary); background: var(--primary-soft); font-size: 11px; }
.initial-avatar.green { color: var(--green); background: var(--green-soft); }
.initial-avatar.gray { color: #646b74; background: #eff1f3; }
.relation-cards p { display: flex; flex-direction: column; gap: 5px; margin: 0; }
.relation-cards b { font-size: 11px; }
.relation-cards small { color: var(--muted); font-size: 8px; }
.detail-media-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 9px; }
.detail-media-grid a { overflow: hidden; border: 1px solid var(--border); border-radius: 6px; }
.detail-media-grid img { width: 100%; height: 160px; object-fit: cover; }
.detail-media-grid span { min-height: 40px; display: flex; align-items: center; padding: 8px 10px; font-size: 9px; }
.source-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
.source-list li { min-height: 72px; display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); }
.source-list li > span { color: var(--subtle); font-size: 10px; }
.source-list b { font-size: 11px; }
.source-list p { margin: 6px 0 0; color: var(--muted); font-size: 9px; }
.source-list em { color: var(--muted); font-size: 9px; font-style: normal; }
.facts-panel { align-self: start; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.facts-panel > header { min-height: 48px; display: flex; align-items: center; padding: 0 17px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; }
.facts-panel dl { margin: 0; padding: 5px 17px; }
.facts-panel dl > div { display: grid; grid-template-columns: 70px 1fr; padding: 12px 0; border-bottom: 1px solid var(--border); }
.facts-panel dt { color: var(--muted); font-size: 9px; }
.facts-panel dd { margin: 0; font-size: 10px; line-height: 1.6; }
.facts-status { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 15px 17px; font-size: 9px; }
.facts-status span { color: var(--muted); }
.facts-status > div { grid-column: 1/-1; height: 4px; overflow: hidden; border-radius: 2px; background: #edf0f2; }
.facts-status i { display: block; height: 100%; background: var(--green); }
.facts-panel > footer { display: flex; align-items: center; justify-content: space-between; padding: 14px 17px; border-top: 1px solid var(--border); background: var(--surface-soft); color: var(--muted); font-size: 9px; }
.facts-panel > footer button { padding: 0; border: 0; color: var(--primary); background: transparent; font-size: 9px; }

/* Event detail */
.event-detail-header { padding: 36px; border: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; background: #fff; }
.event-detail-header h1 { margin: 16px 0 10px; font-size: 32px; }
.event-detail-header > p { margin: 0; color: var(--muted); font-size: 14px; }
.event-facts { display: grid; grid-template-columns: repeat(4,1fr); margin-top: 30px; border: 1px solid var(--border); border-radius: 6px; }
.event-facts > div { min-height: 84px; display: flex; flex-direction: column; justify-content: center; padding: 14px 18px; border-right: 1px solid var(--border); }
.event-facts > div:last-child { border-right: 0; }
.event-facts span { color: var(--muted); font-size: 9px; }
.event-facts b { margin-top: 7px; font-size: 12px; }
.event-facts small { margin-top: 5px; color: var(--subtle); font-size: 8px; }
.event-hero-image { position: relative; overflow: hidden; margin: 0; border: 1px solid var(--border); border-top: 0; background: #e8edf2; }
.event-hero-open { width: 100%; display: block; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.event-hero-image img { width: 100%; height: 480px; display: block; object-fit: cover; transition: opacity .18s ease, transform .5s ease; }
.event-hero-image.is-changing img { opacity: .28; transform: scale(1.008); }
.event-hero-caption { position: absolute; z-index: 2; inset: auto 0 0; min-height: 94px; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 42px 24px 18px; color: #fff; background: linear-gradient(transparent,rgba(8,14,20,.76)); pointer-events: none; }
.event-hero-caption > div { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.event-hero-caption b { overflow: hidden; font-size: 16px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.event-hero-caption span { overflow: hidden; color: rgba(255,255,255,.82); font-size: 11px; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }
.event-hero-caption small { flex: none; color: rgba(255,255,255,.82); font-size: 11px; }
.event-hero-next { position: absolute; z-index: 4; top: 18px; right: 18px; min-height: 34px; display: flex; align-items: center; gap: 6px; padding: 0 12px; border: 1px solid rgba(255,255,255,.5); border-radius: 18px; color: #fff; background: rgba(18,25,33,.5); backdrop-filter: blur(5px); font-size: 12px; }
.event-hero-next:hover { background: rgba(18,25,33,.72); }
.event-hero-timer { position: absolute; z-index: 4; inset: auto 0 0; height: 3px; background: rgba(255,255,255,.2); pointer-events: none; }
.event-hero-timer i { width: 100%; height: 100%; display: block; background: rgba(255,255,255,.88); transform: scaleX(0); transform-origin: left; }
.rich-content [data-markdown-image-preview] { cursor: zoom-in; }
.rich-content [data-markdown-image-preview]:focus-visible { outline: 3px solid rgba(63,102,149,.56); outline-offset: 3px; }
.event-detail-layout { display: grid; grid-template-columns: 210px minmax(0,1fr); gap: 18px; margin-top: 18px; }
.detail-toc { position: sticky; top: 82px; align-self: start; display: flex; flex-direction: column; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.detail-toc > b { padding: 8px 9px 12px; font-size: 12px; }
.detail-toc > a { min-height: 36px; display: flex; align-items: center; padding: 0 9px; border-radius: 5px; color: var(--muted); font-size: 10px; }
.detail-toc > a:hover, .detail-toc > a.active { color: var(--primary); background: var(--primary-soft); }
.detail-toc > a:last-child { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); border-radius: 0; color: var(--primary); }
.summary-box { display: grid; grid-template-columns: repeat(4,1fr); margin-top: 24px; border: 1px solid var(--border); border-radius: 6px; }
.summary-box > div { min-height: 72px; display: flex; flex-direction: column; justify-content: center; padding: 12px; border-right: 1px solid var(--border); }
.summary-box > div:last-child { border-right: 0; }
.summary-box span { color: var(--muted); font-size: 8px; }
.summary-box b { margin-top: 6px; font-size: 12px; }
.related-people-table { width: 100%; border-collapse: collapse; font-size: 10px; }
.related-people-table th { padding: 10px; color: var(--muted); background: var(--surface-soft); text-align: left; font-weight: 500; }
.related-people-table td { padding: 12px 10px; border-bottom: 1px solid var(--border); }
.related-people-table td:first-child, .related-people-table td:first-child a { display: flex; align-items: center; gap: 9px; }
.quote-record { padding: 18px 20px; margin-top: 10px; border: 1px solid var(--border); border-radius: 6px; }
.quote-record > span { color: var(--muted); font-size: 9px; }
.quote-record blockquote { margin: 12px 0 0; font-size: 14px; line-height: 1.8; }

/* Timeline */
.timeline-toolbar { flex-wrap: wrap; }
.timeline-layout { display: grid; grid-template-columns: 170px 1fr; gap: 18px; margin-top: 18px; }
.decade-nav { position: sticky; top: 82px; align-self: start; display: flex; flex-direction: column; padding: 15px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.decade-nav b { padding: 8px; font-size: 11px; }
.decade-nav a { min-height: 36px; display: flex; align-items: center; padding: 0 8px; border-radius: 5px; color: var(--muted); font-size: 10px; }
.decade-nav a:hover { color: var(--primary); background: var(--primary-soft); }
.timeline-list { padding: 0 24px 30px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.timeline-year-group { position: relative; padding: 28px 0 8px; scroll-margin-top: 80px; }
.timeline-year-group::before { content: ""; position: absolute; left: 95px; top: 72px; bottom: -8px; width: 1px; background: var(--border); }
.timeline-year-group:last-child::before { bottom: 30px; }
.timeline-year-group > header { min-height: 42px; display: flex; align-items: baseline; gap: 10px; border-bottom: 1px solid var(--border); }
.timeline-year-group > header b { font-size: 22px; }
.timeline-year-group > header span { color: var(--muted); font-size: 9px; }
.timeline-entry { position: relative; display: grid; grid-template-columns: 72px 18px 150px 1fr 20px; gap: 14px; align-items: center; min-height: 160px; padding: 18px 0; border-bottom: 1px solid var(--border); }
.timeline-entry.text-only { grid-template-columns: 72px 18px 1fr 20px; min-height: 115px; }
.timeline-entry time { color: var(--muted); font-size: 11px; text-align: right; }
.timeline-entry > i { z-index: 2; width: 9px; height: 9px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px var(--primary); background: var(--primary); }
.timeline-entry > i.person-dot { box-shadow: 0 0 0 1px var(--green); background: var(--green); }
.timeline-entry > i.media-dot { box-shadow: 0 0 0 1px #7b828c; background: #7b828c; }
.timeline-entry > img { width: 150px; height: 112px; object-fit: cover; border-radius: 6px; }
.timeline-entry h2 { margin: 9px 0 7px; font-size: 15px; }
.timeline-entry p { margin: 0; color: var(--muted); font-size: 11px; }
.timeline-entry footer { margin-top: 13px; color: var(--subtle); font-size: 9px; }
.timeline-entry > em { color: var(--subtle); font-style: normal; }

/* Mixed relationships */
.relations-page .relationship-list { margin-top: 16px; }
.relation-workspace { margin-top: 18px; }
.graph-legend { display: flex; align-items: center; gap: 18px; }
.graph-legend > span { display: flex; align-items: center; gap: 6px; }
.legend-person { width: 10px; height: 10px; border: 2px solid var(--primary); border-radius: 50%; }
.legend-event { width: 14px; height: 9px; border: 2px solid var(--green); border-radius: 2px; }
.legend-line { width: 17px; height: 1px; background: var(--border-strong); }
.mixed-relation-graph { position: relative; height: 520px; overflow: hidden; background-image: radial-gradient(#dfe3e8 .7px, transparent .8px); background-size: 20px 20px; }
.graph-person, .graph-event { position: absolute; z-index: 3; display: flex; align-items: center; flex-direction: column; justify-content: center; text-align: center; background: #fff; box-shadow: 0 3px 12px rgba(32,36,42,.07); }
.graph-person { width: 94px; height: 94px; border: 2px solid #9fb5cf; border-radius: 50%; }
.graph-person > span { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: var(--primary); background: var(--primary-soft); font-size: 11px; }
.graph-person b { margin-top: 7px; font-size: 11px; }
.graph-event { width: 174px; min-height: 88px; padding: 12px; border: 2px solid #aec2b3; border-radius: 7px; }
.graph-event > span { color: var(--green); font-size: 8px; font-weight: 600; }
.graph-event b { margin-top: 7px; font-size: 11px; }
.graph-event small { margin-top: 5px; color: var(--muted); font-size: 8px; }
.gp-main { left: 17%; top: 35%; }
.gp-partner { left: 44%; top: 10%; }
.gp-daughter { left: 48%; bottom: 9%; }
.ge-dinner { right: 8%; top: 28%; }
.ge-move { right: 14%; bottom: 9%; }
.graph-line { position: absolute; z-index: 1; height: 1px; background: #aab3bd; transform-origin: left center; }
.graph-line span { position: absolute; left: 45%; top: -12px; padding: 2px 5px; color: var(--muted); background: var(--surface); font-size: 8px; white-space: nowrap; }
.gl-1 { width: 29%; left: 24%; top: 40%; transform: rotate(-26deg); }
.gl-2 { width: 31%; left: 24%; top: 53%; transform: rotate(25deg); }
.gl-3 { width: 51%; left: 24%; top: 48%; transform: rotate(-4deg); }
.gl-4 { width: 39%; left: 54%; top: 72%; transform: rotate(-35deg); }
.gl-5 { width: 49%; left: 24%; top: 53%; transform: rotate(19deg); }
.relation-table { font-size: 10px; }
.relation-table-head, .relation-table-row { display: grid; grid-template-columns: 1.3fr 120px 1.7fr 130px 35px; align-items: center; gap: 14px; padding: 0 20px; }
.relation-table-head { min-height: 42px; color: var(--muted); background: var(--surface-soft); }
.relation-table-row { min-height: 72px; border-top: 1px solid var(--border); }
.relation-table-row > div { display: grid; grid-template-columns: 34px 1fr; align-items: center; column-gap: 9px; }
.relation-table-row > div i { grid-row: span 2; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--primary); background: var(--primary-soft); font-style: normal; }
.relation-table-row > div i.type-event { border-radius: 5px; color: var(--green); background: var(--green-soft); }
.relation-table-row > div b { font-size: 10px; }
.relation-table-row > div small { color: var(--muted); font-size: 8px; }
.relation-label { width: max-content; padding: 5px 8px; border-radius: 10px; color: var(--purple); background: var(--purple-soft); font-size: 8px; }
.relation-table-row time { color: var(--muted); }
.relation-table-row > button { border: 0; background: transparent; color: var(--muted); }

/* Media wall */
.media-toolbar { flex-wrap: wrap; }
.masonry-wall { column-count: 4; column-gap: 10px; }
.media-tile { position: relative; width: 100%; display: block; break-inside: avoid; overflow: hidden; margin: 0 0 10px; padding: 0; border: 0; border-radius: 6px; background: #e7eaed; text-align: left; }
.media-tile img { width: 100%; object-fit: cover; transition: transform .25s; }
.media-tile.portrait img { aspect-ratio: .74; }
.media-tile.landscape img { aspect-ratio: 1.4; }
.media-tile.square img { aspect-ratio: 1; }
.media-tile:hover img { transform: scale(1.015); }
.media-overlay { position: absolute; inset: auto 0 0; display: flex; flex-direction: column; gap: 4px; padding: 34px 12px 12px; color: #fff; background: linear-gradient(transparent,rgba(0,0,0,.7)); opacity: 0; transition: opacity .2s; }
.media-tile:hover .media-overlay, .media-tile:focus-visible .media-overlay { opacity: 1; }
.media-overlay b { font-size: 11px; }
.media-overlay small { color: rgba(255,255,255,.8); font-size: 8px; }
.play-button { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; display: grid; place-items: center; padding-left: 3px; border-radius: 50%; color: #fff; background: rgba(20,23,27,.65); font-size: 13px; font-style: normal; transform: translate(-50%,-50%); backdrop-filter: blur(3px); }
.media-lightbox { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 40px; background: rgba(20,23,27,.9); }
.media-lightbox > div { position: relative; max-width: min(1100px,90vw); max-height: 90vh; background: #fff; }
.media-lightbox img { max-width: min(1100px,90vw); max-height: calc(90vh - 70px); object-fit: contain; background: #111; }
.media-lightbox footer { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 11px 15px; }
.media-lightbox footer > div { display: flex; flex-direction: column; gap: 5px; }
.media-lightbox footer b { font-size: 12px; }
.media-lightbox footer span { color: var(--muted); font-size: 9px; }
.media-lightbox footer button { border: 0; color: var(--primary); background: transparent; font-size: 10px; }
.lightbox-close { position: fixed; right: 25px; top: 20px; border: 0; color: #fff; background: transparent; font-size: 32px; }
.lightbox-play { position: absolute; left: 50%; top: 45%; width: 56px; height: 56px; display: grid; place-items: center; padding-left: 4px; border-radius: 50%; color: #fff; background: rgba(0,0,0,.6); font-style: normal; transform: translate(-50%,-50%); }

/* Create entry */
.create-page-wrap { min-height: 100vh; }
.create-shell { padding-top: 42px; }
.create-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 30px; }
.entry-type { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; }
.entry-type span { color: var(--primary); }
.entry-type i { width: 24px; height: 1px; background: var(--border-strong); }
.create-header h1 { margin: 8px 0; font-size: 30px; }
.create-header > div:first-child > p { margin: 0; color: var(--muted); font-size: 13px; }
.draft-status { display: flex; align-items: center; gap: 9px; padding: 10px 13px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.draft-status > span { color: var(--green); font-size: 8px; }
.draft-status p { display: flex; flex-direction: column; gap: 3px; margin: 0; }
.draft-status b { font-size: 9px; }
.draft-status small { color: var(--muted); font-size: 7px; }
.entry-type-picker { margin-top: 30px; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.type-picker-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 0 2px 16px; }
.type-picker-heading > div { display: flex; align-items: baseline; gap: 10px; }
.type-picker-heading b { font-size: 13px; }
.type-picker-heading span, .type-picker-heading p { margin: 0; color: var(--muted); font-size: 9px; }
.type-picker-heading strong { color: var(--primary); font-weight: 600; }
.entry-type-switcher { display: grid; grid-template-columns: repeat(4,1fr); overflow: hidden; border: 1px solid var(--border); border-radius: 7px; }
.entry-type-switcher button { position: relative; min-height: 76px; display: grid; grid-template-columns: 34px 1fr 18px; align-items: center; gap: 10px; padding: 12px 14px; border: 0; border-right: 1px solid var(--border); background: #fff; text-align: left; }
.entry-type-switcher button:last-child { border-right: 0; }
.entry-type-switcher button:hover { background: var(--surface-soft); }
.entry-type-switcher button.active { background: var(--primary-soft); box-shadow: inset 0 -3px 0 var(--primary); }
.entry-type-switcher button > i { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 6px; color: var(--primary); background: var(--primary-soft); font-size: 12px; font-style: normal; }
.entry-type-switcher button.active > i { color: #fff; background: var(--primary); }
.entry-type-switcher button > div { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.entry-type-switcher b { font-size: 11px; }
.entry-type-switcher span { overflow: hidden; color: var(--muted); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.entry-type-switcher em { display: none; color: var(--primary); font-size: 12px; font-style: normal; }
.entry-type-switcher button.active em { display: block; }
.editor-layout { display: grid; grid-template-columns: 220px minmax(0,760px); justify-content: center; gap: 18px; margin-top: 18px; }
.editor-steps { align-self: start; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.editor-steps > span { color: var(--muted); font-size: 9px; }
.editor-steps ol { margin: 15px 0 0; padding: 0; list-style: none; }
.editor-steps li { display: flex; align-items: center; gap: 10px; min-height: 56px; color: var(--muted); }
.editor-steps li > i { width: 25px; height: 25px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--border); border-radius: 50%; background: #fff; font-size: 8px; font-style: normal; }
.editor-steps li.active { color: var(--text); }
.editor-steps li.active > i { color: #fff; border-color: var(--primary); background: var(--primary); }
.editor-steps li > div { display: flex; flex-direction: column; gap: 4px; }
.editor-steps li b { font-size: 10px; }
.editor-steps li small { color: var(--subtle); font-size: 7px; }
.editor-tip { margin-top: 15px; padding: 12px; border-radius: 6px; background: var(--surface-soft); }
.editor-tip b { font-size: 9px; }
.editor-tip p { margin: 6px 0 0; color: var(--muted); font-size: 8px; line-height: 1.6; }
.entry-form { padding: 30px 36px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.form-heading { display: grid; grid-template-columns: 34px 1fr; padding-bottom: 22px; border-bottom: 1px solid var(--border); }
.form-heading > span { color: var(--primary); font-size: 10px; }
.form-heading h2 { margin: 0; font-size: 18px; }
.form-heading p { margin: 6px 0 0; color: var(--muted); font-size: 9px; }
.entry-form label > span, .cover-uploader > span { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; font-size: 10px; font-weight: 550; }
.entry-form label > span i { color: var(--danger); font-size: 7px; font-style: normal; }
.full-field { display: block; margin-top: 25px; }
.entry-form input, .entry-form textarea, .entry-form select { width: 100%; border: 1px solid var(--border); border-radius: 6px; outline: none; background: #fff; font-size: 11px; }
.entry-form input, .entry-form select { height: 40px; padding: 0 11px; }
.entry-form textarea { padding: 10px 11px; resize: vertical; }
.entry-form input:focus, .entry-form textarea:focus, .entry-form select:focus { border-color: #9ab2ce; box-shadow: 0 0 0 3px var(--primary-soft); }
.entry-form label > small { display: block; margin-top: 6px; color: var(--subtle); font-size: 7px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 25px; }
.upload-zone, .cover-uploader > div { display: flex; align-items: center; gap: 14px; margin-top: 24px; padding: 20px; border: 1px dashed var(--border-strong); border-radius: 6px; background: var(--surface-soft); }
.upload-zone > i, .cover-uploader > div > i { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 6px; background: #fff; font-style: normal; }
.upload-zone > div, .cover-uploader p { flex: 1; margin: 0; }
.upload-zone b, .cover-uploader b { font-size: 10px; }
.upload-zone p, .cover-uploader small { margin: 5px 0 0; color: var(--muted); font-size: 8px; }
.upload-zone button, .cover-uploader button { height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: 5px; background: #fff; font-size: 8px; }
.cover-uploader { margin-top: 28px; }
.cover-uploader > div { margin-top: 0; }
.cover-uploader p { display: flex; flex-direction: column; }
.privacy-fields { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin: 28px 0 0; padding: 22px 0 0; border: 0; border-top: 1px solid var(--border); }
.privacy-fields legend { margin-bottom: 12px; font-size: 10px; font-weight: 550; }
.privacy-fields label { position: relative; }
.privacy-fields input { position: absolute; opacity: 0; }
.privacy-fields label > span { min-height: 60px; display: flex; flex-direction: column; align-items: flex-start; margin: 0; padding: 11px; border: 1px solid var(--border); border-radius: 6px; }
.privacy-fields input:checked + span { border-color: #9eb6d1; background: var(--primary-soft); }
.privacy-fields b { font-size: 9px; }
.privacy-fields small { margin-top: 5px; color: var(--muted); font-size: 7px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--border); }
.form-actions a, .form-actions button { height: 36px; display: inline-flex; align-items: center; padding: 0 13px; border: 1px solid var(--border); border-radius: 5px; background: #fff; font-size: 9px; }
.form-actions a { margin-right: auto; border: 0; }
.form-actions button.primary { gap: 18px; color: #fff; border-color: var(--primary); background: var(--primary); }
.save-toast { position: fixed; z-index: 80; right: 24px; bottom: 24px; display: flex; align-items: center; gap: 11px; min-width: 240px; padding: 14px; border-radius: 7px; color: #fff; background: #344d3c; box-shadow: 0 12px 30px rgba(0,0,0,.16); }
.save-toast > span { width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.4); border-radius: 50%; }
.save-toast p { display: flex; flex-direction: column; gap: 3px; margin: 0; }
.save-toast b { font-size: 9px; }
.save-toast small { color: rgba(255,255,255,.75); font-size: 7px; }

@media (max-width: 1040px) {
  .main-nav a { padding-inline: 10px; }
  .global-search span:nth-child(2), .global-search kbd { display: none; }
  .header-actions { min-width: auto; }
  .overview-grid { grid-template-columns: repeat(2,1fr); }
  .home-columns { grid-template-columns: 1fr; }
  .people-grid { grid-template-columns: repeat(2,1fr); }
  .masonry-wall { column-count: 3; }
  .relation-table-head, .relation-table-row { grid-template-columns: 1.1fr 90px 1.3fr 100px 25px; }
}

@media (max-width: 800px) {
  .page-container, .header-inner, .footer-inner { width: min(100% - 28px, 680px); }
  .site-header { height: auto; position: relative; }
  .header-inner { min-height: 62px; flex-wrap: wrap; padding-top: 10px; }
  .brand { min-width: 0; margin-right: auto; }
  .main-nav { order: 3; width: 100%; height: 42px; justify-content: flex-start; overflow-x: auto; }
  .main-nav a { flex: 0 0 auto; }
  .global-search { display: none; }
  .demo-notice { font-size: 9px; }
  .welcome-panel, .page-heading { flex-direction: column; }
  .welcome-panel h1 { font-size: 29px; }
  .featured-event { grid-template-columns: 190px 1fr; }
  .featured-event img { width: 190px; }
  .timeline-strip { overflow-x: auto; grid-template-columns: repeat(5,150px); }
  .directory-toolbar { flex-wrap: wrap; }
  .search-field { min-width: 100%; }
  .event-directory-layout, .timeline-layout, .event-detail-layout { grid-template-columns: 1fr; }
  .event-catalog, .decade-nav, .detail-toc { position: static; }
  .event-catalog nav { display: grid; grid-template-columns: repeat(2,1fr); }
  .person-detail-header { grid-template-columns: 150px 1fr; }
  .person-detail-header > img { width: 150px; height: 180px; }
  .detail-actions { grid-column: 1/-1; }
  .detail-layout { grid-template-columns: 1fr; }
  .facts-panel { grid-row: 1; }
  .event-facts { grid-template-columns: repeat(2,1fr); }
  .event-facts > div:nth-child(2) { border-right: 0; }
  .event-facts > div:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .event-hero-image img { height: 370px; }
  .detail-toc { flex-direction: row; flex-wrap: wrap; }
  .detail-toc > b { width: 100%; }
  .detail-toc > a:last-child { width: 100%; }
  .masonry-wall { column-count: 2; }
  .mixed-relation-graph { height: 600px; }
  .gp-main { left: 8%; }
  .gp-partner { left: 40%; }
  .gp-daughter { left: 38%; }
  .ge-dinner { right: 3%; }
  .ge-move { right: 5%; }
  .relation-table { overflow-x: auto; }
  .relation-table-head, .relation-table-row { min-width: 760px; }
  .entry-type-switcher { grid-template-columns: repeat(2,1fr); }
  .entry-type-switcher button:nth-child(2) { border-right: 0; }
  .entry-type-switcher button:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .editor-layout { grid-template-columns: 1fr; }
  .editor-steps { display: none; }
  .footer-inner { align-items: flex-start; flex-direction: column; gap: 18px; padding: 28px 0; }
  .footer-inner > p { margin: 0; }
}

@media (max-width: 520px) {
  .brand-name { font-size: 15px; }
  .primary-action.small { font-size: 0; }
  .primary-action.small::after { content: "＋ 新建"; font-size: 11px; }
  .home-page, .directory-page { padding-top: 30px; }
  .welcome-panel h1, .page-heading h1 { font-size: 27px; }
  .overview-grid { grid-template-columns: 1fr; }
  .featured-event { grid-template-columns: 1fr; }
  .featured-event img { width: 100%; height: 190px; }
  .event-row-list > a { grid-template-columns: 76px 1fr 15px; padding-inline: 13px; }
  .home-media-grid { grid-template-columns: 1fr; }
  .people-grid { grid-template-columns: 1fr; }
  .person-card-media { height: 300px; }
  .events-searchbar { flex-direction: column; }
  .event-list-card { grid-template-columns: 60px 1fr; gap: 12px; padding-inline: 12px; }
  .event-list-card > time { width: 56px; height: 58px; }
  .event-list-card .row-arrow { display: none; }
  .event-list-main footer { align-items: flex-start; flex-direction: column; gap: 9px; }
  .person-detail-header { grid-template-columns: 1fr; padding: 20px; }
  .person-detail-header > img { width: 130px; height: 150px; }
  .detail-article > section { padding: 25px 20px; }
  .inline-toc { overflow-x: auto; padding-inline: 18px; }
  .inline-toc > * { flex: 0 0 auto; }
  .relation-cards, .detail-media-grid { grid-template-columns: 1fr; }
  .detail-media-grid img { height: 210px; }
  .event-detail-header { padding: 25px 20px; }
  .event-detail-header h1 { font-size: 27px; }
  .event-facts, .summary-box { grid-template-columns: 1fr; }
  .event-facts > div, .summary-box > div { border-right: 0; border-bottom: 1px solid var(--border); }
  .event-facts > div:last-child, .summary-box > div:last-child { border-bottom: 0; }
  .event-hero-image img { height: 270px; }
  .timeline-entry, .timeline-entry.text-only { grid-template-columns: 48px 15px 1fr; gap: 9px; }
  .timeline-entry > img { grid-column: 3; width: 100%; height: 150px; }
  .timeline-entry > div { grid-column: 3; }
  .timeline-entry > em { display: none; }
  .timeline-year-group::before { left: 67px; }
  .mixed-relation-graph { height: 700px; }
  .graph-person { width: 78px; height: 78px; }
  .graph-event { width: 140px; }
  .gp-main { left: 5%; top: 26%; }
  .gp-partner { left: 8%; top: 55%; }
  .gp-daughter { left: 10%; bottom: 5%; }
  .ge-dinner { right: 4%; top: 22%; }
  .ge-move { right: 4%; bottom: 15%; }
  .gl-1, .gl-2, .gl-3, .gl-4, .gl-5 { width: 55%; left: 24%; }
  .masonry-wall { column-count: 1; }
  .media-overlay { opacity: 1; }
  .media-lightbox { padding: 15px; }
  .type-picker-heading { align-items: flex-start; flex-direction: column; gap: 7px; }
  .type-picker-heading > div { align-items: flex-start; flex-direction: column; gap: 5px; }
  .entry-type-picker { padding: 14px; }
  .entry-type-switcher { grid-template-columns: 1fr; }
  .entry-type-switcher button, .entry-type-switcher button:nth-child(2) { border-right: 0; border-bottom: 1px solid var(--border); }
  .entry-type-switcher button:last-child { border-bottom: 0; }
  .entry-form { padding: 24px 18px; }
  .field-row, .privacy-fields { grid-template-columns: 1fr; }
  .form-actions { flex-wrap: wrap; }
  .form-actions a { width: 100%; }
}

/* Full-stack content editing */
.person-editor-layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.portrait-editor {
  position: sticky;
  top: 92px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
}

.portrait-editor-heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}

.portrait-editor-heading b { font-size: 15px; }
.portrait-editor-heading span,
.portrait-editor > p { color: var(--muted); font-size: 12px; line-height: 1.65; }

.portrait-current {
  overflow: hidden;
  width: 100%;
  aspect-ratio: 4 / 5;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #e8edf2;
}

.portrait-current img { width: 100%; height: 100%; display: block; object-fit: cover; }
.portrait-placeholder { width: 100%; height: 100%; display: grid; place-content: center; gap: 8px; color: #607080; text-align: center; }
.portrait-placeholder span { font-size: 46px; font-weight: 650; }
.portrait-placeholder small { font-size: 12px; }
.portrait-select { width: 100%; margin-top: 12px; background: #fff; }

.portrait-crop-panel {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid #bdcddd;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(39, 54, 68, .09);
}

.portrait-canvas-wrap { overflow: hidden; border-radius: 8px; background: #20252a; }
.portrait-canvas-wrap canvas { display: block; width: 100%; height: auto; touch-action: none; }
.portrait-crop-panel label { display: grid; grid-template-columns: 78px 1fr; align-items: center; gap: 8px; margin-top: 11px; color: var(--muted); font-size: 11px; font-weight: 500; }
.portrait-crop-panel input[type="range"] { min-height: 24px; padding: 0; border: 0; }
.portrait-crop-actions { display: flex; gap: 8px; margin-top: 14px; }
.portrait-crop-actions > * { flex: 1; min-height: 36px; }
.portrait-crop-actions .primary-action { border: 0; cursor: pointer; }

.markdown-editor {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
}

.markdown-editor:focus-within { border-color: #91aac5; box-shadow: 0 0 0 3px var(--primary-soft); }
.markdown-editor-heading { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-soft); }
.markdown-editor-heading > div:first-child { display: flex; flex-direction: column; gap: 3px; }
.markdown-editor-heading b { font-size: 14px; }
.markdown-editor-heading span { color: var(--muted); font-size: 11px; font-weight: 400; }
.markdown-mode-switch { display: inline-flex; padding: 3px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.markdown-mode-switch button { min-height: 28px; padding: 0 11px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; cursor: pointer; font-size: 11px; }
.markdown-mode-switch button.active { color: var(--primary); background: var(--primary-soft); font-weight: 650; }

.markdown-toolbar { display: flex; align-items: center; gap: 3px; overflow-x: auto; padding: 7px 10px; border-bottom: 1px solid var(--border); background: #fff; }
.markdown-toolbar button { flex: 0 0 auto; min-width: 32px; min-height: 30px; padding: 0 9px; border: 1px solid transparent; border-radius: 6px; color: #465361; background: transparent; cursor: pointer; font-size: 11px; }
.markdown-toolbar button:hover { border-color: var(--border); background: var(--surface-soft); }
.markdown-toolbar [data-md-upload] { border-color: #cdd9e5; color: var(--primary); background: #f6f9fc; }
.markdown-toolbar [data-md-event-toggle] { border-color: #d8cfbf; color: #705c3d; background: #fbf8f2; }
.markdown-toolbar button:disabled { cursor: not-allowed; opacity: .45; }
.toolbar-spacer { flex: 1 0 10px; }
.markdown-event-reference { padding: 14px; border-bottom: 1px solid var(--border); background: #fbfcfd; }
.markdown-event-reference > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.markdown-event-reference > header > div { display: flex; flex-direction: column; gap: 3px; }
.markdown-event-reference > header b { font-size: 12px; }
.markdown-event-reference > header span { color: var(--muted); font-size: 10px; }
.markdown-event-reference > header button { width: 28px; height: 28px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 19px; }
.markdown-event-reference > label { display: block; margin-top: 11px; }
.markdown-event-reference > label > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.markdown-event-reference input { width: 100%; height: 36px; padding: 0 11px; border: 1px solid var(--border); border-radius: 6px; outline: 0; background: #fff; font-size: 11px; }
.markdown-event-reference input:focus { border-color: #91aac5; box-shadow: 0 0 0 3px var(--primary-soft); }
.markdown-event-reference-list { max-height: 230px; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; overflow-y: auto; margin-top: 10px; }
.markdown-event-reference-list > button { min-width: 0; min-height: 54px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 5px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px; background: #fff; text-align: left; }
.markdown-event-reference-list > button:hover { border-color: #9eb3ca; background: var(--primary-soft); }
.markdown-event-reference-list span { max-width: 100%; overflow: hidden; font-size: 11px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.markdown-event-reference-list small { max-width: 100%; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.markdown-event-reference [data-md-event-empty] { margin: 10px 0 0; color: var(--muted); font-size: 10px; }
.admin-form .markdown-editor textarea { min-height: 170px; padding: 16px; border: 0; border-radius: 0; outline: 0; background: #fff; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; font-size: 13px; line-height: 1.75; }
.admin-form .markdown-editor textarea[hidden] { display: none; }
.markdown-preview { min-height: 170px; padding: 16px; background: #fff; }
.editor-upload-status { min-height: 0; padding: 0 14px; color: #2d6b49; font-size: 11px; line-height: 1.6; }
.editor-upload-status:not(:empty) { padding-top: 8px; }
.editor-upload-status.error { color: var(--danger); }
.markdown-editor > footer { display: flex; justify-content: space-between; gap: 12px; padding: 9px 14px 11px; color: var(--muted); background: #fff; font-size: 10px; }
.markdown-editor > footer code { padding: 2px 4px; border-radius: 3px; background: var(--surface-soft); }

.rich-content { color: #3f4952; font-size: 14px; line-height: 1.9; overflow-wrap: anywhere; }
.rich-content > :first-child { margin-top: 0; }
.rich-content > :last-child { margin-bottom: 0; }
.rich-content p, .rich-content li, .rich-content blockquote, .rich-content h2, .rich-content h3, .rich-content h4, .rich-content h5 { white-space: break-spaces; }
.rich-content p { margin: 0 0 15px; }
.markdown-spacer { height: 1.25em; clear: both; }
.rich-content h2, .rich-content h3, .rich-content h4, .rich-content h5 { margin: 24px 0 10px; color: var(--text); line-height: 1.35; }
.rich-content h2 { font-size: 22px; }
.rich-content h3 { font-size: 19px; }
.rich-content h4, .rich-content h5 { font-size: 16px; }
.rich-content ul, .rich-content ol { margin: 10px 0 17px; padding-left: 24px; }
.rich-content li { margin: 4px 0; }
.rich-content blockquote { margin: 14px 0; padding: 10px 15px; border-left: 3px solid #9bb1c8; color: #52606d; background: #f5f8fb; }
.rich-content pre { overflow-x: auto; padding: 14px; border-radius: 8px; color: #e9eef3; background: #22282e; }
.rich-content code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.rich-content a { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.markdown-media { margin: 12px 0; }
.markdown-media img, .markdown-media video { display: block; width: min(100%, 760px); max-height: 70vh; border-radius: 9px; object-fit: contain; background: #111; }
.markdown-media figcaption { margin-top: 7px; color: var(--muted); font-size: 11px; }
.markdown-media-block { margin: 18px 0; }
.editor-placeholder { color: var(--muted); }
.detail-hero-simple .rich-content { margin: 4px 0 14px; color: var(--muted); }
.detail-hero-simple .rich-content .markdown-media img,
.detail-hero-simple .rich-content .markdown-media video { max-height: 360px; }
.event-detail-header > .rich-content { color: var(--muted); }
.page-heading .rich-content { max-width: 760px; margin-top: 8px; color: var(--muted); }

.relation-row { grid-template-columns: minmax(170px, 1fr) minmax(110px, .55fr) minmax(200px, 1.25fr) 72px; column-gap: 26px; padding: 14px 0; }
.relation-endpoint { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.relation-endpoint b { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; line-height: 1.35; }
.relation-endpoint small { display: block; font-size: 11px; line-height: 1.3; }
.relation-row > .relation-label { justify-self: center; max-width: 100%; text-align: center; white-space: normal; line-height: 1.4; }
.relation-row > form { justify-self: end; }
.relation-note { grid-column: 1 / -1; padding: 10px 13px; border-radius: 8px; background: var(--surface-soft); }
.relation-note .rich-content { font-size: 12px; }
.edit-danger-zone { margin-bottom: 20px; }

@media (max-width: 860px) {
  .person-editor-layout { grid-template-columns: 220px minmax(0, 1fr); gap: 18px; }
  .relation-row { grid-template-columns: minmax(130px, 1fr) minmax(90px, .5fr) minmax(150px, 1fr) auto; column-gap: 14px; }
}

@media (max-width: 680px) {
  .person-editor-layout { grid-template-columns: 1fr; }
  .portrait-editor { position: static; }
  .portrait-current { max-width: 260px; }
  .portrait-select { max-width: 260px; }
  .portrait-crop-panel { max-width: 360px; }
  .markdown-editor-heading { align-items: flex-start; flex-direction: column; }
  .markdown-editor > footer { align-items: flex-start; flex-direction: column; }
  .markdown-event-reference-list { grid-template-columns: 1fr; }
  .person-age-preview { align-items: flex-start; flex-direction: column; }
  .person-age-preview small { text-align: left; }
  .relation-row { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; }
  .relation-row > form { grid-column: 1 / -1; justify-self: end; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

.media-tile video {
  width: 100%;
  min-height: 210px;
  object-fit: cover;
  background: #15191d;
}

.media-document-icon {
  display: grid;
  min-height: 250px;
  place-items: center;
  background: #e9edf1;
  color: #586572;
  font-size: 46px;
  font-weight: 650;
}

.timeline-toolbar .segmented label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}

.timeline-toolbar .segmented label:has(input:checked) {
  color: var(--primary);
  background: var(--primary-soft);
}

.timeline-toolbar .segmented input {
  width: 13px;
  height: 13px;
  margin: 0;
}

.event-detail-header .detail-actions {
  margin-top: 20px;
}

.home-media-grid video,
.home-media-grid .media-document-icon {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

/* v1.2 detail actions, immersive editor, rich media and live relationship graph */
.detail-directory-page { padding-top: 28px; }
.detail-page-top {
  min-height: 94px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  padding-bottom: 22px;
}
.detail-page-top h1 { margin: 7px 0 0; font-size: 34px; letter-spacing: -.025em; }
.detail-top-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; padding-top: 2px; }
.person-alias { margin: 0 0 10px !important; color: var(--muted); font-size: 13px; }
.person-age-meta { color: var(--primary) !important; background: var(--primary-soft) !important; }
.person-age-preview { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 15px; border: 1px solid #d9e3ec; border-radius: 7px; background: #f7fafc; }
.person-age-preview > div { display: flex; align-items: baseline; gap: 12px; }
.person-age-preview span { color: var(--muted); font-size: 10px; }
.person-age-preview b { color: var(--primary); font-size: 14px; }
.person-age-preview small { color: var(--muted); font-size: 10px; line-height: 1.5; text-align: right; }

.markdown-editor-tools { display: flex; align-items: center; gap: 8px; }
.markdown-fullscreen-button {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--primary);
  background: #fff;
  font-size: 11px;
}
.editor-fullscreen-open { overflow: hidden; }
.markdown-editor.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  width: 100vw;
  height: 100vh;
  display: flex;
  overflow: hidden;
  flex-direction: column;
  border: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
}
.markdown-editor.is-fullscreen .markdown-editor-heading { min-height: 66px; flex: 0 0 auto; padding-inline: max(20px, calc((100vw - 1180px) / 2)); }
.markdown-editor.is-fullscreen .markdown-toolbar { min-height: 48px; flex: 0 0 auto; padding-inline: max(20px, calc((100vw - 1180px) / 2)); }
.admin-form .markdown-editor.is-fullscreen textarea,
.markdown-editor.is-fullscreen .markdown-preview {
  width: min(980px, calc(100% - 48px));
  min-height: 0;
  flex: 1 1 auto;
  align-self: center;
  overflow-y: auto;
  padding: 36px 42px;
  font-size: 15px;
  line-height: 1.9;
}
.admin-form .markdown-editor.is-fullscreen textarea { resize: none; }
.markdown-editor.is-fullscreen > footer,
.markdown-editor.is-fullscreen .editor-upload-status { flex: 0 0 auto; padding-inline: max(20px, calc((100vw - 980px) / 2)); }

.rich-content { display: flow-root; }
.markdown-media-block { display: contents; }
.markdown-media {
  position: relative;
  max-width: 100%;
  margin: 12px 0 18px;
}
.markdown-media img,
.markdown-media video {
  display: block;
  width: 100%;
  max-height: none;
  border: 0;
  border-radius: 9px;
  background: transparent;
}
.markdown-media img { height: auto; object-fit: contain; }
.markdown-media video { aspect-ratio: 16 / 9; object-fit: cover; background: #eef1f4; }
.markdown-media.media-size-small { width: min(28%, 300px); }
.markdown-media.media-size-medium { width: min(42%, 480px); }
.markdown-media.media-size-large { width: min(62%, 760px); }
.markdown-media.media-size-full { width: 100%; }
.markdown-media.media-float-left { float: left; margin: 5px 24px 18px 0; }
.markdown-media.media-float-right { float: right; margin: 5px 0 18px 24px; }
.markdown-media.media-float-none { float: none; clear: both; }
.markdown-media.is-selected { outline: 2px solid #4d82bb; outline-offset: 3px; }
.media-layout-popover {
  position: absolute;
  z-index: 5;
  top: 10px;
  right: 10px;
  width: max-content;
  max-width: calc(100vw - 40px);
  padding: 8px;
  border: 1px solid #cbd6e2;
  border-radius: 9px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 8px 24px rgba(39,54,68,.14);
}
.media-layout-popover > div { display: flex; align-items: center; gap: 3px; }
.media-layout-popover > div + div { margin-top: 5px; padding-top: 5px; border-top: 1px solid var(--border); }
.media-layout-popover span { width: 36px; color: var(--muted); font-size: 10px; }
.media-layout-popover button { min-height: 28px; padding: 0 8px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 10px; }
.media-layout-popover button:hover,
.media-layout-popover button.active { color: var(--primary); background: var(--primary-soft); }

.media-file-preview { background: #fff; }
.media-file-preview img { width: 100%; height: auto; max-height: none; object-fit: contain; background: #fff; }
.media-file-preview video { width: 100%; aspect-ratio: 16 / 9; max-height: 78vh; object-fit: cover; background: #eef1f4; }

.relation-directory-toolbar { margin-bottom: 16px; }
.relation-graph-card { overflow: hidden; margin-top: 16px; }
.relation-graph-card > .section-bar { padding-inline: 20px; }
.relation-graph-viewport {
  position: relative;
  height: 640px;
  overflow: hidden;
  border-top: 1px solid var(--border);
  outline: 0;
  background-color: #fbfcfd;
  background-image: radial-gradient(#dce2e8 .7px, transparent .8px);
  background-size: 22px 22px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.relation-graph-viewport.panning { cursor: grabbing; }
.relation-graph-stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 1400px;
  height: 850px;
  transform-origin: 0 0;
  will-change: transform;
}
.relation-graph-stage.is-animating { transition: transform .26s ease-out; }
.relation-graph-stage svg,
.relation-graph-nodes { position: absolute; inset: 0; width: 1400px; height: 850px; overflow: visible; }
.relation-graph-stage svg .relation-graph-edge { opacity: 1; transition: opacity .2s ease; }
.relation-graph-stage svg .relation-graph-edge line { stroke: #aebdcb; stroke-width: 1.5; transition: stroke .2s ease, stroke-width .2s ease; }
.relation-graph-stage svg rect { fill: rgba(255,255,255,.95); stroke: #d7e0e8; stroke-width: 1; }
.relation-graph-stage svg text { fill: #536273; font-family: var(--font); font-size: 12px; font-weight: 600; pointer-events: none; }
.relation-graph-stage svg .relation-graph-edge.is-related-edge line { stroke: var(--primary); stroke-width: 3; }
.relation-graph-stage svg .relation-graph-edge.is-related-edge rect { fill: var(--primary-soft); stroke: #9bb3cb; }
.relation-graph-stage svg .relation-graph-edge.is-related-edge text { fill: var(--primary); font-weight: 700; }
.relation-graph-stage svg .relation-graph-edge.is-muted { opacity: .13; }
.relation-graph-node {
  position: absolute;
  z-index: 3;
  width: var(--node-shell, 112px);
  min-height: calc(var(--node-size, 48px) + 32px);
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 6px;
  padding: 4px;
  border: 0;
  outline: 0;
  background: transparent;
  transform: translate(-50%, -50%);
  cursor: grab;
  touch-action: none;
  transition: opacity .2s ease, filter .2s ease;
}
.relation-graph-node.dragging { cursor: grabbing; }
.relation-graph-node > img {
  width: var(--node-size, 48px);
  height: var(--node-size, 48px);
  min-width: var(--node-size, 48px);
  min-height: var(--node-size, 48px);
  max-width: none;
  display: block;
  aspect-ratio: 1 / 1;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #e5edf6;
  object-fit: cover;
  box-shadow: 0 0 0 1px #b8c6d4, 0 5px 16px rgba(36,51,66,.11);
  transition: box-shadow .18s, transform .18s;
  flex-shrink: 0;
}
.relation-graph-node > span {
  width: var(--node-size, 48px);
  height: var(--node-size, 48px);
  min-width: var(--node-size, 48px);
  min-height: var(--node-size, 48px);
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  border: 3px solid #fff;
  border-radius: 50%;
  color: var(--primary);
  background: #e5edf6;
  box-shadow: 0 0 0 1px #b8c6d4, 0 5px 16px rgba(36,51,66,.11);
  transition: box-shadow .18s, transform .18s;
  flex-shrink: 0;
}
.relation-graph-node > span.relation-graph-name-avatar { padding: 5px; font-size: clamp(9px, calc(var(--node-size, 48px) * .16), 14px); font-weight: 650; line-height: 1.15; overflow-wrap: anywhere; text-align: center; }
.relation-graph-node > b { max-width: var(--node-shell, 108px); overflow: hidden; padding: 2px 7px; border-radius: 5px; background: rgba(255,255,255,.96); font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; text-align: center; white-space: normal; }
.relation-graph-node:hover > img,
.relation-graph-node:hover > span { transform: translateY(-2px); box-shadow: 0 0 0 2px #8eabc8, 0 7px 18px rgba(36,51,66,.15); }
.relation-graph-node.active > img,
.relation-graph-node.active > span { box-shadow: 0 0 0 3px var(--primary), 0 8px 22px rgba(49,95,145,.2); }
.relation-graph-node.is-related > img,
.relation-graph-node.is-related > span { box-shadow: 0 0 0 2px #6f93b8, 0 8px 22px rgba(49,95,145,.17); }
.relation-graph-node.is-related > b { color: var(--primary); background: var(--primary-soft); }
.relation-graph-node.is-muted { opacity: .18; filter: grayscale(.65); }
.relation-graph-node.search-match > b { color: var(--primary); background: var(--primary-soft); }
.relation-graph-help { position: absolute; z-index: 10; left: 18px; bottom: 16px; padding: 7px 9px; border-radius: 6px; color: var(--muted); background: rgba(255,255,255,.9); font-size: 11px; pointer-events: none; }
.relation-graph-controls { position: absolute; z-index: 10; right: 16px; bottom: 14px; display: flex; align-items: center; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: rgba(255,255,255,.96); box-shadow: 0 5px 16px rgba(35,47,59,.08); }
.relation-graph-controls button,
.relation-graph-controls output { min-width: 38px; height: 34px; display: grid; place-items: center; border: 0; border-right: 1px solid var(--border); color: var(--muted); background: transparent; font-size: 11px; }
.relation-graph-controls button:last-child { border-right: 0; }
.relation-graph-controls button:hover { color: var(--primary); background: var(--primary-soft); }
.relation-graph-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.event-relation-list { margin-top: 20px; }
.relation-edit-link { justify-self: end; color: var(--primary); font-size: 12px; }

.relation-admin-form { gap: 24px; }
.relation-kind-switch { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); overflow: hidden; border: 1px solid var(--border); border-radius: 9px; }
.relation-kind-switch label { min-height: 46px; display: flex; align-items: center; justify-content: center; gap: 8px; border-right: 1px solid var(--border); color: var(--muted); background: #fff; cursor: pointer; font-size: 13px; }
.relation-kind-switch label:last-child { border-right: 0; }
.relation-kind-switch label:has(input:checked) { color: var(--primary); background: var(--primary-soft); font-weight: 650; }
.relation-kind-switch input { width: 14px; min-height: 14px; padding: 0; }
.relation-live-preview { overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); }
.relation-live-preview > header { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 16px; border-bottom: 1px solid var(--border); background: #fff; }
.relation-live-preview > header b { font-size: 14px; }
.relation-live-preview > header span { color: var(--muted); font-size: 11px; }
.relation-preview-canvas { min-height: 190px; display: grid; grid-template-columns: 150px minmax(120px,1fr) 150px; align-items: center; gap: 14px; padding: 24px 34px 16px; }
.relation-preview-person { min-width: 0; display: flex; align-items: center; flex-direction: column; gap: 9px; text-align: center; }
.relation-preview-avatar { width: 72px; height: 72px; display: grid; place-items: center; border: 4px solid #fff; border-radius: 50%; color: var(--primary); background: #e5edf6; object-fit: cover; box-shadow: 0 0 0 1px #b8c6d4; font-size: 22px; font-weight: 650; }
.relation-preview-person b { max-width: 100%; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.relation-preview-line { position: relative; height: 1px; background: #afbdca; }
.relation-preview-line span { position: absolute; left: 50%; top: 50%; padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; color: #536273; background: #fff; font-size: 11px; transform: translate(-50%,-50%); white-space: nowrap; }
.relation-live-preview > p { margin: 0; padding: 0 16px 16px; color: var(--muted); font-size: 11px; text-align: center; }
.relation-live-preview > p.error { color: var(--danger); font-weight: 600; }

@media (max-width: 760px) {
  .detail-page-top { flex-direction: column; }
  .detail-top-actions { width: 100%; justify-content: flex-start; }
  .markdown-editor-tools { width: 100%; justify-content: space-between; }
  .markdown-editor.is-fullscreen .markdown-editor-heading { align-items: stretch; }
  .admin-form .markdown-editor.is-fullscreen textarea,
  .markdown-editor.is-fullscreen .markdown-preview { width: 100%; padding: 24px 18px; }
  .markdown-media.media-size-small,
  .markdown-media.media-size-medium,
  .markdown-media.media-size-large,
  .markdown-media.media-size-full { width: 100%; }
  .markdown-media.media-float-left,
  .markdown-media.media-float-right { float: none; clear: both; margin: 14px 0; }
  .media-layout-popover { position: static; width: 100%; margin-top: 8px; }
  .relation-graph-viewport { height: 560px; }
  .relation-preview-canvas { grid-template-columns: 90px minmax(70px,1fr) 90px; padding-inline: 12px; }
  .relation-preview-avatar { width: 58px; height: 58px; }
  .relation-live-preview > header { align-items: flex-start; flex-direction: column; padding-block: 12px; }
  .relation-kind-switch { grid-template-columns: 1fr; }
  .relation-kind-switch label { border-right: 0; border-bottom: 1px solid var(--border); }
  .relation-kind-switch label:last-child { border-bottom: 0; }
}

/* v1.3 event-led home, unified visual archive and immersive lightbox */
.home-review-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
}

.home-review-heading h1 {
  margin: 8px 0 8px;
  font-size: 32px;
  letter-spacing: -.02em;
}

.home-review-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.home-event-search {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 28px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.home-event-search .search-field { min-width: 320px; }
.home-event-search select { height: 40px; padding: 0 34px 0 12px; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: #515862; font-size: 11px; }

.home-featured-event {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, .95fr);
  min-height: 310px;
  overflow: hidden;
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.home-featured-visual { min-height: 310px; overflow: hidden; background: #e8ebef; }
.home-featured-visual img { width: 100%; height: 100%; min-height: 310px; object-fit: cover; transition: transform .28s ease; }
.home-featured-visual:hover img { transform: scale(1.015); }
.home-featured-body { display: flex; align-items: flex-start; flex-direction: column; justify-content: center; padding: 34px 38px; }
.home-featured-body h2 { margin: 14px 0 12px; font-size: 27px; line-height: 1.25; letter-spacing: -.02em; }
.home-featured-meta { display: flex; flex-wrap: wrap; gap: 7px 16px; color: var(--muted); font-size: 11px; }
.home-featured-body > p { margin: 18px 0 24px; color: #56606b; font-size: 13px; line-height: 1.75; }
.home-featured-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.home-event-placeholder { width: 100%; height: 100%; min-height: 160px; display: grid; place-items: center; color: var(--primary); background: linear-gradient(135deg, #e9eff6, #dce6f1); }
.home-event-placeholder span { width: 54px; height: 54px; display: grid; place-items: center; border: 1px solid rgba(63,102,149,.22); border-radius: 50%; background: rgba(255,255,255,.58); font-size: 21px; font-weight: 650; }

.home-event-section { margin-top: 30px; }
.home-event-section > header { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.home-event-section > header > div { display: flex; align-items: baseline; gap: 10px; }
.home-event-section > header h2 { margin: 0; font-size: 18px; }
.home-event-section > header span { color: var(--muted); font-size: 11px; }
.home-event-section > header > a { color: var(--primary); font-size: 12px; }
.home-event-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.home-event-card { min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 9px; background: #fff; transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease; }
.home-event-card:hover { border-color: #c9d2dc; box-shadow: 0 8px 24px rgba(34,43,54,.06); transform: translateY(-2px); }
.home-event-card-media { height: 146px; overflow: hidden; background: #e8ebef; }
.home-event-card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .24s ease; }
.home-event-card:hover .home-event-card-media img { transform: scale(1.025); }
.home-event-card-body { padding: 14px 15px 15px; }
.home-event-card-body time { color: var(--subtle); font-size: 10px; }
.home-event-card-body h3 { min-height: 42px; margin: 6px 0 7px; font-size: 14px; line-height: 1.5; }
.home-event-card-body p { display: -webkit-box; min-height: 34px; overflow: hidden; margin: 0; color: var(--muted); font-size: 10px; line-height: 1.65; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.home-event-card-body footer { display: flex; flex-wrap: wrap; gap: 6px 11px; margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--border); color: var(--subtle); font-size: 9px; }
.home-event-empty { grid-column: 1 / -1; }
.home-page > .overview-grid { margin-top: 34px; }
.home-people { margin-top: 16px; }
.home-people-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); }
.home-people-grid .person-row:nth-child(odd) { border-right: 1px solid var(--border); }

.media-page .page-heading { min-height: 112px; }
.media-toolbar .search-field { min-width: 290px; }
.media-date-field { height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--muted); font-size: 10px; }
.media-date-field input { width: 132px; min-height: 0; padding: 0; border: 0; outline: 0; background: transparent; font-size: 11px; }
.media-count-row strong { color: var(--text); font-size: 13px; }
.media-count-row small { color: var(--subtle); font-size: 10px; }
.masonry-wall { column-gap: 14px; }
.media-tile { margin-bottom: 14px; border-radius: 11px; background: #e7eaed; box-shadow: 0 0 0 1px rgba(34,43,54,.04); }
.media-tile img { width: 100%; height: auto; aspect-ratio: auto; object-fit: contain; background: #eef1f4; }
.media-tile.video video { width: 100%; min-height: 0; aspect-ratio: 16 / 10; object-fit: cover; }
.media-overlay { padding: 54px 14px 14px; border-radius: 0 0 11px 11px; background: linear-gradient(transparent,rgba(10,14,19,.78)); opacity: 1; }
.media-overlay b { font-size: 13px; line-height: 1.4; }
.media-overlay small { color: rgba(255,255,255,.78); font-size: 10px; line-height: 1.45; }

body.lightbox-open { overflow: hidden; }
.media-lightbox {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 52px 48px 70px;
  background: rgba(13,18,24,.74);
  backdrop-filter: blur(1.5px);
  animation: lightbox-fade-in .18s ease-out;
}

.media-lightbox > .media-lightbox-dialog {
  position: relative;
  display: inline-flex;
  max-width: min(1120px, 72vw);
  max-height: 76vh;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 16px;
  background: transparent;
  box-shadow: 0 26px 80px rgba(0,0,0,.38);
  animation: lightbox-rise-in .2s ease-out;
}

.media-lightbox-visual { display: flex; max-width: 100%; max-height: 76vh; background: transparent; }
.media-lightbox-visual img { display: block; width: auto; max-width: min(1120px,72vw); height: auto; max-height: 76vh; object-fit: contain; background: transparent; }
.media-lightbox-visual video { display: block; width: min(1120px,72vw); max-width: 100%; max-height: 76vh; aspect-ratio: 16 / 9; object-fit: contain; background: #090b0d; }
.media-lightbox-caption { position: absolute; z-index: 2; inset: auto 0 0; display: flex; align-items: flex-start; flex-direction: column; gap: 6px; padding: 92px 28px 24px; color: #fff; background: linear-gradient(transparent,rgba(8,11,15,.82)); pointer-events: none; }
.media-lightbox-caption b { font-size: 23px; line-height: 1.3; text-shadow: 0 1px 4px rgba(0,0,0,.25); }
.media-lightbox-caption span { max-width: 720px; color: rgba(255,255,255,.88); font-size: 12px; line-height: 1.65; }
.media-lightbox-caption small { color: rgba(255,255,255,.76); font-size: 11px; }
.lightbox-close,
.lightbox-arrow { position: absolute; z-index: 4; width: 42px; height: 42px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; color: #fff; background: rgba(20,25,31,.52); box-shadow: 0 2px 12px rgba(0,0,0,.16); backdrop-filter: blur(5px); }
.lightbox-close { position: absolute; top: 14px; right: 14px; font-size: 25px; line-height: 1; }
.lightbox-arrow { top: 50%; font-size: 25px; transform: translateY(-50%); }
.lightbox-arrow.previous { left: 16px; }
.lightbox-arrow.next { right: 16px; }
.lightbox-close:hover,
.lightbox-arrow:hover { background: rgba(20,25,31,.72); }
.lightbox-close:focus-visible,
.lightbox-arrow:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.lightbox-helper { position: absolute; left: 50%; bottom: 20px; margin: 0; color: rgba(255,255,255,.76); font-size: 12px; transform: translateX(-50%); }

@keyframes lightbox-fade-in { from { opacity: 0; } }
@keyframes lightbox-rise-in { from { opacity: 0; transform: translateY(8px) scale(.992); } }

@media (max-width: 1040px) {
  .home-event-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .home-featured-event { grid-template-columns: 1.05fr .95fr; }
  .media-lightbox > .media-lightbox-dialog,
  .media-lightbox-visual img { max-width: 86vw; }
  .media-lightbox-visual video { width: 86vw; }
}

@media (max-width: 800px) {
  .home-review-heading { flex-direction: column; }
  .home-event-search { align-items: stretch; flex-direction: column; }
  .home-event-search .search-field { min-width: 0; }
  .home-featured-event { grid-template-columns: 1fr; }
  .home-featured-visual,
  .home-featured-visual img { min-height: 260px; }
  .home-people-grid { grid-template-columns: 1fr; }
  .home-people-grid .person-row:nth-child(odd) { border-right: 0; }
  .media-date-field { justify-content: space-between; }
  .media-lightbox { padding: 72px 18px 62px; }
  .media-lightbox > .media-lightbox-dialog,
  .media-lightbox-visual img { max-width: calc(100vw - 36px); max-height: 76vh; }
  .media-lightbox-visual video { width: calc(100vw - 36px); }
}

@media (max-width: 560px) {
  .home-event-grid { grid-template-columns: 1fr; }
  .home-featured-body { padding: 26px 22px; }
  .home-featured-body h2 { font-size: 23px; }
  .media-count-row small { display: none; }
  .media-lightbox-caption { padding: 70px 18px 17px; }
  .media-lightbox-caption b { font-size: 18px; }
  .media-lightbox-caption span { display: none; }
  .lightbox-close,
  .lightbox-arrow { width: 38px; height: 38px; }
  .lightbox-helper { width: 100%; bottom: 16px; text-align: center; }
}

/* v1.4 event review directory and aligned person-event rows */
.event-review-page { padding-top: 42px; }
.event-review-page .home-review-heading { min-height: 116px; }
.event-directory-search { margin-top: 0; }
.event-directory-section { margin-top: 30px; }

.home-event-card { display: grid; grid-template-rows: auto auto; }
.home-event-card-media {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
}
.home-event-card-media .home-event-placeholder { min-height: 0; }
.home-event-card-body {
  min-height: 0;
  aspect-ratio: 4 / 1;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr auto;
  align-content: center;
  overflow: hidden;
  padding: 10px 12px;
}
.home-event-card-body h3 {
  min-height: 0;
  overflow: hidden;
  margin: 3px 0 4px;
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-event-card-body > p { display: none; }
.home-event-card-body footer {
  flex-wrap: nowrap;
  gap: 5px 9px;
  overflow: hidden;
  margin: 0;
  padding: 0;
  border-top: 0;
  white-space: nowrap;
}

.relation-list-head,
.event-relation-list .relation-row {
  grid-template-columns: minmax(180px, 1fr) minmax(110px, 160px) minmax(260px, 1.35fr) 52px;
  column-gap: 22px;
  padding-inline: 20px;
}
.relation-list-head {
  min-height: 38px;
  display: grid;
  align-items: center;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 10px;
}
.relation-list-head span:nth-child(2) { text-align: center; }
.relation-list-head span:last-child { text-align: right; }
.event-relation-list .relation-row { min-height: 68px; padding-block: 12px; }
.event-relation-list .relation-endpoint { justify-content: center; }
.event-relation-list .relation-row > .relation-label { justify-self: center; }
.event-relation-list .relation-edit-link { align-self: center; justify-self: end; }

@media (max-width: 860px) {
  .relation-list-head,
  .event-relation-list .relation-row {
    grid-template-columns: minmax(130px, 1fr) minmax(90px, 120px) minmax(170px, 1.2fr) 44px;
    column-gap: 12px;
  }
}

@media (max-width: 680px) {
  .relation-list-head { display: none; }
  .event-relation-list .relation-row {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 10px;
    padding-inline: 14px;
  }
  .event-relation-list .relation-edit-link { grid-column: 1 / -1; }
}

/* v1.5 automatic event carousel and administrator avatar */
.user-avatar { display: grid; place-items: center; overflow: hidden; text-decoration: none; }
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.home-featured-visual,
.home-featured-body { transition: opacity .18s ease, transform .18s ease; }
.home-featured-event.is-changing .home-featured-visual { opacity: .2; transform: scale(1.006); }
.home-featured-event.is-changing .home-featured-body { opacity: .18; transform: translateY(3px); }
.home-featured-actions button.secondary-action { border: 1px solid var(--border-strong); cursor: pointer; }
.home-featured-actions button:disabled { cursor: default; opacity: .48; }
.event-carousel-status { width: 100%; display: flex; align-items: center; gap: 12px; margin-top: 20px; color: var(--subtle); font-size: 10px; }
.event-carousel-status > span { white-space: nowrap; }
.event-carousel-status > i { height: 2px; flex: 1; overflow: hidden; border-radius: 999px; background: #e6e9ed; }
.event-carousel-status > i > b { width: 100%; height: 100%; display: block; border-radius: inherit; background: #8ca8c5; transform: scaleX(0); transform-origin: left center; }

.settings-avatar-card { min-height: 190px; display: grid; grid-template-columns: 112px minmax(0,1fr); align-items: center; gap: 24px; }
.settings-avatar-preview { width: 112px; height: 112px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--border); border-radius: 50%; color: var(--primary); background: var(--primary-soft); font-size: 34px; font-weight: 650; box-shadow: 0 0 0 5px #f4f6f8; }
.settings-avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.settings-avatar-card h2 { margin-bottom: 8px; }
.settings-avatar-card p { margin: 0 0 16px; }
.settings-avatar-select { min-height: 36px; cursor: pointer; }
.settings-avatar-select.disabled { cursor: wait; opacity: .55; pointer-events: none; }
.settings-avatar-status { min-height: 18px; margin-top: 10px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.settings-avatar-status.success { color: #2d6b49; }
.settings-avatar-status.error { color: var(--danger); }

/* 事件封面上传 */
.cover-uploader > .editor-upload-status { margin-top: 14px; padding: 0; border: 0; background: transparent; }
.cover-uploader .editor-upload-status.error { color: var(--danger); }
.cover-uploader > div.is-dragover { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); background: var(--primary-soft); }
.cover-preview-row { display: flex; align-items: flex-start; gap: 18px; margin: 18px 0 0; }
.cover-preview { flex: 0 0 auto; width: 210px; height: 128px; overflow: hidden; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-soft); }
.cover-preview img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cover-placeholder { display: grid; place-content: center; justify-items: center; gap: 6px; width: 100%; height: 100%; color: var(--muted); background: var(--surface-soft); }
.cover-placeholder span { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 50%; font-size: 13px; }
.cover-placeholder small { font-size: 9px; }
.cover-preview-meta { flex: 1 1 auto; min-width: 0; }
.cover-preview-meta b { display: block; font-size: 11px; }
.cover-preview-meta p { margin: 7px 0 0; color: var(--muted); font-size: 9px; line-height: 1.7; }
.cover-preview-actions { margin-top: 12px; }

/* 编辑页影像资料区域 */
.event-media-zone { margin-top: 1.75rem; }
.event-media-zone .home-media-grid { gap: 14px; }
.media-edit-card { display: flex; flex-direction: column; }
.media-edit-card > a { display: block; }
.media-edit-actions { display: flex; align-items: center; gap: 10px; padding: 8px 4px 2px; }
.media-edit-actions .text-button { font-size: 9px; }
.media-edit-actions .danger-text { color: var(--danger); background: none; border: 0; padding: 0; cursor: pointer; }
.media-edit-actions form { margin: 0; }

@media (max-width: 720px) {
  .cover-preview-row { flex-direction: column; }
  .cover-preview { width: 100%; height: 190px; }
}

@media (max-width: 560px) {
  .event-carousel-status { align-items: flex-start; flex-direction: column; }
  .event-carousel-status > i { width: 100%; flex: 0 0 2px; }
  .settings-avatar-card { grid-template-columns: 1fr; }
  .person-age-preview { align-items: flex-start; flex-direction: column; }
  .person-age-preview small { text-align: left; }
}
