:root {
  --bg: #090b0e;
  --bg-2: #10141a;
  --surface: rgba(20, 24, 31, 0.72);
  --surface-strong: rgba(25, 31, 40, 0.88);
  --surface-soft: rgba(255, 255, 255, 0.045);
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.2);
  --text: #f4f7fb;
  --muted: #a9b3c0;
  --muted-2: #7f8a99;
  --accent: #ff7a2f;
  --accent-2: #2fd0b3;
  --ok: #4cd878;
  --warn: #f7c948;
  --danger: #ff6876;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  background:
    linear-gradient(120deg, rgba(255, 122, 47, 0.12), transparent 28%),
    linear-gradient(240deg, rgba(47, 208, 179, 0.1), transparent 32%),
    linear-gradient(180deg, #0c0f13 0%, #10141a 52%, #090b0e 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), transparent 82%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 0 28%, rgba(255, 255, 255, 0.04) 28.2% 28.5%, transparent 28.7%),
    linear-gradient(295deg, transparent 0 58%, rgba(47, 208, 179, 0.05) 58.2% 58.55%, transparent 58.8%);
}

a {
  color: inherit;
}

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

button {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 13, 18, 0.76);
  backdrop-filter: blur(18px) saturate(130%);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.2);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  font-size: 17px;
  font-weight: 800;
}

.brand img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 0 0 4px rgba(255, 122, 47, 0.09);
}

.brand-copy {
  display: grid;
}

.brand-copy small {
  color: var(--muted);
  font-size: 12px;
}

.topnav,
.actions-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.lang-switch {
  display: inline-flex;
  gap: 6px;
  margin-right: 6px;
}

.lang-pill {
  min-width: 42px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  text-decoration: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.lang-pill.is-active {
  color: var(--text);
  border-color: rgba(255, 122, 47, 0.38);
  background: rgba(255, 122, 47, 0.1);
}

.topnav a,
.ghost {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  color: var(--muted);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.topnav a:hover,
.ghost:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.07);
}

.page {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 64px;
}

.login-panel {
  min-height: calc(100vh - 160px);
  display: grid;
  align-content: center;
  gap: 22px;
  width: min(720px, 100%);
}

.login-panel > div:first-child,
.section-head,
.guild-row,
.notice,
.flash,
.empty-state,
.code-form,
.codes-output,
.settings-form textarea {
  position: relative;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.025)),
    var(--surface);
  backdrop-filter: blur(20px) saturate(130%);
  box-shadow: var(--shadow);
}

.login-panel > div:first-child::before,
.section-head::before,
.guild-row::before,
.notice::before,
.code-form::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.16), transparent 34%);
  opacity: 0.55;
}

.login-panel > div:first-child {
  border-radius: 8px;
  padding: 28px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 38px;
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: 0;
}

.muted {
  color: var(--muted);
  margin-bottom: 0;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.primary-button {
  color: #140b05;
  font-weight: 800;
  background: linear-gradient(135deg, #ff9a54, var(--accent));
  box-shadow: 0 12px 28px rgba(255, 122, 47, 0.26);
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 34px rgba(255, 122, 47, 0.32);
}

.secondary-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  border-color: var(--line);
}

.secondary-button:hover {
  border-color: rgba(47, 208, 179, 0.42);
  background: rgba(47, 208, 179, 0.08);
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 20px;
  border-radius: 8px;
}

.user-pill,
.guild-title,
.guild-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.user-pill {
  min-height: 48px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px 7px 7px;
  color: var(--text);
  white-space: nowrap;
}

.user-pill img,
.guild-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.guild-icon.placeholder {
  display: grid;
  place-items: center;
  color: #101820;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.guild-list {
  display: grid;
  gap: 12px;
}

.guild-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  border-radius: 8px;
  padding: 16px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.guild-row:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.22);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.095), rgba(255, 255, 255, 0.03)),
    var(--surface-strong);
}

.guild-main > div,
.guild-title > div {
  min-width: 0;
}

.guild-main h2,
.guild-title h1,
.guild-main p,
.guild-title p {
  overflow-wrap: anywhere;
}

.row-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  padding: 0 14px;
  text-decoration: none;
  transition: border-color 160ms ease, background 160ms ease;
}

.row-link:hover {
  border-color: rgba(255, 122, 47, 0.48);
  background: rgba(255, 122, 47, 0.09);
}

.status-stack {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.status {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
}

.status.ok {
  border-color: rgba(76, 216, 120, 0.42);
  color: #a4f4bc;
  background: rgba(76, 216, 120, 0.08);
}

.status.warn {
  border-color: rgba(247, 201, 72, 0.5);
  color: #ffe49a;
  background: rgba(247, 201, 72, 0.08);
}

.status.premium {
  border-color: rgba(47, 208, 179, 0.42);
  color: #9ff4e4;
  background: rgba(47, 208, 179, 0.08);
}

.flash,
.notice,
.empty-state {
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
}

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.notice p {
  margin-bottom: 0;
}

.flash.ok {
  border-color: rgba(76, 216, 120, 0.42);
}

.flash.error {
  border-color: rgba(255, 104, 118, 0.52);
  color: #ffc5cb;
}

.settings-form,
.code-form,
.codes-output {
  display: grid;
  gap: 12px;
}

.editor-shell,
.editor-card,
.editor-json-panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.025)),
    var(--surface);
  backdrop-filter: blur(20px) saturate(130%);
  box-shadow: var(--shadow);
}

.editor-shell {
  padding: 18px;
}

.editor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.editor-mode {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.mode-button {
  min-width: 110px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.mode-button.is-active {
  background: rgba(255, 122, 47, 0.12);
  border-color: rgba(255, 122, 47, 0.28);
  color: var(--text);
}

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

.editor-card {
  padding: 16px;
}

.editor-card .card-head {
  margin-bottom: 14px;
}

.editor-card h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

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

.field-span-2 {
  grid-column: 1 / -1;
}

.switch-field {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

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

.editor-json-panel {
  padding: 16px;
}

.editor-json-panel textarea {
  min-height: 72vh;
}

.is-hidden {
  display: none;
}

.settings-form label,
.codes-output label,
.code-form label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

textarea,
input,
select {
  width: 100%;
  color: var(--text);
  background: rgba(8, 11, 15, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea:focus,
input:focus,
select:focus {
  border-color: rgba(47, 208, 179, 0.52);
  box-shadow: 0 0 0 4px rgba(47, 208, 179, 0.09);
  background: rgba(8, 11, 15, 0.86);
}

select {
  color-scheme: dark;
}

.settings-form textarea {
  min-height: 68vh;
  resize: vertical;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  border-radius: 8px;
}

.codes-output {
  margin-top: 16px;
}

.codes-output textarea {
  min-height: 260px;
  font-family: "JetBrains Mono", Consolas, monospace;
}

.code-form {
  grid-template-columns: repeat(4, minmax(120px, 1fr)) auto;
  align-items: end;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 18px;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin-top: -1px;
  padding: 14px 0 0;
  background: linear-gradient(to top, var(--bg) 0%, rgba(9, 11, 14, 0.88) 64%, transparent);
}

code {
  color: #ffd0b7;
  background: rgba(255, 122, 47, 0.09);
  border: 1px solid rgba(255, 122, 47, 0.22);
  border-radius: 5px;
  padding: 2px 6px;
}

.builder-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 380px;
  gap: 16px;
}

.builder-sidebar,
.builder-preview {
  min-width: 0;
}

.builder-main {
  min-width: 0;
}

.sidebar-card,
.preview-card {
  position: sticky;
  top: 92px;
}

.nav-stack {
  display: grid;
  gap: 8px;
}

.section-chip {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  text-align: left;
  padding: 0 12px;
  cursor: pointer;
}

.section-chip.is-active {
  color: var(--text);
  border-color: rgba(255, 122, 47, 0.34);
  background: rgba(255, 122, 47, 0.12);
}

.editor-stack {
  display: grid;
  gap: 14px;
}

.builder-section {
  display: none;
}

.builder-section.is-active {
  display: block;
}

.label-title {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-weight: 700;
}

.label-hint {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

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

.premium-item {
  min-height: 92px;
  padding: 14px;
  border: 1px solid rgba(255, 122, 47, 0.22);
  border-radius: 8px;
  background: rgba(255, 122, 47, 0.06);
}

.premium-fields {
  margin-top: 8px;
}

.discord-preview {
  display: grid;
  gap: 14px;
  padding: 8px 0 2px;
}

.discord-preview__channel {
  color: var(--muted);
  font-size: 13px;
}

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

.discord-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

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

.discord-header {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.discord-name {
  color: #ffffff;
}

.discord-badge {
  padding: 2px 6px;
  border-radius: 6px;
  background: #5865f2;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.discord-time {
  color: var(--muted-2);
  font-size: 12px;
}

.discord-text {
  color: #dbdee1;
  white-space: pre-wrap;
  line-height: 1.45;
}

.discord-embed {
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr);
  gap: 10px;
  margin-top: 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.045);
  overflow: hidden;
}

.discord-embed__line {
  min-height: 100%;
  background: var(--accent);
}

.discord-embed__body {
  padding: 12px 12px 12px 0;
}

.discord-embed__body strong {
  display: block;
  margin-bottom: 6px;
}

.discord-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.discord-button,
.discord-select {
  min-height: 36px;
  border-radius: 6px;
  border: 1px solid rgba(88, 101, 242, 0.35);
  background: rgba(88, 101, 242, 0.14);
  color: #fff;
  padding: 0 12px;
}

.discord-select {
  width: 100%;
  display: flex;
  align-items: center;
  color: #c5ced8;
}

.preview-divider {
  height: 1px;
  background: var(--line);
}

select[multiple] {
  min-height: 180px;
}

@media (max-width: 820px) {
  .topbar,
  .section-head,
  .notice {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    position: static;
    padding: 16px;
  }

  .topnav,
  .actions-row,
  .notice {
    width: 100%;
  }

  .topnav a,
  .ghost,
  .primary-button,
  .secondary-button {
    flex: 1 1 auto;
  }

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

  .status-stack {
    justify-content: flex-start;
  }

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

  .builder-layout {
    grid-template-columns: 1fr;
  }

  .sidebar-card,
  .preview-card {
    position: static;
  }

  .editor-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .editor-mode {
    width: 100%;
  }

  .mode-button {
    flex: 1 1 auto;
    min-width: 0;
  }

  .editor-grid,
  .field-grid,
  .premium-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .page {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .section-head,
  .login-panel > div:first-child,
  .guild-row,
  .notice,
  .code-form {
    padding: 14px;
  }

  h1 {
    font-size: 30px;
  }

  .guild-title {
    align-items: flex-start;
  }

  .user-pill {
    white-space: normal;
  }
}
