* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #1e1f22;
  color: #dbdee1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #2b2d31;
  border-bottom: 1px solid #232428;
}
.topbar h1 { font-size: 16px; margin: 0; color: #f2f3f5; }
.topbar select {
  background: #1e1f22;
  color: #dbdee1;
  border: 1px solid #3f4147;
  border-radius: 4px;
  padding: 4px 8px;
}

.layout {
  display: flex;
  gap: 16px;
  padding: 16px;
  align-items: flex-start;
}

.panel {
  background: #2b2d31;
  border-radius: 8px;
  padding: 16px;
}
.editor { flex: 1 1 480px; min-width: 380px; }
.preview { flex: 1 1 420px; min-width: 340px; position: sticky; top: 16px; }

.panel h2 { margin-top: 0; font-size: 15px; color: #f2f3f5; }
.panel h3, .panel h4 { color: #f2f3f5; font-size: 13px; margin: 16px 0 6px; }
.preview-hint { font-size: 12px; color: #949ba4; margin: -6px 0 12px; }

.block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.dashboard-list { list-style: none; margin: 0 0 16px; padding: 0; }
.dashboard-list li {
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
  margin-bottom: 4px;
  color: #b5bac1;
  font-size: 14px;
}
.dashboard-list li:hover { background: #35373c; }
.dashboard-list li.active { background: #3f4147; color: #fff; }
.dashboard-list li .mode-tag {
  font-size: 10px;
  color: #949ba4;
  margin-left: 6px;
}

.hidden { display: none !important; }

.form-grid { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.form-grid label { display: flex; flex-direction: column; font-size: 12px; color: #b5bac1; gap: 4px; }
.form-grid input[type="text"],
.form-grid textarea,
.form-grid select {
  background: #1e1f22;
  border: 1px solid #3f4147;
  border-radius: 4px;
  color: #dbdee1;
  padding: 8px;
  font-size: 14px;
  font-family: inherit;
}
.form-grid textarea { min-height: 60px; resize: vertical; }
.form-grid small { color: #949ba4; }

.btn {
  border: none;
  border-radius: 4px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  align-self: flex-start;
}
.btn-primary { background: #5865f2; color: white; }
.btn-primary:hover { background: #4752c4; }
.btn-secondary { background: #4e5058; color: white; }
.btn-secondary:hover { background: #6d6f78; }
.btn-danger { background: #da373c; color: white; }
.btn-danger:hover { background: #a12828; }
.btn-small { padding: 4px 10px; font-size: 12px; }

.base-fields-block { border-top: 1px solid #3f4147; padding-top: 12px; margin-top: 4px; }
.base-field-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.base-field-list li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  background: #1e1f22;
  border-radius: 4px;
  padding: 6px 8px;
}
.base-field-label {
  flex: 1 1 140px;
  background: #2b2d31;
  border: 1px solid #3f4147;
  border-radius: 4px;
  color: #dbdee1;
  padding: 5px 7px;
  font-size: 13px;
  font-family: inherit;
}
.base-field-toggle { display: flex; align-items: center; gap: 4px; font-size: 11px; color: #b5bac1; white-space: nowrap; }
.base-field-toggle input { width: 13px; height: 13px; }
.base-field-delete { flex-shrink: 0; }

.publish-block {
  border-top: 1px solid #3f4147;
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.publish-block select { padding: 6px; border-radius: 4px; background: #1e1f22; color: #dbdee1; border: 1px solid #3f4147; }
.status-text { font-size: 12px; color: #949ba4; }
.status-text.error { color: #f23f42; }
.status-text.success { color: #23a55a; }

/* --- Discord message mock --- */
.discord-message {
  background: #313338;
  border-radius: 6px;
  padding: 14px;
}
.discord-message-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.discord-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: #5865f2; display: flex; align-items: center; justify-content: center;
  color: white; font-weight: bold; font-size: 14px;
}
.discord-bot-name { font-weight: 600; color: #f2f3f5; font-size: 14px; }
.discord-app-tag {
  background: #5865f2; color: white; font-size: 9px; font-weight: 600;
  padding: 1px 4px; border-radius: 3px; margin-left: 4px; vertical-align: middle;
}
.embed-card {
  border-left: 4px solid #5865f2;
  background: #2b2d31;
  border-radius: 4px;
  padding: 10px 12px;
  max-width: 480px;
}

/* click-to-edit affordances */
[contenteditable]:hover { background: rgba(255, 255, 255, 0.06); border-radius: 3px; cursor: text; }
[contenteditable]:focus {
  outline: 1px dashed #5865f2;
  outline-offset: 2px;
  background: rgba(88, 101, 242, 0.1);
  border-radius: 3px;
  cursor: text;
}

.embed-title-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.embed-title { font-weight: 600; color: #f2f3f5; white-space: pre-wrap; padding: 1px 3px; }

.color-swatch {
  width: 18px; height: 18px; padding: 0; border: none; border-radius: 50%;
  cursor: pointer; background: none; flex-shrink: 0;
}
.color-swatch::-webkit-color-swatch-wrapper { padding: 0; border-radius: 50%; }
.color-swatch::-webkit-color-swatch { border: 2px solid #1e1f22; border-radius: 50%; }
.color-swatch::-moz-color-swatch { border: 2px solid #1e1f22; border-radius: 50%; }

.embed-description-input {
  display: block;
  width: 100%;
  resize: none;
  overflow: hidden;
  background: transparent;
  border: none;
  outline: none;
  padding: 1px 3px;
  margin-bottom: 8px;
  color: #dbdee1;
  font-size: 13px;
  font-family: inherit;
  white-space: pre-wrap;
}
.embed-description-input:hover { background: rgba(255, 255, 255, 0.06); border-radius: 3px; cursor: text; }
.embed-description-input:focus {
  outline: 1px dashed #5865f2;
  outline-offset: 0;
  background: rgba(88, 101, 242, 0.1);
  border-radius: 3px;
}

.embed-fields { display: flex; flex-wrap: wrap; gap: 8px; }
.embed-field {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  color: #dbdee1;
  background: #1e1f22;
  border-radius: 4px;
  padding: 4px 6px;
  border: 1px solid transparent;
}
.embed-field.drag-over { border-color: #5865f2; }
.embed-field.dragging { opacity: 0.4; }
.embed-field-empty { color: #949ba4; font-style: italic; }

.pill-drag-handle { cursor: grab; color: #6d6f78; font-size: 12px; padding: 0 1px; }
.pill-drag-handle:active { cursor: grabbing; }
.pill-label { padding: 0 2px; border-radius: 3px; min-width: 6px; }
.pill-emoji { cursor: pointer; padding: 0 2px; border-radius: 3px; }
.pill-emoji:hover { background: rgba(255, 255, 255, 0.08); }
.pill-emoji-empty { color: #6d6f78; font-size: 10px; }
.pill-gear, .pill-delete {
  border: none;
  background: none;
  color: #6d6f78;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 2px;
  border-radius: 3px;
}
.pill-gear:hover, .pill-delete:hover { color: #f2f3f5; background: rgba(255, 255, 255, 0.08); }
.pill-gear-active { color: #5865f2; }
.pill-delete { visibility: hidden; }
.embed-field:hover .pill-delete { visibility: visible; }

.embed-field-add { background: transparent; border: 1px dashed #4e5058; }
.pill-add-btn { background: none; border: none; color: #949ba4; font-size: 12px; cursor: pointer; padding: 2px 2px; }
.pill-add-btn:hover { color: #f2f3f5; }
.pill-add-input {
  background: #1e1f22;
  border: 1px solid #5865f2;
  border-radius: 4px;
  color: #dbdee1;
  font-size: 12px;
  padding: 3px 6px;
  width: 130px;
}

.discord-btn-row { margin-top: 10px; }
.discord-request-btn {
  background: #5865f2; color: white; border: none; border-radius: 4px;
  padding: 8px 14px; font-size: 13px; cursor: pointer;
}
.discord-request-btn:disabled { background: #3f4147; color: #80848e; cursor: not-allowed; }

/* --- modal mock --- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.discord-modal {
  background: #313338; border-radius: 8px; width: 440px; max-height: 80vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.discord-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 8px; font-weight: 600; color: #f2f3f5; font-size: 16px;
}
.modal-close { background: none; border: none; color: #b5bac1; font-size: 20px; cursor: pointer; }
.discord-modal-body { padding: 8px 16px; overflow-y: auto; flex: 1; }
.discord-modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid #232428; }

.modal-field { margin-bottom: 16px; }
.modal-field-label { font-size: 12px; font-weight: 600; color: #f2f3f5; margin-bottom: 6px; display: block; }
.modal-field-label .required-star { color: #f23f42; margin-left: 2px; }
.modal-field input[type="text"], .modal-field textarea {
  width: 100%; background: #1e1f22; border: 1px solid #3f4147; border-radius: 4px;
  color: #dbdee1; padding: 8px; font-size: 14px; font-family: inherit;
}
.checkbox-option { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; color: #dbdee1; }
.checkbox-option input { width: 16px; height: 16px; }
.checkbox-hint { font-size: 11px; color: #949ba4; margin-top: 4px; }
.field-error { color: #f23f42; font-size: 11px; margin-top: 4px; }

/* --- ticket result preview --- */
.ticket-result { border-left: 4px solid #23a55a; background: #2b2d31; border-radius: 4px; padding: 10px 12px; margin-top: 12px; }
.ticket-result h4 { margin: 0 0 6px; color: #f2f3f5; font-size: 13px; }
.ticket-result .result-field { font-size: 12px; margin-bottom: 4px; }
.ticket-result .result-field b { color: #f2f3f5; }
.ticket-result .channel-list { margin-top: 8px; font-size: 12px; color: #949ba4; }
.ticket-result .channel-chip {
  display: inline-block; background: #1e1f22; border-radius: 4px; padding: 2px 8px; margin: 2px 4px 0 0;
}
