/* Plasmoid chamber — simulation + chat chrome */

#chamber,
#field-mind,
#essay {
  scroll-margin-top: 5.5rem;
}

.plasmoid-chamber {
  --plasmoid-cyan: #5ee7ff;
  --plasmoid-magenta: #ff6ec7;
  --plasmoid-violet: #9b7bff;
  --plasmoid-core: #e8ffff;
  --plasmoid-well: #04070c;
  --plasmoid-panel: rgba(8, 14, 20, 0.88);
  --plasmoid-line: rgba(94, 231, 255, 0.28);
  --plasmoid-muted: rgba(210, 230, 240, 0.68);

  margin: 1.75rem 0 2.25rem;
  border: 1px solid var(--plasmoid-line);
  border-radius: 0.65rem;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 60% at 50% 35%, rgba(94, 231, 255, 0.08), transparent 55%),
    radial-gradient(ellipse 50% 40% at 70% 80%, rgba(255, 110, 199, 0.06), transparent 50%),
    var(--plasmoid-well);
  color: #e8f4f8;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 18px 48px rgba(0, 0, 0, 0.35);
}

.plasmoid-chamber__stage {
  position: relative;
  min-height: min(58vh, 28rem);
  background: transparent;
}

.plasmoid-chamber__canvas {
  display: block;
  width: 100%;
  height: min(58vh, 28rem);
  cursor: crosshair;
  touch-action: none;
}

.plasmoid-chamber__hud {
  position: absolute;
  inset: 0.75rem 0.85rem auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.85rem;
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--plasmoid-muted);
  z-index: 2;
}

.plasmoid-chamber__hud span strong {
  color: var(--plasmoid-cyan);
  font-weight: 500;
}

.plasmoid-chamber__hint {
  position: absolute;
  left: 0.85rem;
  bottom: 0.75rem;
  right: 0.85rem;
  margin: 0;
  font-size: 0.78rem;
  color: rgba(210, 230, 240, 0.55);
  pointer-events: none;
  z-index: 2;
}

.plasmoid-chamber__controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem 1rem;
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--plasmoid-line);
  background: var(--plasmoid-panel);
}

.plasmoid-chamber__controls label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--plasmoid-muted);
}

.plasmoid-chamber__controls input[type="range"] {
  width: 100%;
  accent-color: var(--plasmoid-cyan);
  cursor: pointer;
}

.plasmoid-chamber__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0 1rem 0.85rem;
  background: var(--plasmoid-panel);
}

.plasmoid-btn {
  appearance: none;
  padding: 0.42rem 0.85rem;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  color: #e8f4f8;
  background: rgba(94, 231, 255, 0.08);
  border: 1px solid rgba(94, 231, 255, 0.32);
  border-radius: 0.4rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.plasmoid-btn:hover {
  background: rgba(94, 231, 255, 0.16);
  border-color: rgba(94, 231, 255, 0.55);
}

.plasmoid-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.plasmoid-btn[aria-pressed="true"] {
  background: rgba(255, 110, 199, 0.16);
  border-color: rgba(255, 110, 199, 0.55);
  color: #ffe8f6;
}

.plasmoid-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.plasmoid-chat {
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-top: 1px solid var(--plasmoid-line);
  min-height: 18rem;
  background: linear-gradient(180deg, rgba(6, 10, 16, 0.95), rgba(4, 7, 12, 0.98));
}

.plasmoid-chat__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  padding: 0.85rem 1rem 0.65rem;
  border-bottom: 1px solid rgba(94, 231, 255, 0.12);
}

.plasmoid-chat__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #f2fbff;
}

.plasmoid-chat__meta {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  color: var(--plasmoid-muted);
}

.plasmoid-chat__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(94, 231, 255, 0.28);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--plasmoid-cyan);
  background: rgba(94, 231, 255, 0.06);
}

.plasmoid-chat__badge::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--plasmoid-cyan);
  box-shadow: 0 0 8px var(--plasmoid-cyan);
  animation: plasmoid-pulse 1.8s ease-in-out infinite;
}

.plasmoid-chat__badge[data-mode="thinking"]::before {
  background: var(--plasmoid-magenta);
  box-shadow: 0 0 8px var(--plasmoid-magenta);
}

.plasmoid-chat__badge[data-mode="speaking"]::before {
  background: #fff;
  box-shadow: 0 0 10px #fff;
}

.plasmoid-chat__badge[data-mode="offline"]::before {
  background: #667;
  box-shadow: none;
  animation: none;
}

@keyframes plasmoid-pulse {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

.plasmoid-chat__log {
  overflow-y: auto;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 16rem;
  scroll-behavior: smooth;
}

.plasmoid-msg {
  max-width: min(36rem, 92%);
  padding: 0.65rem 0.8rem;
  border-radius: 0.55rem;
  font-size: 0.92rem;
  line-height: 1.5;
}

.plasmoid-msg--user {
  align-self: flex-end;
  background: rgba(255, 110, 199, 0.12);
  border: 1px solid rgba(255, 110, 199, 0.28);
  color: #ffeaf6;
}

.plasmoid-msg--plasmoid {
  align-self: flex-start;
  background: rgba(94, 231, 255, 0.08);
  border: 1px solid rgba(94, 231, 255, 0.22);
  color: #e8f8ff;
}

.plasmoid-msg__who {
  display: block;
  margin-bottom: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.7;
}

.plasmoid-msg__text {
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.plasmoid-msg__text .cursor {
  display: inline-block;
  width: 0.45ch;
  margin-left: 1px;
  background: var(--plasmoid-cyan);
  animation: plasmoid-caret 0.9s step-end infinite;
}

@keyframes plasmoid-caret {
  50% {
    opacity: 0;
  }
}

.plasmoid-chat__compose {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.45rem;
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid rgba(94, 231, 255, 0.12);
}

.plasmoid-chat__compose input[type="text"] {
  width: 100%;
  min-width: 0;
  padding: 0.65rem 0.8rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: #e8f4f8;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(94, 231, 255, 0.28);
  border-radius: 0.45rem;
}

.plasmoid-chat__compose input[type="text"]::placeholder {
  color: rgba(210, 230, 240, 0.4);
}

.plasmoid-chat__compose input[type="text"]:focus {
  outline: none;
  border-color: rgba(94, 231, 255, 0.65);
  box-shadow: 0 0 0 2px rgba(94, 231, 255, 0.12);
}

.plasmoid-settings {
  padding: 0 1rem 1rem;
  border-top: 1px solid rgba(94, 231, 255, 0.1);
  background: rgba(0, 0, 0, 0.25);
}

.plasmoid-settings[hidden] {
  display: none;
}

.plasmoid-settings__grid {
  display: grid;
  gap: 0.65rem;
  padding-top: 0.85rem;
}

.plasmoid-settings label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--plasmoid-muted);
}

.plasmoid-settings input,
.plasmoid-settings select {
  padding: 0.5rem 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #e8f4f8;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(94, 231, 255, 0.22);
  border-radius: 0.35rem;
}

.plasmoid-settings__note {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: rgba(210, 230, 240, 0.55);
}

.plasmoid-disclaimer {
  margin: 1.25rem 0 0;
  padding: 0.9rem 1rem;
  border-left: 3px solid var(--color-panel-outline);
  background: var(--color-surface);
  color: var(--color-muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

@media (max-width: 720px) {
  .plasmoid-chamber__controls {
    grid-template-columns: 1fr;
  }

  .plasmoid-chat__compose {
    grid-template-columns: 1fr auto;
  }

  .plasmoid-chat__compose .plasmoid-btn--mic {
    grid-column: 2;
    grid-row: 1;
  }

  .plasmoid-chat__compose .plasmoid-btn--send {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .plasmoid-chat__badge::before,
  .plasmoid-msg__text .cursor {
    animation: none;
  }
}
