/* =========================================================
   Tokens
   ========================================================= */
:root {
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --sidebar-w: 264px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

:root,
[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0b0c0f;
  --bg-sidebar: #0f1114;
  --surface: #131519;
  --surface-2: #191c21;
  --surface-3: #21252b;
  --input: #0f1114;
  --border: #23272e;
  --border-strong: #30353d;
  --text: #eceef2;
  --text-2: #a4aab5;
  --text-3: #6c7380;
  --accent: #6d6ffb;
  --accent-hover: #5d5ff0;
  --accent-text: #a5a6ff;
  --accent-soft: rgba(109, 111, 251, 0.14);
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.12);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
}

[data-theme='light'] {
  color-scheme: light;
  --bg: #f5f6f8;
  --bg-sidebar: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f5f7;
  --surface-3: #eaecf0;
  --input: #ffffff;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101318;
  --text-2: #4d5562;
  --text-3: #8a919c;
  --accent: #5b5df0;
  --accent-hover: #4b4de0;
  --accent-text: #4b4de0;
  --accent-soft: rgba(91, 93, 240, 0.1);
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.1);
  --shadow: 0 1px 2px rgba(16, 19, 24, 0.05), 0 4px 16px rgba(16, 19, 24, 0.05);
  --shadow-lg: 0 12px 40px rgba(16, 19, 24, 0.14);
}

/* =========================================================
   Base
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; font-feature-settings: 'cv11', 'ss01';
}
.hidden { display: none !important; }
[hidden] { display: none !important; }
a { color: var(--accent-text); }
code { font-family: var(--mono); font-size: 12px; background: var(--surface-3); padding: 1px 6px; border-radius: 4px; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
::selection { background: var(--accent-soft); }

.icon { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
.icon-xs { width: 14px; height: 14px; }

/* Scrollbars discretas */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* =========================================================
   Botones
   ========================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: 500 14px var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:disabled { opacity: .55; cursor: progress; }
.btn:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-sm);
  border: 0; background: transparent; color: var(--text-2); cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn-danger:hover { background: var(--danger-soft); color: var(--danger); }

/* =========================================================
   Login
   ========================================================= */
.login { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(420px, 1fr); min-height: 100vh; }

/* Lado de presentación: siempre oscuro, con la marca */
.login-hero {
  position: relative; overflow: hidden; display: flex; align-items: center; padding: 56px clamp(32px, 6vw, 88px);
  background: #08080f; color: #eceef2; isolation: isolate;
}
.login-bg { position: absolute; inset: 0; z-index: -1; }
.blob { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .55; animation: drift 18s ease-in-out infinite alternate; }
.b1 { width: 520px; height: 520px; left: -140px; top: -160px; background: #5b5df0; }
.b2 { width: 420px; height: 420px; right: -120px; top: 30%; background: #a855f7; animation-delay: -6s; }
.b3 { width: 380px; height: 380px; left: 25%; bottom: -200px; background: #0ea5e9; opacity: .35; animation-delay: -12s; }
@keyframes drift { to { transform: translate(40px, 30px) scale(1.08); } }
.login-grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 40% 40%, #000 30%, transparent 75%);
}
.hero-content { max-width: 580px; display: flex; flex-direction: column; gap: 28px; }
.hero-brand { display: flex; align-items: center; gap: 12px; font-weight: 600; color: #c9cbd4; }
.hero-logo {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #6d6ffb, #a855f7); box-shadow: 0 8px 24px rgba(109, 111, 251, .45);
}
.login-hero h1 { font-size: clamp(32px, 3.6vw, 48px); line-height: 1.08; font-weight: 700; letter-spacing: -0.03em; }
.grad { background: linear-gradient(90deg, #a5a6ff, #e879f9 60%, #67e8f9); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-lead { margin: -8px 0 0; font-size: 16px; line-height: 1.6; color: #a4aab5; max-width: 500px; }

.hero-mock { position: relative; height: 230px; }
.mock-card {
  position: absolute; padding: 12px 14px; border-radius: 12px; font-size: 13px;
  background: rgba(30, 31, 40, .78); border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .45); backdrop-filter: blur(12px); animation: float 7s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-8px); } }
.mock-embed { left: 0; top: 0; width: 330px; }
.mock-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.mock-head small { color: #80848e; font-size: 11px; }
.mock-avatar { width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(135deg, #6d6ffb, #a855f7); }
.mock-tag { background: #5865f2; color: #fff; font-size: 9px; font-weight: 700; padding: 1px 4px; border-radius: 3px; }
.mock-embed-body { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; border-left: 4px solid #57f287; border-radius: 4px; background: #2b2d31; color: #dbdee1; }
.mock-mention { font-style: normal; background: rgba(88, 101, 242, .3); color: #c9cdfb; border-radius: 3px; padding: 0 2px; }
.mock-blocks { right: 0; top: 34px; width: 220px; display: flex; flex-direction: column; gap: 6px; animation-delay: -2.5s; }
.mock-block {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; font-weight: 500;
  background: rgba(255, 255, 255, .04); border-left: 3px solid var(--c);
}
.mock-block .icon { color: var(--c); }
.mock-block code { background: rgba(255, 255, 255, .08); color: #eceef2; }
.mock-blocks .mock-block:nth-child(n + 2) { margin-left: 14px; }
.mock-tickets { left: 70px; bottom: 0; animation-delay: -4.5s; }
.mock-tickets small { color: #a4aab5; }
.mock-buttons { display: flex; gap: 6px; margin-top: 8px; }
.mock-btn { padding: 5px 10px; border-radius: 6px; background: #5865f2; color: #fff; font-weight: 500; font-size: 12px; }
.mock-btn.red { background: #da373c; }
.mock-btn.green { background: #248046; }

.hero-features { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.hero-features li { display: flex; flex-direction: column; gap: 10px; }
.hero-features .icon {
  width: 34px; height: 34px; padding: 8px; border-radius: 10px; color: #a5a6ff;
  background: rgba(109, 111, 251, .14); border: 1px solid rgba(109, 111, 251, .25);
}
.hero-features span { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: #a4aab5; line-height: 1.45; }
.hero-features b { color: #eceef2; font-weight: 600; font-size: 14px; }

/* Lado del formulario: sigue el tema */
.login-side { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; background: var(--bg); }
.login-card { width: 100%; max-width: 400px; }
.login-bot {
  display: flex; align-items: center; gap: 12px; padding: 12px; margin-bottom: 32px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
}
.login-bot-avatar { position: relative; width: 44px; height: 44px; flex-shrink: 0; }
.login-bot-avatar img, .login-bot-fallback { width: 44px; height: 44px; border-radius: 50%; }
.login-bot-fallback { display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--accent), #a855f7); }
.login-bot-avatar .sdot { position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border: 3px solid var(--surface); box-sizing: content-box; }
.login-bot-avatar .s-invisible { background: var(--surface); }
.login-bot-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.login-bot-text b { font-weight: 600; }
.login-bot-text small { color: var(--text-3); font-size: 12.5px; }
.login-card h2 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.login-sub { color: var(--text-2); margin: 8px 0 28px; line-height: 1.55; }
.btn-discord { background: #5865f2; color: #fff; height: 48px; font-size: 15px; font-weight: 600; box-shadow: 0 8px 24px rgba(88, 101, 242, .35); }
.btn-discord:hover { background: #4752c4; }
.discord-logo { width: 22px; height: 22px; fill: currentColor; }
.login-error { color: var(--danger); margin: 12px 0 0; font-size: 13px; min-height: 1px; }
.login-error:empty { margin: 0; }
.login-trust {
  display: flex; align-items: flex-start; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border);
  color: var(--text-3); font-size: 12.5px; line-height: 1.5;
}
.login-trust .icon { color: var(--success); margin-top: 1px; }
.login-foot { position: absolute; top: 16px; right: 16px; }

@media (max-width: 1100px) {
  .hero-mock { display: none; }
  .hero-features { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-hero { padding: 40px 24px 36px; }
  .hero-features { display: none; }
  .hero-content { gap: 18px; }
  .login-side { padding: 60px 16px 48px; justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  .blob, .mock-card { animation: none; }
}

/* =========================================================
   Layout
   ========================================================= */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; }
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.content { flex: 1; overflow-y: auto; padding: 32px 40px 120px; }
.content > * { max-width: 1180px; margin-inline: auto; }
.scrim { display: none; }

/* Sidebar */
.sidebar {
  display: flex; flex-direction: column; gap: 4px; padding: 16px 12px 12px;
  background: var(--bg-sidebar); border-right: 1px solid var(--border); overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; }
.brand-avatar { width: 34px; height: 34px; border-radius: 10px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-text span { font-size: 12px; color: var(--text-3); }

.guild-switcher { position: relative; margin-bottom: 10px; }
.guild-current {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; text-align: left;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: var(--radius);
  font: inherit; cursor: pointer; transition: border-color .15s, background .15s;
}
.guild-current:hover, .guild-current[aria-expanded='true'] { border-color: var(--border-strong); background: var(--surface-3); }
.guild-current .icon { color: var(--text-3); }
.guild-current-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.25; }
.guild-current-text strong { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eyebrow { font-size: 11px; color: var(--text-3); }
.guild-menu {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; right: 0; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.guild-option {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text); font: 500 13px var(--font); text-align: left; cursor: pointer;
}
.guild-option:hover { background: var(--surface-3); }
.guild-option.active { background: var(--accent-soft); color: var(--accent-text); }
.guild-option span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.guild-option .icon { color: var(--accent-text); }
.guild-menu-invite {
  display: flex; align-items: center; gap: 10px; padding: 8px; margin-top: 4px; border-top: 1px solid var(--border);
  color: var(--text-2); font-size: 13px; text-decoration: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.guild-menu-invite:hover { color: var(--text); }
.guild-icon {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0; object-fit: cover;
}
.guild-icon-fallback {
  display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), #a855f7);
  color: #fff; font-weight: 600; font-size: 11px;
}

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-label {
  padding: 16px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-3);
}
.nav button {
  position: relative; display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-2);
  font: 500 13.5px var(--font); text-align: left; cursor: pointer; transition: background .12s, color .12s;
}
.nav button .icon { color: var(--text-3); transition: color .12s; }
.nav button:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.nav button:hover:not(:disabled) .icon { color: var(--text-2); }
.nav button.active { background: var(--accent-soft); color: var(--accent-text); }
.nav button.active .icon { color: var(--accent-text); }
.nav button:disabled { opacity: .4; cursor: not-allowed; }
.nav-dot { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: transparent; }
.nav-dot.on { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
/* La tarjeta de usuario siempre abajo; si hay zona de propietario, va justo encima de ella */
.nav-global { margin-top: auto; padding-top: 8px; }
.nav-global:not(.hidden) + .user-card { margin-top: 10px; }

.user-card {
  display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 10px;
  border-top: 1px solid var(--border);
}
.user-avatar { width: 32px; height: 32px; border-radius: 50%; }
.user-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.25; }
.user-text strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-text span { font-size: 12px; color: var(--text-3); }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 24px 0 40px; flex-shrink: 0;
  border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
}
.menu-btn { display: none; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 13px; min-width: 0; }
.crumbs span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs strong { color: var(--text); font-weight: 600; white-space: nowrap; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-2); font-size: 12px; font-weight: 500;
}
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
[data-theme='dark'] .theme-light, [data-theme='light'] .theme-dark { display: none; }

/* =========================================================
   Páginas, tarjetas y campos
   ========================================================= */
.page { display: flex; flex-direction: column; gap: 20px; animation: fade .2s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 4px; }
.page-head h1 { font-size: 22px; font-weight: 650; }
.page-head p { margin: 6px 0 0; color: var(--text-2); max-width: 680px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 15px; font-weight: 600; }
.card-head p { margin: 2px 0 0; color: var(--text-3); font-size: 13px; }
.card-body { padding: 20px 22px; }
.card-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 14px 22px;
  border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.card-foot .field-hint { margin-right: auto; }
.card > .card-body:only-child { padding: 22px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; align-items: start; }
.grid-cat { display: grid; grid-template-columns: 90px 1fr 170px; gap: 16px; }
.span-2 { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.field-label { font-size: 13px; font-weight: 500; color: var(--text); }
.field-hint { font-size: 12px; color: var(--text-3); margin: 0; }
.item-body > .field, .item-body > .grid-2, .item-body > .grid-cat { margin-bottom: 16px; }

input:not([type='checkbox']):not([type='color']):not([type='radio']), select, textarea {
  width: 100%; padding: 8px 11px; min-height: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--input); color: var(--text);
  font: 14px var(--font); transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.5; }
select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238a919c' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled, select:disabled { opacity: .6; }
input[type='checkbox'] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
input[type='color'] {
  width: 44px; height: 36px; padding: 3px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--input); cursor: pointer;
}

.option-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; transition: border-color .15s;
}
.option-row:hover { border-color: var(--border-strong); }
.option-row:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); background: var(--accent-soft); }
.option-row input { margin-top: 2px; }
.option-row span { display: flex; flex-direction: column; gap: 2px; }
.option-row b { font-weight: 500; }
.option-row small { color: var(--text-3); font-size: 12px; }
.grid-2 > .option-row { align-self: end; }

/* Interruptor de módulo (cabecera de página) */
.module-toggle {
  display: inline-flex; align-items: center; gap: 10px; flex-shrink: 0; cursor: pointer; padding: 6px 12px 6px 6px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
}
.module-toggle input { display: none; }
.track { position: relative; width: 36px; height: 20px; border-radius: 999px; background: var(--surface-3); transition: background .2s; }
.track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .2s var(--ease);
}
input:checked + .track { background: var(--success); }
input:checked + .track::after { transform: translateX(16px); }
.module-toggle-text::after { content: 'Desactivado'; font-size: 13px; font-weight: 500; color: var(--text-3); }
.module-toggle:has(input:checked) .module-toggle-text::after { content: 'Activado'; color: var(--success); }

/* Interruptor pequeño (dentro del editor) */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { display: none; }
.switch span {
  position: relative; width: 36px; height: 20px; border-radius: 999px; background: var(--surface-3); transition: background .2s;
}
.switch span::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .2s var(--ease);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }

.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap; border: 1px solid var(--border); color: var(--text-3);
}
.badge.ok { color: var(--success); background: var(--success-soft); border-color: transparent; }
.badge a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }

/* Roles */
.role-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.role-chip {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); font-size: 13px; font-weight: 500; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.role-chip::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--role-color); }
.role-chip input { display: none; }
.role-chip:hover { border-color: var(--border-strong); }
.role-chip:has(input:checked) {
  border-color: var(--role-color); background: color-mix(in srgb, var(--role-color) 16%, var(--surface));
}
.role-chip.disabled { opacity: .4; cursor: not-allowed; }

/* Listas desplegables (comandos, categorías) */
.item-list { display: flex; flex-direction: column; gap: 10px; }
.list-empty {
  padding: 28px; text-align: center; color: var(--text-3); border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.item-list:not(:empty) + .list-empty { display: none; }
.item { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); transition: border-color .15s; }
.item[open] { border-color: var(--border-strong); background: var(--surface); }
.item > summary {
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; cursor: pointer; list-style: none;
}
.item > summary::-webkit-details-marker { display: none; }
.item-chevron { display: grid; color: var(--text-3); transition: transform .2s var(--ease); }
.item[open] .item-chevron { transform: rotate(90deg); }
.cmd-title { font-weight: 600; }
.item-meta { flex: 1; color: var(--text-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-body { padding: 6px 18px 18px; border-top: 1px solid var(--border); padding-top: 18px; }

/* =========================================================
   Resumen
   ========================================================= */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat { padding: 18px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--text-3); font-size: 13px; font-weight: 500; }
.stat-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }
.stat-value { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; margin-top: 10px; font-variant-numeric: tabular-nums; }
.modules { display: grid; grid-template-columns: repeat(3, 1fr); }
.module {
  display: flex; align-items: center; gap: 14px; padding: 18px 22px; border: 0; background: transparent; text-align: left;
  font: inherit; color: var(--text); cursor: pointer; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border);
  transition: background .15s;
}
.module:nth-child(3n) { border-right: 0; }
.module:nth-last-child(-n + 3) { border-bottom: 0; }
.module:hover { background: var(--surface-2); }
.module-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex-shrink: 0; }
.module.on .module-icon { background: var(--accent-soft); color: var(--accent-text); }
.module-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.module-text b { font-weight: 600; }
.module-text small { color: var(--text-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.module-state { font-size: 12px; font-weight: 500; color: var(--text-3); display: inline-flex; align-items: center; gap: 6px; }
.module-state::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.module.on .module-state { color: var(--success); }
.module.on .module-state::before { background: var(--success); }

.empty { text-align: center; padding: 80px 20px; }
.empty-icon { width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.empty-icon .icon { width: 26px; height: 26px; }
.empty h2 { font-size: 18px; }
.empty p { color: var(--text-2); margin: 8px 0 20px; }

/* =========================================================
   Barra de cambios sin guardar y toasts
   ========================================================= */
.savebar {
  position: fixed; z-index: 40; bottom: 20px; left: calc(var(--sidebar-w) + 40px); right: 40px; max-width: 760px; margin-inline: auto;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 10px 10px 18px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  animation: rise .25s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
.savebar-text { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.savebar-text .icon { color: var(--warn); }
.savebar-actions { display: flex; gap: 8px; }
.savebar.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.toasts { position: fixed; z-index: 50; top: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: flex-start; gap: 10px; max-width: 380px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 13px;
  animation: slide .25s var(--ease);
}
.toast::before { content: ''; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.toast-error::before { background: var(--danger); }
.toast-warn::before { background: var(--warn); }
@keyframes slide { from { opacity: 0; transform: translateX(16px); } }

/* =========================================================
   Editor de mensajes
   ========================================================= */
.msg-editor label:not(.switch):not(.check):not(.role-chip) {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 13px; font-weight: 500; color: var(--text);
}
.msg-editor label.check, label.check { display: flex; flex-direction: row; align-items: center; gap: 8px; font-weight: 400; color: var(--text-2); }
.msg-editor .switch { margin-bottom: 14px; }
.me-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.me-embed { border-left: 2px solid var(--border-strong); padding-left: 16px; margin-bottom: 14px; }
.me-row { display: flex; gap: 12px; align-items: flex-end; }
.me-row .grow { flex: 1; }
.me-color { flex: 0 0 auto; }
.msg-editor details:not(.item) { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 12px; margin-bottom: 8px; background: var(--surface-2); }
.msg-editor details:not(.item)[open] { padding-bottom: 2px; }
.msg-editor details:not(.item) > summary { cursor: pointer; padding: 9px 0; font-size: 13px; font-weight: 500; color: var(--text-2); }
.msg-editor details:not(.item) > summary:hover { color: var(--text); }
.me-field { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.me-field .f-value { grid-column: 1 / -1; grid-row: 2; }
.me-field label.check { margin: 0; font-size: 12px; }
.me-field .btn { height: 30px; padding: 0 10px; }
.me-add-field { margin: 10px 0 10px; }
.me-vars .hint { font-size: 12px; color: var(--text-3); margin: 0 0 8px; }
.me-var-group { width: 100%; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); margin: 10px 0 2px; }
.me-var-list { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 10px; }
.var-chip {
  font: 12px var(--mono); padding: 3px 8px; border-radius: 5px; cursor: pointer;
  background: var(--accent-soft); color: var(--accent-text); border: 1px solid transparent; transition: border-color .15s, background .15s;
}
.var-chip:hover { border-color: var(--accent); }
.me-preview-col { position: sticky; top: 0; }
.me-preview-label { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; }
.me-preview-label .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.me-preview {
  background: #313338; color: #dbdee1; border-radius: var(--radius); padding: 16px; min-height: 90px;
  border: 1px solid var(--border); font-size: 15px;
}
.me-preview .muted { color: #949ba4; }
.error-text { color: var(--danger); }
.small { font-size: 12px; }
.muted { color: var(--text-3); }

/* Vista previa estilo Discord (siempre en tema oscuro de Discord) */
.dc-msg { display: flex; gap: 14px; }
.dc-avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.dc-body { min-width: 0; flex: 1; }
.dc-head { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.dc-name { font-weight: 600; color: #f2f3f5; }
.dc-bot { background: #5865f2; color: #fff; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 3px; }
.dc-time { font-size: 12px; color: #949ba4; }
.dc-content, .dc-desc { line-height: 1.375; overflow-wrap: anywhere; }
.dc-embed {
  display: flex; gap: 16px; margin-top: 6px; max-width: 520px; background: #2b2d31;
  border-left: 4px solid; border-radius: 4px; padding: 10px 16px 14px 12px;
}
.dc-embed-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.dc-author { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: #f2f3f5; }
.dc-author-icon { width: 24px; height: 24px; border-radius: 50%; }
.dc-title { font-weight: 700; font-size: 16px; color: #f2f3f5; }
.dc-embed a { color: #00a8fc; text-decoration: none; }
.dc-embed a:hover { text-decoration: underline; }
.dc-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dc-field { grid-column: 1 / -1; font-size: 14px; }
.dc-field.inline { grid-column: auto; }
.dc-field-name { font-weight: 600; margin-bottom: 2px; color: #f2f3f5; }
.dc-image { max-width: 100%; border-radius: 4px; margin-top: 4px; }
.dc-thumb { width: 80px; height: 80px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.dc-footer { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #b5bac1; }
.dc-footer-icon { width: 20px; height: 20px; border-radius: 50%; }
.dc-preview code, .me-preview code { background: #2b2d31; color: #dbdee1; }
.mention { background: rgba(88, 101, 242, .3); color: #c9cdfb; border-radius: 3px; padding: 0 2px; font-weight: 500; }
.spoiler { background: #1e1f22; color: transparent; border-radius: 3px; }
.spoiler:hover { color: inherit; }
.quote { display: block; border-left: 4px solid #4e5058; padding-left: 10px; }
.me-preview .h1, .me-preview .h2, .me-preview .h3 { display: block; font-weight: 700; margin: 4px 0; color: #f2f3f5; }
.me-preview .h1 { font-size: 22px; } .me-preview .h2 { font-size: 19px; } .me-preview .h3 { font-size: 16px; }
.subtext { font-size: 12px; color: #949ba4; }
.dc-body pre { background: #2b2d31; border: 1px solid #1e1f22; padding: 8px; border-radius: 4px; white-space: pre-wrap; margin: 4px 0; font-family: var(--mono); font-size: 13px; }
.dc-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.dc-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 0 16px; height: 32px; border-radius: 8px;
  font-size: 14px; font-weight: 500; color: #fff; background: #5865f2;
}
.dc-btn-Secondary { background: #4e5058; }
.dc-btn-Success { background: #248046; }
.dc-btn-Danger { background: #da373c; }
.dc-emoji { font-size: 16px; line-height: 1; }
img.dc-emoji { width: 18px; height: 18px; }
.dc-select {
  display: flex; justify-content: space-between; max-width: 400px; margin-top: 8px; padding: 10px 12px;
  background: #1e1f22; border-radius: 4px; color: #949ba4; font-size: 14px;
}
.dc-select-options { max-width: 400px; background: #2b2d31; border: 1px solid #1e1f22; border-radius: 0 0 4px 4px; }
.dc-option { display: flex; gap: 10px; align-items: center; padding: 8px 12px; font-size: 14px; }
.dc-option + .dc-option { border-top: 1px solid #1e1f22; }
.dc-option-desc { font-size: 12px; color: #949ba4; }
.dc-note { margin-top: 8px; font-size: 13px; color: #f0b232; }
.dc-file {
  display: flex; align-items: center; gap: 10px; max-width: 400px; margin-top: 8px; padding: 12px;
  background: #2b2d31; border: 1px solid #1e1f22; border-radius: 8px;
}
.dc-file-icon { font-size: 26px; }
.dc-file-name { color: #00a8fc; font-size: 14px; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1200px) {
  .me-grid { grid-template-columns: 1fr; }
  .me-preview-col { position: static; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .modules { grid-template-columns: repeat(2, 1fr); }
  .module:nth-child(3n) { border-right: 1px solid var(--border); }
  .module:nth-child(2n) { border-right: 0; }
  .module:nth-last-child(-n + 3) { border-bottom: 1px solid var(--border); }
  .module:nth-last-child(-n + 2) { border-bottom: 0; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 45; inset: 0 auto 0 0; width: min(var(--sidebar-w), 85vw);
    transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: var(--shadow-lg);
  }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 44; background: rgba(0, 0, 0, .5); }
  .menu-btn { display: inline-grid; margin-left: -6px; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px 120px; }
  .savebar { left: 16px; right: 16px; bottom: 16px; }
}

@media (max-width: 640px) {
  .grid-2, .grid-cat { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; gap: 14px; }
  .card-head { flex-wrap: wrap; padding: 16px; }
  .card-body, .card > .card-body:only-child { padding: 16px; }
  .stats { gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 22px; }
  .modules { grid-template-columns: 1fr; }
  .module, .module:nth-child(n) { border-right: 0 !important; border-bottom: 1px solid var(--border) !important; }
  .module:last-child { border-bottom: 0 !important; }
  .status-pill span { display: none; }
  .savebar { flex-direction: column; align-items: stretch; padding: 12px; }
  .savebar-actions .btn { flex: 1; }
  .me-row { flex-wrap: wrap; }
  .crumbs span, .crumbs .icon { display: none; }
}

/* =========================================================
   Comandos: creador por bloques
   ========================================================= */
.c-blue { --c: #3b82f6; }
.c-green { --c: #22c55e; }
.c-red { --c: #ef4444; }
.c-yellow { --c: #eab308; }
.c-orange { --c: #f97316; }
.c-gray { --c: #8b93a1; }
.c-purple { --c: #a855f7; }

.cmd-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 560px; overflow: hidden; }
.cmd-side { border-right: 1px solid var(--border); background: var(--surface-2); display: flex; flex-direction: column; }
.cmd-side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 10px; }
.cmd-list { display: flex; flex-direction: column; gap: 2px; padding: 0 8px 12px; overflow-y: auto; }
.cmd-list-item {
  position: relative; display: grid; grid-template-columns: 1fr auto; gap: 0 8px; padding: 9px 10px; border: 0;
  border-radius: var(--radius-sm); background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.cmd-list-item:hover { background: var(--surface-3); }
.cmd-list-item.active { background: var(--accent-soft); }
.cmd-list-item.active b { color: var(--accent-text); }
.cmd-list-item b { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmd-list-item small { grid-column: 1; font: 12px var(--mono); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmd-list-item.off b { color: var(--text-3); }
.cmd-count {
  grid-column: 2; grid-row: 1 / span 2; align-self: center; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-3); font-size: 11px; font-weight: 600; display: grid; place-items: center;
}
.cmd-main { min-width: 0; }
.cmd-start { text-align: center; padding: 56px 24px; }
.cmd-start h2 { font-size: 18px; }
.cmd-start > p { color: var(--text-2); margin: 6px 0 24px; }
.templates { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; max-width: 720px; margin: 0 auto; text-align: left; }
.template {
  display: flex; flex-direction: column; gap: 4px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); color: var(--text); font: inherit; cursor: pointer; transition: border-color .15s, transform .15s;
}
.template:hover { border-color: var(--accent); transform: translateY(-1px); }
.template-icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); margin-bottom: 6px; }
.template small { color: var(--text-3); font-size: 12px; }

.cb { padding: 20px 22px 24px; }
.cb-head { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.cb-name {
  flex: 1; min-width: 0; font-size: 18px !important; font-weight: 650; border-color: transparent !important; background: transparent !important;
  padding-left: 6px !important; margin-left: -6px;
}
.cb-name:hover { border-color: var(--border) !important; }
.cb-name:focus { border-color: var(--accent) !important; }
.cb-settings { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.cb-cooldown { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; }
.cb-cooldown input { width: 72px !important; min-height: 32px !important; padding: 4px 8px !important; }
.cb-settings .module-toggle { padding: 4px 10px 4px 4px; }

/* Cuerpo del creador: bloques a la izquierda, paleta a la derecha */
.cb-body { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 20px; align-items: start; }
.cb-palette {
  position: sticky; top: 0; display: flex; flex-direction: column; max-height: calc(100vh - 140px);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); overflow: hidden;
}
.cb-palette-search { margin: 10px 10px 6px; width: calc(100% - 20px) !important; }
.cb-palette-target { padding: 0 12px 8px; font-size: 11.5px; color: var(--text-3); border-bottom: 1px solid var(--border); }
.cb-palette-target b { color: var(--accent-text); font-weight: 600; }
.cb-palette-list { overflow-y: auto; padding: 4px 6px 10px; overscroll-behavior: contain; }
.cb-palette-group {
  position: sticky; top: -4px; z-index: 1; padding: 10px 6px 4px; background: var(--surface-2);
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3);
}
.cb-palette-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 6px; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--text); font: inherit; text-align: left; cursor: grab;
}
.cb-palette-item:hover { background: var(--surface); border-color: color-mix(in srgb, var(--c) 45%, transparent); }
.cb-palette-item:active { cursor: grabbing; }
.cb-palette-item .cb-menu-text small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cb-list.is-active { box-shadow: inset 2px 0 0 var(--accent); padding-left: 8px; }
.cb-branch-root > .cb-list.is-active { box-shadow: none; padding-left: 0; }

.cb-flow { display: flex; flex-direction: column; }
.cb-block {
  position: relative; border: 1px solid var(--border); border-left: 4px solid var(--c); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
.cb-block.dragging { opacity: .35; }
.cb-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; }
.cb-trigger { background: color-mix(in srgb, var(--c) 8%, var(--surface)); }
.cb-trigger .cb-row { padding: 14px; }
.cb-hint { padding: 0 14px 12px; font-size: 12px; color: var(--text-3); }
.cb-badge {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 6px;
  background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--text); font-weight: 600; font-size: 13px; white-space: nowrap;
}
.cb-badge .icon { color: var(--c); }
.cb-word { color: var(--text-2); font-size: 13px; }
.cb-desc { color: var(--text-3); font-size: 13px; }
.cb-select, .cb-input { width: auto !important; min-height: 30px !important; padding: 4px 10px !important; font-size: 13px !important; }
.cb-select { padding-right: 30px !important; max-width: 260px; }
.cb-input { min-width: 140px; }
.cb-grow { flex: 1; min-width: 160px; }
.cb-num { width: 72px !important; min-width: 0; }
.cb-emoji { width: 90px !important; min-width: 0; }
.cb-inline { display: inline-flex; align-items: center; gap: 6px; }
.cb-trigger-field { display: flex; align-items: center; flex: 1; min-width: 200px; }
.cb-prefix {
  height: 30px; padding: 0 10px; display: grid; place-items: center; font: 600 13px var(--mono);
  border: 1px solid var(--border-strong); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: var(--surface-3);
}
.cb-prefix:not([hidden]) + .cb-input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important; }
.cb-trigger-field .cb-input { flex: 1; font-family: var(--mono) !important; }
.cb-grip { display: grid; place-items: center; width: 20px; color: var(--text-3); cursor: grab; margin-left: -4px; }
.cb-grip:active { cursor: grabbing; }
.cb-tools { display: inline-flex; gap: 2px; margin-left: auto; opacity: .55; transition: opacity .15s; }
.cb-block:hover > .cb-row > .cb-tools, .cb-tools:focus-within { opacity: 1; }
.cb-tools .icon-btn { width: 28px; height: 28px; }
.cb-tools .icon-btn:disabled { opacity: .3; cursor: default; background: transparent; }

/* Conector vertical entre el disparador y los bloques */
.cb-branch-root { padding-left: 18px; position: relative; }
.cb-branch-root::before { content: ''; position: absolute; left: 18px; top: 0; height: 14px; border-left: 2px solid var(--border-strong); }
.cb-list { display: flex; flex-direction: column; gap: 10px; padding: 14px 0 10px; min-height: 52px; border-radius: var(--radius); transition: background .15s; }
.cb-list.drop-target { background: var(--accent-soft); }
.cb-drop { height: 3px; border-radius: 2px; background: var(--accent); margin: -6px 0; box-shadow: 0 0 0 3px var(--accent-soft); }
.cb-empty {
  padding: 14px; text-align: center; font-size: 12.5px; color: var(--text-3);
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.cb-add {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; height: 30px; padding: 0 12px;
  border: 1px dashed var(--border-strong); border-radius: 999px; background: transparent; color: var(--text-2);
  font: 500 12.5px var(--font); cursor: pointer;
}
.cb-add:hover { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.cb-branch { display: flex; flex-direction: column; min-width: 0; }
.cb-block, .cb-list { min-width: 0; }

.cb-branches { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 0 12px 12px 26px; }
.cb-branches .cb-branch { border-left: 2px solid color-mix(in srgb, var(--c) 45%, transparent); padding-left: 14px; }
.cb-branch-label {
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--c); padding-top: 6px;
}
.cb-branches .cb-branch:last-child .cb-branch-label { color: var(--text-3); }
.cb-branches .cb-list { padding: 8px 0; }

.cb-message { margin: 0 12px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.cb-message > summary { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; list-style: none; }
.cb-message > summary::-webkit-details-marker { display: none; }
.cb-message-chevron { color: var(--text-3); transition: transform .2s var(--ease); }
.cb-message[open] .cb-message-chevron { transform: rotate(90deg); }
.cb-message-preview { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-message-preview.empty { color: var(--warn); }
.cb-message-body { padding: 12px; border-top: 1px solid var(--border); background: var(--surface); border-radius: 0 0 var(--radius-sm) var(--radius-sm); }

/* Menú flotante (añadir bloque / plantillas) */
.cb-menu {
  position: fixed; z-index: 60; width: 300px; max-height: 70vh; overflow-y: auto; padding: 6px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  animation: fade .15s var(--ease);
}
.cb-menu-group { padding: 8px 8px 4px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.cb-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.cb-menu-item:hover { background: var(--surface-3); }
.cb-menu-icon {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0;
  background: color-mix(in srgb, var(--c, var(--accent)) 15%, transparent); color: var(--c, var(--accent-text));
}
.cb-menu-text { display: flex; flex-direction: column; min-width: 0; }
.cb-menu-text b { font-weight: 500; font-size: 13px; }
.cb-menu-text small { color: var(--text-3); font-size: 12px; }

@media (max-width: 900px) {
  .cmd-shell { grid-template-columns: 1fr; }
  .cmd-side { border-right: 0; border-bottom: 1px solid var(--border); }
  .cmd-list { flex-direction: row; overflow-x: auto; padding-bottom: 10px; }
  .cmd-list-item { min-width: 170px; }
  .templates { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .cb { padding: 16px; }
  .cb-head { flex-direction: column; align-items: stretch; }
  .cb-settings { justify-content: space-between; }
  .cb-branch-root { padding-left: 0; }
  .cb-branch-root::before { display: none; }
  .cb-branches { padding-left: 12px; }
  .cb-palette { display: none; }
  .cb-tools { opacity: 1; }
  .templates { grid-template-columns: 1fr; }
  .cb-select { max-width: 100%; }
}

/* =========================================================
   Propietario
   ========================================================= */
.table-list { display: flex; flex-direction: column; }
.table-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 120px 140px auto; align-items: center; gap: 16px;
  padding: 12px 22px; border-top: 1px solid var(--border);
}
.table-row:first-child { border-top: 0; }
.table-row:hover { background: var(--surface-2); }
.table-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.table-main .guild-icon { width: 36px; height: 36px; border-radius: 10px; }
.table-main div { display: flex; flex-direction: column; min-width: 0; }
.table-main b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-main small { font: 11px var(--mono); color: var(--text-3); }
.table-cell { font-size: 13px; }
.table-actions { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; font-size: 13px; }
.kv span { color: var(--text-3); }
.kv b { font-weight: 500; font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }

.presence-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.presence-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.presence-preview { position: sticky; top: 0; }

.status-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.status-picker label { cursor: pointer; }
.status-picker input { position: absolute; opacity: 0; pointer-events: none; }
.status-picker span {
  display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface-2); font-weight: 500; transition: border-color .15s, background .15s;
}
.status-picker label:hover span { border-color: var(--border-strong); }
.status-picker input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.status-picker input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.sdot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.s-online { background: #23a55a; }
.s-idle { background: #f0b232; }
.s-dnd { background: #f23f43; }
.s-invisible { background: transparent; box-shadow: inset 0 0 0 3px #80848e; }

.activity-list { display: flex; flex-direction: column; gap: 8px; }
.activity-list:not(:empty) + .list-empty { display: none; }
.activity-row { display: grid; grid-template-columns: 200px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.activity-opts { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.input-suffix { display: flex; align-items: center; gap: 10px; }
.input-suffix input { width: 110px !important; }
.input-suffix span { color: var(--text-3); font-size: 13px; }

.member-preview {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--radius); background: #2b2d31; color: #f2f3f5;
}
.member-avatar { position: relative; flex-shrink: 0; }
.member-avatar img { width: 40px; height: 40px; border-radius: 50%; display: block; }
.member-avatar .sdot { position: absolute; right: -2px; bottom: -2px; width: 14px; height: 14px; border: 3px solid #2b2d31; box-sizing: content-box; }
.member-avatar .s-invisible { background: #2b2d31; box-shadow: inset 0 0 0 3px #80848e; }
.member-text { display: flex; flex-direction: column; min-width: 0; }
.member-text b { font-weight: 600; }
.member-text small { color: #b5bac1; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.presence-now { margin-top: 14px; }
.presence-now span { color: var(--text); }

.profile-body { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 32px; align-items: start; }
.profile-avatar { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.profile-avatar img {
  width: 128px; height: 128px; border-radius: 50%; object-fit: cover;
  border: 4px solid var(--surface-2); box-shadow: 0 0 0 1px var(--border);
}
.profile-fields { display: flex; flex-direction: column; gap: 20px; }

@media (max-width: 1100px) {
  .presence-layout { grid-template-columns: 1fr; }
  .presence-preview { position: static; }
}
@media (max-width: 760px) {
  .table-row { grid-template-columns: minmax(0, 1fr) auto; padding: 12px 16px; }
  .table-row .table-cell { display: none; }
  .status-picker { grid-template-columns: 1fr 1fr; }
  .activity-row { grid-template-columns: 1fr auto; }
  .activity-row select { grid-column: 1 / -1; }
  .profile-body { grid-template-columns: 1fr; }
}

/* Disparador de reacción */
.cb-row-sub { padding-top: 0; }
.cb-row-sub > .icon { color: var(--text-3); }
.cb-link-status { font-size: 12px; color: var(--success); white-space: nowrap; }
.cb-link-status.bad { color: var(--danger); }

/* =========================================================
   Tutorial guiado
   ========================================================= */
.tour { position: fixed; inset: 0; z-index: 80; }
.tour-blocker { position: absolute; inset: 0; }
.tour-spot {
  position: fixed; border-radius: 12px; pointer-events: none;
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 9999px rgba(5, 6, 10, .66);
  transition: top .35s var(--ease), left .35s var(--ease), width .35s var(--ease), height .35s var(--ease);
}
.tour.centered .tour-spot { box-shadow: 0 0 0 9999px rgba(5, 6, 10, .72); }
.tour-pop {
  position: fixed; width: min(360px, calc(100vw - 32px)); padding: 18px 18px 14px; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
  transition: top .35s var(--ease), left .35s var(--ease), opacity .2s;
}
.tour.moving .tour-pop { opacity: .4; }
.tour.centered .tour-pop { width: min(440px, calc(100vw - 32px)); padding: 26px 24px 18px; text-align: center; }
.tour.centered .tour-pop::before {
  content: ''; display: block; width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' fill='none' stroke='white' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m12 3-1.9 5.8a2 2 0 0 1-1.29 1.29L3 12l5.8 1.9a2 2 0 0 1 1.29 1.29L12 21l1.9-5.8a2 2 0 0 1 1.29-1.29L21 12l-5.8-1.9a2 2 0 0 1-1.29-1.29Z'/%3E%3C/svg%3E") center / 26px no-repeat, linear-gradient(135deg, var(--accent), #a855f7);
  box-shadow: 0 8px 24px rgba(109, 111, 251, .4);
}
.tour-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.tour.centered .tour-head { position: absolute; top: 12px; right: 12px; left: 16px; }
.tour-count { font-size: 12px; font-weight: 600; color: var(--accent-text); }
.tour-close { border: 0; background: transparent; color: var(--text-3); font-size: 14px; width: 26px; height: 26px; border-radius: 6px; cursor: pointer; }
.tour-close:hover { background: var(--surface-3); color: var(--text); }
.tour-title { font-size: 16px; font-weight: 650; margin: 0 0 6px; }
.tour.centered .tour-title { font-size: 20px; }
.tour-text { margin: 0 0 14px; color: var(--text-2); line-height: 1.55; font-size: 13.5px; }
.tour-bar { height: 3px; border-radius: 2px; background: var(--surface-3); overflow: hidden; margin-bottom: 12px; }
.tour-bar span { display: block; height: 100%; background: var(--accent); transition: width .35s var(--ease); }
.tour-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tour-foot-right { display: flex; gap: 8px; margin-left: auto; }

@media (prefers-reduced-motion: reduce) {
  .tour-spot, .tour-pop, .tour-bar span { transition: none; }
}

/* =========================================================
   Historial de cambios
   ========================================================= */
.audit-list { display: flex; flex-direction: column; padding: 6px 0; }
.audit-day {
  padding: 14px 22px 6px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3);
}
.audit-day:first-letter { text-transform: uppercase; }
.audit-item { display: flex; align-items: flex-start; gap: 12px; padding: 10px 22px; }
.audit-item:hover { background: var(--surface-2); }
.audit-avatar { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; }
.audit-text { flex: 1; min-width: 0; padding-top: 5px; line-height: 1.45; color: var(--text-2); overflow-wrap: anywhere; }
.audit-text b { color: var(--text); font-weight: 600; }
.audit-time { flex-shrink: 0; padding-top: 6px; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.audit-empty { padding: 24px 22px; text-align: center; color: var(--text-3); }
.audit-compact .audit-item { padding: 9px 22px; }
.audit-more { justify-content: center; }
@media (max-width: 640px) {
  .audit-item { flex-wrap: wrap; padding: 10px 16px; }
  .audit-time { padding-top: 0; margin-left: 42px; width: 100%; }
}

/* =========================================================
   Modo admin y herramientas de propietario
   ========================================================= */
.admin-toggle {
  display: flex; align-items: center; gap: 10px; margin: 2px 0 6px; padding: 8px 10px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
}
.admin-toggle input { display: none; }
.admin-toggle .track { flex-shrink: 0; }
.admin-toggle input:checked + .track { background: var(--warn); }
.admin-toggle-text { display: flex; flex-direction: column; line-height: 1.25; }
.admin-toggle-text b { font-size: 13px; font-weight: 600; }
.admin-toggle-text small { font-size: 11.5px; color: var(--text-3); }
.admin-toggle:has(input:checked) { border-color: color-mix(in srgb, var(--warn) 55%, transparent); background: var(--warn-soft); }

.admin-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--warn) 50%, transparent); background: var(--warn-soft); color: var(--warn);
  font: 600 12px var(--font);
}
.admin-pill:hover { background: color-mix(in srgb, var(--warn) 22%, transparent); }
body.admin-mode .topbar { box-shadow: inset 0 -2px 0 var(--warn); }
.admin-tag {
  font-style: normal; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 1px 5px; border-radius: 4px; color: var(--warn); background: var(--warn-soft); flex-shrink: 0;
}

.audit-guild {
  display: inline-block; margin-left: 8px; padding: 0 6px; border-radius: 4px; font-size: 11.5px;
  background: var(--surface-3); color: var(--text-2); vertical-align: 1px;
}

/* Consola */
.console-card { overflow: hidden; }
.console-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.console-toolbar .btn { margin-left: auto; }
.console-live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.console-live .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.segmented { display: inline-flex; padding: 3px; border-radius: 8px; background: var(--surface-3); }
.segmented button {
  border: 0; background: transparent; color: var(--text-2); font: 500 12.5px var(--font); padding: 5px 12px;
  border-radius: 6px; cursor: pointer;
}
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.console-out {
  height: min(60vh, 560px); overflow: auto; padding: 10px 0; background: #0a0b0e; color: #d6d9df;
  font: 12.5px/1.55 var(--mono);
}
.console-out .audit-empty { color: #80848e; }
.console-line { display: flex; gap: 14px; padding: 1px 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.console-line:hover { background: rgba(255, 255, 255, .03); }
.console-time { color: #6b7280; flex-shrink: 0; }
.lvl-warn { color: #fbbf24; background: rgba(245, 158, 11, .06); }
.lvl-error { color: #f87171; background: rgba(239, 68, 68, .08); }

/* Control */
.blacklist-grid { align-items: stretch; }
.blacklist-grid .card { display: flex; flex-direction: column; }
.blacklist-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-bottom: 14px; }
.blacklist-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.blacklist-list .audit-empty { padding: 18px; }
.blacklist-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; }
.blacklist-row + .blacklist-row { border-top: 1px solid var(--border); }
.blacklist-row div { display: flex; flex-direction: column; min-width: 0; }
.blacklist-row small { color: var(--text-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Pantalla de mantenimiento / sin acceso */
.status-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.status-card {
  width: 100%; max-width: 440px; padding: 36px 32px; text-align: center; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.status-icon { font-size: 44px; margin-bottom: 10px; }
.status-card h1 { font-size: 22px; }
.status-card p { color: var(--text-2); margin: 10px 0 24px; line-height: 1.55; }

@media (max-width: 760px) {
  .blacklist-form { grid-template-columns: 1fr; }
  .console-toolbar .btn { margin-left: 0; }
}

/* =========================================================
   Selector de variables
   ========================================================= */
.me-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.me-toolbar .hint { margin: 0; font-size: 12px; color: var(--text-3); }
.me-var-icon { font: 700 12px var(--mono); color: var(--accent-text); }

.vp {
  position: fixed; z-index: 90; display: flex; flex-direction: column; max-height: min(460px, 70vh);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  animation: fade .12s var(--ease); overflow: hidden;
}
.vp-head { position: relative; padding: 8px; border-bottom: 1px solid var(--border); }
.vp-search { padding-right: 44px !important; }
.vp-count {
  position: absolute; right: 18px; top: 50%; transform: translateY(-50%); font-size: 11px; font-weight: 600;
  color: var(--text-3); background: var(--surface-3); padding: 1px 7px; border-radius: 999px;
}
.vp-list { overflow-y: auto; padding: 4px 6px 6px; flex: 1; overscroll-behavior: contain; }
.vp-group {
  position: sticky; top: -4px; z-index: 1; padding: 8px 8px 4px; background: var(--surface);
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3);
}
.vp-item {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 7px 8px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.vp-item.active { background: var(--accent-soft); }
.vp-key { flex-shrink: 0; max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--surface-3); color: var(--accent-text); }
.vp-item.active .vp-key { background: transparent; }
.vp-text { display: flex; flex-direction: column; min-width: 0; font-size: 12.5px; line-height: 1.35; }
.vp-desc { color: var(--text-2); }
.vp-sample { color: var(--text-3); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vp-empty { padding: 20px; text-align: center; color: var(--text-3); font-size: 13px; }
.vp-foot { padding: 6px 12px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-3); }
@media (max-width: 640px) {
  .vp-item { flex-direction: column; gap: 2px; }
  .vp-key { max-width: 100%; }
  .vp-foot { display: none; }
}

/* Bloques interactivos (botones, menús, formularios) */
.c-teal { --c: #14b8a6; }
.c-pink { --c: #ec4899; }
.cb-items { display: flex; flex-direction: column; gap: 10px; padding: 0 12px 12px 26px; }
.cb-item { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.cb-item-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; }
.cb-item-title { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--c); min-width: 64px; }
.cb-item > .cb-branch { padding: 0 10px 10px 18px; border-left: 2px solid color-mix(in srgb, var(--c) 45%, transparent); margin-left: 12px; }
.cb-item > .cb-row-sub { padding: 0 10px 10px; }
.cb-items > .cb-hint { padding: 0; }
.cb-items > .cb-branch { margin-top: 4px; border-left: 2px solid color-mix(in srgb, var(--c) 45%, transparent); padding-left: 14px; }
.cb-field-id { width: 120px !important; min-width: 0; font-family: var(--mono) !important; }
.cb-field-var { font-size: 11.5px; }
.cb-num-text { width: 90px !important; min-width: 0; }
.cb-check { margin: 0; font-size: 12.5px; white-space: nowrap; }
.cb-menu-search { width: calc(100% - 8px) !important; margin: 4px 4px 6px; }
.cb-menu-list { display: flex; flex-direction: column; }
.cb-menu-item.active { background: var(--surface-3); }
.cb-menu-empty { padding: 16px; text-align: center; font-size: 12.5px; color: var(--text-3); }
.dc-btn-Link { background: #4e5058; }
.dc-btn-Link::after { content: '↗'; margin-left: 2px; opacity: .8; }

@media (max-width: 1280px) {
  .cb-body { grid-template-columns: 1fr; }
  .cb-palette { display: none; } /* en pantallas estrechas se usa «Añadir bloque», que también tiene buscador */
}
@media (max-width: 640px) {
  .cb-items { padding-left: 12px; }
  .cb-item > .cb-branch { margin-left: 4px; padding-left: 10px; }
}

/* =========================================================
   Diálogos y compartir comandos
   ========================================================= */
.dialog-backdrop {
  position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; padding: 16px;
  background: rgba(5, 6, 10, .6); animation: fade .15s var(--ease);
}
.dialog {
  width: min(480px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.dialog-wide { width: min(640px, 100%); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 10px; }
.dialog-head h2 { font-size: 17px; }
.dialog-body { padding: 4px 18px 16px; overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.share-lead { margin: 0 0 12px; color: var(--text-2); }
.share-sub { margin-top: 18px; }
.share-note { margin: 16px 0 0; font-size: 12.5px; color: var(--text-3); }
.code-box { display: flex; gap: 8px; align-items: stretch; }
.code-box > :first-child { flex: 1; }
.code-short {
  text-align: center; font: 700 26px var(--mono) !important; letter-spacing: .12em; height: 56px; color: var(--accent-text) !important;
}
.code-full { font: 11.5px/1.4 var(--mono) !important; resize: none; word-break: break-all; }
.code-box .btn { align-self: center; }

.import-input { font-family: var(--mono) !important; resize: vertical; }
.import-status { min-height: 18px; margin: 8px 0; font-size: 12.5px; color: var(--text-3); }
.import-status.bad { color: var(--danger); }
.import-card { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.import-card > b { font-size: 15px; }
.import-facts { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--text-3); align-items: center; }
.import-setup { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--warn-soft); font-size: 12.5px; }
.import-setup b { color: var(--warn); }
.import-setup ul { margin: 4px 0 0; padding-left: 18px; color: var(--text-2); }
.cmd-side-actions { display: inline-flex; align-items: center; gap: 4px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent-text); font: inherit; cursor: pointer; text-decoration: underline; }

/* ---------- Discord oficial ---------- */
.official-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, #5865f2 35%, var(--border));
  background: linear-gradient(135deg, color-mix(in srgb, #5865f2 16%, transparent), color-mix(in srgb, #5865f2 4%, transparent));
  color: var(--text); text-decoration: none; transition: border-color .12s, transform .12s;
}
.official-link[hidden] { display: none; }
.official-link:hover { border-color: #5865f2; transform: translateY(-1px); }
.official-link > .icon { color: var(--text-3); flex-shrink: 0; }
.official-link-icon {
  width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0; display: grid; place-items: center;
  background: #5865f2; color: #fff; overflow: hidden;
}
.official-link-icon img { width: 100%; height: 100%; object-fit: cover; }
.official-link-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.25; }
.official-link-text b { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.official-link-text small { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login-card .official-link { margin-top: 16px; }
/* En el menú lateral: abajo, entre la zona de propietario y la tarjeta de usuario */
.official-card { margin-top: auto; }
.nav-global:not(.hidden) + .official-card { margin-top: 10px; }
.official-card:not([hidden]) + .user-card,
.nav-global:not(.hidden) + .official-card[hidden] + .user-card { margin-top: 10px; }
.official-tag {
  font-style: normal; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 1px 6px; border-radius: 4px; color: #fff; background: #5865f2; flex-shrink: 0; vertical-align: 3px;
}
h1 .official-tag { font-size: 11px; margin-left: 6px; vertical-align: 5px; }
.nav-label .official-tag { margin-left: 4px; vertical-align: 0; font-size: 9px; }
.official-preview { max-width: 320px; }
.input-with-btn { display: flex; gap: 8px; align-items: center; }
.input-with-btn input { flex: 1; min-width: 0; }
.counter-list { display: flex; flex-direction: column; gap: 8px; }
.counter-row { display: grid; grid-template-columns: 220px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.counter-row .counter-now { grid-column: 2 / 3; font-size: 12px; color: var(--text-3); margin-top: -4px; }
.counter-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.counter-empty { color: var(--text-3); font-size: 13px; margin: 0; }
@media (max-width: 720px) {
  .counter-row { grid-template-columns: 1fr auto; }
  .counter-row select { grid-column: 1 / -1; }
  .counter-row .counter-now { grid-column: 1 / -1; }
}
.status-states { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 8px; }
.status-state { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.status-state-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.status-state-head .sdot { width: 10px; height: 10px; }
.color-field { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-3); cursor: pointer; }
.color-field input[type="color"] { width: 34px; height: 26px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; cursor: pointer; }
.status-autocolor { margin: 12px 0 18px; }
.preview-states, .join-tabs-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; font-size: 13px; color: var(--text-3); }
.join-tabs-row { justify-content: space-between; margin-bottom: 6px; }
.join-messages { border-top: 1px solid var(--border); }
.join-messages > .field-hint { display: block; margin-bottom: 12px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius); background: var(--surface-3); }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 7px; font: 500 12.5px var(--font); color: var(--text-2); cursor: pointer; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
@media (max-width: 720px) { .status-states { grid-template-columns: 1fr; } }
.table-search { position: relative; padding: 12px 22px; border-bottom: 1px solid var(--border); }
.table-search .icon { position: absolute; left: 34px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.table-search input { width: 100%; padding-left: 36px !important; }
.table-empty { padding: 24px 20px; text-align: center; color: var(--text-3); font-size: 13px; }
mark.hl { background: color-mix(in srgb, var(--accent) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
@media (max-width: 1180px) and (min-width: 761px) {
  .table-row { grid-template-columns: minmax(0, 1fr) 110px auto; }
  .table-row .table-cell.muted { display: none; }
}
