:root {
  color-scheme: dark;
  --ink: #f7f3e8;
  --muted: #aab7c2;
  --panel: rgba(11, 16, 22, 0.74);
  --line: rgba(247, 243, 232, 0.16);
  --past: #d68b55;
  --present: #72c6b5;
  --future: #8fb6ff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
.app {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #070b10;
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.1);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: rgba(255, 255, 255, 0.17);
}

input,
textarea {
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.28);
  outline: none;
}

textarea {
  padding-top: 10px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: rgba(114, 198, 181, 0.72);
  box-shadow: 0 0 0 3px rgba(114, 198, 181, 0.16);
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

#scene.mouse-look-active {
  cursor: none;
}

.startup-error {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 10;
  border: 1px solid rgba(255, 120, 120, 0.55);
  border-radius: 8px;
  padding: 12px 14px;
  color: #ffd6d6;
  background: rgba(70, 12, 20, 0.92);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.42);
  font-size: 0.86rem;
  line-height: 1.4;
}

.startup-error.hidden {
  display: none;
}

.hud,
.legend,
.avatar-panel,
.hush-detail-panel,
.narrator-panel {
  position: fixed;
  z-index: 2;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(16px);
}

.hud {
  top: 16px;
  right: 16px;
  left: auto;
  display: grid;
  width: min(330px, calc(100vw - 32px));
  gap: 10px;
  padding: 12px;
}

.brand h1,
.brand strong,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 1.55rem;
  line-height: 1;
  letter-spacing: 0;
}

.brand p {
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.45;
}

.brand strong {
  display: block;
  margin-top: 7px;
  color: var(--ink);
  font-size: 0.92rem;
}

.readout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  background: rgba(0, 0, 0, 0.25);
}

.readout span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  text-transform: uppercase;
}

.readout small {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 750;
}

.readout .atmosphere-label {
  color: var(--atmosphere-color, var(--present));
  font-size: 0.72rem;
  text-transform: uppercase;
}

.readout strong {
  font-size: 1.25rem;
}

.controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.controls button {
  min-height: 36px;
  padding: 0 8px;
  font-size: 0.74rem;
}

.movement-readout {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: rgba(0, 0, 0, 0.2);
}

.movement-readout span {
  color: var(--atmosphere-color, var(--present));
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.movement-readout strong {
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1.3;
}

.search-form,
.hush-form,
.discovery-form {
  display: grid;
  grid-template-columns: 1fr 64px;
  gap: 8px;
}

.avatar-quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.avatar-quick-actions button {
  min-height: 32px;
  padding: 0 7px;
  font-size: 0.72rem;
}

.auth-card {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px;
  background: rgba(0, 0, 0, 0.2);
}

.auth-card strong {
  color: var(--atmosphere-color, var(--present));
  font-size: 0.76rem;
}

.auth-card input {
  min-height: 34px;
  font-size: 0.78rem;
}

.auth-card div {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.auth-card button {
  min-height: 32px;
  padding: 0 6px;
  font-size: 0.68rem;
}

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

.hush-form.hidden,
.hush-guide.hidden {
  display: none;
}

.hush-form #hushTitle {
  grid-column: 1 / -1;
}

.hush-form button {
  grid-column: 1 / -1;
}

.hush-guide {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.24);
}

.hush-guide strong {
  font-size: 0.9rem;
}

.guide-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.guide-options button.active {
  border-color: rgba(114, 198, 181, 0.88);
  background: rgba(114, 198, 181, 0.22);
}

.guide-field {
  display: grid;
  gap: 7px;
}

.guide-field textarea {
  min-height: 88px;
}

.guide-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 7px;
}

.preview-card {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px;
  background: rgba(0, 0, 0, 0.26);
}

.preview-card span {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

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

.discovery-form button {
  grid-column: 1 / -1;
}

.search-form small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.search-form.matched small {
  color: var(--present);
}

.search-form.missing small {
  color: var(--past);
}

.avatar-panel {
  right: auto;
  top: 16px;
  left: auto;
  display: grid;
  width: min(360px, calc(100vw - 32px));
  gap: 10px;
  padding: 12px;
}

.hush-detail-panel {
  right: auto;
  bottom: auto;
  display: grid;
  width: min(292px, calc(100vw - 32px));
  max-height: min(360px, calc(100vh - 32px));
  overflow: auto;
  gap: 8px;
  padding: 10px;
}

.hush-detail-panel.expanded {
  width: min(380px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  gap: 10px;
  padding: 12px;
}

.hush-detail-panel.hidden {
  display: none;
}

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

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

.avatar-panel-head strong,
.avatar-panel-toggle {
  font-size: 0.92rem;
}

.avatar-panel-toggle {
  min-height: 30px;
  border: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 900;
  text-align: left;
}

.avatar-panel-toggle:hover {
  background: transparent;
  color: var(--present);
}

#closeAvatarPanel {
  width: 34px;
  min-height: 34px;
  padding: 0;
}

#closeHushDetail {
  width: 34px;
  min-height: 34px;
  padding: 0;
}

#expandHushDetail {
  margin-left: auto;
  min-height: 30px;
  padding: 0 9px;
  font-size: 0.72rem;
}

.hush-detail-body h2 {
  margin: 8px 0 0;
  font-size: 1.05rem;
  line-height: 1.2;
}

.hush-detail-panel:not(.expanded) #currentUser,
.hush-detail-panel:not(.expanded) .hush-detail-body dl,
.hush-detail-panel:not(.expanded) .historical-context,
.hush-detail-panel:not(.expanded) .creator-edit-form,
.hush-detail-panel:not(.expanded) .social-actions,
.hush-detail-panel:not(.expanded) .dream-actions,
.hush-detail-panel:not(.expanded) .comment-form,
.hush-detail-panel:not(.expanded) .comment-list,
.hush-detail-panel:not(.expanded) .evidence-form,
.hush-detail-panel:not(.expanded) .evidence-list {
  display: none;
}

.hush-detail-panel:not(.expanded) .hush-detail-body h2 {
  font-size: 0.98rem;
}

.hush-detail-panel:not(.expanded) .hush-detail-body p {
  max-height: 4.2em;
  overflow: hidden;
}

.truth-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.24);
}

.truth-summary span,
.truth-badge {
  border-radius: 999px;
  padding: 4px 8px;
  color: #07101a;
  background: var(--past);
  font-size: 0.72rem;
  font-weight: 900;
}

.truth-summary strong {
  color: var(--muted);
  font-size: 0.78rem;
}

.truth-badge.supported,
.truth-summary.supported span {
  background: var(--present);
}

.truth-badge.verified,
.truth-summary.verified span,
.truth-badge.highly-verified,
.truth-summary.highly-verified span {
  background: var(--future);
}

.hush-detail-body p {
  margin: 7px 0 0;
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.45;
}

.hush-detail-body dl {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
}

.hush-detail-body div {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 10px;
}

.hush-detail-body dt,
.hush-detail-body dd {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
}

.hush-detail-body dt {
  color: var(--muted);
  font-weight: 800;
}

.historical-context {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px;
  background: rgba(0, 0, 0, 0.22);
}

.context-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 850;
}

.context-toggle input {
  min-width: auto;
  min-height: auto;
  width: 16px;
  height: 16px;
}

.historical-context strong {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
}

.context-list {
  display: grid;
  gap: 6px;
  max-height: 116px;
  overflow: auto;
}

.context-item {
  display: grid;
  gap: 3px;
  border: 1px solid rgba(247, 243, 232, 0.12);
  border-radius: 7px;
  padding: 7px;
  background: rgba(255, 255, 255, 0.055);
  cursor: pointer;
}

.context-item strong {
  margin: 0;
  font-size: 0.76rem;
}

.context-item span {
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.25;
}

.social-actions,
.dream-actions,
.comment-form,
.evidence-form,
.creator-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.dream-actions.hidden,
.social-actions.hidden,
.evidence-form.hidden,
.evidence-list.hidden,
.truth-summary.hidden {
  display: none;
}

.dream-actions span {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  color: #e8d5ff;
  background: rgba(137, 92, 255, 0.18);
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
}

.creator-edit-form {
  display: grid;
  gap: 8px;
}

.creator-edit-form.hidden {
  display: none;
}

.creator-edit-form textarea {
  min-height: 76px;
}

.social-actions button.active {
  border-color: rgba(114, 198, 181, 0.88);
  background: rgba(114, 198, 181, 0.22);
}

.dream-actions button.active {
  border-color: rgba(190, 142, 255, 0.9);
  background: rgba(137, 92, 255, 0.28);
}

.world-filter {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.world-filter button {
  min-height: 36px;
  padding: 0 8px;
  font-size: 0.72rem;
}

.world-filter button.active {
  border-color: rgba(114, 198, 181, 0.86);
  background: rgba(114, 198, 181, 0.18);
}

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

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

.comment-list,
.evidence-list {
  display: grid;
  gap: 6px;
  max-height: 112px;
  overflow: auto;
}

.comment-item,
.evidence-item {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 8px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.22);
  font-size: 0.76rem;
  line-height: 1.35;
}

.evidence-item a {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.comment-meta {
  color: var(--ink);
  font-weight: 800;
}

.comment-actions {
  display: flex;
  gap: 6px;
}

.comment-actions button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 0.72rem;
}

.avatar-panel-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.profile-card {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: rgba(0, 0, 0, 0.24);
}

.profile-card strong {
  font-size: 0.88rem;
}

.profile-card span {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.3;
}

.avatar-panel > small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.hush-list,
.mission-list {
  display: grid;
  gap: 6px;
  max-height: 132px;
  overflow: auto;
}

.hush-item,
.mission-item {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.24);
}

.hush-item.fresh-reality {
  border-color: rgba(114, 183, 255, 0.74);
  box-shadow: 0 0 0 1px rgba(114, 183, 255, 0.18), 0 0 22px rgba(114, 183, 255, 0.18);
}

.hush-item.fresh-dream {
  border-color: rgba(201, 156, 255, 0.78);
  box-shadow: 0 0 0 1px rgba(201, 156, 255, 0.2), 0 0 22px rgba(137, 92, 255, 0.2);
}

.hush-item strong {
  display: block;
  font-size: 0.82rem;
}

.hush-item .truth-badge {
  display: inline-block;
  margin-top: 7px;
}

.seeded-badge {
  display: inline-block;
  margin-top: 7px;
  border-radius: 999px;
  padding: 4px 8px;
  color: #07101a;
  background: #e7c565;
  font-size: 0.72rem;
  font-weight: 900;
}

.type-badge {
  display: inline-block;
  margin-top: 7px;
  border-radius: 999px;
  padding: 4px 8px;
  color: #07101a;
  font-size: 0.72rem;
  font-weight: 900;
}

.type-badge.reality {
  background: #72b7ff;
}

.type-badge.dream {
  color: #170724;
  background: #c99cff;
}

.fresh-badge {
  display: inline-block;
  margin-top: 7px;
  border-radius: 999px;
  padding: 4px 8px;
  color: #07101a;
  font-size: 0.72rem;
  font-weight: 950;
}

.fresh-badge.reality {
  background: #72b7ff;
}

.fresh-badge.dream {
  color: #170724;
  background: #d9b6ff;
}

.hush-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.mission-item {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.narrator-panel {
  left: 16px;
  bottom: 16px;
  width: min(500px, calc(100vw - 32px));
  padding: 11px 13px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.avatar-panel.matched > small {
  color: var(--present);
}

.avatar-panel.missing > small {
  color: var(--past);
}

.legend {
  right: 16px;
  bottom: 16px;
  display: flex;
  gap: 10px;
  padding: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.swatch {
  width: 13px;
  height: 13px;
  border-radius: 50%;
}

.swatch.past {
  background: var(--past);
}

.swatch.present {
  background: var(--present);
}

.swatch.future {
  background: var(--future);
}

.mini-map {
  position: fixed;
  right: auto;
  top: 16px;
  left: 16px;
  z-index: 2;
  display: grid;
  width: 180px;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(16px);
}

.mini-map-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.76rem;
}

.mini-map-head strong {
  color: var(--ink);
}

.mini-map-head strong span {
  margin-left: 5px;
  color: var(--atmosphere-color, var(--present));
}

.mini-map-plane {
  position: relative;
  height: 138px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    rgba(0, 0, 0, 0.22);
  background-size: 34px 34px;
}

.mini-map-plane::before,
.mini-map-plane::after {
  position: absolute;
  content: "";
  background: rgba(247, 243, 232, 0.12);
}

.mini-map-plane::before {
  top: 50%;
  left: 0;
  width: 100%;
  height: 1px;
}

.mini-map-plane::after {
  top: 0;
  left: 50%;
  width: 1px;
  height: 100%;
}

.mini-map-user,
.mini-map-dot {
  position: absolute;
  display: block;
  border-radius: 999px;
  transform: translate(-50%, -50%);
}

.mini-map-user {
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  background: var(--ink);
  box-shadow: 0 0 0 4px rgba(114, 198, 181, 0.22);
}

.mini-map-user::after {
  position: absolute;
  top: -9px;
  left: 4px;
  width: 0;
  height: 0;
  border-right: 3px solid transparent;
  border-bottom: 9px solid var(--present);
  border-left: 3px solid transparent;
  content: "";
}

.mini-map-dot {
  width: 8px;
  height: 8px;
  background: var(--present);
  box-shadow: 0 0 10px currentColor;
}

.mini-map-dot.dream {
  color: #d9b6ff;
  background: #d9b6ff;
}

.mini-map-dot.reality {
  color: #72b7ff;
  background: #72b7ff;
}

.mini-map-dot.system {
  color: #f1d28a;
  background: #f1d28a;
}

.mini-map small {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.3;
}

.welcome-panel {
  position: fixed;
  right: 214px;
  bottom: 16px;
  z-index: 3;
  display: grid;
  width: min(390px, calc(100vw - 32px));
  gap: 10px;
  border: 1px solid rgba(114, 198, 181, 0.34);
  border-radius: 8px;
  padding: 14px;
  background: rgba(7, 11, 16, 0.86);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(18px);
}

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

.welcome-panel strong {
  font-size: 1rem;
}

.welcome-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.42;
}

.welcome-panel div {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.welcome-panel button {
  min-height: 36px;
  padding: 0 8px;
  font-size: 0.72rem;
}

@media (max-width: 680px) {
  .hud {
    left: 10px;
    right: 10px;
    top: 162px;
    width: auto;
    padding: 12px;
  }

  .legend {
    right: 10px;
    bottom: 10px;
    left: 10px;
    justify-content: space-between;
  }

  .mini-map {
    top: 10px;
    right: auto;
    bottom: auto;
    left: 10px;
    width: 146px;
  }

  .mini-map-plane {
    height: 96px;
  }

  .narrator-panel {
    right: 10px;
    bottom: 210px;
    left: 10px;
    width: auto;
  }

  .welcome-panel {
    right: 10px;
    bottom: 210px;
    left: 10px;
    width: auto;
  }

  .avatar-panel {
    right: 10px;
    top: auto;
    bottom: 104px;
    left: 10px;
    width: auto;
    max-height: 48vh;
    overflow: auto;
  }

  .hush-detail-panel {
    width: min(292px, calc(100vw - 20px));
    max-height: 42vh;
  }
}
