*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  background: #0d0d0d;
  color: #e0e0e0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  overflow: hidden;
  height: 100dvh;
  width: 100dvw;
}

/* Background graph — landing animation */
#bg-graph {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 1;
  transition: opacity 1s ease-in-out;
}

body.graph-active #bg-graph {
  opacity: 0;
}

#graph {
  position: absolute;
  inset: 0;
  z-index: 2;
}

/* Search panel — idle: centered landing */
#search-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  width: 320px;
  transition: top 0.35s ease-in-out, left 0.35s ease-in-out,
              transform 0.35s ease-in-out, width 0.35s ease-in-out;
}

/* Graph active: move to corner */
body.graph-active #search-panel {
  top: 18px;
  left: 18px;
  transform: translate(0, 0);
  width: 520px;
}

/* Landing branding */
#search-landing {
  text-align: center;
  margin-bottom: 18px;
  max-height: 80px;
  overflow: hidden;
  opacity: 1;
  transition: max-height 0.3s ease-in-out, opacity 0.2s ease-in-out,
              margin-bottom 0.3s ease-in-out;
}

body.graph-active #search-landing {
  max-height: 0;
  opacity: 0;
  margin-bottom: 0;
  pointer-events: none;
}

#search-app-name {
  font-size: 26px;
  font-weight: 300;
  letter-spacing: 0.1em;
  color: #d0d0d0;
  text-transform: uppercase;
  text-shadow: 0 0 24px #0d0d0d, 0 0 48px #0d0d0d;
}

/* Search row — horizontal layout */
#search-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

/* Input wrapper */
#search-input-wrap {
  position: relative;
  flex: 2;
  min-width: 0;
}

#search-input {
  width: 100%;
  padding: 10px 34px 10px 14px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
#search-input:focus { border-color: #666; }

/* Clear button — hit target expanded to 32×32 for voice/dictation use */
#search-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  color: #555;
  font-size: 15px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}
#search-clear.visible { display: flex; }
#search-clear:hover,
#search-clear:focus-visible { color: #aaa; outline: none; }

#search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1;
  list-style: none;
  background: #1a1a1a;
  border: 1px solid #333;
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 240px;
  overflow-y: auto;
}
#search-results li {
  padding: 8px 14px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
#search-results li:hover,
#search-results li.highlighted { background: #262626; }
#search-results .result-name { font-weight: 500; }
#search-results .result-listeners {
  font-size: 11px;
  color: #666;
  white-space: nowrap;
}

/* Connect-to input — amber-family accent, mirrors primary search */
#connect-wrap {
  position: relative;
  flex: 2;
  min-width: 0;
}

#connect-spacer {
  flex: 0 0 18px;
}

#connect-input {
  width: 100%;
  padding: 10px 34px 10px 14px;
  background: #1a1a1a;
  border: 1px solid #3a2e18;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
#connect-input:focus { border-color: #6a5228; }
#connect-input::placeholder { color: #5a4820; }

#connect-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  color: #555;
  font-size: 15px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}
#connect-clear.visible { display: flex; }
#connect-clear:hover,
#connect-clear:focus-visible { color: #aaa; outline: none; }

#connect-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1;
  list-style: none;
  background: #1a1a1a;
  border: 1px solid #3a2e18;
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 240px;
  overflow-y: auto;
}
#connect-results li {
  padding: 8px 14px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
#connect-results li:hover,
#connect-results li.highlighted { background: #262216; }

#connect-hint {
  font-size: 11px;
  color: #888;
  text-align: center;
  padding: 6px 14px 0;
  letter-spacing: 0.02em;
}

/* Clear chain button */
#clear-chain {
  flex: none;
  align-self: stretch;
  padding: 5px 10px;
  background: none;
  border: 1px solid #333;
  border-radius: 6px;
  color: #888;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.1s, border-color 0.1s;
}
#clear-chain:hover { color: #e05a54; border-color: #e05a54; }

/* Tagline */
#search-tagline {
  font-size: 12px;
  color: #888;
  text-align: center;
  margin-top: 10px;
  letter-spacing: 0.04em;
  opacity: 1;
  transition: opacity 0.35s ease-in-out;
  pointer-events: none;
  user-select: none;
}

body.graph-active #search-tagline {
  opacity: 0.2;
}

/* Status slot mirrors search-row flex so idler/error sit under the two inputs */
#search-status {
  display: flex;
  gap: 6px;
  margin-top: 0;
}
#search-status:has(#search-idler:not([hidden])),
#search-status:has(#search-error:not([hidden])) {
  margin-top: 12px;
}
#search-status .status-inputs {
  flex: 4;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
#search-status .status-tail {
  flex: 1;
}

#search-idler {
  width: 50%;
}

.wave {
  display: flex;
  align-items: center;
  gap: 3px;
  width: 100%;
  height: 18px;
}

.wave span {
  flex: 1;
  height: 100%;
  background: #888;
  border-radius: 1px;
  transform: scaleY(0.18);
  transform-origin: center;
  animation: wave 1.1s ease-in-out infinite;
}

.wave span:nth-child(1)  { animation-delay: -1.04s; }
.wave span:nth-child(2)  { animation-delay: -0.97s; }
.wave span:nth-child(3)  { animation-delay: -0.90s; }
.wave span:nth-child(4)  { animation-delay: -0.83s; }
.wave span:nth-child(5)  { animation-delay: -0.76s; }
.wave span:nth-child(6)  { animation-delay: -0.69s; }
.wave span:nth-child(7)  { animation-delay: -0.62s; }
.wave span:nth-child(8)  { animation-delay: -0.55s; }
.wave span:nth-child(9)  { animation-delay: -0.48s; }
.wave span:nth-child(10) { animation-delay: -0.41s; }
.wave span:nth-child(11) { animation-delay: -0.34s; }
.wave span:nth-child(12) { animation-delay: -0.27s; }
.wave span:nth-child(13) { animation-delay: -0.20s; }
.wave span:nth-child(14) { animation-delay: -0.13s; }
.wave span:nth-child(15) { animation-delay: -0.06s; }
.wave span:nth-child(16) { animation-delay:  0.00s; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.18); }
  50%      { transform: scaleY(1); }
}

@media (prefers-reduced-motion: reduce) {
  .wave span { animation: none; transform: scaleY(0.45); }
}

#search-error {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 18px;
  font-size: 12px;
  color: #aaa;
  letter-spacing: 0.01em;
  text-align: center;
}

#search-error .status-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 1px solid #555;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 600;
  color: #aaa;
  flex-shrink: 0;
  line-height: 1;
}

#connect-error {
  font-size: 12px;
  color: #b89060;
  text-align: center;
  padding: 8px 14px 0;
}

/* Detail panel */
#detail-panel {
  position: absolute;
  bottom: 18px;
  left: 18px;
  z-index: 10;
  width: 600px;
  background: #161616;
  border: 1px solid #2e2e2e;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  cursor: default;
}

#detail-close,
#detail-help,
#landing-help {
  position: absolute;
  top: 8px;
  z-index: 2;
  width: 36px;
  height: 36px;
  background: rgba(0,0,0,0.5);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity 0.15s;
}
#detail-close { right: 8px; }
#detail-help,
#landing-help { left: 8px; font-size: 15px; font-weight: 500; }
#detail-close:hover,
#detail-help:hover,
#landing-help:hover { opacity: 1; }

/* Help views sit flat on their panel surfaces — no second elevation */
#detail-help-inner,
#landing-help-inner {
  padding: 44px 20px 20px;
}

.help-section {
  margin-bottom: 18px;
}
.help-section:last-child { margin-bottom: 0; }

.help-label {
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 10px;
}

.help-keys {
  display: grid;
  grid-template-columns: minmax(96px, max-content) 1fr;
  column-gap: 16px;
  row-gap: 8px;
  align-items: center;
}

.help-keys dt {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.help-keys dd {
  font-size: 13px;
  color: #c8c8c8;
  line-height: 1.4;
}

#detail-help-view kbd,
#landing-help-view kbd {
  display: inline-block;
  min-width: 22px;
  padding: 2px 7px;
  background: #252525;
  border: 1px solid #383838;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: #d0d0d0;
  text-align: center;
  line-height: 1.4;
}

#detail-help-view p,
#landing-help-view p {
  font-size: 13px;
  line-height: 1.65;
  color: #aaa;
  margin-bottom: 8px;
}
#detail-help-view p:last-child,
#landing-help-view p:last-child { margin-bottom: 0; }

/* Hero image header */
#detail-hero {
  position: relative;
  height: 150px;
  background: #222;
  overflow: hidden;
}

#detail-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

#detail-hero-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(22,22,22,0.97) 0%, rgba(22,22,22,0.35) 55%, transparent 100%);
}

#detail-hero-text {
  position: absolute;
  bottom: 12px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

#detail-hero-text-left { flex: 1; min-width: 0; }

#detail-name {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  text-shadow: 0 1px 6px rgba(0,0,0,0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#detail-listeners {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  margin-top: 3px;
}

/* Tags row — always visible, with persistent divider to body */
#detail-tags-row {
  padding: 11px 16px 13px;
  border-bottom: 1px solid #2a2a2a;
}

#detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#detail-center {
  flex-shrink: 0;
  width: 52px;
  height: 26px;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  color: rgba(255,255,255,0.8);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#detail-center:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.4);
  color: #fff;
}

.tag {
  background: #252525;
  border: 1px solid #383838;
  border-radius: 4px;
  padding: 3px 9px;
  font-size: 11.5px;
  color: #c8c8c8;
  letter-spacing: 0.02em;
}

/* Body — bio + link, persistent-open per accessibility doctrine */
#detail-body-inner {
  padding: 12px 16px 16px;
}

#detail-bio {
  font-size: 13px;
  color: #aaa;
  line-height: 1.65;
  max-height: 100px;
  overflow-y: auto;
  margin-bottom: 12px;
}

#detail-link {
  font-size: 12px;
  font-weight: 500;
  color: #e05a54;
  text-decoration: none;
  letter-spacing: 0.01em;
}
#detail-link:hover { color: #f07a74; text-decoration: underline; }

/* Zoom / center controls */
#controls {
  position: absolute;
  bottom: 18px;
  right: 18px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease-in-out;
}

#controls.controls-visible {
  opacity: 1;
  pointer-events: auto;
}

#controls button {
  width: 36px;
  height: 36px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  color: #ccc;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s;
}

#controls button:hover  { background: #262626; color: #fff; }
#controls button:active { background: #333; }

#controls button[data-tooltip] { position: relative; }

#controls button[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: #e8e8e8;
  color: #111;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 5px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

#controls button[data-tooltip]:hover::after { opacity: 1; }

/* Scrollbar styling */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

/* Focus-visible rings for keyboard / dictation users */
button:focus-visible,
a:focus-visible {
  outline: 2px solid #888;
  outline-offset: 2px;
}
#detail-close:focus-visible,
#detail-help:focus-visible,
#landing-help:focus-visible,
#detail-center:focus-visible {
  outline-color: rgba(255, 255, 255, 0.5);
}

/* Landing popup — disclaimer, mirrors detail-panel framing + hover slide-up */
#landing-popup {
  position: absolute;
  bottom: 18px;
  left: 18px;
  z-index: 50;
  width: 600px;
  max-width: calc(100vw - 36px);
  background: #161616;
  border: 1px solid #2e2e2e;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

body.graph-active #landing-popup {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease-in-out;
}

#landing-popup-header {
  padding: 14px 16px 14px 56px;
  border-bottom: 1px solid #2a2a2a;
}

#landing-popup-title {
  font-size: 22px;
  font-weight: 300;
  letter-spacing: 0.1em;
  color: #d0d0d0;
  text-transform: uppercase;
  line-height: 1.2;
  text-shadow: 0 0 24px #0d0d0d, 0 0 48px #0d0d0d;
}

#landing-popup-body-inner {
  padding: 12px 16px 16px;
}

#landing-popup p {
  font-size: 13px;
  line-height: 1.65;
  color: #aaa;
  margin-bottom: 8px;
}
#landing-popup p:last-child { margin-bottom: 0; }

#landing-popup a {
  color: #d0d0d0;
  text-decoration: underline;
}
#landing-popup a:hover { color: #fff; }
