:root {
  color-scheme: light;
  --bg: #f7f6f1;
  --surface: #ffffff;
  --surface-soft: #efeee8;
  --ink: #171816;
  --muted: #65675f;
  --line: #d9d9d0;
  --shadow: 0 22px 70px rgba(25, 27, 24, 0.10);
  --radius: 22px;
  --focus: #171816;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% -10%, rgba(255, 243, 108, 0.28), transparent 31rem),
    radial-gradient(circle at 100% 15%, rgba(130, 183, 223, 0.20), transparent 28rem),
    var(--bg);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
[role="button"]:focus-visible {
  outline: 3px solid rgba(23, 24, 22, 0.22);
  outline-offset: 3px;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 76px;
  padding: 12px clamp(18px, 4vw, 52px);
  border-bottom: 1px solid rgba(23, 24, 22, 0.08);
  background: rgba(247, 246, 241, 0.88);
  backdrop-filter: blur(18px);
}

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

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 16px;
  letter-spacing: -0.02em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid rgba(23, 24, 22, 0.22);
  border-radius: 50%;
  background: conic-gradient(
    #f6d77f 0 14%,
    #f77f83 14% 28%,
    #8d8d8d 28% 42%,
    #82b7df 42% 56%,
    #fff36c 56% 74%,
    #b9a1d0 74% 86%,
    #8bd5aa 86% 100%
  );
  box-shadow: inset 0 0 0 8px rgba(255,255,255,.58);
}

.connection-cluster {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}

.status-pill,
.presence-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.7);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c49719;
}

.status-pill.is-live .status-dot {
  background: #2c9d58;
  box-shadow: 0 0 0 4px rgba(44, 157, 88, .13);
}

.status-pill.is-offline .status-dot {
  background: #c94747;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: clamp(20px, 3vw, 36px);
  width: min(1580px, calc(100% - 36px));
  margin: 0 auto;
  padding: clamp(28px, 4vw, 54px) 0 56px;
}

.workspace {
  min-width: 0;
}

.intro-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: -0.04em;
}

h1 {
  max-width: 720px;
  font-size: clamp(38px, 6vw, 70px);
  line-height: .96;
}

h2 {
  font-size: 22px;
}

.lede {
  max-width: 690px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: clamp(15px, 1.5vw, 18px);
  line-height: 1.55;
}

.name-control {
  display: grid;
  gap: 7px;
  min-width: 210px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.name-control input,
.name-dialog input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.8);
  color: var(--ink);
}

.name-control input {
  height: 42px;
  padding: 0 12px;
}

.search-wrap {
  position: relative;
  z-index: 10;
  max-width: 780px;
  margin-bottom: 16px;
}

.search-box {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 0 15px;
  border: 1px solid #cacbc2;
  border-radius: 16px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 12px 32px rgba(25,27,24,.07);
}

.search-box:focus-within {
  border-color: #8e9186;
  box-shadow: 0 0 0 4px rgba(23,24,22,.07), 0 12px 32px rgba(25,27,24,.08);
}

.search-icon {
  color: var(--muted);
  font-size: 25px;
  transform: rotate(-15deg);
}

.search-box input {
  min-width: 0;
  height: 54px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
}

.search-box kbd {
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.search-result {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid #ecece6;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.search-result:last-child {
  border-bottom: 0;
}

.search-result:hover,
.search-result.is-active {
  background: #f4f3ee;
}

.result-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--swatch);
}

.result-copy {
  min-width: 0;
}

.result-copy strong,
.result-copy small {
  display: block;
}

.result-copy strong {
  font-size: 14px;
}

.result-copy small {
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-action {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.selection-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 780px;
  margin: 0 0 16px;
  padding: 14px 15px 14px 17px;
  border: 1px solid rgba(23,24,22,.12);
  border-radius: 16px;
  background: rgba(255,255,255,.72);
}

.selection-banner > div {
  min-width: 0;
}

.selection-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.selection-banner strong {
  margin-right: 8px;
  font-size: 17px;
}

#selectionPath {
  color: var(--muted);
  font-size: 13px;
}

.wheel-card {
  overflow: hidden;
  border: 1px solid rgba(23,24,22,.10);
  border-radius: var(--radius);
  background: rgba(255,255,255,.78);
  box-shadow: var(--shadow);
}

.wheel-stage {
  width: 100%;
  aspect-ratio: 1;
  max-height: min(78vh, 1100px);
  padding: clamp(8px, 2vw, 20px);
}

#emotionWheel {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.segment {
  cursor: pointer;
}

.segment path {
  stroke: rgba(20, 20, 18, .78);
  stroke-width: 1.65;
  vector-effect: non-scaling-stroke;
  transition: filter 140ms ease, opacity 140ms ease, stroke-width 140ms ease;
}

.segment:hover path,
.segment.is-focused path {
  filter: brightness(1.03) saturate(1.1);
  stroke: #111;
  stroke-width: 3.5;
}

.segment.has-others path {
  filter: saturate(1.16);
  stroke: rgba(17,17,17,.96);
  stroke-width: 3.1;
}

.segment.is-mine path {
  filter: saturate(1.24) brightness(.98);
  stroke: #111;
  stroke-width: 5.2;
}

.segment text {
  fill: #1b1c1a;
  pointer-events: none;
  user-select: none;
  dominant-baseline: middle;
  text-anchor: middle;
  font-weight: 650;
  letter-spacing: -.015em;
}

.segment.depth-0 text {
  font-size: 26px;
  font-weight: 720;
}

.segment.depth-1 text {
  font-size: 17px;
}

.segment.depth-2 text {
  font-size: 13.5px;
}

.selection-badge circle {
  fill: #171816;
  stroke: #fff;
  stroke-width: 2.5;
  vector-effect: non-scaling-stroke;
}

.selection-badge text {
  fill: white;
  text-anchor: middle;
  dominant-baseline: middle;
  font-size: 12px;
  font-weight: 850;
}

.wheel-hint {
  margin: 0;
  padding: 0 18px 18px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.people-panel {
  position: sticky;
  top: 102px;
  align-self: start;
  overflow: hidden;
  border: 1px solid rgba(23,24,22,.10);
  border-radius: var(--radius);
  background: rgba(255,255,255,.74);
  box-shadow: 0 18px 50px rgba(25,27,24,.07);
}

.panel-heading {
  padding: 20px 20px 15px;
  border-bottom: 1px solid var(--line);
}

.participant-list {
  display: grid;
  gap: 0;
  max-height: min(62vh, 670px);
  overflow: auto;
}

.participant {
  display: grid;
  grid-template-columns: 12px minmax(0,1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid #e9e9e2;
}

.participant:last-child {
  border-bottom: 0;
}

.participant-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--participant-color, #bdbfb7);
}

.participant-copy {
  min-width: 0;
}

.participant-copy strong,
.participant-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-copy strong {
  font-size: 13px;
}

.participant-copy span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.participant-you {
  padding: 3px 6px;
  border-radius: 999px;
  background: #ecece5;
  color: var(--muted);
  font-size: 9px;
  font-weight: 850;
  text-transform: uppercase;
}

.empty-participants {
  padding: 26px 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.privacy-note {
  display: grid;
  gap: 4px;
  padding: 16px 18px;
  border-top: 1px solid var(--line);
  background: rgba(238,238,232,.62);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.privacy-note strong {
  color: var(--ink);
}

.button {
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.button-primary {
  border: 1px solid #171816;
  background: #171816;
  color: white;
}

.button-secondary {
  border: 1px solid #c8c9c0;
  background: white;
}

.button-ghost {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
}

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

.name-dialog {
  width: min(440px, calc(100vw - 30px));
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 28px 90px rgba(15, 16, 14, .24);
}

.name-dialog::backdrop {
  background: rgba(23,24,22,.34);
  backdrop-filter: blur(4px);
}

.name-dialog form {
  display: grid;
  gap: 18px;
  padding: 28px;
}

.name-dialog h2 {
  font-size: 30px;
}

.name-dialog p:not(.eyebrow) {
  margin: -8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.name-dialog label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.name-dialog input {
  height: 46px;
  padding: 0 12px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
}

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

  .people-panel {
    position: static;
  }

  .participant-list {
    max-height: 320px;
  }
}

@media (max-width: 760px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .connection-cluster {
    width: 100%;
    justify-content: flex-start;
  }

  .app-shell {
    width: min(100% - 20px, 1580px);
    padding-top: 24px;
  }

  .intro-row {
    align-items: stretch;
    flex-direction: column;
  }

  .name-control {
    min-width: 0;
    max-width: 320px;
  }

  .wheel-stage {
    padding: 3px;
  }

  .segment.depth-0 text {
    font-size: 24px;
  }

  .segment.depth-1 text {
    font-size: 16px;
  }

  .segment.depth-2 text {
    font-size: 13px;
  }
}

@media (max-width: 520px) {
  .connection-cluster .button-ghost {
    display: none;
  }

  .search-box kbd {
    display: none;
  }

  .search-box {
    grid-template-columns: auto 1fr;
  }

  .selection-banner {
    align-items: flex-start;
  }

  #selectionPath {
    display: block;
    margin-top: 4px;
  }
}
