/*
 * Histograph styles
 */

:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d12;
  --bg-gradient-top: #151922;
  --panel: rgba(22, 26, 35, 0.82);
  --panel-solid: #161a23;
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
  --text: #eef1f6;
  --muted: #94a0b8;
  --accent: #b4bcc9;
  --accent-soft: rgba(180, 188, 201, 0.12);
  --danger: #ff7b72;
  --success: #3dd68c;
  --input-bg: rgba(255, 255, 255, 0.04);
  --detail-bg: rgba(18, 21, 29, 0.92);
  --button-on-accent: #f8fafc;
  --button-bg: linear-gradient(180deg, #4b5563 0%, #374151 100%);
  --button-text: #f8fafc;
  --flash-success-bg: rgba(61, 214, 140, 0.12);
  --flash-error-bg: rgba(255, 123, 114, 0.12);
  --chip-bg: rgba(255, 255, 255, 0.04);
  --chip-active-bg: rgba(180, 188, 201, 0.14);
  --filter-chip-border: rgba(255, 255, 255, 0.05);
  --focus-ring: 0 0 0 3px rgba(180, 188, 201, 0.22);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --graph-node-text: #f8fafc;
  --graph-node-border: #111827;
  --graph-edge-color: #64748b;
  --graph-edge-label: #cbd5e1;
  --graph-edge-label-bg: #161a23;
  --graph-highlight-border: #eef1f6;
  --type-figure: #f5bf4f;
  --type-place: #34d399;
  --type-event: #fb7185;
  --type-other: #94a3b8;
  --home-backdrop-wash: linear-gradient(
    180deg,
    rgba(11, 13, 18, 0.55) 0%,
    rgba(11, 13, 18, 0.72) 42%,
    rgba(11, 13, 18, 0.9) 76%,
    rgba(11, 13, 18, 0.96) 100%
  );
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f5f4;
  --bg-gradient-top: #fafaf9;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-solid: #ffffff;
  --panel-border: rgba(15, 23, 42, 0.08);
  --panel-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  --text: #1c1917;
  --muted: #78716c;
  --accent: #57534e;
  --accent-soft: rgba(87, 83, 78, 0.08);
  --danger: #dc2626;
  --success: #059669;
  --input-bg: #fafaf9;
  --detail-bg: rgba(255, 255, 255, 0.96);
  --button-on-accent: #ffffff;
  --button-bg: linear-gradient(180deg, #57534e 0%, #44403c 100%);
  --button-text: #ffffff;
  --flash-success-bg: rgba(5, 150, 105, 0.1);
  --flash-error-bg: rgba(220, 38, 38, 0.08);
  --chip-bg: #fafaf9;
  --chip-active-bg: rgba(87, 83, 78, 0.08);
  --filter-chip-border: rgba(15, 23, 42, 0.06);
  --focus-ring: 0 0 0 3px rgba(87, 83, 78, 0.14);
  --graph-node-text: #1c1917;
  --graph-node-border: #111827;
  --graph-edge-color: #94a3b8;
  --graph-edge-label: #475569;
  --graph-edge-label-bg: #ffffff;
  --graph-highlight-border: #111827;
  --type-figure: #ca8a04;
  --type-place: #059669;
  --type-event: #e11d48;
  --type-other: #64748b;
  --home-backdrop-wash: linear-gradient(
    180deg,
    rgba(250, 247, 240, 0.28) 0%,
    rgba(245, 245, 244, 0.62) 40%,
    rgba(245, 245, 244, 0.9) 76%,
    rgba(245, 245, 244, 0.96) 100%
  );
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, var(--bg-gradient-top) 0%, transparent 42%),
    linear-gradient(180deg, var(--bg-gradient-top) 0%, var(--bg) 100%);
  color: var(--text);
  overflow: hidden;
  transition: background 0.25s ease, color 0.25s ease;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  max-width: none;
  width: 100%;
  height: 100vh;
  margin: 0;
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 14px;
}

.app-header {
  position: relative;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 14px 18px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--panel-shadow);
  flex-shrink: 0;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none;
}

body.page-marketing {
  overflow: auto;
  overflow-x: hidden;
  background: var(--bg);
}

.home-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-color: var(--bg);
  background-image: var(--home-backdrop-wash), url("/landing-map.webp");
  background-size: auto, cover;
  background-position: center, center 28%;
  background-repeat: no-repeat;
}

.home-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    0
    max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 0;
}

.home-header,
.home-main,
.home-footer {
  position: relative;
  z-index: 1;
}

.home-header {
  position: sticky;
  top: max(12px, env(safe-area-inset-top));
  z-index: 40;
  width: min(1120px, 100%);
  margin: 0 auto;
}

.home-main {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 48px 0 96px;
  display: flex;
  flex-direction: column;
  gap: 72px;
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 56px;
  align-items: center;
  padding: 12px 0 8px;
}

.home-hero-copy h2,
.home-how-intro h3,
.home-types h3 {
  font-family: Newsreader, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.home-hero-copy h2 {
  margin: 0 0 18px;
  font-size: clamp(40px, 6vw, 72px);
  line-height: 0.98;
}

[data-theme="light"] .home-hero-copy .eyebrow,
[data-theme="light"] .home-hero-copy .home-lead {
  text-shadow: 0 1px 12px rgba(250, 247, 240, 0.75);
}

[data-theme="dark"] .home-hero-copy h2,
[data-theme="dark"] .home-hero-copy .eyebrow,
[data-theme="dark"] .home-hero-copy .home-lead {
  text-shadow: 0 1px 18px rgba(11, 13, 18, 0.7);
}

.home-lead {
  max-width: 36rem;
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.65;
}

.home-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.home-actions .button {
  padding: 13px 18px;
}

.home-visual {
  position: relative;
  margin: 0;
}

.home-visual-glow {
  position: absolute;
  inset: 12% -8% auto;
  height: 70%;
  background: radial-gradient(circle at center, rgba(245, 191, 79, 0.22), transparent 68%);
  filter: blur(28px);
  pointer-events: none;
}

.home-visual-frame {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid var(--panel-border);
  background: #0b0d12;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
}

.home-visual-chrome {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.home-visual-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
}

.home-visual-title {
  margin-left: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}

.home-visual-image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
}

.home-visual figcaption {
  margin: 12px 2px 0;
  color: var(--muted);
  font-size: 13px;
}

.home-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  background: var(--panel-border);
  box-shadow: var(--panel-shadow);
}

.home-stats div {
  display: grid;
  gap: 4px;
  padding: 22px 24px;
  background: var(--panel);
}

.home-stats strong {
  font-size: 28px;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.home-stats span {
  color: var(--muted);
  font-size: 13px;
}

.home-how,
.home-how-intro {
  display: grid;
  gap: 22px;
}

.home-how {
  scroll-margin-top: 96px;
}

.home-how-intro h3,
.home-types h3 {
  margin: 0;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.12;
}

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

.home-card {
  padding: 24px;
}

.home-card-index {
  display: block;
  margin-bottom: 18px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent);
}

.home-grid h4 {
  margin: 0 0 8px;
  font-size: 20px;
  letter-spacing: -0.03em;
}

.home-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.home-types {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 40px;
  align-items: center;
  padding: 36px;
}

.home-types p:last-child {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.6;
  max-width: 36rem;
}

.home-types ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.home-types li {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  background: var(--chip-bg);
}

.home-types li strong,
.home-types li span {
  display: block;
}

.home-types li span:not(.home-type-dot) {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.home-type-dot {
  width: 12px;
  height: 12px;
  margin-top: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.home-type-dot.legend-figure {
  background: var(--type-figure);
}

.home-type-dot.legend-place {
  background: var(--type-place);
}

.home-type-dot.legend-event {
  background: var(--type-event);
}

.home-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 32px 36px;
}

.home-cta h3 {
  margin: 0 0 8px;
  font-family: Newsreader, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: clamp(28px, 4vw, 36px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.12;
}

.home-cta p {
  margin: 0;
  max-width: 36rem;
  color: var(--muted);
  line-height: 1.55;
}

.home-footer {
  margin-top: auto;
  border-top: 1px solid var(--panel-border);
  background: var(--panel);
  padding:
    40px
    max(16px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

.home-footer-inner {
  width: min(1120px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 0.7fr));
  gap: 32px;
}

.home-footer-brand p {
  margin: 14px 0 0;
  max-width: 28rem;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.home-footer-brand strong {
  display: block;
  font-size: 20px;
  letter-spacing: -0.03em;
}

.home-footer nav {
  display: grid;
  align-content: start;
  gap: 8px;
}

.home-footer nav p {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.home-footer nav a {
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.home-footer nav a:hover {
  color: var(--accent);
}

.home-footer-copy {
  width: min(1120px, 100%);
  margin: 28px auto 0;
  padding-top: 20px;
  border-top: 1px solid var(--panel-border);
  color: var(--muted);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.home-footer-copy a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  flex-shrink: 0;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}

.app-header h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.auth-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-user {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

a.auth-user:hover {
  color: var(--accent);
}

.auth-link {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.auth-link:hover {
  opacity: 0.8;
}

.auth-signup {
  padding: 8px 12px;
  font-size: 12px;
  text-decoration: none;
  display: inline-block;
}

.auth-signout {
  color: var(--muted);
}

.auth-callout-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(100%, 420px);
  padding: 28px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--panel-shadow);
}

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

.auth-brand h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.auth-form {
  margin-top: 8px;
}

.auth-switch {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-switch a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.header-copy {
  max-width: 360px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}

.theme-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.theme-toggle-track {
  position: relative;
  display: block;
  width: 72px;
  height: 28px;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--chip-bg);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.theme-toggle-label {
  position: absolute;
  top: 0;
  right: 8px;
  bottom: 0;
  left: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--muted);
  pointer-events: none;
}

.theme-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease, background 0.2s ease;
}

.theme-toggle:hover .theme-toggle-track {
  border-color: var(--accent);
}

.theme-toggle[aria-pressed="true"] .theme-toggle-track {
  background: var(--accent-soft);
}

.theme-toggle[aria-pressed="true"] .theme-toggle-label {
  right: 26px;
  left: 8px;
}

.theme-toggle[aria-pressed="true"] .theme-toggle-thumb {
  transform: translateX(44px);
  background: var(--accent);
}

.flash-stack {
  display: grid;
  gap: 8px;
  flex-shrink: 0;
}

.flash {
  margin: 0;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
}

.flash-notice {
  background: var(--flash-success-bg);
}

.flash-alert {
  background: var(--flash-error-bg);
}

.notification-bell {
  position: relative;
}

.notification-bell-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: var(--panel-solid);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.notification-bell-button:hover {
  border-color: var(--accent);
}

.notification-bell-icon {
  width: 18px;
  height: 18px;
}

.notification-bell-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.notification-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 50;
  width: min(360px, calc(100vw - 32px));
  padding: 14px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  background: var(--panel-solid);
  box-shadow: var(--panel-shadow);
}

.notification-panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.notification-panel-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.notification-panel-count {
  font-size: 12px;
  color: var(--muted);
}

.notification-panel-empty {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.notification-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
}

.notification-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
}

.notification-item p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.notification-item.notification-approved {
  background: var(--flash-success-bg);
}

.notification-item.notification-rejected {
  background: var(--flash-error-bg);
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  flex: 1;
  min-height: 0;
}

.graph-panel,
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(18px);
  box-shadow: var(--panel-shadow);
}

.graph-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.graph-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
  flex-wrap: wrap;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
}

.graph-scope-nav {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: var(--chip-bg);
}

.graph-scope-nav-full {
  display: flex;
  width: 100%;
}

.graph-scope-nav-full .scope-tab {
  flex: 1;
  text-align: center;
}

.sidebar-scope {
  padding: 14px;
}

.sidebar-scope-copy {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.scope-tab {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.scope-tab:hover {
  color: var(--text);
}

.scope-tab.is-active {
  background: var(--panel-solid);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

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

.type-filters,
.timeline-filter,
.search-bar,
.path-finder {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.timeline-filter {
  flex-direction: row;
  align-items: center;
  flex: 1;
  min-width: 260px;
  max-width: 520px;
  gap: 12px;
}

.timeline-range-label {
  flex-shrink: 0;
  min-width: 88px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  white-space: nowrap;
}

.timeline-range {
  position: relative;
  flex: 1;
  height: 28px;
  min-width: 100px;
}

.timeline-range-track,
.timeline-range-fill {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  border-radius: 999px;
}

.timeline-range-track {
  left: 0;
  right: 0;
  background: var(--chip-bg);
  border: 1px solid var(--panel-border);
}

.timeline-range-fill {
  background: var(--accent);
  pointer-events: none;
}

.timeline-range-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}

.timeline-range-start {
  z-index: 3;
}

.timeline-range-end {
  z-index: 4;
}

.timeline-range-input::-webkit-slider-runnable-track {
  height: 4px;
  background: transparent;
  border: 0;
}

.timeline-range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  pointer-events: auto;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  border: 2px solid var(--panel-solid);
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.timeline-range-input::-moz-range-track {
  height: 4px;
  background: transparent;
  border: 0;
}

.timeline-range-input::-moz-range-thumb {
  pointer-events: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--panel-solid);
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.timeline-fields,
.search-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.search-bar {
  flex: 1;
  min-width: 220px;
  max-width: 380px;
}

.search-row {
  flex: 1;
  min-width: 180px;
}

.path-finder {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  flex: 1 1 100%;
}

.path-finder-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 220px;
}

.path-finder-row select {
  min-width: 160px;
  max-width: 240px;
  flex: 1;
  padding: 8px 11px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.path-finder-swap {
  padding: 8px;
  font-size: 16px;
  line-height: 1;
}

.path-finder-hint {
  margin: 0;
  width: 100%;
  font-size: 12px;
  color: var(--muted);
}

.path-result {
  position: absolute;
  top: 18px;
  left: 18px;
  max-width: min(420px, calc(100% - 36px));
  padding: 18px;
  border-radius: var(--radius-md);
  background: var(--detail-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(16px);
  box-shadow: var(--panel-shadow);
  z-index: 4;
}

.path-chain,
.path-sentence {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.path-chain {
  font-weight: 600;
  color: var(--text);
}

.path-hops {
  margin: 0 0 14px;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.path-hops span {
  color: var(--muted);
  font-style: italic;
}

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

.timeline-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.filter-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.search-row input[type="search"] {
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.search-row input[type="search"] {
  flex: 1;
}

.search-row input[type="search"]:focus,
.stack-form input:focus,
.stack-form select:focus,
.stack-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.type-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--filter-chip-border);
  background: var(--chip-bg);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.type-toggle:hover {
  border-color: var(--panel-border);
}

.type-toggle:has(input:checked) {
  background: var(--chip-active-bg);
  border-color: var(--panel-border);
}

.type-toggle input {
  accent-color: var(--accent);
  margin: 0;
}

.legend-figure,
.entity-badge-figure { color: var(--type-figure); }

.legend-place,
.entity-badge-place { color: var(--type-place); }

.legend-event,
.entity-badge-event { color: var(--type-event); }

.legend-other,
.entity-badge-other { color: var(--type-other); }

.graph-hint {
  display: none;
  margin: 0;
  width: 100%;
  font-size: 12px;
  color: var(--muted);
}

.graph-filters {
  border: 0;
}

.graph-filters-toggle {
  display: none;
}

@media (min-width: 981px) {
  .graph-filters .graph-toolbar {
    display: flex !important;
  }

  .graph-filters > summary {
    display: none;
  }
}

.graph-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.mobile-scope-bar {
  display: none;
}

.graph-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.graph-detail-header .detail-type {
  margin: 0;
}

.graph-detail-close {
  display: none;
  padding: 8px 10px;
  font-size: 13px;
}

.graph-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 360px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.panel-note,
.entity-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.search-field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 14px;
}

.search-empty {
  margin-bottom: 8px;
}

.graph-loading,
.graph-error {
  margin: 0;
  padding: 18px 20px;
  color: var(--muted);
  font-size: 14px;
  position: relative;
  z-index: 2;
}

.graph-error {
  color: var(--danger);
}

.graph-detail {
  position: absolute;
  top: 18px;
  left: 18px;
  max-width: 300px;
  padding: 18px;
  border-radius: var(--radius-md);
  background: var(--detail-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(16px);
  box-shadow: var(--panel-shadow);
  z-index: 3;
}

.detail-type {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.graph-detail h2 {
  margin: 0 0 8px;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.sidebar {
  display: grid;
  gap: 14px;
  align-content: start;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.panel {
  padding: 18px;
}

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

.stack-form label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.stack-form input,
.stack-form select,
.stack-form textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.date-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-hint,
.entity-dates,
.detail-dates {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.entity-dates {
  margin-top: 4px;
}

.detail-dates {
  margin-bottom: 8px;
  color: var(--accent);
  font-weight: 500;
}

.detail-author,
.entity-author {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.entity-author {
  margin-top: 4px;
}

.button,
input.button,
a.button {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  background: var(--button-bg);
  color: var(--button-text);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

.button:hover,
input.button:hover,
a.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.16);
}

.button-danger {
  background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
}

a.button.button-ghost,
.button.button-ghost {
  background: transparent;
  color: var(--text);
  box-shadow: none;
  border: 1px solid var(--panel-border);
}

a.button.button-ghost:hover,
.button.button-ghost:hover {
  background: var(--accent-soft);
  box-shadow: none;
}

.account-layout {
  display: grid;
  gap: 16px;
  max-width: 720px;
}

.account-details {
  display: grid;
  gap: 12px;
  margin: 0;
}

.account-details div {
  display: grid;
  gap: 4px;
}

.account-details dt {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.account-details dd {
  margin: 0;
  font-size: 15px;
}

.account-danger h2 {
  color: var(--danger);
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  transition: opacity 0.15s ease;
}

.text-button:hover {
  opacity: 0.75;
}

.entity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.entity-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  content-visibility: auto;
  contain-intrinsic-size: 0 84px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.entity-item:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.entity-item:first-child {
  padding-top: 12px;
}

.entity-badge {
  display: inline-flex;
  align-items: center;
  margin-bottom: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--chip-bg);
}

.entity-badge-figure { background: rgba(245, 191, 79, 0.14); }
.entity-badge-place { background: rgba(52, 211, 153, 0.14); }
.entity-badge-event { background: rgba(251, 113, 133, 0.14); }
.entity-badge-other { background: rgba(148, 163, 184, 0.16); }

.link-label {
  display: inline-block;
  margin: 0 6px;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  margin: 0 0 6px 6px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.status-badge-pending {
  color: #b45309;
  background: rgba(245, 158, 11, 0.16);
}

.status-badge-rejected {
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.12);
}

.moderation-layout {
  display: grid;
  gap: 20px;
  padding: 20px;
}

.moderation-item {
  align-items: flex-start;
}

.moderation-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.button-small {
  padding: 8px 12px;
  font-size: 13px;
}

.review-link {
  font-weight: 600;
}

.detail-status {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  text-transform: capitalize;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .home-hero,
  .home-types,
  .home-cta,
  .home-footer-inner {
    grid-template-columns: 1fr;
  }

  .home-cta {
    flex-direction: column;
    align-items: flex-start;
    padding: 24px;
  }

  .home-hero {
    gap: 32px;
  }

  .home-main {
    padding: 32px 0 72px;
    gap: 56px;
  }

  .app-shell {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    padding:
      max(12px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      calc(76px + env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }

  .app-header {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
  }

  .brand-logo {
    width: 38px;
    height: 38px;
  }

  .app-header .eyebrow {
    display: none;
  }

  .app-header h1 {
    font-size: 20px;
  }

  .header-actions {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    width: auto;
    margin-left: auto;
    gap: 10px;
  }

  .auth-nav {
    gap: 8px;
  }

  .auth-user {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .notification-panel {
    position: fixed;
    top: auto;
    bottom: calc(72px + env(safe-area-inset-bottom));
    left: 12px;
    right: 12px;
    width: auto;
  }

  .mobile-scope-bar {
    display: flex;
    position: fixed;
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 40;
    gap: 6px;
    padding: 4px;
    border: 1px solid var(--panel-border);
    border-radius: 999px;
    background: var(--panel-solid);
    box-shadow: var(--panel-shadow);
    backdrop-filter: blur(18px);
  }

  .mobile-scope-bar .scope-tab {
    flex: 1;
    text-align: center;
    padding: 12px 10px;
    font-size: 13px;
  }

  .sidebar-scope {
    display: none;
  }

  .app-grid {
    grid-template-columns: 1fr;
    flex: none;
    gap: 12px;
  }

  .graph-panel {
    min-height: 52vh;
    min-height: 52dvh;
  }

  .graph-stage {
    min-height: 42vh;
    min-height: 42dvh;
  }

  .graph-filters-toggle {
    display: list-item;
    list-style: none;
    cursor: pointer;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    border-bottom: 1px solid var(--panel-border);
  }

  .graph-filters-toggle::-webkit-details-marker {
    display: none;
  }

  .graph-filters:not([open]) .graph-filters-toggle {
    border-bottom: 0;
  }

  .graph-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    padding: 14px 16px 16px;
  }

  .type-filters,
  .search-bar,
  .path-finder {
    width: 100%;
    max-width: none;
    flex-direction: column;
    align-items: stretch;
  }

  .timeline-filter {
    width: 100%;
    max-width: none;
    flex-wrap: wrap;
  }

  .timeline-range {
    flex: 1 1 160px;
    height: 36px;
  }

  .timeline-range-label {
    flex: 1 1 auto;
    text-align: left;
  }

  .search-row input[type="search"],
  .stack-form input,
  .stack-form select,
  .stack-form textarea {
    font-size: 16px;
  }

  .search-row input[type="search"] {
    min-height: 44px;
  }

  .path-finder-row select {
    max-width: none;
    min-height: 44px;
    font-size: 16px;
  }

  .path-result {
    top: auto;
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
    max-height: 42vh;
    max-height: 42dvh;
    overflow-y: auto;
  }

  .type-toggle {
    min-height: 44px;
    padding: 10px 14px;
  }

  .graph-hint {
    display: block;
  }

  .graph-detail {
    top: auto;
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
    max-height: 45vh;
    max-height: 45dvh;
    overflow-y: auto;
    padding: 16px;
  }

  .graph-detail-close {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }

  .graph-detail h2 {
    font-size: 20px;
  }

  .sidebar {
    overflow: visible;
  }

  .panel {
    padding: 16px;
  }

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

  .entity-item {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .entity-item .text-button,
  .entity-item .button_to {
    align-self: flex-start;
    min-height: 44px;
    padding: 10px 0;
    font-size: 14px;
  }

  .button,
  input.button,
  a.button {
    width: 100%;
    min-height: 48px;
  }

  .moderation-layout {
    padding: 0;
  }

  .moderation-item {
    flex-direction: column;
  }

  .moderation-actions {
    flex-direction: row;
    width: 100%;
  }

  .moderation-actions .button,
  .moderation-actions .button_to {
    flex: 1;
  }

  .auth-shell {
    padding:
      max(16px, env(safe-area-inset-top))
      max(16px, env(safe-area-inset-right))
      max(16px, env(safe-area-inset-bottom))
      max(16px, env(safe-area-inset-left));
  }

  .auth-panel {
    padding: 22px;
  }
}

@media (max-width: 640px) {
  .header-actions .auth-nav .review-link {
    font-size: 12px;
  }

  .auth-signout {
    font-size: 12px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .home-hero {
    grid-template-columns: 1fr;
    gap: 28px;
    padding: 8px 0 0;
  }

  .home-hero-copy h2 {
    font-size: clamp(36px, 11vw, 52px);
  }

  .home-stats,
  .home-grid,
  .home-types,
  .home-footer-inner {
    grid-template-columns: 1fr;
  }

  .home-main {
    padding: 28px 0 64px;
    gap: 48px;
  }

  .home-types {
    padding: 22px;
  }

  .home-header .auth-nav .text-button:first-child {
    display: none;
  }
}
