:root {
  --bg: #000;
  --surface: #111;
  --surface-2: #1a1a1a;
  --border: #333;
  --border-light: #444;
  --text: #fff;
  --muted: #888;
  --dim: #555;
  --add-bg: rgba(34, 197, 94, 0.14);
  --list-add-bg: rgba(59, 130, 246, 0.16);
  --remove-bg: rgba(239, 68, 68, 0.14);
  --gone-bg: rgba(168, 85, 247, 0.16);
  --subject-color: #facc15;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}

@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.18s;
  animation-timing-function: ease;
}

.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  view-transition-name: topbar;
}

::view-transition-old(topbar),
::view-transition-new(topbar) {
  animation: none;
}

.topbar-inner {
  max-width: 90rem;
  margin: 0 auto;
  padding: 0.9rem 1.2rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
}

.topbar-end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  grid-column: 3;
}

.profile-menu {
  position: relative;
}

.profile-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  max-width: 10rem;
  padding: 0.2rem 0.45rem 0.2rem 0.2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.profile-menu-trigger:hover,
.profile-menu.is-open .profile-menu-trigger {
  border-color: var(--border-light);
  background: var(--surface-2);
}

.profile-avatar {
  flex: 0 0 auto;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #3a3a3a, #1c1c1c);
  border: 1px solid var(--border-light);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #f2f2f2;
}

.profile-avatar-lg {
  width: 2.1rem;
  height: 2.1rem;
  font-size: 0.9rem;
}

.profile-menu-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text);
}

.profile-menu-caret {
  width: 0.45rem;
  height: 0.45rem;
  margin-right: 0.15rem;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg) translateY(-1px);
  transition: transform 0.12s;
}

.profile-menu.is-open .profile-menu-caret {
  transform: rotate(225deg) translateY(-1px);
}

.profile-menu-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  z-index: 40;
  width: min(14rem, 70vw);
  padding: 0.55rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.profile-menu-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.4rem 0.65rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.4rem;
}

.profile-menu-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.profile-menu-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dim);
}

.profile-menu-user {
  font-size: 0.85rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-menu-item {
  width: 100%;
  display: block;
  padding: 0.55rem 0.65rem;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: 0.8rem;
  text-align: left;
  cursor: pointer;
}

.profile-menu-item:hover {
  background: var(--surface-2);
  border-color: var(--border);
}

.profile-menu-logout {
  color: #f0a0a0;
}

.profile-menu-logout:hover {
  color: #ffb4b4;
}

.page-auth {
  min-height: calc(100vh - 2rem);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  width: min(100%, 24rem);
}

.auth-brand {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
}

.auth-sub {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.auth-form .btn-main {
  margin-top: 0.75rem;
}

.auth-switch {
  margin: 1rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.auth-switch a {
  color: var(--text);
}

@media (max-width: 640px) {
  .topbar-inner {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 0.65rem 0.75rem;
  }

  .brand-line {
    grid-column: 1;
    grid-row: 1;
  }

  .topbar-end {
    grid-column: 2;
    grid-row: 1;
  }

  .profile-menu-name {
    display: none;
  }

  .profile-menu-trigger {
    padding-right: 0.35rem;
  }

  .profile-menu-caret {
    display: none;
  }

  .topnav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    justify-content: center;
    flex-wrap: wrap;
  }
}

.brand-line {
  justify-self: start;
}

.topnav {
  justify-self: center;
}

.lang-switch {
  justify-self: end;
  display: flex;
  gap: 0.25rem;
}

.lang-btn {
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.lang-btn:hover {
  color: var(--text);
  border-color: var(--border-light);
}

.lang-btn.active {
  color: var(--text);
  border-color: var(--border-light);
  background: var(--surface-2);
}

.brand-line {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
}

.brand-line h1 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topnav {
  display: flex;
  gap: 0.5rem;
}

.topnav-link {
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.78rem;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.topnav-link:hover {
  border-color: var(--border-light);
  color: var(--text);
  background: var(--bg);
}

.topnav-link.active {
  border-color: var(--text);
  color: var(--text);
}

.page {
  width: 100%;
  max-width: 90rem;
  margin: 0 auto;
  padding: 1.2rem;
  display: grid;
  gap: 1rem;
}

.page-home,
.page-settings {
  grid-template-columns: minmax(17rem, 20rem) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  min-height: calc(100vh - 4.5rem);
}

.page-help {
  grid-template-columns: minmax(13rem, 16rem) minmax(0, 1fr);
  align-items: start;
  gap: 1rem;
  padding-bottom: 2rem;
}

.help-sidebar {
  position: sticky;
  top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1rem;
}

.help-sidebar .panel-title {
  margin-bottom: 0.15rem;
}

.help-toc {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.help-toc-link {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.88rem;
  line-height: 1.35;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}

.help-toc-link:hover {
  background: var(--surface-2);
  border-color: var(--border);
}

.help-toc-link:target,
.help-toc-link.is-active {
  background: var(--surface-2);
  border-color: var(--border-light);
}

.help-toc-num {
  flex: 0 0 auto;
  width: 1.35rem;
  height: 1.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
}

.help-quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border);
}

.help-quick-link {
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 0.72rem;
  text-decoration: none;
  transition: color 0.12s, border-color 0.12s;
}

.help-quick-link:hover {
  color: var(--text);
  border-color: var(--border-light);
}

.help-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.help-hero {
  padding: 1.25rem 1.35rem;
  background: linear-gradient(145deg, var(--surface) 0%, var(--surface-2) 100%);
}

.help-hero-title {
  margin: 0 0 0.45rem;
  font-size: clamp(1.15rem, 2.5vw, 1.45rem);
  font-weight: 650;
  letter-spacing: -0.01em;
}

.help-hero-lead {
  margin: 0;
  max-width: 42rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.help-block {
  padding: 0;
  overflow: hidden;
  scroll-margin-top: 5.5rem;
}

.help-block-highlight {
  border-color: var(--border-light);
}

.help-block-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.help-block-num {
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-light);
}

.help-block-title {
  margin: 0;
  font-size: clamp(0.95rem, 2vw, 1.05rem);
  font-weight: 650;
  line-height: 1.3;
}

.help-block-body {
  padding: 1rem 1.15rem 1.15rem;
}

.help-block-body > p:last-child,
.help-block-body > .help-hint:last-child,
.help-block-body > .help-action:last-child {
  margin-bottom: 0;
}

.help-intro {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.92rem;
}

.help-token-targets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1rem;
}

.help-token-chip {
  display: inline-flex;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.help-path {
  margin-top: 1.35rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.help-path-macos {
  padding: 1rem;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.help-path-finish {
  padding: 0.85rem 1rem;
  border: 1px solid rgba(34, 197, 94, 0.25);
  border-radius: 8px;
  background: rgba(34, 197, 94, 0.06);
}

.help-path-head {
  margin-bottom: 0.85rem;
}

.help-path-title {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--text);
}

.help-path-lead {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.45;
}

.help-browser-block {
  margin-bottom: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}

.help-browser-block:last-of-type {
  margin-bottom: 0;
}

.help-browser-block-safari {
  margin-top: 0.85rem;
}

.help-browser-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.help-browser-title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 650;
}

.help-browser-badge {
  flex-shrink: 0;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #4ade80;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.28);
}

.help-browser-body {
  padding: 0.75rem 0.85rem 0.85rem;
}

.help-browser-body .help-step-list {
  margin-bottom: 0;
}

.help-path .help-step-list {
  margin-bottom: 0;
}

.help-step-finish {
  border-color: rgba(34, 197, 94, 0.28);
  background: rgba(34, 197, 94, 0.08);
}

.help-step-finish .help-step-num {
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.12);
}

.help-callout-compact {
  margin-top: 0.85rem;
}

.help-subtitle {
  margin: 1.35rem 0 0.65rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.help-subtitle + .help-intro {
  margin-bottom: 0.85rem;
}

.help-subtitle + .help-step-list {
  margin-top: 0;
}

.help-block-body p {
  margin: 0 0 0.75rem;
  line-height: 1.6;
}

.help-step-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.help-step {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
  padding: 0.75rem 0.85rem;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.help-step-num {
  width: 1.6rem;
  height: 1.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-light);
}

.help-step p {
  margin: 0;
  line-height: 1.55;
  font-size: 0.92rem;
}

.help-code {
  display: inline-block;
  margin: 0 0.15rem;
  padding: 0.12em 0.45em;
  border-radius: 4px;
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", monospace;
  font-size: 0.88em;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.help-callout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.65rem;
  align-items: start;
  margin: 0.75rem 0 0;
  padding: 0.85rem 0.95rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  line-height: 1.55;
}

.help-callout-icon {
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.help-callout strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.88rem;
}

.help-callout p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.help-callout-info {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.22);
}

.help-callout-info .help-callout-icon {
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.15);
}

.help-callout-warn {
  background: rgba(250, 204, 21, 0.08);
  border-color: rgba(250, 204, 21, 0.22);
}

.help-callout-warn .help-callout-icon {
  color: #facc15;
  background: rgba(250, 204, 21, 0.15);
}

.help-feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: 0.65rem;
}

.help-feature {
  padding: 0.75rem 0.85rem;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.help-feature-title {
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.35;
}

.help-feature-desc {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.5;
}

.help-legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: 0.5rem;
}

.help-legend-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  font-size: 0.84rem;
  line-height: 1.4;
  border: 1px solid var(--border);
}

.help-legend-symbol {
  flex: 0 0 1.35rem;
  width: 1.35rem;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
}

.help-legend-list-add {
  background: var(--list-add-bg);
}

.help-legend-list-add .help-legend-symbol {
  color: #60a5fa;
}

.help-legend-add {
  background: var(--add-bg);
}

.help-legend-add .help-legend-symbol {
  color: #4ade80;
}

.help-legend-remove {
  background: var(--remove-bg);
}

.help-legend-remove .help-legend-symbol {
  color: #f87171;
}

.help-legend-gone {
  background: var(--gone-bg);
}

.help-legend-gone .help-legend-symbol {
  color: #c084fc;
}

.help-legend-mutual {
  background: rgba(250, 204, 21, 0.1);
}

.help-hint {
  margin-top: 0.75rem;
}

.help-action {
  margin: 1rem 0 0;
}

.help-action .btn {
  width: 100%;
  max-width: 16rem;
}

.page-settings {
  height: calc(100vh - 4.5rem);
  overflow: hidden;
}

.home-sidebar,
.settings-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
}

.settings-sidebar {
  overflow: hidden;
}

.settings-session-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.settings-session-card .profile-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin-bottom: 0;
}

.settings-main {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0.85rem 1rem 0.9rem;
  gap: 0.65rem;
}

.settings-main .config-form {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.settings-main > .panel-title {
  margin-bottom: 0;
  flex-shrink: 0;
}

.settings-form-footer {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0;
  flex-shrink: 0;
  margin-top: auto;
}

.settings-form-footer .btn-main {
  width: auto;
  min-width: 8rem;
  margin-left: auto;
}

.page-graph {
  max-width: none;
  width: 100%;
  height: calc(100vh - 4.5rem);
  min-height: calc(100vh - 4.5rem);
  padding: 0;
  gap: 0;
  grid-template-columns: minmax(0, 1fr) minmax(15rem, 18.5rem);
  grid-template-rows: minmax(0, 1fr);
  position: relative;
  overflow: hidden;
}

.graph-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #000;
}

.graph-stage:fullscreen,
.graph-stage:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  background: #000;
}

.graph-overlay {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.45rem;
  pointer-events: none;
}

.graph-overlay > * {
  pointer-events: auto;
}

.graph-overlay-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: rgba(17, 17, 17, 0.88);
  color: var(--text);
  cursor: pointer;
}

.graph-overlay-btn:hover {
  border-color: #aaa;
  background: rgba(26, 26, 26, 0.95);
}

.graph-overlay-btn .graph-icon-enter,
.graph-overlay-btn .graph-icon-exit {
  display: block;
  flex-shrink: 0;
}

.graph-overlay-btn .graph-icon-exit {
  display: none;
}

.graph-stage.is-fullscreen .graph-overlay-btn .graph-icon-enter {
  display: none;
}

.graph-stage.is-fullscreen .graph-overlay-btn .graph-icon-exit {
  display: block;
}

.graph-search-form {
  display: flex;
  align-items: center;
  order: -1;
  padding: 0.2rem 0.65rem;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: rgba(17, 17, 17, 0.92);
}

.graph-search-input {
  width: min(16rem, 55vw);
  margin: 0;
  padding: 0.35rem 0;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  outline: none;
}

.graph-search-input::placeholder {
  color: var(--muted);
}

.graph-search-msg {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  margin: 0;
  max-width: 16rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(17, 17, 17, 0.92);
  color: var(--muted);
  font-size: 0.72rem;
  text-align: right;
}

.graph-search-msg.hidden {
  display: none;
}

.graph-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

.graph-panel.hidden {
  display: none;
}

.graph-panel-header {
  flex-shrink: 0;
  padding: 0.75rem 0.85rem 0.55rem;
  border-bottom: 1px solid var(--border);
}

.graph-panel-title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.graph-panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.65rem 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.graph-panel-section {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.65rem 0.7rem;
}

.graph-panel-section-title {
  margin: 0 0 0.55rem;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.graph-panel-stats {
  margin: 0;
  display: grid;
  gap: 0.35rem;
  font-size: 0.72rem;
}

.graph-panel-stats div {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.graph-panel-stats dt {
  margin: 0;
  color: var(--muted);
}

.graph-panel-stats dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.graph-cluster-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 12rem;
  overflow-y: auto;
}

.graph-cluster-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.72rem;
  padding: 0.2rem 0;
}

.graph-cluster-item input[type="checkbox"] {
  flex-shrink: 0;
}

.graph-cluster-swatch {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.graph-cluster-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.graph-cluster-count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.graph-panel-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  border: none;
  padding: 0;
}

.graph-panel .field {
  margin-bottom: 0.45rem;
}

.graph-panel .field:last-child {
  margin-bottom: 0;
}

.graph-panel .field-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.graph-panel .field-label output {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-size: 0.68rem;
}

.graph-panel input[type="range"] {
  width: 100%;
  accent-color: var(--text);
}

@media (max-width: 900px) {
  .page-graph {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .graph-panel {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 42vh;
  }
}

.graph-canvas {
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #000;
}

.page-graph.is-empty {
  grid-template-columns: 1fr;
}

.page-graph.is-empty .graph-panel {
  display: none;
}

.graph-stage.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

.graph-stage.is-empty .graph-overlay,
.graph-stage.is-empty .graph-canvas {
  display: none;
}

.graph-empty {
  position: static;
  z-index: 2;
  width: min(100%, 22rem);
  margin: 0 auto;
  padding: 2rem 1.5rem;
  text-align: center;
  pointer-events: none;
}

.graph-empty.hidden {
  display: none !important;
}

.graph-empty-inner {
  width: 100%;
  text-align: center;
}

.graph-empty-title {
  margin: 0 0 0.45rem;
  font-size: 1rem;
  font-weight: 650;
  color: var(--text);
  text-align: center;
}

.graph-empty-hint {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--muted);
  text-align: center;
}

.graph-empty strong {
  color: var(--text);
}

.home-scan-card {
  flex-shrink: 0;
}

.home-history-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.home-changes-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  container-type: inline-size;
  container-name: changes-panel;
}

.home-changes-panel .scan-header-bar {
  border-bottom: none;
}

.home-changes-panel .legend {
  border-top: none;
}

.home-changes-panel .change-line {
  border-bottom: none;
}

.home-changes-panel .person-group + .person-group {
  border-top: none;
}

.home-changes-panel .person-section-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.home-changes-panel .changes-card {
  border: none;
}

.home-changes-panel .changes-card-header {
  border-bottom: none;
}

.home-changes-panel .changes-card + .changes-section--panel-full {
  border-top: none;
}

.card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0.95rem 1rem;
}

.brand-sub {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.panel-title {
  margin: 0 0 0.6rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.panel-title-row .panel-title {
  margin: 0;
}

.panel-title-row .btn-icon {
  margin-top: 0;
}

.btn.btn-icon,
.btn-icon {
  flex: 0 0 2rem;
  width: 2rem;
  min-width: 2rem;
  max-width: 2rem;
  height: 2rem;
  padding: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  line-height: 1;
  text-align: center;
  border-radius: 6px;
}

.profile-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.profile-card.is-pending {
  opacity: 0.65;
  pointer-events: none;
}

.profile-card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.profile-card .profile-head {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
}

.profile-card .profile-select {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-align: left;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.profile-card .profile-select:hover {
  border-color: var(--border-light);
}

.profile-card.is-active .profile-select {
  border-color: var(--text);
}

.profile-card .session-user,
.profile-card a.session-user {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
}

.profile-card a.session-user:hover {
  color: var(--text);
  text-decoration: underline;
}

.profile-card .session-user.is-empty {
  color: var(--muted);
  font-weight: 500;
}

.profile-card .profile-delete {
  width: 2.1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.profile-card .profile-delete:hover {
  color: var(--text);
  border-color: var(--border-light);
}

.profile-card .profile-actions {
  display: flex;
  gap: 0.4rem;
}

.profile-card .profile-actions .btn {
  flex: 1;
}

.panel-hint {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
}

.panel-hint.warn {
  color: var(--dim);
  font-style: italic;
}

/* Session */

.session-box {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.session-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dim);
  flex-shrink: 0;
}

.session-dot.ok { background: var(--text); }
.session-dot.err { background: var(--muted); outline: 2px solid var(--border-light); }

.session-user {
  font-weight: 600;
  font-size: 0.85rem;
}

.session-source {
  font-size: 0.7rem;
  color: var(--muted);
}

/* Config form */

.config-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.config-form.config-form-grid {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  align-content: stretch;
}

.config-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem 0.85rem;
  flex: 1;
  min-height: 0;
  align-content: stretch;
}

.config-panels > .config-fieldset {
  min-height: 0;
  overflow: auto;
}

.config-fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.7rem 0.65rem;
  margin: 0;
}

.config-fieldset legend {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0 0.25rem;
}

.config-behavior {
  flex-shrink: 0;
  padding: 0.55rem 0.7rem 0.7rem;
}

.config-blacklist {
  flex-shrink: 0;
}

.page-blacklist {
  max-width: 42rem;
}

.blacklist-page-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.1rem 1.2rem 1.25rem;
}

.blacklist-back {
  margin: 0 0 0.35rem;
}

.blacklist-back a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
}

.blacklist-back a:hover {
  color: var(--text);
}

.blacklist-search-field {
  margin-bottom: 0.35rem;
}

.blacklist-search {
  width: 100%;
  max-width: 22rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.blacklist-summary {
  margin: 0;
}

.blacklist-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 18rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}

.blacklist-list-page {
  max-height: min(70vh, 36rem);
}

.blacklist-list:empty {
  display: none;
}

.blacklist-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.blacklist-item:last-child {
  border-bottom: none;
}

.blacklist-item:hover {
  background: var(--surface-2);
}

.blacklist-item.is-excluded {
  background: color-mix(in srgb, var(--remove-bg) 55%, var(--bg));
}

.blacklist-item input[type="checkbox"] {
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.blacklist-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.blacklist-user {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.blacklist-sub {
  color: var(--muted);
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.config-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
}

.config-option {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.config-option:hover {
  border-color: var(--border-light);
  background: var(--surface-2);
}

.config-option:has(input:checked) {
  border-color: color-mix(in srgb, var(--text) 35%, var(--border));
  background: color-mix(in srgb, var(--surface-2) 70%, var(--bg));
}

.config-option input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0.1rem 0 0;
  flex-shrink: 0;
  accent-color: var(--text);
  cursor: pointer;
}

.config-option-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.config-option-title {
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

.config-option-hint {
  font-size: 0.65rem;
  color: var(--dim);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.field.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}

.field {
  display: block;
  margin-bottom: 0.4rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field-label {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.field input:not([type="checkbox"]) {
  width: 100%;
  padding: 0.38rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.78rem;
  font-family: ui-monospace, monospace;
}

.secret-input {
  position: relative;
  display: block;
}

.secret-input input {
  padding-right: 2.4rem;
}

/* Masquage fiable (évite le bug navigateur des input password vidés par JS) */
.secret-input input.is-secret-masked {
  -webkit-text-security: disc;
  text-security: disc;
}

.secret-toggle {
  position: absolute;
  top: 50%;
  right: 0.25rem;
  transform: translateY(-50%);
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.secret-toggle:hover {
  color: var(--text);
  background: var(--surface-2);
}

.secret-toggle-icon {
  width: 1.05rem;
  height: 1.05rem;
  display: block;
  background: currentColor;
  /* œil (masqué par défaut = password) */
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E") center / contain no-repeat;
}

.secret-toggle[aria-pressed="true"] .secret-toggle-icon {
  /* œil barré (valeur visible) */
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24'/%3E%3Cline x1='1' y1='1' x2='23' y2='23'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24'/%3E%3Cline x1='1' y1='1' x2='23' y2='23'/%3E%3C/svg%3E") center / contain no-repeat;
}

.field-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.65rem;
  cursor: pointer;
  font-size: 0.8rem;
}

.field-checkbox input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--text);
  cursor: pointer;
}

.field input:focus {
  outline: none;
  border-color: var(--border-light);
}

.field-hint {
  margin: 0.25rem 0 0.4rem;
  font-size: 0.66rem;
  color: var(--dim);
  line-height: 1.35;
}

.field + .field-hint {
  margin-top: 0.2rem;
}

.btn-sm {
  margin-top: 0.35rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.75rem;
  text-align: center;
}

.config-msg {
  font-size: 0.75rem;
  padding: 0.5rem 0.65rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.config-msg.ok {
  border-color: var(--border-light);
  color: var(--text);
}

.config-msg.err {
  border-color: var(--border-light);
  color: var(--muted);
}

.config-msg.hidden {
  display: none;
}

/* Buttons */

.btn {
  display: block;
  width: 100%;
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border-light);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-main {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  text-align: center;
  font-weight: 600;
}

.btn-main:hover:not(:disabled) {
  background: #ddd;
  border-color: #ddd;
  color: var(--bg);
}

.btn-ghost {
  margin-top: 0.5rem;
}

.btn-test-session {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-test-mark {
  display: none;
  width: 1.05rem;
  height: 1.05rem;
  flex: 0 0 auto;
  background: currentColor;
  -webkit-mask: center / contain no-repeat;
  mask: center / contain no-repeat;
}

.btn-test-session.is-ok,
.btn-test-session.is-err {
  font-weight: 600;
}

.btn-test-session.is-ok {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.55);
  background: rgba(34, 197, 94, 0.12);
}

.btn-test-session.is-ok .btn-test-mark {
  display: block;
  /* check */
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
}

.btn-test-session.is-err {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.55);
  background: rgba(239, 68, 68, 0.12);
}

.btn-test-session.is-err .btn-test-mark {
  display: block;
  /* x */
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3C/svg%3E");
}

.btn-test-session.is-testing {
  opacity: 0.7;
}

.btn-desc {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--muted);
  margin-top: 0.15rem;
}

/* Advanced */

.advanced {
  margin-top: 0.75rem;
}

.advanced summary {
  font-size: 0.75rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  padding: 0.35rem 0;
  list-style: none;
}

.advanced summary::-webkit-details-marker { display: none; }

.advanced summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s;
}

.advanced[open] summary::before {
  transform: rotate(90deg);
}

.advanced-body {
  padding: 0.5rem 0 0;
}

/* Job progress */

.job-panel {
  margin-top: 0.85rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.job-panel.hidden { display: none; }

.job-panel.job-error { border-color: var(--border-light); }

.job-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.job-progress {
  margin-bottom: 0.65rem;
}

.job-progress.hidden {
  display: none;
}

.job-sublabel {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--dim);
  margin-bottom: 0.25rem;
}

.job-text {
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  word-break: break-all;
}

.job-panel.job-error .job-text { color: var(--text); }

.job-stop {
  margin-top: 0.75rem;
  width: 100%;
}

.progress-track {
  height: 3px;
  background: var(--border);
  border-radius: 1px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--text);
  transition: width 0.3s ease;
}

/* History */

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

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

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

.history-item {
  display: grid;
  grid-template-columns: 2.2rem 1fr auto;
  gap: 0.25rem 0.5rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  margin-bottom: 2px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  font-size: 0.72rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.history-item:hover {
  background: var(--bg);
  border-color: var(--border);
}

.history-item.active {
  background: var(--bg);
  border-color: var(--text);
}

.history-item.search-miss {
  opacity: 0.35;
}

.history-item.search-hit:not(.active) {
  border-color: rgba(96, 165, 250, 0.55);
}

.search-scan-link {
  margin: 0 0.15rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  cursor: pointer;
}

.search-scan-link:hover {
  border-color: #60a5fa;
  color: #60a5fa;
}

.h-id {
  color: var(--muted);
  font-family: ui-monospace, monospace;
}

.h-date {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.h-changes {
  font-family: ui-monospace, monospace;
  color: var(--muted);
}

.history-item.active .h-changes,
.history-item.has-changes .h-changes {
  color: var(--text);
  font-weight: 600;
}


.scan-header-bar {
  padding: 0.75rem 1.15rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 0.75rem;
  flex-shrink: 0;
}

.scan-subject {
  flex: 0 1 12.5rem;
  width: 12.5rem;
  max-width: 100%;
  min-width: 0;
  text-align: left;
}

.scan-subject[hidden] {
  display: none !important;
}

.scan-subject-user {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scan-subject-sub {
  margin-top: 0.15rem;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.changes-search {
  display: block;
  flex: 0 1 12.5rem;
  width: 12.5rem;
  max-width: 100%;
  min-width: 0;
  margin-left: auto;
}

.changes-search-input {
  width: 100%;
  min-width: 0;
  height: 2.25rem;
  padding: 0 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  line-height: 1.2;
  transition: border-color 0.12s, background 0.12s;
}

.changes-search-input::placeholder {
  color: var(--muted);
}

.changes-search-input:hover {
  border-color: var(--border-light);
}

.changes-search-input:focus {
  outline: none;
  border-color: var(--text);
  background: var(--surface-2);
}

.changes-search-empty {
  margin: 0;
  padding: 1rem 1.25rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  flex-shrink: 0;
}

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

.scan-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  flex: 1 1 12rem;
  width: auto;
  max-width: 100%;
  min-width: 0;
  margin: 0;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.12s, background 0.12s;
}

.nav-btn:hover:not(:disabled) {
  border-color: var(--text);
  background: var(--surface-2);
}

.nav-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.scan-info {
  text-align: center;
  min-width: 0;
  flex: 1 1 auto;
  padding: 0 0.1rem;
  overflow: hidden;
}

.scan-date {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scan-meta {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.15rem;
  font-family: ui-monospace, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@container changes-panel (max-width: 36rem) {
  .scan-header-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .scan-subject,
  .scan-nav,
  .changes-search {
    flex: none;
    width: 100%;
    max-width: none;
    margin-left: 0;
  }

  .scan-subject {
    text-align: center;
  }

  .scan-nav {
    order: 1;
  }

  .changes-search {
    order: 2;
  }
}

.content {
  flex: 1;
  padding: 1rem 1.25rem;
  overflow-y: auto;
  min-height: 0;
}

.home-changes-panel .content:has(.changes-layout) {
  padding: 0;
}

.home-changes-panel .person-group.changes-group {
  padding: 0;
}

.home-changes-panel .person-group-title {
  padding: 0.35rem 0 0.15rem;
}

.home-changes-panel .changes-section.changes-section--panel-full {
  overflow: visible;
}

.home-changes-panel .person-section-body > .person-group:first-child .person-group-title {
  padding-top: 0.35rem;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 4rem 1.5rem;
  font-size: 0.9rem;
  max-width: 24rem;
  margin: 0 auto;
  line-height: 1.6;
}

.empty strong {
  color: var(--text);
  font-weight: 600;
}

/* Changes */

.changes-layout {
  width: 100%;
}

.changes-section {
  width: 100%;
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.changes-section--panel-full {
  margin: 0;
  width: 100%;
  border: none;
  border-radius: 0;
}

.changes-section.changes-section--panel-full {
  margin-top: 0;
}

.changes-card + .changes-section--panel-full {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
}

.page-home .changes-card {
  max-width: none;
  margin: 0;
}

.changes-layout > .changes-card:last-child {
  border-bottom: none;
}

.changes-layout > .changes-section--panel-full:last-child .person-section-body > .person-group:last-child > .change-line:last-child {
  border-bottom: none;
}

.changes-card {
  max-width: 36rem;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.changes-card-header {
  padding: 0.85rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.85rem;
}

.changes-card-header .sub {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.75rem;
  font-family: ui-monospace, monospace;
}

.changes-group {
  padding: 0.5rem 0;
}

.changes-group-title {
  padding: 0.4rem 1.25rem 0.25rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.person-group-title {
  padding: 0.55rem 1.25rem 0.35rem;
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  font-weight: 600;
}

.person-group + .person-group {
  border-top: 1px solid var(--border);
}

a.person-subject {
  color: var(--subject-color);
  font-weight: 600;
  text-decoration: none;
}

a.person-subject:hover {
  color: #fde047;
  text-decoration: underline;
}

.person-delta {
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.person-delta-add {
  color: #4ade80;
}

.person-delta-remove {
  color: #f87171;
}

.change-line {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 1.25rem;
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border);
}

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

.change-trail {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  margin-left: auto;
}

.change-line:last-child { border-bottom: none; }

.change-line.add {
  background: var(--add-bg);
}

.change-line.list-add {
  background: var(--list-add-bg);
}

.change-line.remove {
  background: var(--remove-bg);
}

.change-line.gone {
  background: var(--gone-bg);
}

.change-op {
  width: 1rem;
  flex-shrink: 0;
  font-weight: 700;
  color: var(--muted);
}

.change-line.add .change-op::before { content: "+"; }
.change-line.add .change-op { color: #4ade80; }
.change-line.list-add .change-op::before { content: ">"; }
.change-line.list-add .change-op { color: #60a5fa; }
.change-line.remove .change-op::before { content: "−"; }
.change-line.remove .change-op { color: #f87171; }
.change-line.gone .change-op::before { content: "×"; }
.change-line.gone .change-op { color: #c084fc; }

.change-user-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  flex-wrap: wrap;
}

.change-user,
a.change-user {
  font-weight: 600;
}

a.change-user {
  color: inherit;
  text-decoration: none;
}

a.change-user:hover {
  text-decoration: underline;
}

.session-user a.change-user {
  color: inherit;
}

.badge-verified {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  margin-left: 0;
  line-height: 0;
}

.badge-verified img {
  display: block;
  width: 16px;
  height: 16px;
}

.badge-mutual {
  display: inline-flex;
  align-items: center;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #111;
  background: var(--subject-color);
  line-height: 1.3;
}

.legend-badge {
  vertical-align: middle;
}

.legend .badge-verified {
  margin-left: 0;
}

.change-name { color: var(--muted); }

.change-detail {
  color: var(--muted);
  font-size: 0.75rem;
}

/* Legend */

.legend {
  padding: 0.75rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.65rem 1.1rem;
  font-size: 0.7rem;
  color: var(--muted);
}

.legend-filter {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.15rem 0.1rem;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.legend-filter:hover {
  color: var(--text);
}

/* Actif = type masqué : gris + barre traversante */
.legend-filter.is-active,
.legend-filter[aria-pressed="true"] {
  color: var(--dim);
  text-decoration: none;
}

.legend-filter.is-active::after,
.legend-filter[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  left: -0.1rem;
  right: -0.1rem;
  top: 50%;
  height: 2px;
  background: var(--dim);
  transform: translateY(-50%);
  pointer-events: none;
}

.legend-filter.is-active strong,
.legend-filter[aria-pressed="true"] strong,
.legend-filter.is-active .badge-mutual,
.legend-filter[aria-pressed="true"] .badge-mutual,
.legend-filter.is-active .badge-verified,
.legend-filter[aria-pressed="true"] .badge-verified {
  opacity: 0.45;
  filter: grayscale(1);
}

.legend strong {
  color: var(--text);
  font-family: ui-monospace, monospace;
}

.legend-list-add {
  color: #60a5fa;
}

.legend-gone {
  color: #c084fc;
}

/* Dialog */

.dialog {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  max-width: 22rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
}

.dialog-box {
  padding: 1.25rem;
  margin: 0;
}

.dialog-box h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.dialog-box p {
  margin: 0 0 1.25rem;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

.dialog-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.dialog-actions .btn {
  width: auto;
  min-width: 5.5rem;
  text-align: center;
}

.hidden { display: none !important; }

/* Mobile */

@media (max-width: 900px) {
  .page-home,
  .page-settings,
  .page-help {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .help-sidebar {
    position: static;
    order: -1;
  }

  .help-toc {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.4rem;
    padding-bottom: 0.15rem;
    scrollbar-width: thin;
  }

  .help-toc-link {
    flex: 0 0 auto;
    max-width: 14rem;
    padding: 0.4rem 0.65rem;
    white-space: nowrap;
  }

  .help-toc-num {
    width: 1.2rem;
    height: 1.2rem;
    font-size: 0.68rem;
  }

  .help-quick-links {
    display: none;
  }

  .help-block {
    scroll-margin-top: 7rem;
  }

  .page-settings {
    height: auto;
    overflow: visible;
  }

  .settings-main {
    overflow: visible;
  }

  .config-panels {
    grid-template-columns: 1fr;
  }

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

  .home-history-card {
    max-height: 14rem;
  }
}

@media (max-width: 640px) {
  .page-help {
    padding: 0.85rem;
    gap: 0.75rem;
  }

  .help-hero,
  .help-block-body {
    padding-left: 0.9rem;
    padding-right: 0.9rem;
  }

  .help-block-head {
    padding: 0.75rem 0.9rem;
  }

  .help-feature-grid,
  .help-legend-grid {
    grid-template-columns: 1fr;
  }

  .help-action .btn {
    max-width: none;
    width: 100%;
  }

  .config-options {
    grid-template-columns: 1fr;
  }
}
