:root {
  --bg: #111214;
  --bg-soft: #17181c;
  --bg-elevated: #1e2025;
  --panel: rgba(24, 25, 30, 0.94);
  --panel-strong: rgba(30, 32, 37, 0.98);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(88, 101, 242, 0.28);
  --text: #f2f3f5;
  --muted: #b5bac1;
  --muted-soft: #949ba4;
  --brand: #5865f2;
  --brand-soft: #7289ff;
  --green: #23a559;
  --red: #ed4245;
  --amber: #f0b232;
  --pointer-x: 50vw;
  --pointer-y: 36vh;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 12%, rgba(88, 101, 242, 0.12), transparent 20%),
    radial-gradient(circle at 86% 10%, rgba(237, 66, 69, 0.1), transparent 18%),
    linear-gradient(180deg, #0d0e10 0%, #111214 36%, #101114 100%);
  font-family: "Inter", system-ui, sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.cosmos,
.grid,
.pointer-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.cosmos--red {
  background: radial-gradient(circle at 84% 8%, rgba(237, 66, 69, 0.16), transparent 22%);
  filter: blur(18px);
}

.cosmos--blue {
  background: radial-gradient(circle at 14% 10%, rgba(88, 101, 242, 0.16), transparent 20%);
  filter: blur(18px);
}

.grid {
  opacity: 0.08;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(circle at center, black, transparent 82%);
}

.pointer-glow {
  opacity: 0;
  background:
    radial-gradient(circle 180px at var(--pointer-x) var(--pointer-y), rgba(88, 101, 242, 0.14), transparent 62%),
    radial-gradient(circle 260px at calc(var(--pointer-x) + 2vw) calc(var(--pointer-y) - 3vh), rgba(237, 66, 69, 0.09), transparent 70%);
  transition: opacity 0.24s ease;
}

body.has-pointer .pointer-glow {
  opacity: 1;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1740px, 100%);
  margin: 0 auto;
  padding: 16px 16px 44px;
}

.app-topbar,
.surface,
.import-shell {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.app-topbar {
  position: sticky;
  top: 10px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 18px;
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand-soft), #3949c2);
  font-weight: 800;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy strong {
  font-size: 0.98rem;
}

.brand-copy small {
  color: var(--muted-soft);
  font-size: 0.76rem;
}

.app-actions,
.compact-actions,
.preview-switcher,
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.action-chip,
.icon-chip,
.preview-tab {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 9px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 11px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.action-chip:hover,
.icon-chip:hover,
.preview-tab:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.16);
}

.action-chip--primary {
  background: linear-gradient(135deg, var(--brand), #3e4bbf);
  border-color: transparent;
}

.action-chip--danger,
.icon-chip--danger {
  color: #ffb0b4;
  border-color: rgba(237, 66, 69, 0.2);
  background: rgba(237, 66, 69, 0.08);
}

.action-chip--send {
  background: linear-gradient(135deg, #23a559, #168f4a);
  border-color: transparent;
  color: #f8fffb;
}

.action-chip--small {
  min-height: 34px;
  padding: 8px 12px;
}

.icon-chip {
  width: 38px;
  padding: 0;
}

.builder-grid {
  display: grid;
  grid-template-columns: minmax(300px, 340px) minmax(520px, 1fr) minmax(360px, 430px);
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}

.sidebar,
.editor,
.preview {
  display: grid;
  gap: 16px;
}

.surface {
  border-radius: 18px;
  padding: 16px;
  contain: layout paint style;
  content-visibility: auto;
  contain-intrinsic-size: 280px;
}

.surface--preview {
  position: sticky;
  top: 76px;
}

.surface-head {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.surface-head h2,
.surface-head p {
  margin: 0;
}

.surface-head h2 {
  font-size: 1rem;
}

.surface-head p {
  color: var(--muted-soft);
  font-size: 0.88rem;
  line-height: 1.5;
}

.surface-head--row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.stack-fields,
.editor-sections,
.embed-list,
.fields-stack {
  display: grid;
  gap: 12px;
}

.field,
.toggle {
  display: grid;
  gap: 8px;
}

.field span,
.toggle span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.field input,
.field textarea,
.field-card input,
.field-card textarea,
#import-json {
  width: 100%;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  outline: none;
  color: var(--text);
  background: #111216;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field-card input:focus,
.field-card textarea:focus,
#import-json:focus {
  border-color: rgba(88, 101, 242, 0.36);
  box-shadow: 0 0 0 4px rgba(88, 101, 242, 0.08);
}

.color-wrap {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
}

#embed-color {
  min-height: 42px;
  padding: 4px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.embed-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

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

.embed-item.is-active {
  border-color: rgba(88, 101, 242, 0.32);
  background: linear-gradient(135deg, rgba(88, 101, 242, 0.1), rgba(255, 255, 255, 0.03));
}

.embed-item-swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
}

.embed-item-copy {
  min-width: 0;
}

.embed-item-copy strong,
.embed-item-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.embed-item-copy strong {
  font-size: 0.92rem;
}

.embed-item-copy small,
.embed-item-count {
  color: var(--muted-soft);
  font-size: 0.78rem;
}

.editor-block {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.025);
}

.editor-block summary {
  list-style: none;
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  cursor: pointer;
}

.editor-block summary::-webkit-details-marker {
  display: none;
}

.editor-block summary span {
  font-weight: 700;
}

.editor-block summary small {
  color: var(--muted-soft);
}

.editor-block[open] {
  border-color: rgba(88, 101, 242, 0.16);
}

.editor-block-body {
  padding: 0 16px 16px;
}

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

.field--wide {
  grid-column: 1 / -1;
}

.fields-toolbar {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 12px;
}

.field-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.field-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.remove-field {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 11px;
  color: #ffb0b4;
  background: rgba(237, 66, 69, 0.1);
  cursor: pointer;
}

.status-box {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.18);
  color: var(--muted);
  line-height: 1.55;
  white-space: pre-wrap;
}

.status-box.status--success {
  color: #9addb3;
  border-color: rgba(35, 165, 89, 0.18);
}

.status-box.status--error {
  color: #ffb0b4;
  border-color: rgba(237, 66, 69, 0.18);
}

.preview-switcher {
  justify-content: flex-end;
}

.preview-tab.is-active {
  border-color: rgba(88, 101, 242, 0.32);
  background: rgba(88, 101, 242, 0.14);
}

.preview-pane.is-hidden,
.json-pane.is-hidden {
  display: none;
}

.discord-stage,
.json-pane pre {
  min-height: 760px;
  margin: 0;
  padding: 16px;
  overflow: auto;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: #2b2d31;
}

.json-pane pre {
  background: #111216;
  color: #d9dde3;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.84rem;
  line-height: 1.65;
}

.placeholder {
  display: grid;
  place-items: center;
  min-height: 560px;
  text-align: center;
  color: var(--muted);
}

.placeholder strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
}

.discord-message {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
}

.discord-avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  object-fit: cover;
  background: linear-gradient(135deg, var(--brand-soft), #3949c2);
}

.discord-body {
  min-width: 0;
}

.discord-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.discord-head strong {
  font-size: 0.98rem;
}

.bot-tag {
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--brand);
  font-size: 0.7rem;
  font-weight: 800;
}

.discord-time {
  color: #a5aab1;
  font-size: 0.78rem;
}

.discord-content {
  margin-top: 6px;
  color: #dbdee1;
  white-space: pre-wrap;
  line-height: 1.55;
}

.embed-stack {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.discord-embed {
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr);
  gap: 12px;
  max-width: 620px;
}

.discord-embed-bar {
  border-radius: 999px;
}

.discord-embed-card {
  padding: 12px 14px;
  border-radius: 6px;
  background: rgba(47, 49, 54, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.embed-author,
.embed-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #c7ccd1;
  font-size: 0.78rem;
}

.embed-author img,
.embed-footer img {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  object-fit: cover;
}

.embed-title {
  display: inline-block;
  margin-top: 8px;
  color: #fff;
  font-weight: 700;
}

.embed-description {
  margin-top: 8px;
  color: #dbdee1;
  white-space: pre-wrap;
  line-height: 1.5;
}

.embed-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.embed-grid.has-thumbnail {
  grid-template-columns: minmax(0, 1fr) 80px;
}

.embed-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.embed-field-card strong,
.embed-field-card span {
  display: block;
}

.embed-field-card strong {
  color: #fff;
  font-size: 0.84rem;
}

.embed-field-card span {
  margin-top: 4px;
  color: #dbdee1;
  font-size: 0.82rem;
  white-space: pre-wrap;
}

.embed-thumbnail,
.embed-image {
  border-radius: 8px;
  object-fit: cover;
}

.embed-thumbnail {
  width: 80px;
  height: 80px;
}

.embed-image {
  width: 100%;
  margin-top: 12px;
  max-height: 320px;
}

.embed-footer {
  margin-top: 12px;
}

.import-dialog {
  width: min(740px, calc(100vw - 30px));
  padding: 0;
  border: 0;
  background: transparent;
}

.import-dialog::backdrop {
  background: rgba(0, 0, 0, 0.66);
  backdrop-filter: blur(10px);
}

.import-shell {
  padding: 18px;
  border-radius: 18px;
}

#import-json {
  min-height: 300px;
  margin-top: 14px;
  font-family: "JetBrains Mono", monospace;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 14px;
}

.reveal {
  opacity: 0;
  transform: translate3d(0, 16px, 0);
  transition:
    opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal.is-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.ui-ripple {
  position: absolute;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0));
  animation: ripple-out 0.56s ease-out forwards;
  pointer-events: none;
}

@keyframes ripple-out {
  from {
    opacity: 0.45;
    width: 0;
    height: 0;
  }

  to {
    opacity: 0;
    width: 280px;
    height: 280px;
  }
}

@media (max-width: 1420px) {
  .builder-grid {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .preview {
    grid-column: 1 / -1;
  }

  .surface--preview {
    position: static;
  }
}

@media (max-width: 980px) {
  .builder-grid {
    grid-template-columns: 1fr;
  }

  .app-topbar {
    flex-direction: column;
    align-items: start;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding-inline: 12px;
  }

  .form-grid,
  .field-card {
    grid-template-columns: 1fr;
  }

  .action-chip,
  .preview-tab {
    width: 100%;
  }

  .app-actions,
  .dialog-actions {
    width: 100%;
    flex-direction: column;
  }

  .surface-head--row {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .reveal,
  .action-chip,
  .icon-chip,
  .preview-tab,
  .embed-item {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }

  .pointer-glow {
    display: none;
  }
}
