/* ─── Admin layout ─────────────────────────────────────────────────────── */

#admin-main {
  flex: 1;
  display: flex;
  overflow: hidden;
  width: min(1200px, 100%);
  margin: 0 auto;
}

/* ─── Nav menu ──────────────────────────────────────────────────────────── */
#admin-nav {
  width: 160px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
  flex-shrink: 0;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  text-align: left;
  padding: 0.6rem 1.25rem;
  cursor: pointer;
  font-size: 0.92rem;
  font-family: inherit;
  border-left: 3px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.nav-btn:hover { color: var(--color-text); background: var(--color-surface2); }
.nav-btn.active {
  color: var(--color-accent);
  border-left-color: var(--color-accent);
  background: rgba(233,69,96,0.08);
}

/* ─── Content area ─────────────────────────────────────────────────────── */
#admin-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
}

.admin-section {}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.section-header h1 {
  font-size: 1.3rem;
  font-weight: 700;
}

.btn-group { display: flex; gap: 0.5rem; }

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  padding: 0.45rem 1rem;
  border-radius: 6px;
  border: none;
  font-size: 0.88rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary  { background: var(--color-accent); color: #fff; }
.btn-primary:hover:not(:disabled)  { opacity: 0.85; }
.btn-secondary {
  background: var(--color-surface2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover:not(:disabled) { background: var(--color-border); }
.btn-danger  { background: #c0392b; color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: 0.85; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-icon {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.btn-icon:hover { color: var(--color-text); background: var(--color-surface2); }

/* ─── Loading & error rows ──────────────────────────────────────────────── */
.loading-row {
  color: var(--color-text-muted);
  padding: 1rem 0;
  font-size: 0.9rem;
}

.error-banner {
  background: rgba(233,69,96,0.12);
  border: 1px solid rgba(233,69,96,0.4);
  color: var(--color-accent);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.warning-banner {
  background: rgba(255,193,7,0.12);
  border: 1px solid rgba(255,193,7,0.5);
  color: #c8970a;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.success-banner {
  background: rgba(58,201,122,0.12);
  border: 1px solid rgba(58,201,122,0.4);
  color: #3ac97a;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* ─── Connector list ────────────────────────────────────────────────────── */
.connector-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.conn-type-heading {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  padding: 0.9rem 0 0.4rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 0.25rem;
}

.conn-empty { color: var(--color-text-muted); font-size: 0.85rem; padding: 0.5rem 0 0.75rem; }

.conn-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
}
.conn-card:last-child { border-bottom: none; }

.conn-active-star {
  color: #f1c40f;
  font-size: 1rem;
  margin-top: 0.15rem;
  flex-shrink: 0;
  min-width: 1rem;
}

.conn-info { flex: 1; min-width: 0; }
.conn-name {
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.conn-nsfw-badge {
  font-size: 0.68rem;
  font-weight: 700;
  background: rgba(233,69,96,0.15);
  border: 1px solid rgba(233,69,96,0.45);
  border-radius: 10px;
  padding: 0.1rem 0.5rem;
  color: var(--color-accent);
  letter-spacing: 0.04em;
}

.conn-backend-badge {
  font-size: 0.72rem;
  font-weight: 400;
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 0.1rem 0.5rem;
  color: var(--color-text-muted);
}
.conn-meta { font-size: 0.82rem; color: var(--color-text-muted); margin-top: 0.25rem; }
.conn-status { font-size: 0.8rem; margin-top: 0.2rem; }
.conn-status.ok { color: #3ac97a; }
.conn-status.fail { color: var(--color-accent); }
.conn-status.unknown { color: var(--color-text-muted); }

.conn-test-feedback {
  margin-top: 0.35rem;
  font-size: 0.78rem;
  line-height: 1.4;
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
  border: 1px solid transparent;
  word-break: break-word;
}

.conn-test-feedback.ok {
  color: #3ac97a;
  background: rgba(58,201,122,0.12);
  border-color: rgba(58,201,122,0.35);
}

.conn-test-feedback.warn {
  color: #f39c12;
  background: rgba(243,156,18,0.12);
  border-color: rgba(243,156,18,0.35);
}

.conn-test-feedback.fail {
  color: var(--color-accent);
  background: rgba(233,69,96,0.12);
  border-color: rgba(233,69,96,0.35);
}

.conn-actions { display: flex; gap: 0.35rem; align-items: center; flex-shrink: 0; }

/* ─── Character list ────────────────────────────────────────────────────── */
.character-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.char-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
}
.char-card:last-child { border-bottom: none; }

.char-card-avatar {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--color-surface2);
  flex-shrink: 0;
  border: 1px solid var(--color-border);
}

.char-card-info { flex: 1; min-width: 0; }
.char-card-name { font-weight: 600; font-size: 0.95rem; }
.char-card-desc {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.char-card-tags {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 0.2rem;
}

.char-card-actions { display: flex; gap: 0.35rem; align-items: center; flex-shrink: 0; }

/* ─── Dropdown menu ─────────────────────────────────────────────────────── */
.dropdown-wrap { position: relative; }
.dropdown-menu {
  position: absolute;
  right: 0;
  top: 110%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  min-width: 160px;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  overflow: hidden;
}
.dropdown-menu button {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--color-text);
  text-align: left;
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s;
}
.dropdown-menu button:hover { background: var(--color-surface2); }
.dropdown-menu button.danger { color: var(--color-accent); }

/* ─── Dialog ────────────────────────────────────────────────────────────── */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.dialog {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.dialog-wide  { max-width: 620px; }
.dialog-narrow{ max-width: 380px; }

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.dialog-header h2 { font-size: 1.05rem; font-weight: 700; }
.dialog-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  line-height: 1;
}
.dialog-close:hover { color: var(--color-text); background: var(--color-surface2); }

.dialog-body {
  padding: 1rem 1.25rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.dialog-footer {
  padding: 0 1.25rem;
  flex-shrink: 0;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem 1rem;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

/* ─── Form fields ───────────────────────────────────────────────────────── */
.field-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.field-row label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-muted);
}
.field-row input[type="text"],
.field-row input[type="number"],
.field-row input[type="password"],
.field-row select,
.field-row textarea {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text);
  font-size: 0.9rem;
  font-family: inherit;
  padding: 0.45rem 0.7rem;
  transition: border-color 0.15s;
}
.field-row input:focus,
.field-row select:focus,
.field-row textarea:focus { outline: none; border-color: var(--color-accent); }
.field-row textarea { resize: vertical; }
.field-row .field-error {
  font-size: 0.78rem;
  color: var(--color-accent);
  min-height: 1em;
}
.field-row .required { color: var(--color-accent); }
.field-row-check {
  flex-direction: row;
  align-items: center;
}
.field-row-check label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--color-text);
  font-weight: 400;
}
.field-row-check input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--color-accent);
  cursor: pointer;
  flex-shrink: 0;
}

.quick-setup-note {
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--color-text-muted);
  background: rgba(58, 201, 122, 0.08);
  border: 1px solid rgba(58, 201, 122, 0.22);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  margin-bottom: 0.2rem;
}

.advanced-config-details {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface2);
  margin-top: 1rem;
}

.advanced-config-details > summary {
  cursor: pointer;
  list-style: none;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--color-text);
  padding: 0.65rem 0.8rem;
}

.advanced-config-details > summary::-webkit-details-marker {
  display: none;
}

.advanced-config-details > summary::after {
  content: '▾';
  float: right;
  color: var(--color-text-muted);
  transition: transform 0.18s ease;
}

.advanced-config-details[open] > summary::after {
  transform: rotate(180deg);
}

.advanced-config-body {
  border-top: 1px solid var(--color-border);
  padding: 0.65rem 0.8rem 0.8rem;
}

.field-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin: 0 0 0.6rem;
}

.field-row-nsfw {
  gap: 0.45rem;
}

.nsfw-toggle {
  display: inline-flex;
  width: 220px;
  max-width: 100%;
}

.nsfw-toggle-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.nsfw-toggle-track {
  width: 100%;
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-bg);
  overflow: hidden;
  min-height: 34px;
  cursor: pointer;
}

.nsfw-toggle-option {
  z-index: 2;
  text-align: center;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 34px;
  user-select: none;
  transition: color 0.18s ease;
}

.nsfw-toggle-option-off {
  color: var(--color-text);
}

.nsfw-toggle-option-on {
  color: var(--color-text-muted);
}

.nsfw-toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  border-radius: 999px;
  background: rgba(58, 201, 122, 0.22);
  border: 1px solid rgba(58, 201, 122, 0.45);
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.nsfw-toggle-input:checked + .nsfw-toggle-track .nsfw-toggle-knob {
  transform: translateX(100%);
  background: rgba(233, 69, 96, 0.2);
  border-color: rgba(233, 69, 96, 0.48);
}

.nsfw-toggle-input:checked + .nsfw-toggle-track .nsfw-toggle-option-off {
  color: var(--color-text-muted);
}

.nsfw-toggle-input:checked + .nsfw-toggle-track .nsfw-toggle-option-on {
  color: var(--color-text);
}

.nsfw-toggle-input:focus-visible + .nsfw-toggle-track {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.field-help {
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--color-text-muted);
}

.code-input {
  width: 100%;
  min-height: 220px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
  line-height: 1.45;
}

.code-editor {
  width: 100%;
  position: relative;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}

.code-editor:focus-within {
  border-color: var(--color-accent);
}

.code-highlight {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0.75rem 0.8rem;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  pointer-events: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
  line-height: 1.45;
}

.code-input.code-input-overlay {
  position: relative;
  z-index: 1;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: var(--color-text);
  -webkit-text-fill-color: transparent;
  padding: 0.75rem 0.8rem;
  resize: vertical;
  overflow: auto;
}

.code-input.code-input-overlay::placeholder {
  color: var(--color-text-muted);
  -webkit-text-fill-color: var(--color-text-muted);
}

.tok-muted { color: var(--color-text-muted); }
.tok-comment { color: #90a0a8; }
.tok-selector { color: #80cbc4; }
.tok-tag { color: #64b5f6; }
.tok-attr { color: #ffd166; }
.tok-value { color: #c5e1a5; }
.tok-string { color: #ffcc80; }
.tok-number { color: #f48fb1; }

.field-divider {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  padding-top: 0.75rem;
  margin-top: 0.25rem;
}

/* ─── Avatar in char form ────────────────────────────────────────────────── */
.char-avatar-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 0.5rem;
}
.char-edit-avatar {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
}

/* ─── Drop zone ─────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: 8px;
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--color-accent);
  background: rgba(233,69,96,0.06);
}
.drop-hint { font-size: 0.8rem; margin-top: 0.35rem; color: var(--color-text-muted); }

/* ─── Health section ─────────────────────────────────────────────────────── */
.health-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 1.5rem;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.health-dl dt { color: var(--color-text-muted); }
.health-dl dd { font-weight: 500; }

.health-subheading {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.health-connectors { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.health-row { font-size: 0.9rem; display: flex; align-items: center; gap: 0.5rem; }
.health-type { width: 4rem; color: var(--color-text-muted); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; }
.health-na { color: var(--color-text-muted); font-size: 0.85rem; }

/* ─── Statistics section ─────────────────────────────────────────────────── */
.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stats-card {
  background: linear-gradient(150deg, rgba(255, 179, 71, 0.16), rgba(80, 227, 194, 0.08));
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
}

.stats-card-label {
  color: var(--color-text-muted);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stats-card-value {
  margin-top: 0.35rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.stats-panel {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.01);
  padding: 0.75rem;
  margin-bottom: 0.9rem;
}

.stats-canvas {
  width: 100%;
  height: 260px;
  border-radius: 6px;
  display: block;
}

.stats-table-wrap {
  overflow-x: auto;
}

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

.stats-table th,
.stats-table td {
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  padding: 0.45rem 0.35rem;
}

.stats-table th {
  color: var(--color-text-muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Status badges (Telegram + Operations) ─────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-running  { background: rgba(80, 227, 194, 0.16); color: #35c9a6; border-color: rgba(80, 227, 194, 0.35); }
.badge-disabled { background: rgba(255, 255, 255, 0.06); color: var(--color-text-muted); border-color: var(--color-border); }
.badge-warn     { background: rgba(255, 179, 71, 0.16); color: #e8973a; border-color: rgba(255, 179, 71, 0.35); }
.badge-error    { background: rgba(255, 92, 92, 0.14); color: #ef5f5f; border-color: rgba(255, 92, 92, 0.35); }

/* ─── Operations section ────────────────────────────────────────────────── */
.obs-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.obs-filters { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.obs-filters select {
  background: var(--color-surface2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  font-family: inherit;
}

.obs-autorefresh {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.obs-card-hint { margin-top: 0.2rem; font-size: 0.72rem; color: var(--color-text-muted); }
.obs-muted { color: var(--color-text-muted); font-size: 0.78rem; }
.obs-error-text { color: #ef5f5f; word-break: break-word; }
.obs-empty { color: var(--color-text-muted); font-size: 0.85rem; padding: 0.5rem 0.2rem; }
.obs-note { color: var(--color-text-muted); font-size: 0.76rem; margin-bottom: 0.4rem; }
.obs-subhead { margin: 0.9rem 0 0.4rem; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); }
.obs-link { color: var(--color-accent); text-decoration: none; font-size: 0.8rem; }
.obs-link:hover { text-decoration: underline; }

.obs-webhook {
  margin-top: 0.6rem;
  display: grid;
  gap: 0.25rem;
  font-size: 0.82rem;
  border: 1px dashed var(--color-border);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
}
.obs-webhook .obs-muted { display: inline-block; min-width: 9rem; }

/* ─── Media library section ─────────────────────────────────────────────── */

/* Inline select control in section-header */
.select-inline {
  background: var(--color-surface2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
}
.select-inline:focus { outline: 2px solid var(--color-accent); }

/* Table wrapper */
.medias-table-wrap {
  overflow-x: auto;
}

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

.medias-table th,
.medias-table td {
  padding: 0.55rem 0.7rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.medias-table th {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  background: var(--color-surface);
  white-space: nowrap;
}

.medias-table tr:hover td { background: rgba(255,255,255,0.03); }

.col-preview  { width: 72px; }
.col-type     { width: 80px; }
.col-date     { white-space: nowrap; }
.col-conv,
.col-msg      { font-family: ui-monospace, Menlo, Monaco, Consolas, monospace; font-size: 0.78rem; color: var(--color-text-muted); }
.col-url      { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-actions  { width: 80px; text-align: right; }

/* Thumbnail in table */
.media-thumb-sm {
  display: block;
  width: 60px;
  height: 48px;
  object-fit: cover;
  border-radius: 5px;
  cursor: zoom-in;
  border: 1px solid var(--color-border);
  background: var(--color-surface2);
}

/* Audio/Video preview button */
.media-preview-btn {
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text);
  font-size: 0.78rem;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  white-space: nowrap;
}
.media-preview-btn:hover { background: var(--color-surface); }

/* Type badges with colour accents */
.media-type-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  padding: 0.15rem 0.55rem;
  white-space: nowrap;
}
.media-type-image { background: rgba(56,139,253,0.15); color: #58a6ff; border-color: rgba(56,139,253,0.4); }
.media-type-video { background: rgba(188,100,255,0.15); color: #c084fc; border-color: rgba(188,100,255,0.4); }
.media-type-audio { background: rgba(63,213,136,0.15); color: #3fd588; border-color: rgba(63,213,136,0.4); }

/* ─── Pagination ──────────────────────────────────────────────────────────── */
.medias-pagination { min-height: 2rem; margin: 0.5rem 0; }

.pagination-bar {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.pagination-info {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin-left: 0.5rem;
}

.pagination-ellipsis {
  color: var(--color-text-muted);
  padding: 0 0.2rem;
  font-size: 0.88rem;
}

/* ─── Lightbox dialog ────────────────────────────────────────────────────── */
.media-lightbox {
  border: none;
  border-radius: 12px;
  background: var(--color-surface);
  color: var(--color-text);
  padding: 1.25rem;
  max-width: min(90vw, 1000px);
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}

.media-lightbox::backdrop {
  background: rgba(0,0,0,0.75);
}

.media-lightbox-close {
  position: absolute;
  top: 0.6rem;
  right: 0.8rem;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--color-text-muted);
  line-height: 1;
}
.media-lightbox-close:hover { color: var(--color-text); }

.media-lightbox-body {
  display: flex;
  justify-content: center;
  align-items: center;
}

.lightbox-img {
  max-width: 100%;
  max-height: 75vh;
  border-radius: 8px;
  display: block;
}

.lightbox-video {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
  display: block;
}

.lightbox-audio {
  width: min(100%, 480px);
  margin: 1.5rem auto;
  display: block;
}

.media-lightbox-caption {
  margin-top: 0.75rem;
  font-size: 0.82rem;
  color: var(--color-text-muted);
  word-break: break-all;
  max-height: 4rem;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ─── Toast (admin variant: supports success) ────────────────────────────── */
#toast.error   { background: rgba(233,69,96,0.92); }
#toast.success { background: rgba(39,174,96,0.92); }

/* ─── Header logo admin badge ───────────────────────────────────────────── */
.admin-badge {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  padding: 1px 5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  align-self: center;
  margin-left: 0.1rem;
}

/* ─── Header admin link ─────────────────────────────────────────────────── */
#header .chat-link {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 4px 10px;
  transition: color 0.2s, border-color 0.2s;
}
#header .chat-link:hover { color: var(--color-text); border-color: var(--color-text-muted); }

/* ─── Responsive ────────────────────────────────────────────────────────── */

/* ─── Admin login modal ───────────────────────────────────────────────────── */
#admin-login-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

#admin-login-modal.modal-active {
  display: flex;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-bg);
}

.modal-content {
  position: relative;
  z-index: 1;
  background: var(--color-surface);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  border: 1px solid var(--color-border);
}

.modal-content h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.5rem;
}

.modal-content p {
  margin: 0 0 1.5rem 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

#admin-login-form .form-group {
  margin-bottom: 1rem;
}

#admin-login-form label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 500;
  font-size: 0.9rem;
}

#admin-login-form input[type="password"] {
  width: 100%;
  padding: 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 1rem;
  font-family: inherit;
}

#admin-login-form input[type="password"]:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.form-error {
  background: rgba(233, 69, 96, 0.15);
  color: #e94560;
  padding: 0.8rem;
  border-radius: 4px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}
/* ─── Prompt editor blocks ──────────────────────────────────────────────── */

.prompt-block {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  background: var(--color-surface);
}

.prompt-block-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

.prompt-block-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.prompt-block-title {
  font-size: 0.95rem;
}

.prompt-block-desc {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin: 0 0 0.6rem;
}

.prompt-block-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.prompt-textarea {
  width: 100%;
  box-sizing: border-box;
  font-family: monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg);
  color: var(--color-text);
  resize: vertical;
}

.prompt-textarea:focus {
  outline: none;
  border-color: var(--color-accent);
}

.prompt-feedback {
  font-size: 0.82rem;
  margin-top: 0.3rem;
  min-height: 1.2em;
}

.prompt-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 10px;
  background: var(--color-border);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.prompt-badge-custom {
  background: var(--color-accent, #6c8ebf);
  color: #fff;
}

@media (max-width: 640px) {
  #admin-nav { width: 120px; }
  #admin-content { padding: 1rem; }
  .dialog { max-width: 100%; }
  .col-conv, .col-msg, .col-url { display: none; }
  .prompt-block-header { flex-direction: column; }
}
