* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: #f5f6f8;
  color: #1f2329;
  font-size: 14px;
}

.app { min-height: 100vh; }

.topbar {
  background: #07c160;
  color: #fff;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.brand { font-size: 16px; font-weight: 600; }

.view {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

/* List */
.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.list-header h2 { margin: 0; font-size: 18px; }

.config-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.config-card {
  background: #fff;
  border: 1px solid #e5e6eb;
  border-radius: 8px;
  padding: 16px;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.config-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-color: #07c160;
}
.config-card h3 {
  margin: 0 0 6px 0;
  font-size: 15px;
  font-weight: 600;
}
.config-card .meta {
  color: #86909c;
  font-size: 12px;
  margin-bottom: 12px;
}
.config-card .link-row {
  display: flex;
  gap: 6px;
  align-items: center;
  background: #f7f8fa;
  padding: 6px 8px;
  border-radius: 4px;
  margin-bottom: 10px;
  font-size: 12px;
}
.config-card .link-row input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 12px;
  color: #4e5969;
  outline: none;
}
.config-card .actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.empty-hint {
  text-align: center;
  padding: 60px 20px;
  color: #86909c;
}

/* Edit view */
.edit-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
}
@media (max-width: 1100px) {
  .edit-grid { grid-template-columns: 1fr; }
}

.edit-form {
  background: #fff;
  border: 1px solid #e5e6eb;
  border-radius: 8px;
  padding: 20px 24px;
}
.edit-form h2 { margin: 0 0 16px 0; font-size: 18px; }

fieldset {
  border: 1px solid #e5e6eb;
  border-radius: 6px;
  padding: 12px 16px 16px;
  margin: 0 0 18px 0;
}
fieldset legend {
  font-weight: 600;
  color: #1f2329;
  padding: 0 6px;
}
fieldset label {
  display: block;
  margin-bottom: 10px;
  font-size: 13px;
  color: #4e5969;
}
fieldset label input,
fieldset label textarea,
fieldset label select {
  display: block;
  width: 100%;
  padding: 7px 10px;
  margin-top: 4px;
  border: 1px solid #d9dce4;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
fieldset label input:focus,
fieldset label textarea:focus,
fieldset label select:focus {
  border-color: #07c160;
}
fieldset label textarea {
  min-height: 60px;
  resize: vertical;
}
.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.avatar-preview-row { margin-top: 4px; }
.avatar-preview {
  width: 40px; height: 40px;
  border-radius: 4px;
  background: #f0f0f0;
  object-fit: cover;
}

/* Participants */
.participant-item, .message-item {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: #f7f8fa;
  border-radius: 6px;
  margin-bottom: 8px;
  position: relative;
}
.participant-item {
  grid-template-columns: 50px 1fr 1fr auto;
  align-items: center;
}
.participant-item img {
  width: 40px; height: 40px; border-radius: 4px; background: #fff;
  object-fit: cover;
}
.participant-item input {
  padding: 6px 8px;
  border: 1px solid #d9dce4;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
}

/* Messages */
.message-item {
  grid-template-columns: 110px 1fr auto;
  align-items: start;
}
.message-item select,
.message-item input,
.message-item textarea {
  padding: 6px 8px;
  border: 1px solid #d9dce4;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.message-item textarea {
  min-height: 38px;
  resize: vertical;
}
.message-item .msg-type-tag {
  font-size: 11px;
  color: #86909c;
  margin-top: 2px;
}

.msg-add-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 7px 14px;
  border: 1px solid #d9dce4;
  background: #fff;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  color: #1f2329;
  transition: all 0.15s;
}
.btn:hover { border-color: #07c160; color: #07c160; }
.btn-primary {
  background: #07c160;
  color: #fff;
  border-color: #07c160;
}
.btn-primary:hover { background: #06ad56; color: #fff; }
.btn-danger {
  color: #f53f3f;
  border-color: #fbcfcf;
}
.btn-danger:hover { background: #f53f3f; color: #fff; border-color: #f53f3f; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-ghost {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-color: rgba(255,255,255,0.3);
}
.btn-ghost:hover { background: rgba(255,255,255,0.25); color: #fff; }
.btn-icon {
  padding: 4px 8px;
  font-size: 12px;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 16px;
  border-top: 1px solid #f0f1f3;
}

/* Preview */
.edit-preview {
  position: sticky;
  top: 16px;
  align-self: start;
}
.preview-label {
  color: #86909c;
  font-size: 12px;
  margin-bottom: 8px;
  text-align: center;
}
.phone-frame {
  width: 360px;
  height: 640px;
  margin: 0 auto;
  border: 8px solid #222;
  border-radius: 32px;
  overflow: hidden;
  background: #000;
}
.phone-frame iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #ededed;
}
.preview-actions {
  text-align: center;
  margin-top: 10px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 10px 18px;
  border-radius: 4px;
  font-size: 13px;
  z-index: 999;
  animation: toastIn 0.2s;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
