:root {
  --bg: #0c1016;
  --panel: rgba(19, 27, 38, 0.84);
  --panel-border: rgba(127, 155, 194, 0.18);
  --text: #edf4ff;
  --muted: #93a4bf;
  --accent: #6fd0ff;
  --link: #7ef2c3;
  --graph-bg: radial-gradient(circle at top, #1d2940 0%, #111823 52%, #090d14 100%);
  --shadow: 0 24px 54px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(111, 208, 255, 0.16), transparent 24%),
    linear-gradient(135deg, #0f1520, #0b1119 58%, #06090e);
}

button,
input,
textarea,
select,
a {
  font: inherit;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Fraunces", serif;
  line-height: 1.05;
}

h1 {
  font-size: 2.2rem;
}

h2 {
  font-size: 1.35rem;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.lede,
.hint,
.status,
.person-card__meta {
  color: var(--muted);
}

.hint,
.status {
  font-size: 0.92rem;
}

.status {
  min-height: 1.2em;
  margin: 10px 0 0;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.94rem;
  font-weight: 500;
}

input,
textarea,
select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid rgba(127, 155, 194, 0.18);
  border-radius: 14px;
  background: rgba(14, 20, 30, 0.88);
  color: var(--text);
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(111, 208, 255, 0.22);
  border-color: var(--accent);
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 700;
  color: #071018;
  background: linear-gradient(135deg, #6fd0ff, #7ef2c3);
  cursor: pointer;
  transition: transform 140ms ease;
  box-shadow: 0 10px 24px rgba(111, 208, 255, 0.22);
}

button:hover {
  transform: translateY(-1px);
}

.text-link,
.person-card__link {
  color: var(--link);
  font-weight: 700;
  text-decoration: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  padding: 24px;
  border-right: 1px solid var(--panel-border);
  background: rgba(10, 15, 23, 0.92);
  backdrop-filter: blur(24px);
  overflow-y: auto;
}

.panel {
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-panel {
  background:
    linear-gradient(160deg, rgba(22, 31, 44, 0.95), rgba(14, 21, 32, 0.92)),
    var(--panel);
}

.controls-panel,
form,
.detail-grid,
.selected-person,
.link-toggles-panel,
.toggle-list {
  display: grid;
  gap: 12px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.graph-stage,
.graph-page {
  position: relative;
  min-height: 100vh;
  padding: 24px;
}

.page-public .graph-page {
  padding: 0;
  overflow: hidden;
}

.graph-stage--admin {
  padding: 26px;
}

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

#graph {
  width: 100%;
  height: calc(100vh - 48px);
  border-radius: 32px;
  border: 1px solid rgba(127, 155, 194, 0.14);
  background: var(--graph-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), var(--shadow);
  touch-action: none;
}

.page-public #graph {
  height: 100vh;
  border-radius: 0;
  border: 0;
  box-shadow: none;
}

.page-admin #graph {
  height: calc(100vh - 90px);
}

#edge-layer path {
  fill: none;
  stroke: rgba(187, 205, 230, 0.34);
  stroke-width: 2.4;
}

#group-layer,
#arrow-layer {
  pointer-events: none;
}

.group-visual__shape {
  stroke-width: 2;
  stroke-dasharray: 10 8;
}

.group-visual__label {
  font-size: 13px;
  font-weight: 700;
  text-anchor: middle;
  paint-order: stroke;
  stroke: rgba(9, 13, 20, 0.9);
  stroke-width: 6px;
  stroke-linejoin: round;
}

#arrowhead path {
  fill: rgba(205, 222, 246, 0.76);
}

#edge-layer path.edge--romantic {
  stroke: rgba(46, 153, 77, 0.88);
  stroke-dasharray: 8 8;
}

#edge-layer path.edge--intimate {
  stroke: rgba(196, 42, 42, 0.9);
  stroke-dasharray: 4 7;
}

.node {
  cursor: pointer;
  pointer-events: all;
}

.node-hit {
  pointer-events: all;
  fill: rgba(0, 0, 0, 0.001);
  stroke: none;
}

.node-visual {
  fill: rgba(226, 237, 255, 0.96);
  stroke: rgba(111, 208, 255, 0.18);
  stroke-width: 3;
  transition: stroke 180ms ease;
}

.node-group-ring {
  fill: none;
  stroke: transparent;
  stroke-width: 5;
  opacity: 0;
}

.node.has-group .node-group-ring {
  stroke: var(--group-color, rgba(159, 181, 212, 0.82));
  opacity: 1;
}

.node-avatar,
.node-visual,
.node-hit {
  cursor: grab;
}

.node-avatar {
  pointer-events: none;
}

.node text {
  font-size: 14px;
  font-weight: 700;
  fill: var(--text);
  text-anchor: middle;
  pointer-events: none;
}

.node:hover .node-visual,
.node.is-active .node-visual {
  stroke: var(--accent);
}

.node.is-self .node-visual {
  stroke: #2f7c71;
  stroke-width: 5;
  filter:
    drop-shadow(0 0 0 rgba(47, 124, 113, 0.24))
    drop-shadow(0 0 22px rgba(47, 124, 113, 0.38));
}

.node.is-self .node-avatar {
  filter: saturate(1.08) brightness(1.02);
}

.node.is-dragging .node-visual {
  stroke: var(--link);
  filter: drop-shadow(0 12px 18px rgba(47, 124, 113, 0.22));
}

.node.is-dragging .node-avatar,
.node.is-dragging .node-visual,
.node.is-dragging .node-hit {
  cursor: grabbing;
}

#arrow-layer path {
  pointer-events: none;
}

.person-card {
  display: flex;
  gap: 14px;
  align-items: center;
}

.person-card--compact {
  align-items: flex-start;
}

.person-card__avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid rgba(237, 244, 255, 0.18);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.24);
}

.person-card--compact .person-card__avatar {
  width: 56px;
  height: 56px;
}

.person-card__name {
  margin-bottom: 6px;
}

.person-card__alias {
  margin: 0 0 6px;
  font-size: 0.88rem;
  color: var(--muted);
}

.detail-grid {
  margin-top: 14px;
}

.detail-label {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

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

.chip {
  border: 1px solid rgba(126, 242, 195, 0.18);
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 0.88rem;
  color: var(--link);
  background: rgba(13, 26, 24, 0.92);
}

.chip--group {
  border-color: color-mix(in srgb, var(--chip-color, #6fd0ff) 34%, transparent);
  color: var(--chip-color, #6fd0ff);
  background: color-mix(in srgb, var(--chip-color, #6fd0ff) 14%, rgba(13, 26, 24, 0.92));
 }

.chip--group::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--chip-color, #6fd0ff);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--chip-color, #6fd0ff) 18%, transparent);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.92rem;
  font-weight: 500;
}

.switch {
  position: relative;
  display: inline-flex;
  width: 54px;
  height: 32px;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch__slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(127, 155, 194, 0.22);
  transition: background 160ms ease;
}

.switch__slider::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #f3fbff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.24);
  transition: transform 160ms ease;
}

.switch input:checked + .switch__slider {
  background: linear-gradient(135deg, #6fd0ff, #7ef2c3);
}

.switch input:checked + .switch__slider::before {
  transform: translateX(22px);
}

.overlay-card {
  position: absolute;
  z-index: 2;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: rgba(17, 25, 37, 0.84);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

.overlay-stack {
  position: absolute;
  z-index: 2;
  display: grid;
  gap: 14px;
}

.overlay-stack--bottom-left {
  left: 32px;
  bottom: 32px;
  width: min(390px, calc(100vw - 64px));
  max-height: calc(100vh - 64px);
}

.overlay-panel {
  margin: 0;
  display: grid;
  align-content: end;
  gap: 10px;
  max-height: 100%;
}

.overlay-panel__summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  margin-bottom: 0;
  padding: 10px 12px 10px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: rgba(17, 25, 37, 0.72);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.overlay-panel__summary::-webkit-details-marker {
  display: none;
}

.overlay-panel__label {
  display: grid;
  gap: 2px;
}

.overlay-panel__actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.overlay-panel__icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid rgba(127, 155, 194, 0.18);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(34, 48, 69, 0.9);
  color: var(--text);
  box-shadow: none;
  transform: none;
  transition:
    background 140ms ease,
    color 140ms ease,
    border-color 140ms ease,
    opacity 140ms ease;
}

.overlay-panel__icon-button:hover {
  transform: none;
  border-color: rgba(111, 208, 255, 0.38);
  background: rgba(42, 60, 85, 0.96);
}

.overlay-panel__icon-button--display {
  pointer-events: none;
  opacity: 0.92;
}

.overlay-panel__icon-button.is-active {
  background: linear-gradient(135deg, #6fd0ff, #7ef2c3);
  color: #071018;
}

.overlay-panel:not([open]) .overlay-card--controls {
  display: none;
}

.overlay-card--server {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  max-width: 100%;
}

.page-public .overlay-card--server {
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  padding-left: 0;
}

.overlay-card--controls {
  position: static;
  width: 100%;
  max-height: min(620px, calc(100vh - 132px));
  overflow: auto;
  padding: 14px 15px;
  display: grid;
  gap: 12px;
  background: rgba(17, 25, 37, 0.3);
  transition: background 180ms ease;
  scrollbar-width: thin;
}

.overlay-card--watermark {
  position: absolute;
  padding: 10px 0 0;
}

.overlay-card--bottom-right {
  right: 32px;
  bottom: 32px;
  max-width: min(560px, calc(100vw - 64px));
  width: min(560px, calc(100vw - 64px));
}

.overlay-card--controls:hover {
  background: rgba(17, 25, 37, 0.84);
}

.overlay-block {
  display: grid;
  gap: 8px;
}

.server-logo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid rgba(237, 244, 255, 0.18);
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.24);
  background: rgba(237, 244, 255, 0.08);
}

.legend-list {
  display: grid;
  gap: 10px;
}

.zoom-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.zoom-row button {
  padding: 7px 11px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
}

.legend-line {
  display: inline-block;
  width: 52px;
  height: 0;
  border-top: 3px solid rgba(187, 205, 230, 0.5);
  border-radius: 999px;
}

.legend-line--introduction::after {
  content: ">";
  position: relative;
  left: 46px;
  top: -11px;
  color: rgba(237, 244, 255, 0.76);
  font-weight: 700;
}

.legend-line--romantic {
  border-top-style: dashed;
  border-top-color: rgba(46, 153, 77, 0.88);
}

.legend-line--intimate {
  border-top-style: dotted;
  border-top-color: rgba(196, 42, 42, 0.9);
}

.selected-person--compact {
  min-height: 0;
}

.selected-person--compact .person-card {
  gap: 10px;
}

.selected-person--compact .person-card__avatar {
  width: 48px;
  height: 48px;
}

.selected-person--compact .detail-grid {
  margin-top: 10px;
  gap: 10px;
}

.session-block {
  padding-top: 4px;
  border-top: 1px solid rgba(127, 155, 194, 0.12);
}

.session-card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.session-card__avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(237, 244, 255, 0.18);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.24);
}

.session-card__name,
.session-card__meta {
  margin: 0;
}

.session-card__name {
  font-size: 0.92rem;
  font-weight: 700;
}

.session-card__meta {
  font-size: 0.84rem;
  color: var(--muted);
}

.logout-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  margin-top: 2px;
  border-radius: 999px;
  padding: 10px 14px;
  color: #071018;
  font-weight: 700;
  text-decoration: none;
  background: linear-gradient(135deg, #6fd0ff, #7ef2c3);
  box-shadow: 0 10px 24px rgba(111, 208, 255, 0.2);
}

.file-upload {
  overflow: hidden;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--panel-border);
  }

  .page-admin #graph {
    height: 70vh;
  }
}

@media (max-width: 720px) {
  .graph-page,
  .graph-stage {
    padding: 12px;
  }

  #graph {
    height: calc(100vh - 24px);
    border-radius: 24px;
  }

  .page-public #graph {
    border-radius: 0;
  }

  .overlay-stack--bottom-left,
  .overlay-card--bottom-right {
    left: 16px;
    right: 16px;
    width: auto;
  }

  .overlay-card--server,
  .overlay-card--controls,
  .overlay-panel__summary {
    width: 100%;
  }
}
