:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --text: #20242c;
  --muted: #6a7280;
  --line: #dfe4ec;
  --primary: #5865f2;
  --primary-dark: #3e49c9;
  --success: #177245;
  --danger: #b42318;
  --shadow: 0 14px 36px rgba(28, 36, 55, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 7px;
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
  min-height: 42px;
  padding: 0 18px;
}

button:hover {
  background: var(--primary-dark);
}

.secondary {
  background: #eef1f8;
  color: var(--text);
}

.secondary:hover {
  background: #e1e6f0;
}

.topbar {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 28px clamp(18px, 4vw, 52px);
}

.eyebrow {
  color: var(--primary);
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  margin-bottom: 4px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  letter-spacing: 0;
}

h2 {
  font-size: 1.25rem;
}

h3 {
  font-size: 1rem;
  margin-bottom: 10px;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.status {
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 800;
  padding: 8px 12px;
  white-space: nowrap;
}

.status-on {
  background: #e6f6ed;
  color: var(--success);
}

.status-off {
  background: #fff1f0;
  color: var(--danger);
}

.layout {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1fr) 330px;
  padding: 24px clamp(18px, 4vw, 52px) 46px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.intro-panel,
.layout > .panel:nth-child(2) {
  grid-column: 1;
}

.note-panel {
  align-self: start;
  display: grid;
  gap: 14px;
  grid-column: 2;
  grid-row: 1 / span 2;
}

.token-form {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}

.inline-field {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
}

label {
  color: var(--text);
  display: grid;
  font-weight: 800;
  gap: 8px;
}

input,
select,
textarea {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  min-height: 42px;
  padding: 10px 12px;
  width: 100%;
}

textarea {
  line-height: 1.45;
  min-height: 170px;
  resize: vertical;
}

.hint {
  font-size: 0.9rem;
}

.section-header {
  align-items: start;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 20px;
}

.switch {
  align-items: center;
  display: flex;
  font-size: 0.95rem;
  gap: 8px;
  white-space: nowrap;
}

.switch input {
  height: 18px;
  min-height: 0;
  width: 18px;
}

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

.message-field {
  margin-bottom: 14px;
}

.variables {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.variables button {
  background: #eef1f8;
  color: #303744;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem;
  font-weight: 700;
  min-height: 34px;
  padding: 0 10px;
}

.variables button:hover {
  background: #dfe5f1;
}

.preview {
  background: #f3f5f9;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 18px;
  padding: 16px;
}

#messagePreview {
  color: #303744;
  line-height: 1.5;
  min-height: 48px;
  white-space: pre-wrap;
  word-break: break-word;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toast {
  bottom: 20px;
  left: 50%;
  max-width: min(520px, calc(100vw - 32px));
  opacity: 0;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 14px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast-visible {
  background: #20242c;
  border-radius: 8px;
  color: #ffffff;
  opacity: 1;
  padding: 12px 16px;
  transform: translate(-50%, 0);
}

.toast-success {
  background: var(--success);
}

.toast-error {
  background: var(--danger);
}

.redirect-page {
  display: grid;
  gap: 12px;
  min-height: 100vh;
  place-content: center;
  text-align: center;
}

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

  .intro-panel,
  .layout > .panel:nth-child(2),
  .note-panel {
    grid-column: auto;
    grid-row: auto;
  }
}

@media (max-width: 640px) {
  .topbar,
  .section-header,
  .inline-field {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    gap: 12px;
  }

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