:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-muted: #f7f8f8;
  --ink: #171b1f;
  --muted: #626b73;
  --line: #d9dddf;
  --accent: #f3c43b;
  --accent-strong: #be7f15;
  --teal: #1f8a8a;
  --green: #167a3d;
  --red: #b42318;
  --shadow: 0 12px 28px rgba(24, 30, 34, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(245, 243, 238, 0)),
    var(--bg);
  color: var(--ink);
  overflow-x: hidden;
}

body.dark-mode {
  --bg: #101417;
  --surface: #171d21;
  --surface-muted: #20272c;
  --ink: #f4f1e9;
  --muted: #aab3ba;
  --line: #303a41;
  --accent: #f3c43b;
  --accent-strong: #f0a42a;
  --shadow: 0 14px 30px rgba(0, 0, 0, 0.28);
  background: var(--bg);
}

a {
  color: #126d7a;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

body.dark-mode a {
  color: #7bd3dd;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

h1,
h2,
h3 {
  margin: 0 0 16px;
  line-height: 1.12;
  letter-spacing: 0;
}

h1 {
  font-size: 34px;
  font-weight: 760;
}

h2 {
  font-size: 22px;
  font-weight: 720;
}

h3 {
  font-size: 17px;
  font-weight: 700;
}

p {
  margin: 0 0 16px;
}

hr {
  margin: 24px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

body.dark-mode .site-header {
  background: rgba(16, 20, 23, 0.9);
}

.navbar {
  width: min(1180px, calc(100% - 32px));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid #171b1f;
  background: var(--accent);
  color: #171b1f;
  font-size: 14px;
  font-weight: 900;
}

.brand-text {
  font-size: 18px;
}

.nav-links {
  margin: 0 0 0 auto;
  padding: 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-links a,
.nav-dropdown-trigger {
  display: block;
  padding: 9px 11px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  min-height: 0;
  cursor: pointer;
}

.nav-links a:hover,
.nav-dropdown-trigger:hover,
.nav-dropdown-trigger:focus-visible {
  background: var(--surface-muted);
  color: var(--ink);
  text-decoration: none;
  transform: none;
  outline: none;
}

.nav-dropdown {
  position: relative;
}

.nav-dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 1001;
  display: none;
  min-width: 240px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu {
  display: grid;
  gap: 2px;
}

.nav-links .nav-dropdown-menu a {
  padding: 9px 10px;
}

.theme-toggle,
.nav-toggle,
button,
input[type="submit"],
.button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid #171b1f;
  border-radius: 6px;
  background: #171b1f;
  color: #fff;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  box-shadow: none;
}

.theme-toggle {
  min-width: 64px;
  margin-left: 4px;
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.theme-toggle:hover,
button:hover,
input[type="submit"]:hover,
.button:hover {
  transform: translateY(-1px);
  text-decoration: none;
}

.nav-toggle {
  display: none;
  width: 42px;
  padding: 0;
  margin-left: auto;
  background: var(--surface);
  border-color: var(--line);
}

.nav-toggle span {
  width: 18px;
  height: 2px;
  margin: 2px 0;
  background: var(--ink);
}

.nav-links .nav-dropdown-trigger {
  appearance: none;
  display: block;
  min-height: 0;
  padding: 9px 11px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.5;
  white-space: nowrap;
  box-shadow: none;
}

.nav-links .nav-dropdown-trigger:hover,
.nav-links .nav-dropdown-trigger:focus-visible {
  background: var(--surface-muted);
  color: var(--ink);
  transform: none;
  outline: none;
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 54px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.page-kicker {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lede {
  max-width: 720px;
  color: var(--muted);
  font-size: 18px;
}

.panel,
.summary-block,
.network-section {
  margin-bottom: 24px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-block p {
  white-space: pre-wrap;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.form-grid .form-action {
  align-self: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.form-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.form-note.is-sampled {
  color: var(--accent-strong);
}

.form-note.is-complete {
  color: var(--green);
}

.panel > form:not(.form-grid) {
  display: grid;
  max-width: 620px;
  gap: 14px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

input,
textarea,
select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

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

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(31, 138, 138, 0.22);
  border-color: var(--teal);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  background: var(--surface-muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

tbody tr:hover {
  background: var(--surface-muted);
}

.rank-cell {
  width: 72px;
  color: var(--muted);
  font-weight: 750;
}

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

.note {
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  background: var(--surface-muted);
  color: var(--muted);
}

.flash-messages {
  width: min(1180px, calc(100% - 32px));
  margin: 16px auto 0;
}

.flash-message {
  padding: 12px 14px;
  border-radius: 6px;
  color: #fff;
  font-weight: 650;
}

.flash-message.success {
  background: var(--green);
}

.flash-message.error {
  background: var(--red);
}

.comment-list,
.comment-list ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.comment-list > li {
  margin-bottom: 10px;
}

.drop-item {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.drop-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.drop-author {
  font-weight: 850;
}

.drop-time {
  color: var(--muted);
}

.drop-reply-indicator {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.drop-content {
  white-space: pre-wrap;
}

.drop-replies {
  margin: 12px 0 0 16px;
  padding-left: 16px;
  border-left: 2px solid var(--line);
}

.drop-replies .drop-item {
  box-shadow: none;
}

.wisdom-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.wisdom-summary > div {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric-value {
  display: block;
  color: var(--ink);
  font-size: 24px;
  font-weight: 850;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.wisdom-feed {
  display: grid;
  gap: 10px;
}

.wisdom-drop {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.wisdom-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.wisdom-author {
  color: var(--accent-strong);
  font-weight: 900;
}

.wisdom-wave {
  font-weight: 750;
}

.wisdom-content {
  white-space: pre-wrap;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-top: 22px;
}

.pagination-status {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.button.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.loading-state {
  display: none;
  margin: 18px 0 0;
  color: var(--muted);
}

.author-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 14px;
}

.author-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.avatar,
.avatar-fallback {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-fallback {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--accent);
  color: #171b1f;
  font-weight: 850;
}

.network-canvas {
  width: 100%;
  height: 660px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(23, 33, 38, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 33, 38, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 18% 12%, rgba(31, 138, 138, 0.12), transparent 28%),
    radial-gradient(circle at 82% 20%, rgba(243, 196, 59, 0.12), transparent 26%),
    #fff;
  background-size: 28px 28px, 28px 28px, auto, auto, auto;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.86), inset 0 -18px 36px rgba(23, 33, 38, 0.04);
  overflow: hidden;
}

.network-canvas canvas {
  outline: none;
}

body.dark-mode .network-canvas {
  background:
    linear-gradient(rgba(244, 241, 233, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(244, 241, 233, 0.045) 1px, transparent 1px),
    radial-gradient(circle at 18% 12%, rgba(31, 138, 138, 0.16), transparent 28%),
    radial-gradient(circle at 82% 20%, rgba(243, 196, 59, 0.12), transparent 26%),
    #11171b;
  background-size: 28px 28px, 28px 28px, auto, auto, auto;
}

.network-canvas-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin: -4px 0 10px;
}

.network-tool-button {
  min-height: 32px;
  padding: 6px 10px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.network-tool-button:hover {
  background: var(--surface-muted);
  transform: none;
}

.network-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  margin: -2px 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-dot,
.legend-line {
  display: inline-block;
  flex: 0 0 auto;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border: 2px solid var(--teal);
  border-radius: 999px;
  background: #d8f1ef;
}

.legend-dot.is-top {
  border-color: var(--accent);
  background: #fff0a8;
}

.legend-dot.is-selected {
  border-color: #2f6fed;
  background: #dfe9ff;
}

.legend-dot.is-cluster {
  border-color: #7856d8;
  background: #ece6ff;
}

.legend-line {
  width: 24px;
  height: 3px;
  border-radius: 999px;
  background: rgba(22, 122, 61, 0.62);
}

.legend-line.is-negative {
  background: rgba(180, 35, 24, 0.72);
}

.legend-line.is-muted {
  background: rgba(89, 99, 106, 0.42);
}

div.vis-tooltip {
  max-width: 300px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12px;
  line-height: 1.4;
  white-space: normal;
}

body.dark-mode div.vis-tooltip {
  background: var(--surface);
  color: var(--ink);
}

.network-toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  align-items: end;
}

.network-status {
  margin: -4px 0 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.network-status.is-stale {
  color: var(--red);
}

.network-metric {
  min-height: 22px;
  margin: -2px 0 10px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
}

.network-actions {
  margin: 0 0 12px;
}

.rep-trail {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.rep-trail-heading {
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 850;
}

.rep-trail-summary {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.rep-trail-list {
  display: grid;
  gap: 8px;
}

.rep-trail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.rep-trail-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.rep-trail-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.rep-trail-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.rep-trail-row span {
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.rep-trail-rating {
  color: var(--green);
  font-weight: 850;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.zk-steps {
  margin: 18px 0 0;
  padding-left: 22px;
}

.zk-steps li {
  margin: 10px 0;
  padding-left: 4px;
}

.content-list {
  margin: 0;
  padding-left: 20px;
}

.content-list li {
  margin: 8px 0;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

@media (max-width: 900px) {
  .navbar {
    min-height: 64px;
  }

  .nav-toggle {
    display: inline-flex;
    flex-direction: column;
  }

  .nav-links {
    position: absolute;
    top: 64px;
    right: 16px;
    left: 16px;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .nav-links.show {
    display: flex;
  }

  .nav-dropdown-menu {
    position: static;
    display: grid;
    min-width: 0;
    margin: 2px 0 4px 10px;
    padding: 4px;
    border: 0;
    box-shadow: none;
    background: var(--surface-muted);
  }

  .theme-toggle {
    margin-left: 0;
  }

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

@media (max-width: 640px) {
  h1 {
    font-size: 28px;
  }

  .page-shell,
  .navbar,
  .flash-messages {
    width: min(100% - 24px, 1180px);
  }

  .page-header {
    display: block;
  }

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

  .panel,
  .summary-block,
  .network-section {
    padding: 16px;
  }

  .network-canvas {
    height: 520px;
  }
}
