:root {
  --bg: #1e1f22;
  --bg2: #2b2d31;
  --bg3: #313338;
  --text: #f2f3f5;
  --muted: #949ba4;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --danger: #ed4245;
  --success: #57f287;
  --border: #3f4147;
  --radius: 8px;
  --sidebar: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

.hidden { display: none !important; }

.screen { min-height: 100vh; }

/* Login */
.login-card {
  max-width: 420px;
  margin: 10vh auto;
  padding: 2.5rem;
  background: var(--bg2);
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}

.logo { font-size: 3rem; margin-bottom: .5rem; }
.logo-sm { font-weight: 700; font-size: 1.1rem; }

.login-card h1 { margin-bottom: .5rem; }
.login-card p { color: var(--muted); margin-bottom: 1.5rem; }
.hint { font-size: .85rem; color: var(--danger); margin-top: 1rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .6rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  font-size: .95rem;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
  transition: background .15s;
}

.btn-discord { background: var(--accent); width: 100%; }
.btn-discord:hover { background: var(--accent-hover); }
.btn-primary { background: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { filter: brightness(.9); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm { padding: .35rem .75rem; font-size: .85rem; }

/* Topbar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}

.user-menu { display: flex; align-items: center; gap: .75rem; }
.user-menu img, .sidebar-user img { width: 32px; height: 32px; border-radius: 50%; }

.container { max-width: 900px; margin: 2rem auto; padding: 0 1rem; }
.container h2 { margin-bottom: 1.5rem; }

.guild-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.guild-card {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: border-color .15s, transform .15s;
  text-align: center;
}

.guild-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.guild-card img { width: 64px; height: 64px; border-radius: 50%; margin-bottom: .75rem; }
.guild-card .name { font-weight: 600; }
.guild-card .count { color: var(--muted); font-size: .85rem; }
.guild-card .badge {
  display: inline-block;
  margin-top: .55rem;
  font-size: .75rem;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: #3d3f45;
  color: var(--muted);
}
.guild-card .badge.wait { background: #3d3518; color: #f0c75e; }
.guild-card .badge.off { background: #3d2424; color: #f0a0a0; }
.guild-card .btn { margin-top: .75rem; width: 100%; }

.license-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
.license-box h3 { margin-bottom: .35rem; font-size: 1.05rem; }
.license-box .subtitle { color: var(--muted); font-size: .9rem; margin: 0 0 .85rem; }
.license-box .form-row { margin-top: 0; }
.license-box input[type="text"] {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: .6rem .8rem;
  font-size: .95rem;
}

/* Dashboard layout */
#dashboard { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
  position: fixed;
  height: 100vh;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 1rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.sidebar-head img { width: 40px; height: 40px; border-radius: 50%; }

.nav { flex: 1; padding: 1rem 0; }

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: .65rem 1.25rem;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: .95rem;
}

.nav-item:hover, .nav-item.active { background: var(--bg3); color: var(--text); }
.nav-item.active { border-left: 3px solid var(--accent); }
.nav-item.back { margin-top: auto; color: var(--muted); }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
  font-size: .85rem;
}

.main-content {
  margin-left: var(--sidebar);
  flex: 1;
  padding: 2rem;
  max-width: calc(100vw - var(--sidebar));
}

.page h1 { margin-bottom: 1.5rem; }
.subtitle { color: var(--muted); margin-bottom: 1rem; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.search-input {
  padding: .5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  min-width: 240px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg2);
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.stat-card .value { font-size: 1.75rem; font-weight: 700; }
.stat-card .label { color: var(--muted); font-size: .85rem; }

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.table th, .table td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: var(--bg2); color: var(--muted); font-weight: 600; }
.table tr:hover td { background: var(--bg3); }

.member-cell { display: flex; align-items: center; gap: .75rem; }
.member-cell img { width: 36px; height: 36px; border-radius: 50%; }

.tags { display: flex; flex-wrap: wrap; gap: .5rem; }
.tag {
  background: var(--bg3);
  padding: .25rem .6rem;
  border-radius: 4px;
  font-size: .8rem;
}

/* Modal */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.modal-box {
  position: relative;
  background: var(--bg2);
  border-radius: 12px;
  width: min(560px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  border: 1px solid var(--border);
}

.modal-close {
  position: absolute;
  top: .75rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-header { display: flex; gap: 1rem; margin-bottom: 1rem; }
.modal-header img { width: 64px; height: 64px; border-radius: 50%; }
.muted { color: var(--muted); font-size: .85rem; }

.modal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .75rem;
  margin-bottom: 1rem;
}

.modal-stats div {
  background: var(--bg3);
  padding: .75rem;
  border-radius: var(--radius);
  text-align: center;
}

.gribcode-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  margin-bottom: 1rem;
}

.gribcode-label {
  font-size: .75rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .25rem;
}

.gribcode-hint { margin: 0 0 .65rem; }

.gribcode-value {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.05rem;
  letter-spacing: .04em;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: .55rem .75rem;
  border-radius: var(--radius);
  margin-bottom: .65rem;
}

.guild-owner-tools {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  margin-top: .75rem;
  width: 100%;
}
.status-select {
  width: 100%;
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .4rem .5rem;
}
.archive-card { opacity: .92; }

#guild-picker {
  position: relative;
}
#guild-picker .container {
  padding-bottom: 7rem;
}

.recycle-bin {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 40;
  width: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  padding: .65rem .4rem .5rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
.recycle-bin:hover,
.recycle-bin:focus-visible {
  background: rgba(88, 101, 242, .18);
  border-color: rgba(88, 101, 242, .4);
  outline: none;
}
.recycle-icon-wrap {
  position: relative;
  width: 52px;
  height: 58px;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .45));
}
.recycle-svg {
  width: 48px;
  height: 54px;
  display: block;
}
.recycle-arrows { fill: #6b7785; }
.recycle-bin.is-full .recycle-arrows { fill: #3d8c40; }
.recycle-caption {
  font-size: .8rem;
  line-height: 1.2;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .85);
  user-select: none;
}
.recycle-count {
  position: absolute;
  top: -4px;
  right: -8px;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 .28rem;
  border-radius: 999px;
  background: #e81123;
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 2px var(--bg);
}
.archive-modal-box {
  width: min(960px, 96vw);
}
.archive-modal-box .subtitle { margin: .35rem 0 1rem; color: var(--muted); }
.archive-modal-box .guild-card { cursor: default; }
.archive-modal-box .guild-card:hover { transform: none; }

@media (max-width: 720px) {
  .recycle-bin { right: 12px; bottom: 12px; width: 80px; }
}

.gribcode-actions { margin: 0; }

.tabs { display: flex; gap: .5rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tab {
  background: none;
  border: none;
  color: var(--muted);
  padding: .5rem 1rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-panel { padding: .5rem 0; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: .35rem; color: var(--muted); font-size: .85rem; }

.form-group input, .form-group select {
  width: 100%;
  padding: .5rem .75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  margin-top: .25rem;
}

.form-row { display: flex; gap: .75rem; margin-top: 1rem; }

.card-list { display: grid; gap: .75rem; margin-bottom: 1.5rem; }

.admin-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg3);
  padding: .75rem 1rem;
  border-radius: var(--radius);
}
.admin-card-info { flex: 1; }

.admin-card img { width: 40px; height: 40px; border-radius: 50%; }

.timeline { display: flex; flex-direction: column; gap: .75rem; }
.timeline-item {
  background: var(--bg3);
  padding: .75rem;
  border-radius: var(--radius);
  border-left: 3px solid var(--accent);
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--bg3);
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  z-index: 200;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}

.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }

@media (max-width: 768px) {
  .sidebar { width: 100%; height: auto; position: relative; }
  .main-content { margin-left: 0; }
  #dashboard { flex-direction: column; }
  .chat-layout { flex-direction: column; }
  .channel-list { width: 100%; max-height: 200px; }
}

/* Chat / messages */
.chat-layout {
  display: flex;
  gap: 1rem;
  min-height: 520px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg2);
}

.channel-list {
  width: 240px;
  min-width: 240px;
  background: var(--bg3);
  overflow-y: auto;
  padding: .5rem 0;
  border-right: 1px solid var(--border);
}

.channel-category {
  padding: .5rem 1rem .25rem;
  font-size: .75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.channel-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: .45rem 1rem;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: .9rem;
}

.channel-item:hover, .channel-item.active {
  background: var(--bg2);
  color: var(--text);
}

.channel-item.active { border-left: 3px solid var(--accent); }

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-header {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  background: var(--bg3);
}

.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  min-height: 200px;
  max-height: 360px;
}

.chat-msg {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
}

.chat-msg img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chat-msg-body { min-width: 0; }

.chat-msg-author {
  font-weight: 600;
  font-size: .85rem;
  margin-bottom: .15rem;
}

.chat-msg-author.bot { color: var(--accent); }

.chat-msg-text {
  font-size: .9rem;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-msg-time {
  font-size: .75rem;
  color: var(--muted);
  margin-top: .2rem;
}

.chat-embed-preview {
  background: var(--bg);
  border-left: 4px solid var(--accent);
  padding: .5rem .75rem;
  border-radius: 4px;
  margin-top: .25rem;
}

.chat-compose {
  border-top: 1px solid var(--border);
  padding: 1rem;
  background: var(--bg3);
}

.compose-tabs { margin-bottom: .75rem; }

.chat-compose textarea,
.chat-compose input[type="text"] {
  width: 100%;
  padding: .6rem .75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  margin-bottom: .5rem;
  font-family: inherit;
  resize: vertical;
}

.chat-compose textarea { min-height: 80px; }

/* Player forms builder */
.form-builder-layout {
  display: flex;
  gap: 1rem;
  min-height: 560px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg2);
}

.form-builder-sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg3);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.form-builder-sidebar .sidebar-label {
  padding: .75rem 1rem .35rem;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}

.form-builder-main {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem 1.5rem;
}

.form-editor-empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--muted);
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-builder-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}

.form-builder-panel {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.form-builder-panel h3 {
  font-size: .95rem;
  margin-bottom: .75rem;
  color: var(--text);
}

.fields-builder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1rem 0 .5rem;
}

.fields-builder-head h3 { margin-bottom: 0; }

.field-builder-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-bottom: 1rem;
}

.field-builder-empty {
  padding: .75rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.field-builder-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: flex-start;
  padding: .55rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.field-builder-row-main {
  flex: 1;
  min-width: 280px;
  display: grid;
  grid-template-columns: 1.2fr 1fr auto auto;
  gap: .4rem;
  align-items: center;
}

.field-builder-columns {
  display: grid;
  grid-template-columns: 1.2fr 1fr auto auto;
  gap: .4rem;
  font-size: .72rem;
  padding: 0 .55rem .25rem;
  margin-left: 0;
}

.field-builder-row-extra {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  gap: .4rem;
  padding-left: .25rem;
}

.field-extra-label {
  font-size: .78rem;
  color: var(--muted);
  white-space: nowrap;
}

.field-builder-row-extra .fb-default {
  flex: 1;
  padding: .45rem .55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: .85rem;
  font-family: inherit;
}

.input-with-emoji {
  display: flex;
  gap: .4rem;
  align-items: center;
}

.input-with-emoji .fb-emoji-input {
  width: 52px;
  flex-shrink: 0;
  text-align: center;
  padding: .5rem .35rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  font-family: inherit;
}

.input-with-emoji input:not(.fb-emoji-input) {
  flex: 1;
}

.field-builder-row-main .fb-emoji {
  text-align: center;
  padding: .45rem .35rem;
}

.icon-options-editor {
  flex-direction: column;
  align-items: stretch;
  gap: .5rem;
}

.icon-options-list {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}

.icon-option-chip {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .25rem .45rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1.1rem;
}

.icon-option-remove {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: .95rem;
  line-height: 1;
  padding: 0 .1rem;
}

.icon-option-remove:hover { color: var(--danger); }

.icon-options-add {
  display: flex;
  gap: .35rem;
  align-items: center;
}

.icon-options-add .fb-icon-new {
  flex: 1;
  padding: .45rem .55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: .85rem;
  font-family: inherit;
}

.icon-default-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
}

.icon-default-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 1.15rem;
  cursor: pointer;
}

.icon-default-btn.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(88, 101, 242, .35);
}

.icon-choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.icon-choice-grid.preview .icon-choice-btn {
  cursor: default;
  opacity: .95;
}

.icon-choice-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg2);
  font-size: 1.35rem;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}

.icon-choice-btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.icon-choice-btn.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(88, 101, 242, .4);
  background: var(--bg3);
}

.icon-choice-btn.has-img {
  width: auto;
  min-width: 76px;
  height: auto;
  padding: 6px 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  line-height: 1.2;
}

.icon-choice-caption {
  font-size: 0.65rem;
  color: var(--text2);
  max-width: 80px;
  text-align: center;
  line-height: 1.15;
  word-break: break-word;
}

.icon-option-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: .35rem;
}

.icon-options-list .fb-icon-label {
  min-width: 140px;
  flex: 1;
  max-width: 220px;
}

.icon-choice-img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

.icon-option-chip.has-img {
  padding: .2rem .35rem;
  font-size: 0;
}

.icon-default-btn.has-img {
  width: 40px;
  height: 40px;
  padding: 2px;
  line-height: 0;
}

.icon-upload-hint {
  font-size: .75rem;
  margin: 0;
}

.preview-icon-value {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
  vertical-align: middle;
}

.icon-options-add .fb-icon-file {
  display: none;
}

.choice-options-list {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}

.choice-option-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .25rem .55rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .85rem;
}

.choice-option-remove {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: .95rem;
  line-height: 1;
}

.choice-option-remove:hover { color: var(--danger); }

.choice-options-add {
  display: flex;
  gap: .35rem;
  align-items: center;
}

.choice-options-add .fb-choice-new {
  flex: 1;
  padding: .45rem .55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: .85rem;
  font-family: inherit;
}

.choice-default-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
}

.choice-default-btn {
  padding: .35rem .65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: .82rem;
  cursor: pointer;
  max-width: 100%;
}

.choice-default-btn.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(88, 101, 242, .35);
}

.text-choice-list {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.text-choice-list.preview .text-choice-btn {
  cursor: default;
}

.text-choice-btn {
  width: 100%;
  text-align: left;
  padding: .55rem .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg2);
  color: var(--text);
  font-size: .9rem;
  cursor: pointer;
  font-family: inherit;
}

.text-choice-btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.text-choice-btn.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(88, 101, 242, .35);
  background: var(--bg3);
}

.text-choice-btn:disabled {
  cursor: default;
}

.emoji-picker {
  position: absolute;
  z-index: 300;
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  max-width: 260px;
  padding: .5rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}

.emoji-pick-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 6px;
  background: var(--bg3);
  font-size: 1.15rem;
  cursor: pointer;
}

.emoji-pick-btn:hover {
  background: var(--bg);
}

.field-builder-row-main input,
.field-builder-row-main select {
  width: 100%;
  padding: .45rem .55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: .85rem;
  font-family: inherit;
}

.field-builder-row-actions {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.fb-req {
  font-size: .8rem;
  color: var(--muted);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: .25rem;
}

.color-input-row {
  display: flex;
  gap: .5rem;
  align-items: center;
}

.color-input-row input[type="color"] {
  width: 42px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
}

.color-input-row input[type="text"] {
  flex: 1;
  padding: .55rem .7rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}

.form-builder-preview-panel .preview-hint {
  font-size: .8rem;
  margin: -.35rem 0 .75rem;
}

.preview-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}

.preview-player,
.preview-discord {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem;
  min-height: 200px;
}

.preview-panel-title {
  font-size: .8rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: .5rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.preview-field {
  margin-bottom: .65rem;
}

.preview-field label {
  display: block;
  font-size: .8rem;
  margin-bottom: .25rem;
  color: var(--muted);
}

.preview-field input,
.preview-field textarea {
  width: 100%;
  padding: .45rem .55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-family: inherit;
  font-size: .85rem;
}

.preview-submit {
  width: 100%;
  margin-top: .5rem;
  opacity: .7;
}

.form-builder-actions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* Message templates (shared list) */
.template-layout {
  display: flex;
  gap: 1rem;
  min-height: 480px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg2);
  margin-bottom: 1.5rem;
}

.template-list {
  width: 260px;
  min-width: 260px;
  background: var(--bg3);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: .5rem 0;
}

.template-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: .65rem 1rem;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: .9rem;
}

.template-item:hover, .template-item.active {
  background: var(--bg2);
  color: var(--text);
}

.template-item.active { border-left: 3px solid var(--accent); }

.template-item small {
  display: block;
  font-size: .75rem;
  color: var(--muted);
  margin-top: .15rem;
}

.template-main {
  flex: 1;
  padding: 1rem 1.25rem;
  overflow-y: auto;
}

.template-empty {
  padding: 2rem;
  text-align: center;
}

.template-form .form-group { margin-bottom: .75rem; }

.template-form label {
  display: block;
  font-size: .85rem;
  margin-bottom: .35rem;
  color: var(--muted);
}

.template-form input,
.template-form textarea,
.template-form select {
  width: 100%;
  padding: .55rem .7rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  font-family: inherit;
}

.template-preview-wrap {
  margin: 1rem 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.template-preview-wrap h3 {
  font-size: .9rem;
  margin-bottom: .5rem;
  color: var(--muted);
}

.template-preview {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  min-height: 80px;
}

.preview-content { white-space: pre-wrap; word-break: break-word; margin-bottom: .5rem; }

.preview-embed {
  border-left: 4px solid var(--accent);
  padding: .5rem .75rem;
  background: var(--bg);
  border-radius: 4px;
}

.preview-embed-title { font-weight: 700; margin-bottom: .35rem; }

.preview-embed-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .5rem;
  margin-top: .5rem;
}

.preview-embed-field-name {
  font-size: .75rem;
  font-weight: 700;
  color: var(--muted);
}

.template-admin {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  background: var(--bg2);
}

.template-admin summary {
  cursor: pointer;
  font-weight: 600;
}

.template-admin-body {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.template-admin textarea,
.template-admin input {
  width: 100%;
  padding: .55rem .7rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  font-family: inherit;
}

.submit-container { max-width: 960px; margin: 0 auto; padding: 1.5rem; }

.aliases-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.aliases-add-card,
.aliases-list-card {
  padding: 1rem 1.25rem;
}

.alias-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.alias-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .55rem .75rem;
  background: var(--bg3);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.note-item .note-meta {
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: .35rem;
}

.note-item .note-body {
  margin-bottom: .5rem;
  white-space: pre-wrap;
}

@media (max-width: 768px) {
  .template-layout { flex-direction: column; }
  .template-list { width: 100%; max-height: 180px; }
  .form-builder-layout { flex-direction: column; }
  .form-builder-sidebar { width: 100%; max-height: 180px; }
  .form-builder-grid { grid-template-columns: 1fr; }
  .field-builder-row-main { grid-template-columns: 1fr; }
  .field-builder-columns { display: none; }
  .preview-split { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .aliases-layout { grid-template-columns: 1fr; }
}
