:root {
  color-scheme: dark;
  --bg: #1a1a2e;
  --bg-deep: #121224;
  --panel: rgba(20, 20, 42, 0.88);
  --panel-soft: rgba(0, 0, 0, 0.18);
  --panel-border: rgba(236, 72, 153, 0.2);
  --text: #fdf2f8;
  --muted: #d8b4fe;
  --accent: #ec4899;
  --accent-strong: #f472b6;
  --accent-deep: #be185d;
  --accent-soft: rgba(236, 72, 153, 0.14);
  --purple: #7c3aed;
  --purple-soft: rgba(88, 28, 135, 0.64);
  --success: #22c55e;
  --warning: #fbbf24;
  --danger: #ef4444;
  --shadow: 0 32px 70px rgba(0, 0, 0, 0.38);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  font-family: "Inter", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 18%, rgba(124, 58, 237, 0.18), transparent 26%),
    radial-gradient(circle at 82% 12%, rgba(236, 72, 153, 0.18), transparent 24%),
    linear-gradient(180deg, #1d1b34 0%, #11101f 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.42), transparent 84%);
}

.ambient {
  position: fixed;
  width: 36rem;
  height: 36rem;
  border-radius: 999px;
  filter: blur(90px);
  opacity: 0.3;
  pointer-events: none;
  animation: drift 18s ease-in-out infinite;
}

.ambient--north {
  top: -12rem;
  left: -9rem;
  background: rgba(124, 58, 237, 0.26);
}

.ambient--south {
  right: -8rem;
  bottom: -14rem;
  background: rgba(236, 72, 153, 0.24);
  animation-delay: -7s;
}

.grid-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 22% 0%, rgba(244, 114, 182, 0.08), transparent 30%),
    radial-gradient(circle at 100% 10%, rgba(124, 58, 237, 0.08), transparent 28%);
}

.site-shell {
  position: relative;
  z-index: 1;
  width: min(980px, 100%);
}

.app-shell {
  position: relative;
  padding: 1.8rem;
  border-radius: var(--radius-xl);
  background: radial-gradient(circle at top, #1f1f44 0%, #1a1a2e 62%, #131328 100%);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.app-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 0%, rgba(236, 72, 153, 0.08), transparent 30%);
}

.entry-view,
.dashboard {
  position: relative;
  z-index: 1;
}

.entry-view {
  text-align: center;
  padding: 0.8rem 0;
}

.brand-title,
.modal-card h2,
.section-title {
  margin: 0;
  font-family: "Playfair Display", serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-title {
  color: var(--accent-strong);
  font-size: clamp(3rem, 6vw, 4.6rem);
}

.brand-title--small {
  font-size: clamp(2rem, 4vw, 2.8rem);
}

.entry-copy,
.dashboard-note,
.modal-text,
.message__body,
.setup-card__help,
.noscript-banner {
  color: var(--muted);
}

.entry-copy {
  margin: 0.35rem 0 1.5rem;
  font-size: 1rem;
}

.entry-form {
  display: grid;
  gap: 0.8rem;
  width: min(30rem, 100%);
  margin: 0 auto;
}

.field-label {
  font-size: 0.95rem;
  font-weight: 600;
  text-align: left;
}

.text-input {
  width: 100%;
  min-height: 3.6rem;
  padding: 0 1.2rem;
  border: 1px solid rgba(236, 72, 153, 0.24);
  border-radius: 999px;
  background: rgba(88, 28, 135, 0.18);
  color: var(--text);
  font: inherit;
  font-size: 1.35rem;
  letter-spacing: 0.28em;
  text-align: center;
  outline: none;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.text-input:focus {
  border-color: rgba(244, 114, 182, 0.48);
  box-shadow: 0 0 0 4px rgba(236, 72, 153, 0.12);
  transform: translateY(-1px);
}

.text-input::placeholder {
  color: rgba(216, 180, 254, 0.38);
  letter-spacing: 0.2em;
}

.button,
.preset-button,
.stepper__button,
.lock-button {
  appearance: none;
  border: 0;
  font: inherit;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    opacity 160ms ease;
}

.button:hover,
.button:focus-visible,
.preset-button:hover,
.preset-button:focus-visible,
.stepper__button:hover,
.stepper__button:focus-visible,
.lock-button:hover,
.lock-button:focus-visible {
  transform: translateY(-1px);
}

.button:disabled,
.preset-button:disabled,
.stepper__button:disabled,
.lock-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.button {
  min-height: 3.25rem;
  padding: 0.85rem 1.25rem;
  border-radius: 999px;
  font-weight: 700;
}

.button--primary {
  color: white;
  background: linear-gradient(135deg, var(--accent), #db2777);
  box-shadow: 0 14px 28px rgba(236, 72, 153, 0.24);
}

.button--ghost {
  color: var(--text);
  background: rgba(88, 28, 135, 0.52);
  border: 1px solid rgba(236, 72, 153, 0.14);
}

.message-slot {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.message {
  padding: 1rem 1.05rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(236, 72, 153, 0.14);
  background: rgba(20, 17, 43, 0.84);
}

.message__title {
  margin: 0 0 0.35rem;
  font-weight: 700;
}

.message__body {
  margin: 0;
  line-height: 1.6;
}

.message--error {
  border-color: rgba(239, 68, 68, 0.24);
  background: rgba(127, 29, 29, 0.22);
}

.message--success {
  border-color: rgba(34, 197, 94, 0.24);
  background: rgba(20, 83, 45, 0.22);
}

.message--warning {
  border-color: rgba(251, 191, 36, 0.24);
  background: rgba(113, 63, 18, 0.22);
}

.setup-card {
  display: grid;
  gap: 0.8rem;
}

.setup-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.setup-card__code {
  margin: 0;
  max-height: 18rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  background: rgba(7, 5, 18, 0.92);
  border: 1px solid rgba(236, 72, 153, 0.14);
  overflow: auto;
  color: #fbcfe8;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.84rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.hidden {
  display: none !important;
}

.dashboard {
  display: grid;
  gap: 1rem;
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.dashboard-header__actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.status-pill,
.room-pill,
.mode-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.15rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.9rem;
}

.status-pill--sync {
  color: #fdf2f8;
  background: rgba(236, 72, 153, 0.16);
  border: 1px solid rgba(236, 72, 153, 0.22);
}

.status-pill--sync.is-waiting {
  color: #fef3c7;
  background: rgba(251, 191, 36, 0.14);
  border-color: rgba(251, 191, 36, 0.24);
}

.status-pill--sync.is-offline {
  color: #fecdd3;
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.24);
}

.dashboard-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.8rem 1rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(236, 72, 153, 0.14);
  color: var(--muted);
}

.strip-divider {
  opacity: 0.5;
}

.strip-label {
  font-weight: 600;
}

.room-pill,
.mode-pill {
  background: rgba(88, 28, 135, 0.42);
  border: 1px solid rgba(236, 72, 153, 0.14);
  color: #fbcfe8;
}

.room-pill {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.dashboard-note {
  margin: 0;
  text-align: center;
  line-height: 1.55;
}

.dashboard-note--secondary {
  font-size: 0.95rem;
}

.dashboard-note--center {
  margin-top: 0.9rem;
}

.chart-panel,
.modes-panel,
.controls-panel {
  background: rgba(0, 0, 0, 0.18);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.chart-panel__header {
  display: flex;
  justify-content: center;
}

.chart-readout {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  color: var(--muted);
}

.chart-readout strong {
  color: var(--text);
}

.wave-shell {
  position: relative;
  min-height: 290px;
  margin-top: 1rem;
  padding: 2.1rem 0.6rem 0.6rem;
  border-radius: 20px;
  background: rgba(5, 4, 18, 0.46);
  overflow: hidden;
}

.wave-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 0%, rgba(236, 72, 153, 0.1), transparent 40%),
    linear-gradient(180deg, rgba(124, 58, 237, 0.08), transparent 42%);
}

#vibration-chart {
  width: 100%;
  height: 100%;
}

.lock-button-wrap {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
}

.lock-button {
  width: 78px;
  height: 78px;
  padding: 0.7rem 0.35rem;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: rgba(88, 28, 135, 0.84);
  border: 2px solid rgba(236, 72, 153, 0.24);
  color: var(--text);
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
}

.lock-button.is-locked {
  background: rgba(239, 68, 68, 0.88);
  animation: pulse-red 1.5s infinite;
}

.lock-button__icon {
  width: 1.05rem;
  height: 1.05rem;
  border: 2px solid currentColor;
  border-radius: 0.25rem;
  position: relative;
}

.lock-button__icon::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: 0.72rem;
  height: 0.64rem;
  border: 2px solid currentColor;
  border-bottom: 0;
  border-radius: 0.72rem 0.72rem 0 0;
  transform: translateX(-50%);
}

.lock-button.is-unlocked .lock-button__icon::before {
  transform: translateX(-50%) rotate(-28deg);
  transform-origin: center bottom;
}

.wave-overlay {
  position: absolute;
  inset: 0.7rem;
  z-index: 5;
  display: grid;
  place-content: center;
  gap: 0.35rem;
  padding: 1.2rem;
  text-align: center;
  border-radius: 18px;
  background: rgba(4, 4, 14, 0.78);
}

.wave-overlay strong {
  font-size: 1.2rem;
}

.wave-overlay span {
  color: var(--muted);
}

.wave-overlay--soft {
  inset: auto 1rem 1rem auto;
  width: min(220px, calc(100% - 2rem));
  background: rgba(236, 72, 153, 0.18);
  border: 1px solid rgba(236, 72, 153, 0.18);
}

.wave-overlay--removed {
  inset: 0;
  border-radius: var(--radius-lg);
  background: rgba(4, 4, 14, 0.78);
}

.controls-container {
  position: relative;
  display: grid;
  gap: 1rem;
}

.section-title {
  margin-bottom: 0.85rem;
  text-align: center;
  color: #f9a8d4;
  font-size: 1.3rem;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.preset-button {
  min-height: 4.7rem;
  padding: 0.9rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(236, 72, 153, 0.14);
  background: rgba(88, 28, 135, 0.52);
  color: white;
  display: grid;
  gap: 0.2rem;
  text-align: center;
}

.preset-button span {
  font-weight: 700;
}

.preset-button small {
  color: #e9d5ff;
}

.preset-button.is-active {
  background: linear-gradient(135deg, var(--accent), #db2777);
  border-color: rgba(244, 114, 182, 0.3);
  box-shadow: 0 0 18px rgba(236, 72, 153, 0.24);
}

.preset-button--danger.is-active,
.preset-button--danger:hover {
  background: linear-gradient(135deg, #db2777, #be123c);
}

.preset-button.is-disabled {
  opacity: 0.42;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.value-card {
  padding: 1rem;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.18);
}

.value-card.is-disabled {
  opacity: 0.45;
}

.value-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.95rem;
  color: var(--muted);
}

.value-card__top strong {
  color: #f9a8d4;
  font-size: 1.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.stepper {
  display: grid;
  grid-template-columns: 4rem minmax(0, 1fr) 4rem;
  align-items: center;
  gap: 0.85rem;
}

.stepper__button {
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  background: rgba(88, 28, 135, 0.58);
  border: 1px solid rgba(236, 72, 153, 0.16);
  color: white;
  font-size: 1.8rem;
  font-weight: 700;
}

.meter {
  position: relative;
  height: 0.8rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.meter__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 10%;
  border-radius: inherit;
  background: linear-gradient(90deg, #c084fc, var(--accent));
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
}

.status-indicator__dot {
  width: 0.82rem;
  height: 0.82rem;
  border-radius: 50%;
}

.status-indicator__dot.is-in {
  background: var(--success);
}

.status-indicator__dot.is-loosely {
  background: var(--warning);
}

.status-indicator__dot.is-removed {
  background: var(--danger);
}

.secret-hotspot {
  position: absolute;
  left: 50%;
  width: 70px;
  height: 44px;
  transform: translateX(-50%);
  opacity: 0;
  border: 0;
  background: transparent;
}

.secret-hotspot--center {
  bottom: 1.1rem;
}

.secret-hotspot--lower {
  bottom: 4.3rem;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(4, 4, 14, 0.72);
  backdrop-filter: blur(16px);
}

.modal-card {
  width: min(32rem, 100%);
  padding: 1.45rem;
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(31, 31, 68, 0.98), rgba(18, 18, 36, 0.96));
  border: 1px solid rgba(236, 72, 153, 0.18);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 0.55rem;
  color: #f9a8d4;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.modal-text {
  margin: 0.8rem 0 0;
  line-height: 1.65;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

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

.noscript-banner {
  position: fixed;
  inset: auto 1rem 1rem 1rem;
  z-index: 40;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-md);
  background: rgba(127, 29, 29, 0.24);
  border: 1px solid rgba(239, 68, 68, 0.24);
}

@keyframes drift {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(1rem, -1.2rem, 0) scale(1.04);
  }
}

@keyframes pulse-red {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.42);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

@media (max-width: 720px) {
  body {
    align-items: flex-start;
  }

  .app-shell {
    padding: 1.1rem;
  }

  .dashboard-header,
  .dashboard-header__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .brand-title {
    font-size: 3rem;
  }

  .preset-grid,
  .control-grid {
    grid-template-columns: 1fr;
  }

  .stepper {
    grid-template-columns: 3.4rem minmax(0, 1fr) 3.4rem;
  }

  .stepper__button {
    width: 3.4rem;
    height: 3.4rem;
  }

  .wave-shell {
    min-height: 250px;
  }
}
