/* Cortex Servergenerator — dark glass UI */

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/assets/fonts/Inter-Regular.woff2') format('woff2');
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/assets/fonts/Inter-Medium.woff2') format('woff2');
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/assets/fonts/Inter-SemiBold.woff2') format('woff2');
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/assets/fonts/Inter-Bold.woff2') format('woff2');
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url('/assets/fonts/Inter-ExtraBold.woff2') format('woff2');
}

:root {
    --bg-base: #0e0e12;
    --bg-surface: #141419;
    --bg-surface-glass: rgba(20, 20, 25, 0.72);
    --bg-elevated: rgba(30, 30, 38, 0.9);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(0, 229, 255, 0.35);
    --text-main: #ffffff;
    --text-muted: #a3a6aa;
    --accent-cyan: #00e5ff;
    --accent-purple: #9d00ff;
    --accent-blue: #5865F2;
    --accent-red: #eb455f;
    --accent-green: #2ed573;
    --accent-yellow: #ffa502;
    --discord-channel: #949ba4;
    --discord-category: #949ba4;
    --font-primary: 'Inter', system-ui, sans-serif;
    --radius: 14px;
    --radius-sm: 10px;
    --header-h: 72px;
    --tabs-h: 0px;
}

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

html,
body {
    min-height: 100%;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-base);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

.muted {
    color: var(--text-muted);
}

.sm {
    font-size: 0.85rem;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.text-warn {
    color: var(--accent-yellow);
}

/* Ambient */
.ambient-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.ambient-sphere {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.35;
}

.sphere-cyan {
    top: -15%;
    left: 5%;
    width: 520px;
    height: 520px;
    background: radial-gradient(circle, var(--accent-cyan) 0%, transparent 70%);
}

.sphere-purple {
    bottom: -10%;
    right: -5%;
    width: 560px;
    height: 560px;
    background: radial-gradient(circle, var(--accent-purple) 0%, transparent 70%);
}

/* Header */
.glass-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(14, 14, 18, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #fff;
    font-weight: 800;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.logo-icon {
    color: var(--accent-cyan);
    text-shadow: 0 0 14px rgba(0, 229, 255, 0.45);
}

.header-title {
    flex: 1;
    min-width: 0;
}

.header-title h1 {
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-title h1 i {
    color: var(--accent-cyan);
}

.header-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.avatar-placeholder,
#userAvatar img,
#userAvatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(0, 229, 255, 0.12);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-cyan);
    overflow: hidden;
    object-fit: cover;
}

#userAvatar img {
    width: 100%;
    height: 100%;
    border: none;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 500;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Mobile tabs */
.mobile-tabs {
    display: none;
    position: sticky;
    top: var(--header-h);
    z-index: 90;
    background: rgba(14, 14, 18, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 6px 10px;
    gap: 6px;
    overflow-x: auto;
}

.mobile-tab {
    flex: 1;
    min-width: 72px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 10px 8px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.mobile-tab i {
    font-size: 0.95rem;
}

.mobile-tab.active {
    color: var(--accent-cyan);
    background: rgba(0, 229, 255, 0.08);
    border-color: rgba(0, 229, 255, 0.25);
}

/* Layout */
.app-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 20px 80px;
}

.panel {
    background: var(--bg-surface-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 18px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.panel-head {
    margin-bottom: 16px;
}

.panel-head-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    flex-wrap: wrap;
}

.panel-head h2 {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-head h2 i {
    color: var(--accent-cyan);
}

.empty-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 14px;
}

.guild-card {
    position: relative;
}

.guild-card-nobot {
    opacity: 0.72;
}

.guild-card-nobot:hover {
    opacity: 0.9;
}

.guild-badge {
    display: inline-block;
    margin-top: 6px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: uppercase;
}

.guild-badge-ok {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.35);
}

.guild-badge-warn {
    background: rgba(251, 191, 36, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.35);
}

.row-between {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.subhead {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 18px 0 10px;
    color: #e8e8ec;
}

.subhead.tight {
    margin-top: 0;
}

.glass-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px;
}

/* Buttons & inputs */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 16px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s, transform 0.1s;
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.25), rgba(88, 101, 242, 0.3));
    border-color: rgba(0, 229, 255, 0.4);
    color: #fff;
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.12);
}

.btn-primary:hover:not(:disabled) {
    border-color: var(--accent-cyan);
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.35), rgba(88, 101, 242, 0.4));
}

.btn-ghost {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    background: rgba(235, 69, 95, 0.12);
    border-color: rgba(235, 69, 95, 0.35);
    color: #ff8a9a;
}

.btn-secondary {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.18), rgba(6, 182, 212, 0.18));
    border-color: rgba(124, 58, 237, 0.4);
    color: #e0e7ff;
    box-shadow: 0 0 16px rgba(124, 58, 237, 0.12);
}

.btn-secondary:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.28), rgba(6, 182, 212, 0.28));
    border-color: rgba(124, 58, 237, 0.6);
    color: #fff;
}

.live-edit-cta {
    margin-top: 0.5rem;
    display: block;
}

.link-purple {
    color: #a78bfa;
    text-decoration: underline;
    cursor: pointer;
}

.link-purple:hover {
    color: #c4b5fd;
}

.btn-danger:hover:not(:disabled) {
    background: rgba(235, 69, 95, 0.22);
}

.btn-sm {
    padding: 7px 10px;
    font-size: 0.8rem;
}

.btn-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-group.wrap {
    flex-wrap: wrap;
    margin-top: 10px;
}

.input-dark {
    width: 100%;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: #fff;
    font-family: inherit;
    font-size: 0.9rem;
    padding: 10px 12px;
    outline: none;
    transition: border-color 0.15s;
}

.input-dark:focus {
    border-color: rgba(0, 229, 255, 0.45);
    box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.1);
}

.input-dark optgroup {
    background: #0d0e14;
    color: #00e5ff;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    padding: 8px 6px 4px 6px;
}

.input-dark option {
    background: #181924;
    color: #e2e8f0;
    padding: 6px 12px;
    font-weight: 400;
}

.input-dark optgroup option {
    background: #1a1c29;
    color: #f1f5f9;
    padding-left: 18px;
}

.textarea {
    resize: vertical;
    min-height: 96px;
}

.field-row {
    margin-bottom: 12px;
}

.field-row label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

/* Guild grid */
.section-guilds {
    margin-bottom: 20px;
}

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

.guild-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.25);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
    text-align: left;
    color: inherit;
    font-family: inherit;
    width: 100%;
}

.guild-card:hover {
    border-color: rgba(0, 229, 255, 0.4);
    background: rgba(0, 229, 255, 0.06);
    transform: translateY(-1px);
}

.guild-card.selected {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 1px rgba(0, 229, 255, 0.25);
}

.guild-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    object-fit: cover;
    background: rgba(88, 101, 242, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    font-size: 1rem;
}

.guild-card-name {
    font-weight: 600;
    font-size: 0.92rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.empty-guilds {
    margin-top: 12px;
}

.empty-card {
    text-align: center;
    padding: 36px 20px;
    max-width: 480px;
    margin: 0 auto;
}

.empty-icon {
    font-size: 2.5rem;
    color: var(--accent-blue);
    margin-bottom: 12px;
}

.empty-card h3 {
    margin-bottom: 8px;
}

.empty-card .btn {
    margin-top: 16px;
}

.loading-state {
    color: var(--text-muted);
    padding: 20px;
    text-align: center;
    grid-column: 1 / -1;
}

/* Guild bar */
.guild-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.guild-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.guild-icon-sm {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    object-fit: cover;
}

.guild-icon-fallback {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(88, 101, 242, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.guild-bar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.guild-bar-actions select {
    min-width: 200px;
}

/* Niche & packs */
.niche-grid,
.pack-grid,
.style-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.niche-card,
.pack-card,
.style-card {
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.28);
    border-radius: var(--radius-sm);
    padding: 12px;
    cursor: pointer;
    text-align: left;
    color: inherit;
    font-family: inherit;
    transition: border-color 0.15s, background 0.15s;
}

.niche-card:hover,
.pack-card:hover,
.style-card:hover {
    border-color: rgba(0, 229, 255, 0.35);
}

.niche-card.selected,
.pack-card.selected,
.style-card.selected {
    border-color: var(--accent-cyan);
    background: rgba(0, 229, 255, 0.08);
    box-shadow: 0 0 0 1px rgba(0, 229, 255, 0.2);
}

.niche-card i,
.pack-card i,
.style-card i {
    color: var(--accent-cyan);
    margin-bottom: 6px;
    display: block;
    font-size: 1.1rem;
}

.niche-card .label,
.pack-card .label,
.style-card .label {
    font-weight: 600;
    font-size: 0.9rem;
    display: block;
}

.niche-card .desc,
.pack-card .desc,
.style-card .desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}

.style-card .style-preview {
    display: block;
    margin-top: 6px;
    font-size: 0.72rem;
    color: var(--accent-cyan, #00e5ff);
    opacity: 0.9;
    line-height: 1.35;
    word-break: break-word;
}

.badge-soon {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent-yellow);
    background: rgba(255, 165, 2, 0.12);
    border: 1px solid rgba(255, 165, 2, 0.3);
    border-radius: 999px;
    padding: 2px 8px;
    vertical-align: middle;
    margin-left: 6px;
}

.badge-ai {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent-cyan);
    background: rgba(0, 229, 255, 0.12);
    border: 1px solid rgba(0, 229, 255, 0.35);
    border-radius: 999px;
    padding: 2px 8px;
    vertical-align: middle;
    margin-left: 6px;
}

.provider-toggle {
    display: flex;
    gap: 8px;
    margin: 8px 0 12px 0;
    flex-wrap: wrap;
}

.provider-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.provider-pill:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.provider-pill.selected {
    background: rgba(0, 229, 255, 0.12);
    border-color: rgba(0, 229, 255, 0.55);
    color: var(--accent-cyan);
}

.provider-pill[data-provider="gemini"].selected {
    background: rgba(255, 184, 0, 0.14);
    border-color: rgba(255, 184, 0, 0.55);
    color: #ffb800;
}

.provider-pill-meta {
    font-size: 0.7rem;
    font-weight: 500;
    opacity: 0.7;
    letter-spacing: 0.02em;
}

.ai-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.ai-note {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.usage-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: rgba(0, 229, 255, 0.06);
    border: 1px solid rgba(0, 229, 255, 0.18);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.usage-bar span {
    font-variant-numeric: tabular-nums;
}

/* Full-screen loading overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 8, 12, 0.72);
    backdrop-filter: blur(4px);
}

.loading-overlay.hidden {
    display: none;
}

.loading-card {
    text-align: center;
    padding: 28px 36px;
    max-width: 320px;
}

.loading-spin {
    font-size: 1.75rem;
    color: var(--accent-cyan);
    margin-bottom: 12px;
}

/* Consent / generic modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 3100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(8, 8, 12, 0.78);
    backdrop-filter: blur(6px);
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    width: min(560px, 100%);
    max-height: min(80vh, 640px);
    overflow: auto;
    padding: 22px 24px;
}

.modal-content h2 {
    font-size: 1.15rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.consent-body {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.55;
    white-space: pre-wrap;
    margin-bottom: 18px;
    max-height: 50vh;
    overflow: auto;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.refine-modal-hint {
    margin: 0 0 12px;
    line-height: 1.45;
}

.refine-modal-hint strong {
    color: var(--text-primary, #e8e8ec);
    font-weight: 600;
}

.field-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-muted, #a0a0ab);
}

.refine-modal-textarea {
    width: 100%;
    min-height: 140px;
    margin-bottom: 16px;
    resize: vertical;
}

/* Editor grid — 3 columns desktop */
.editor-grid {
    display: grid;
    grid-template-columns: 1.15fr 1fr 0.95fr;
    gap: 14px;
    margin-top: 14px;
    align-items: start;
}

.editor-col {
    min-height: 420px;
}

/* Channel tree (Discord-like) */
.channel-tree {
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px;
    max-height: 420px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.tree-cat {
    margin-top: 6px;
}

.tree-cat-head,
.tree-ch,
.tree-uncat-label {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--discord-channel);
    font-family: inherit;
    font-size: 0.88rem;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
}

.tree-cat-head {
    color: var(--discord-category);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-top: 4px;
}

.tree-cat-head:hover,
.tree-ch:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #dbdee1;
}

.tree-cat-head.selected,
.tree-ch.selected {
    background: rgba(88, 101, 242, 0.35);
    color: #fff;
}

.tree-ch {
    padding-left: 18px;
}

.tree-ch i {
    width: 16px;
    text-align: center;
    opacity: 0.85;
}

.tree-uncat-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    cursor: default;
    margin-top: 8px;
}

.tree-empty {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 16px;
    text-align: center;
}

/* Roles list */
.roles-list {
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px;
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.role-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: none;
    background: transparent;
    color: #fff;
    font-family: inherit;
    font-size: 0.9rem;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
}

.role-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.role-item.selected {
    background: rgba(0, 229, 255, 0.1);
    box-shadow: inset 0 0 0 1px rgba(0, 229, 255, 0.3);
}

.role-color-bar {
    width: 4px;
    height: 22px;
    border-radius: 2px;
    flex-shrink: 0;
}

.role-item .name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.role-item .meta {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Props / toggles */
.item-props {
    margin-top: 4px;
}

.color-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 8px;
    align-items: end;
}

.color-row label {
    grid-column: 1 / -1;
}

.color-row input[type="color"] {
    width: 44px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: transparent;
    padding: 2px;
    cursor: pointer;
}

.toggle-row,
.perm-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.perm-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.toggle input {
    accent-color: var(--accent-cyan);
}

.toggle span {
    color: #d8d8de;
}

/* Deploy */
.deploy-card,
.deploy-help,
.stats-mini {
    margin-bottom: 12px;
}

.code-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.template-code {
    flex: 1;
    display: block;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.95rem;
    color: var(--accent-cyan);
    letter-spacing: 0.04em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-pill,
.dirty-pill {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(0, 229, 255, 0.12);
    color: var(--accent-cyan);
    border: 1px solid rgba(0, 229, 255, 0.3);
    margin-right: 6px;
}

.dirty-pill {
    background: rgba(255, 165, 2, 0.12);
    color: var(--accent-yellow);
    border-color: rgba(255, 165, 2, 0.35);
}

.help-list {
    margin: 10px 0 0 18px;
    font-size: 0.85rem;
}

.help-list li {
    margin-bottom: 4px;
}

.deploy-help code,
.deploy-help strong {
    color: #e8e8ec;
}

.stats-mini {
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.stats-mini .stat {
    flex: 1;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stats-mini .stat span {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-cyan);
}

/* Toasts */
.toast-host {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(360px, calc(100vw - 32px));
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    background: rgba(20, 20, 28, 0.95);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent-cyan);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 0.88rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    animation: toast-in 0.2s ease;
}

.toast.error {
    border-left-color: var(--accent-red);
}

.toast.success {
    border-left-color: var(--accent-green);
}

.toast.warn {
    border-left-color: var(--accent-yellow);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    margin-left: 0.5rem;
    padding: 0 0.25rem;
    opacity: 0.6;
    transition: opacity 0.15s, color 0.15s;
    flex-shrink: 0;
}

.toast-close:hover {
    opacity: 1;
    color: var(--text-main);
}

/* Toasts need to allow a close button beside the message text */
.toast {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast-link {
    color: var(--accent-cyan);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.toast-link:hover {
    color: #7ef0ff;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 1100px) {
    .editor-grid {
        grid-template-columns: 1fr 1fr;
    }

    .editor-grid .editor-col:last-child {
        grid-column: 1 / -1;
    }
}

@media (max-width: 820px) {
    :root {
        --tabs-h: 62px;
        --header-h: 60px;
    }

    /* Tabs only when a server is selected (body.sg-workspace-open set by JS) */
    body.sg-workspace-open .mobile-tabs {
        display: flex;
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    body.sg-workspace-open .mobile-tabs::-webkit-scrollbar {
        display: none;
    }

    .mobile-tab {
        min-height: 48px;
        min-width: 64px;
        flex: 1 0 auto;
        padding: 8px 10px;
        font-size: 0.72rem;
        /* larger tap target */
        touch-action: manipulation;
    }

    .glass-header {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .header-inner {
        padding: 0 14px;
        height: var(--header-h);
        gap: 10px;
    }

    .header-sub {
        display: none;
    }

    .user-name {
        display: none;
    }

    .header-title h1 {
        font-size: 0.95rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .logo-text {
        font-size: 1.05rem;
    }

    .avatar-placeholder,
    #userAvatar,
    #userAvatar img {
        width: 34px;
        height: 34px;
    }

    .app-main {
        padding: 14px 12px calc(28px + env(safe-area-inset-bottom));
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .panel {
        padding: 14px;
        border-radius: 12px;
    }

    .panel-head-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .panel-head-row .btn {
        width: 100%;
    }

    .section-guilds .panel-head-row {
        flex-direction: column;
    }

    .guild-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .guild-card {
        min-height: 52px;
        padding: 10px;
        /* prevent accidental double-tap zoom */
        touch-action: manipulation;
    }

    .niche-grid,
    .pack-grid,
    .style-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .niche-card,
    .pack-card,
    .style-card {
        min-height: 48px;
        padding: 12px 14px;
        touch-action: manipulation;
    }

    .editor-grid {
        grid-template-columns: 1fr;
        margin-top: 0;
        gap: 12px;
    }

    .panel[data-panel="setup"] {
        margin-bottom: 12px;
    }

    /* Mobile tab visibility controlled by JS + class */
    .workspace .tab-panel {
        display: none !important;
    }

    .workspace .tab-panel.mobile-active {
        display: block !important;
    }

    .editor-col {
        min-height: 0;
    }

    .guild-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .guild-bar-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .guild-bar-actions select {
        min-width: 0;
        width: 100%;
        font-size: 16px;
        /* iOS: no zoom on focus */
        min-height: 44px;
    }

    .guild-bar-actions .btn {
        width: 100%;
        min-height: 44px;
    }

    /* iOS input zoom fix: font-size >= 16px */
    .input-dark,
    .textarea,
    select.input-dark {
        font-size: 16px;
        min-height: 44px;
    }

    .textarea {
        min-height: 110px;
    }

    .ai-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .ai-actions .btn {
        width: 100%;
        min-height: 46px;
    }

    .ai-note {
        text-align: center;
        line-height: 1.4;
    }

    .usage-bar {
        flex-direction: column;
        gap: 6px;
    }

    .btn-group {
        flex-wrap: wrap;
    }

    .btn-group .btn {
        flex: 1 1 auto;
        min-height: 40px;
    }

    .code-row {
        flex-wrap: wrap;
    }

    .template-code {
        white-space: normal;
        word-break: break-all;
        font-size: 0.85rem;
        min-width: 0;
        width: 100%;
    }

    .code-row .btn {
        width: 100%;
    }

    .channel-tree,
    .roles-list {
        max-height: min(50vh, 360px);
    }

    .tree-cat-head,
    .tree-ch {
        min-height: 40px;
        padding: 10px 10px;
        font-size: 0.9rem;
    }

    .perm-grid {
        grid-template-columns: 1fr;
    }

    .color-row {
        grid-template-columns: auto 1fr;
        gap: 8px;
    }

    .row-between {
        flex-wrap: wrap;
        gap: 8px;
    }

    .stats-mini {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 8px;
        text-align: center;
    }

    .toast-host {
        left: 12px;
        right: 12px;
        bottom: max(12px, env(safe-area-inset-bottom));
        max-width: none;
    }

    .toast {
        font-size: 0.9rem;
        padding: 14px;
        /* allow long invite links to wrap */
        word-break: break-word;
    }

    .modal-overlay {
        padding: 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        align-items: flex-end;
    }

    .modal-content {
        width: 100%;
        max-height: min(88vh, 720px);
        border-radius: 16px 16px 12px 12px;
        padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
    }

    .modal-actions {
        flex-direction: column-reverse;
        gap: 8px;
    }

    .modal-actions .btn {
        width: 100%;
        min-height: 46px;
    }

    .loading-card {
        margin: 16px;
        max-width: calc(100vw - 32px);
    }

    .empty-actions {
        flex-direction: column;
    }

    .empty-actions .btn {
        width: 100%;
    }
}

/* Very small phones */
@media (max-width: 380px) {
    .guild-grid {
        grid-template-columns: 1fr;
    }

    .header-title h1 i {
        display: none;
    }

    .mobile-tab {
        font-size: 0.68rem;
        min-width: 56px;
        padding: 8px 4px;
    }
}

@media (min-width: 821px) {
    .mobile-tabs {
        display: none !important;
    }

    .workspace .tab-panel {
        display: block;
    }

    .panel[data-panel="setup"] {
        margin-bottom: 0;
    }
}

/* ────────────────────────────────────────────────────────────────────────
   Cortex Studio: Variant-Picker (1–3 Vorlagen vergleichen)
   ──────────────────────────────────────────────────────────────────────── */

.variant-picker {
    margin-top: 1.25rem;
    border: 1px solid rgba(124, 58, 237, 0.25);
    background: linear-gradient(135deg,
            rgba(124, 58, 237, 0.06) 0%,
            rgba(6, 182, 212, 0.04) 100%);
}

.variant-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    padding: 0.25rem 0 0.5rem;
}

.variant-card {
    position: relative;
    background: rgba(20, 20, 28, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 1rem 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    transition: transform 160ms ease, border-color 160ms ease,
        box-shadow 160ms ease, background 160ms ease;
    backdrop-filter: blur(6px);
}

.variant-card:hover {
    transform: translateY(-3px);
    border-color: rgba(124, 58, 237, 0.5);
    box-shadow: 0 12px 28px -12px rgba(124, 58, 237, 0.55);
    background: rgba(28, 22, 42, 0.85);
}

.variant-card.is-selected {
    border-color: rgba(16, 185, 129, 0.7);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.35),
        0 12px 28px -12px rgba(16, 185, 129, 0.5);
}

.variant-card.is-error {
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(60, 20, 25, 0.55);
}

.variant-card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}

.variant-card-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #f1f5f9;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.variant-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 0.45rem;
    border-radius: 8px;
    font-weight: 800;
    font-size: 0.85rem;
    background: linear-gradient(135deg, #7c3aed, #06b6d4);
    color: #fff;
    letter-spacing: 0.5px;
}

.variant-tagline {
    font-size: 0.85rem;
    color: #94a3b8;
    font-style: italic;
}

.variant-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.variant-stats .stat-pill {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    padding: 0.18rem 0.55rem;
    font-size: 0.78rem;
    color: #cbd5e1;
}

.variant-stats .stat-pill.voice {
    border-color: rgba(34, 197, 94, 0.35);
    color: #86efac;
}

.variant-stats .stat-pill.text {
    border-color: rgba(59, 130, 246, 0.35);
    color: #93c5fd;
}

.variant-stats .stat-pill.warn {
    border-color: rgba(234, 179, 8, 0.4);
    color: #fde68a;
}

.variant-preview {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 0.55rem 0.7rem;
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.82rem;
    line-height: 1.45;
}

.variant-preview-cat {
    color: #a5b4fc;
    font-weight: 600;
    margin-top: 0.35rem;
}

.variant-preview-cat:first-child {
    margin-top: 0;
}

.variant-preview-ch {
    padding-left: 0.85rem;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.variant-preview-ch .fa-hashtag {
    color: #64748b;
    font-size: 0.7rem;
}

.variant-preview-ch .fa-volume-up {
    color: #22c55e;
    font-size: 0.7rem;
}

.variant-preview-more {
    padding-left: 0.85rem;
    color: #64748b;
    font-style: italic;
}

.variant-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    color: #fca5a5;
    font-size: 0.85rem;
}

.variant-card-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.4rem;
    margin-top: auto;
}

.variant-card-footer .btn {
    font-size: 0.82rem;
    padding: 0.4rem 0.7rem;
}

.variant-card-footer .btn-primary {
    background: linear-gradient(135deg, #7c3aed, #06b6d4);
    border: none;
}

.variant-card-footer .btn-primary:hover {
    filter: brightness(1.1);
}

.variant-warnings {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.variant-warnings .warn {
    color: #fde68a;
    font-size: 0.78rem;
}

/* ────────────────────────────────────────────────────────────────────────
   Cortex Studio: Live-Edit (präzise Prompts gegen den Live-Server)
   ──────────────────────────────────────────────────────────────────────── */

.live-edit-panel {
    margin-top: 1.25rem;
    border: 1px solid rgba(6, 182, 212, 0.25);
    background: linear-gradient(135deg,
            rgba(6, 182, 212, 0.04) 0%,
            rgba(16, 185, 129, 0.03) 100%);
}

.live-edit-prompt-row {
    margin: 0.75rem 0;
}

.live-edit-quick-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.live-edit-quick-actions .btn {
    font-size: 0.8rem;
    padding: 0.25rem 0.55rem;
}

.live-edit-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.live-edit-plan {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}

.live-edit-clarification {
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid rgba(234, 179, 8, 0.3);
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
    color: #fde68a;
    font-size: 0.88rem;
    margin-bottom: 0.75rem;
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.live-edit-clarification i {
    margin-top: 0.1rem;
    flex-shrink: 0;
}

.live-edit-clarification-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

.live-edit-clarification-answer {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.live-edit-clarification-answer .input-dark {
    flex: 1;
    min-width: 0;
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
}

.live-edit-clarification-answer .btn {
    flex-shrink: 0;
    white-space: nowrap;
}

.live-edit-list {
    list-style: none;
    margin: 0.4rem 0 0.6rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.live-edit-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 10px;
    padding: 0.55rem 0.75rem;
    font-size: 0.87rem;
    line-height: 1.5;
}

.live-edit-list li.is-danger {
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.07);
}

.live-edit-list li.is-danger .le-kind {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

.le-kind {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    background: rgba(124, 58, 237, 0.18);
    border: 1px solid rgba(124, 58, 237, 0.35);
    color: #c4b5fd;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 55px;
    text-align: center;
}

.le-summary {
    flex: 1;
    color: #e2e8f0;
    word-break: break-word;
}

.le-warn {
    color: #fde68a;
    font-size: 0.78rem;
    margin-top: 0.2rem;
}

.le-error {
    color: #f87171;
    font-size: 0.78rem;
    margin-top: 0.2rem;
}

/* Live-Edit plan step status */
.le-status-slot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 2px;
}

.le-status {
    font-size: 0.85rem;
}

.le-status.st-pending {
    color: rgba(148, 163, 184, 0.45);
}

.le-status.st-running {
    color: var(--accent-cyan, #00e5ff);
}

.le-status.st-ok {
    color: #34d399;
}

.le-status.st-error {
    color: #f87171;
}

.le-status.st-skipped {
    color: #fbbf24;
}

.live-edit-list li[data-status="running"] {
    border-color: rgba(0, 229, 255, 0.5);
    background: rgba(0, 229, 255, 0.06);
    box-shadow: 0 0 0 1px rgba(0, 229, 255, 0.15);
}

.live-edit-list li[data-status="ok"] {
    border-color: rgba(52, 211, 153, 0.25);
}

.live-edit-list li[data-status="error"] {
    border-color: rgba(248, 113, 113, 0.35);
    background: rgba(248, 113, 113, 0.05);
}

.live-edit-list li[data-status="skipped"] {
    border-color: rgba(251, 191, 36, 0.3);
    background: rgba(251, 191, 36, 0.05);
}

/* Before → after chips */
.le-ba {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.35rem;
}

.le-chip {
    display: inline-block;
    padding: 0.12rem 0.45rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.le-chip-before {
    background: rgba(148, 163, 184, 0.12);
    border: 1px solid rgba(148, 163, 184, 0.3);
    color: #94a3b8;
}

.le-chip-after {
    background: rgba(52, 211, 153, 0.12);
    border: 1px solid rgba(52, 211, 153, 0.35);
    color: #6ee7b7;
}

.le-arrow {
    color: #64748b;
    font-size: 0.8rem;
}

/* Live-Edit apply progress */
.live-edit-progress {
    margin: 0.4rem 0 0.6rem;
}

.le-progress-track {
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    overflow: hidden;
}

.le-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent-purple, #9d00ff), var(--accent-cyan, #00e5ff));
    transition: width 0.3s ease;
}

.le-progress-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.35rem;
}

.live-edit-danger {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 10px;
    padding: 0.6rem 0.75rem;
    margin: 0.4rem 0;
}

.live-edit-apply-row {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.live-edit-result {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}

.live-edit-result .fa-circle-check {
    color: #10b981;
}

/* ────────────────────────────────────────────────────────────────────────
   Cortex Studio: Refine Diff-Preview (Phase 3)
   ──────────────────────────────────────────────────────────────────────── */

.refine-diff-modal {
    max-width: 720px;
    width: 92%;
    max-height: 88vh;
    overflow-y: auto;
}

.refine-diff-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.6rem 0 0.8rem;
}

.refine-diff-summary .diff-pill {
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
}

.refine-diff-summary .diff-pill.add {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.3);
    color: #6ee7b7;
}

.refine-diff-summary .diff-pill.del {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.refine-diff-summary .diff-pill.mod {
    background: rgba(234, 179, 8, 0.12);
    border-color: rgba(234, 179, 8, 0.3);
    color: #fde68a;
}

.refine-diff-body {
    max-height: 50vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.25);
    margin-bottom: 0.6rem;
}

.refine-diff-section {
    margin-bottom: 0.6rem;
}

.refine-diff-section h4 {
    margin: 0.2rem 0 0.3rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
}

.refine-diff-row {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.4rem 0.55rem;
    border-radius: 8px;
    margin-bottom: 0.3rem;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.refine-diff-row.added {
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.07);
}

.refine-diff-row.removed {
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.07);
}

.refine-diff-row.modified {
    border-color: rgba(234, 179, 8, 0.3);
    background: rgba(234, 179, 8, 0.07);
}

.refine-diff-row .row-name {
    font-weight: 600;
    color: #e2e8f0;
}

.refine-diff-row .row-changes {
    color: #cbd5e1;
    font-size: 0.8rem;
    margin-left: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.refine-diff-row .row-changes .change-line {
    color: #94a3b8;
}

.refine-diff-row .row-changes .change-line b {
    color: #e2e8f0;
}

.refine-diff-row .row-changes .change-line .before {
    color: #fca5a5;
    text-decoration: line-through;
    margin-right: 0.3rem;
}

.refine-diff-row .row-changes .change-line .after {
    color: #6ee7b7;
    margin-right: 0.3rem;
}

.refine-diff-danger {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 10px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
}

@media (max-width: 600px) {
    .variant-grid {
        grid-template-columns: 1fr;
    }

    .live-edit-quick-actions {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* -----------------------------------------------------------
   Cortex Studio Overhaul � Phases 4�11
   ----------------------------------------------------------- */

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.studio-breadcrumb {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    margin-top: 0.15rem;
    flex-wrap: wrap;
}

/* Theme light */
body.theme-light {
    --bg-base: #f4f5f8;
    --bg-surface: #ffffff;
    --bg-surface-glass: rgba(255, 255, 255, 0.86);
    --bg-elevated: rgba(255, 255, 255, 0.95);
    --border-color: rgba(0, 0, 0, 0.08);
    --text-main: #1a1b1e;
    --text-muted: #5c6370;
    --discord-channel: #4e5058;
    --discord-category: #5c6370;
}

body.theme-light .glass-header,
body.theme-light .glass-card,
body.theme-light .panel {
    color: var(--text-main);
}

body.theme-light .input-dark {
    background: #eef0f4;
    color: var(--text-main);
    border-color: rgba(0, 0, 0, 0.1);
}

body.theme-light .ambient-bg {
    opacity: 0.35;
}

/* Sidebar layout (Phase 7) */
.studio-shell {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 1rem;
    align-items: start;
}

.studio-sidebar {
    position: sticky;
    top: calc(var(--header-h) + 12px);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    border-radius: var(--radius);
    background: var(--bg-surface-glass);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
}

.studio-mode-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    padding: 0.75rem 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-main);
    cursor: pointer;
    text-align: left;
    font: inherit;
    transition: border-color 0.15s, background 0.15s;
}

.studio-mode-btn i {
    color: var(--accent-cyan);
    margin-bottom: 0.1rem;
}

.studio-mode-btn span {
    font-weight: 600;
    font-size: 0.95rem;
}

.studio-mode-btn small {
    color: var(--text-muted);
    font-size: 0.72rem;
}

.studio-mode-btn:hover {
    background: rgba(0, 229, 255, 0.06);
}

.studio-mode-btn.active {
    border-color: rgba(0, 229, 255, 0.35);
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.12), rgba(157, 0, 255, 0.1));
}

.studio-mode-btn:focus-visible {
    outline: 2px solid var(--accent-cyan);
    outline-offset: 2px;
}

.studio-main {
    min-width: 0;
}

/* Mode panels: hide non-active modes on desktop when workspace open */
body.sg-workspace-open .mode-panel {
    display: none;
}

body.sg-workspace-open[data-studio-mode="setup"] .mode-panel[data-mode-panel="setup"] {
    display: block;
}

body.sg-workspace-open[data-studio-mode="setup"] .editor-grid.mode-panel {
    display: grid;
}

body.sg-workspace-open[data-studio-mode="live"] .mode-panel[data-mode-panel="live"] {
    display: block;
}

body.sg-workspace-open[data-studio-mode="library"] .mode-panel[data-mode-panel="library"] {
    display: block;
}

body.sg-workspace-open[data-studio-mode="deploy"] .mode-panel[data-mode-panel="deploy"] {
    display: block;
}

body.sg-workspace-open[data-studio-mode="deploy"] #panelDeploy {
    display: block;
}

body.sg-workspace-open[data-studio-mode="embeds"] .mode-panel[data-mode-panel="embeds"] {
    display: block;
}

/* Live edit always visible when mode=live (remove old hidden class dependency) */
body.sg-workspace-open[data-studio-mode="live"] #liveEditSection {
    display: block !important;
}

body.sg-workspace-open[data-studio-mode="live"] #liveEditSection.hidden {
    display: block !important;
}

/* Library */
.library-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.library-filters .input-dark {
    flex: 1 1 180px;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}

.library-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.9rem;
    background: var(--bg-elevated);
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-height: 140px;
}

.library-card h4 {
    font-size: 0.95rem;
    font-weight: 600;
}

.library-card .lib-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.library-card .lib-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.library-card .lib-tag {
    font-size: 0.68rem;
    padding: 0.12rem 0.4rem;
    border-radius: 999px;
    background: rgba(157, 0, 255, 0.15);
    color: var(--accent-cyan);
}

.library-card .lib-actions {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.skeleton-card {
    height: 140px;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.04) 25%,
            rgba(255, 255, 255, 0.09) 50%,
            rgba(255, 255, 255, 0.04) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.2s infinite linear;
}

/* Detailed skeletons (L3: contextual placeholders instead of spinner) */
.skeleton {
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.04) 25%,
            rgba(255, 255, 255, 0.09) 50%,
            rgba(255, 255, 255, 0.04) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.2s infinite linear;
    border-radius: 6px;
}

.skeleton-variant {
    height: 180px;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.skeleton-line {
    height: 14px;
    width: 100%;
}

.skeleton-line.title {
    height: 20px;
    width: 72%;
}

.skeleton-line.short {
    width: 55%;
}

.skeleton-line.wide {
    width: 90%;
}

.skeleton-stat-row {
    display: flex;
    gap: 0.3rem;
}

.skeleton-stat-row .skeleton-line {
    width: 58px;
    height: 20px;
    border-radius: 999px;
}

.skeleton-tree {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.3rem;
}

.skeleton-tree-line {
    height: 12px;
    width: 100%;
}

.skeleton-tree-line.indent {
    width: 82%;
    margin-left: 1rem;
}

.skeleton-tree-line.indent2 {
    width: 70%;
    margin-left: 2rem;
}

.skeleton-list-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
}

.skeleton-list-item .skeleton-circle {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-list-item .skeleton-lines {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.skeleton-guild-card {
    height: 92px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.skeleton-guild-card .skeleton-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-guild-card .skeleton-lines {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

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

@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Channel extras */
.input-with-action {
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

.input-with-action .input-dark {
    flex: 1;
}

.channel-extra input[type="range"] {
    width: 100%;
    accent-color: var(--accent-cyan);
}

/* Emoji-Picker (L2) */
.emoji-picker-trigger {
    padding: 0.2rem 0.4rem;
    font-size: 1rem;
    line-height: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
}

.emoji-picker-trigger:hover {
    background: rgba(0, 229, 255, 0.08);
    border-color: rgba(0, 229, 255, 0.3);
}

.emoji-picker-popover {
    position: absolute;
    z-index: 250;
    width: 280px;
    max-height: 280px;
    background: rgba(20, 20, 28, 0.98);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.4rem;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
}

.emoji-picker-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.4rem;
}

.emoji-picker-tabs button {
    flex: 1;
    padding: 0.3rem;
    font-size: 1.1rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.emoji-picker-tabs button:hover {
    background: rgba(0, 229, 255, 0.08);
}

.emoji-picker-tabs button.active {
    background: rgba(0, 229, 255, 0.12);
    border-color: rgba(0, 229, 255, 0.35);
}

.emoji-picker-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    overflow-y: auto;
    max-height: 200px;
    scrollbar-width: thin;
}

.emoji-picker-grid button {
    font-size: 1.3rem;
    padding: 4px;
    text-align: center;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.1s;
    min-height: 32px;
}

.emoji-picker-grid button:hover {
    background: rgba(255, 255, 255, 0.12);
}

@media (max-width: 820px) {
    .emoji-picker-popover {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        max-height: 50vh;
        border-radius: 16px 16px 0 0;
    }

    .emoji-picker-grid {
        grid-template-columns: repeat(6, 1fr);
        max-height: 40vh;
    }
}

/* Permission browser */
.perm-browser-modal {
    max-width: 640px;
    max-height: 90vh;
    overflow: auto;
    width: min(640px, 96vw);
}

.perm-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0.75rem 0;
}

.perm-tab {
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    font-size: 0.8rem;
}

.perm-tab.active {
    color: var(--text-main);
    border-color: var(--accent-cyan);
    background: rgba(0, 229, 255, 0.1);
}

.perm-browser-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 320px;
    overflow: auto;
    margin-bottom: 0.75rem;
}

.perm-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    align-items: center;
    padding: 0.4rem 0.5rem;
    border-radius: 8px;
    border: 1px solid transparent;
}

.perm-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.perm-row.danger .perm-label {
    color: var(--accent-red);
}

.perm-label {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.perm-badge-danger {
    font-size: 0.65rem;
    padding: 0.05rem 0.35rem;
    border-radius: 4px;
    background: rgba(235, 69, 95, 0.2);
    color: var(--accent-red);
}

.perm-tri {
    display: inline-flex;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.perm-tri button {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 0.3rem 0.55rem;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
}

.perm-tri button.active-allow {
    background: rgba(46, 213, 115, 0.25);
    color: var(--accent-green);
}

.perm-tri button.active-deny {
    background: rgba(235, 69, 95, 0.25);
    color: var(--accent-red);
}

.perm-tri button.active-inherit {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
}

.perm-browser-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.perm-bulk {
    margin-bottom: 0.75rem;
}

/* Emoji popover */
.emoji-popover {
    position: fixed;
    z-index: 1200;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    display: grid;
    grid-template-columns: repeat(8, 1.6rem);
    gap: 0.25rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.emoji-popover button {
    border: none;
    background: transparent;
    font-size: 1.1rem;
    cursor: pointer;
    border-radius: 4px;
    line-height: 1.4;
}

.emoji-popover button:hover {
    background: rgba(0, 229, 255, 0.12);
}

/* Toast queue spacing */
.toast-host {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    pointer-events: none;
}

.toast-host .toast {
    pointer-events: auto;
}

/* Drag and drop */
.channel-tree .tree-item.dragging {
    opacity: 0.45;
}

.channel-tree .tree-item.drag-over {
    outline: 1px dashed var(--accent-cyan);
    outline-offset: 2px;
}

.roles-list .role-item.dragging {
    opacity: 0.45;
}

.apply-preview {
    margin-top: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    background: rgba(0, 229, 255, 0.06);
    border: 1px solid rgba(0, 229, 255, 0.2);
    font-size: 0.85rem;
}

/* Swipe hints (L5: mobile mode navigation) */
.swipe-hint {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 48px;
    background: rgba(0, 229, 255, 0.15);
    border-radius: 6px;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--accent-cyan);
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 50;
    pointer-events: none;
}

.swipe-hint.left {
    left: 4px;
}

.swipe-hint.right {
    right: 4px;
}

.swipe-hint.visible {
    opacity: 0.7;
}

.guild-grid.swipe-refreshing {
    transition: transform 0.2s ease;
}

.pull-indicator {
    position: absolute;
    top: -32px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--accent-cyan);
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.pull-indicator.visible {
    opacity: 0.8;
}

@media (max-width: 820px) {
    .swipe-hint {
        display: flex;
    }

    .app-main {
        touch-action: pan-y;
    }
}

.apply-preview ul {
    margin: 0.4rem 0 0 1.1rem;
}

@media (max-width: 980px) {
    .studio-shell {
        grid-template-columns: 1fr;
    }

    .studio-sidebar {
        display: none;
    }
}

/* Focus indicators (a11y) */
.btn:focus-visible,
.input-dark:focus-visible,
.mobile-tab:focus-visible,
.tree-item:focus-visible,
.role-item:focus-visible {
    outline: 2px solid var(--accent-cyan);
    outline-offset: 2px;
}

/* ══════════════════════════════════════════════════════════════
   Role Graph (Rollen-Abhängigkeitsgraph)
   ══════════════════════════════════════════════════════════════ */
.graph-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.graph-stat-pill {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    white-space: nowrap;
}

.graph-stat-pill.danger {
    border-color: #E74C3C;
    background: rgba(231, 76, 60, 0.12);
    color: #E74C3C;
}

.graph-stat-pill.success {
    border-color: #2ECC71;
    background: rgba(46, 204, 113, 0.12);
    color: #2ECC71;
}

.graph-stat-pill.warn {
    border-color: #F1C40F;
    background: rgba(241, 196, 15, 0.12);
    color: #F1C40F;
}

.graph-container {
    position: relative;
    width: 100%;
    min-height: 400px;
    max-height: 65vh;
    overflow: hidden;
    border-radius: 8px;
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    cursor: grab;
}

.graph-container:active {
    cursor: grabbing;
}

#roleGraphCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

.graph-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.75rem;
    padding: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.legend-item .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot.hierarchy {
    background: #5865F2;
}

.dot.overwrite {
    background: #2ECC71;
}

.dot.overlap {
    background: #F1C40F;
}

.dot.danger {
    background: #E74C3C;
}

.graph-detail {
    margin-top: 0.75rem;
    padding: 0.75rem;
    border-radius: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    font-size: 0.8rem;
    max-height: 180px;
    overflow-y: auto;
}

.graph-detail h4 {
    margin: 0 0 0.4rem 0;
    font-size: 0.85rem;
}

.graph-detail .perm-tag {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    margin: 0.15rem;
    background: rgba(88, 101, 242, 0.2);
    color: #5865F2;
    border: 1px solid rgba(88, 101, 242, 0.3);
}

.graph-detail .perm-tag.danger-tag {
    background: rgba(231, 76, 60, 0.2);
    color: #E74C3C;
    border-color: rgba(231, 76, 60, 0.3);
}

.btn-row {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

/* ══════════════════════════════════════════════════════════════
   Mobile Optimizations & Graphical Enhancements (Pillar 2)
   ══════════════════════════════════════════════════════════════ */

/* ── Safe Area Support ─────────────────────────────────────── */
:root {
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Mobile-Optimized Touch Targets ───────────────────────── */
@media (max-width: 820px) {

    /* Larger touch targets for mobile */
    .role-hierarchy-card,
    .live-edit-plan-item,
    .variant-card,
    .guild-card {
        min-height: 56px;
        padding: 14px 16px;
    }

    .btn {
        min-height: 48px;
        font-size: 1rem;
        padding: 12px 20px;
    }

    .btn-sm {
        min-height: 44px;
        font-size: 0.9rem;
        padding: 10px 16px;
    }

    .mobile-tab {
        min-height: 56px;
    }

    /* Touch-friendly input fields */
    .input-dark,
    textarea.input-dark {
        min-height: 48px;
        font-size: 16px;
        /* Prevents iOS zoom */
        padding: 12px 14px;
    }

    /* Bottom Sheet Modals */
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
        justify-content: stretch;
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        border-radius: 24px 24px 0 0;
        max-height: 90vh;
        padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    }

    /* Swipe to dismiss gesture hint */
    .modal-content::before {
        content: "";
        display: block;
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 2px;
        margin: 0 auto 16px;
    }

    /* Floating Action Button */
    .fab-live-edit {
        position: fixed;
        bottom: calc(80px + env(safe-area-inset-bottom));
        right: 20px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
        box-shadow: 0 4px 20px rgba(0, 229, 255, 0.4);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 100;
        border: none;
        cursor: pointer;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .fab-live-edit:hover,
    .fab-live-edit:active {
        transform: scale(1.1);
        box-shadow: 0 6px 28px rgba(0, 229, 255, 0.5);
    }

    .fab-live-edit i {
        color: #fff;
        font-size: 1.2rem;
    }

    /* Enhanced Live-Edit Cards */
    .live-edit-plan-item {
        padding: 16px;
        border-radius: 12px;
        margin-bottom: 8px;
    }

    .live-edit-diff {
        font-size: 0.85rem;
        padding: 10px;
        border-radius: 8px;
    }

    /* Mobile toast positioning */
    .toast-container {
        bottom: calc(24px + env(safe-area-inset-bottom));
        left: 12px;
        right: 12px;
    }

    .toast {
        max-width: 100%;
        width: 100%;
    }

    /* Mobile table/scroll container */
    .perm-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px;
        padding: 0 16px;
    }
}

/* ── Role Hierarchy Visualization ───────────────────────────── */
.role-hierarchy-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: linear-gradient(180deg,
            rgba(0, 229, 255, 0.05) 0%,
            rgba(157, 0, 255, 0.05) 100%);
    border-radius: 12px;
    border: 1px solid rgba(0, 229, 255, 0.15);
}

.role-hierarchy-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(20, 20, 28, 0.8);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    cursor: pointer;
}

.role-hierarchy-card:hover {
    border-color: rgba(0, 229, 255, 0.4);
    transform: translateX(4px);
    background: rgba(25, 25, 35, 0.9);
}

.role-hierarchy-bar {
    width: 4px;
    height: 28px;
    border-radius: 2px;
    flex-shrink: 0;
}

.role-hierarchy-bar.admin {
    background: linear-gradient(180deg, #ffc107, rgba(255, 193, 7, 0.5));
}

.role-hierarchy-bar.moderator {
    background: linear-gradient(180deg, #9d00ff, rgba(157, 0, 255, 0.5));
}

.role-hierarchy-bar.member {
    background: linear-gradient(180deg, #00e5ff, rgba(0, 229, 255, 0.5));
}

.role-hierarchy-bar.guest {
    background: linear-gradient(180deg, #a3a6aa, rgba(163, 166, 170, 0.5));
}

.role-hierarchy-info {
    flex: 1;
    min-width: 0;
}

.role-hierarchy-name {
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.role-hierarchy-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.role-hierarchy-level {
    font-size: 0.7rem;
    color: var(--accent-cyan);
    background: rgba(0, 229, 255, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    min-width: 32px;
    text-align: center;
}

/* ── Animated Gradient Border ──────────────────────────────── */
@keyframes gradient-shift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.animated-border {
    position: relative;
}

.animated-border::before {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple), var(--accent-cyan));
    background-size: 200% 100%;
    animation: gradient-shift 3s ease infinite;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.animated-border:hover::before,
.animated-border.active::before {
    opacity: 1;
}

/* ── Pulse Animation for AI Processing ─────────────────────── */
@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(0, 229, 255, 0.4);
    }

    50% {
        box-shadow: 0 0 20px 10px rgba(0, 229, 255, 0);
    }
}

.ai-processing {
    animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes spin-slow {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.spin-slow {
    animation: spin-slow 3s linear infinite;
}

/* ── Success/Error Micro-animations ───────────────────────── */
@keyframes success-pop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes error-shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-5px);
    }

    40%,
    80% {
        transform: translateX(5px);
    }
}

.success-pop {
    animation: success-pop 0.3s ease-out;
}

.error-shake {
    animation: error-shake 0.4s ease-out;
}

/* ── Progress Indicator ────────────────────────────────────── */
.progress-container {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
    border-radius: 2px;
    transition: width 0.3s ease;
}

@keyframes progress-indeterminate {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(400%);
    }
}

.progress-indeterminate .progress-bar {
    width: 30%;
    animation: progress-indeterminate 1.5s ease-in-out infinite;
}

/* ── Enhanced Toast Notifications ─────────────────────────── */
.toast {
    padding: 14px 18px;
    background: rgba(15, 15, 22, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
    font-size: 0.9rem;
    pointer-events: auto;
    animation: toast-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 360px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.toast-icon {
    flex-shrink: 0;
    font-size: 1.2em;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-success {
    border-color: rgba(46, 213, 115, 0.4);
}

.toast-error {
    border-color: rgba(235, 69, 95, 0.4);
}

.toast-info {
    border-color: rgba(0, 229, 255, 0.4);
}

/* ── Floating Particles (Subtle Background) ───────────────── */
.floating-particles {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--accent-cyan);
    border-radius: 50%;
    opacity: 0.3;
    animation: particle-float linear infinite;
}

@keyframes particle-float {
    0% {
        transform: translateY(100vh) scale(0);
        opacity: 0;
    }

    10% {
        opacity: 0.3;
    }

    90% {
        opacity: 0.3;
    }

    100% {
        transform: translateY(-20px) scale(1);
        opacity: 0;
    }
}

/* ────────────────────────────────────────────────────────────────────────
   Cortex Studio: Embed Editor
   ──────────────────────────────────────────────────────────────────────── */

.embed-editor-grid {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 18px;
    margin-top: 14px;
    align-items: start;
}

.embed-config-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.embed-preview-col {
    position: sticky;
    top: calc(var(--header-h) + 16px);
}

.embed-section {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.embed-section h3.subhead {
    margin: 0 0 12px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-cyan);
    display: flex;
    align-items: center;
    gap: 6px;
}

.embed-section h3.subhead i {
    opacity: 0.8;
}

/* Zielkanal-Auswahl: Icon im Eingabefeld, Discord-Reihenfolge im Dropdown */
.embed-channel-select {
    position: relative;
}

.embed-channel-select-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
    z-index: 1;
}

.embed-channel-select .input-dark {
    padding-left: 34px;
    appearance: none;
    -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #8b93a1 50%),
        linear-gradient(135deg, #8b93a1 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
    background-size: 5px 5px;
    background-repeat: no-repeat;
    cursor: pointer;
}

.embed-channel-select .input-dark option,
.embed-channel-select .input-dark optgroup option {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.embed-channel-select .input-dark:has(option:checked[value=""]) {
    color: #9aa3b2;
}

/* Dropdown-Optionen: Zeilenhohe, abgesetzte Kategorien */
.embed-channel-select .input-dark optgroup {
    background: #0d0e14;
    color: var(--accent-cyan, #00e5ff);
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    padding: 8px 6px 4px 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin-top: 2px;
}

.embed-channel-select .input-dark option {
    background: #181924;
    color: #e2e8f0;
    padding: 8px 12px;
    font-weight: 400;
}

.embed-channel-select .input-dark optgroup option {
    background: #1a1c29;
    color: #f1f5f9;
    padding-left: 20px;
}

.embed-channel-select .input-dark option:hover,
.embed-channel-select .input-dark optgroup option:hover {
    background: #232635;
}

/* KI Enhancer */
.embed-ai-enhancer {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.embed-ai-enhancer textarea {
    min-height: 100px;
}

.embed-ai-enhancer .style-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.embed-ai-enhancer .style-row select {
    flex: 1;
}

.embed-ai-enhancer .enhance-status {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 8px 12px;
    background: rgba(0, 229, 255, 0.06);
    border: 1px solid rgba(0, 229, 255, 0.15);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.embed-ai-enhancer .enhance-status.loading {
    color: var(--accent-cyan);
}

.embed-ai-enhancer .enhance-status.success {
    color: var(--accent-green);
    border-color: rgba(46, 213, 115, 0.25);
    background: rgba(46, 213, 115, 0.06);
}

.embed-ai-enhancer .enhance-status.error {
    color: var(--accent-red);
    border-color: rgba(235, 69, 95, 0.25);
    background: rgba(235, 69, 95, 0.06);
}

/* Color picker */
.embed-color-section {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.embed-color-section input[type="color"] {
    width: 44px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: transparent;
    padding: 3px;
    cursor: pointer;
}

.embed-color-section .color-presets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.embed-color-section .color-preset {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.12s;
}

.embed-color-section .color-preset:hover {
    transform: scale(1.15);
}

.embed-color-section .color-preset.selected {
    border-color: #fff;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
}

/* Embed Fields */
.embed-fields-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
}

.embed-field-item {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.embed-field-item .field-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.embed-field-item .field-num {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 8px;
    border-radius: 4px;
}

.embed-field-item .field-actions {
    display: flex;
    gap: 4px;
}

.embed-field-item .field-actions button {
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: background 0.12s;
}

.embed-field-item .field-actions .btn-remove {
    background: rgba(235, 69, 95, 0.15);
    color: #ff8a9a;
}

.embed-field-item .field-actions .btn-remove:hover {
    background: rgba(235, 69, 95, 0.3);
}

.embed-field-item .field-inputs {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.embed-field-item .field-inputs input,
.embed-field-item .field-inputs textarea {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    color: #fff;
    font-family: inherit;
    font-size: 0.85rem;
    padding: 8px 10px;
    outline: none;
    transition: border-color 0.12s;
}

.embed-field-item .field-inputs input:focus,
.embed-field-item .field-inputs textarea:focus {
    border-color: rgba(0, 229, 255, 0.4);
}

.embed-field-item .field-inputs textarea {
    min-height: 60px;
    resize: vertical;
}

.embed-field-item .field-inline-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.embed-field-item .field-inline-row label {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.embed-field-item .field-inline-row input[type="checkbox"] {
    accent-color: var(--accent-cyan);
}

/* Preview Box */
.embed-preview-box {
    background: #36393f;
    border-radius: 8px;
    padding: 16px;
    min-height: 200px;
}

.embed-preview-inner {
    display: flex;
    gap: 16px;
}

.embed-preview-discord {
    flex: 1;
    background: #36393f;
    border-radius: 4px;
}

.embed-preview-discord .ep-author {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.embed-preview-discord .ep-author-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    display: flex;
    align-items: center;
    justify-content: center;
}

.embed-preview-discord .ep-author-info {
    display: flex;
    flex-direction: column;
}

.embed-preview-discord .ep-author-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
}

.embed-preview-discord .ep-author-tag {
    font-size: 0.75rem;
    color: #b9bbbe;
}

.embed-preview-discord .ep-embed {
    margin-left: 44px;
    background: #2f3136;
    border-radius: 4px;
    border-left: 4px solid var(--accent-cyan);
    padding: 12px 16px;
}

.embed-preview-discord .ep-title {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 8px;
}

.embed-preview-discord .ep-description {
    font-size: 0.9rem;
    color: #dcddde;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Markdown-Darstellung in der Embed-Vorschau */
.embed-preview-discord .ep-title strong,
.embed-preview-discord .ep-description strong,
.embed-preview-discord .ep-field-name strong,
.embed-preview-discord .ep-field-value strong {
    font-weight: 700;
    color: #fff;
}

.embed-preview-discord .ep-description em,
.embed-preview-discord .ep-field-value em {
    font-style: italic;
}

.embed-preview-discord .ep-description u,
.embed-preview-discord .ep-field-value u {
    text-decoration: underline;
}

.embed-preview-discord .ep-description s,
.embed-preview-discord .ep-field-value s {
    text-decoration: line-through;
}

.embed-preview-discord .md-code {
    background: #1e1f22;
    border: 1px solid #2e3136;
    border-radius: 3px;
    padding: 1px 4px;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.85em;
    color: #dcddde;
    white-space: pre-wrap;
}

.embed-preview-discord .md-code-block {
    background: #1e1f22;
    border: 1px solid #2e3136;
    border-radius: 4px;
    padding: 8px 10px;
    margin: 4px 0;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.85em;
    color: #dcddde;
    white-space: pre;
    overflow-x: auto;
}

.embed-preview-discord .md-quote {
    border-left: 3px solid #4f545c;
    padding-left: 8px;
    margin: 2px 0;
    color: #b9bbbe;
}

.embed-preview-discord .md-li {
    margin: 1px 0;
}

.embed-preview-discord .md-h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    margin: 4px 0 2px;
}

.embed-preview-discord .md-h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    margin: 4px 0 2px;
}

.embed-preview-discord .md-h3 {
    font-size: 0.98rem;
    font-weight: 700;
    color: #fff;
    margin: 4px 0 2px;
}

.embed-preview-discord .md-spoiler {
    background: #1e1f22;
    border-radius: 3px;
    color: transparent;
    transition: color 0.15s;
}

.embed-preview-discord .md-spoiler:hover {
    color: #dcddde;
}

.embed-preview-discord .ep-description a,
.embed-preview-discord .ep-field-value a,
.embed-preview-discord .ep-title a {
    color: #00b0f4;
    text-decoration: none;
}

.embed-preview-discord .ep-description a:hover,
.embed-preview-discord .ep-field-value a:hover {
    text-decoration: underline;
}

.embed-preview-discord .ep-field {
    margin-top: 8px;
    display: flex;
}

.embed-preview-discord .ep-field-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    flex: 0 0 30%;
}

.embed-preview-discord .ep-field-value {
    font-size: 0.85rem;
    color: #dcddde;
    flex: 1;
}

.embed-preview-discord .ep-field.inline {
    flex: 1;
    display: inline-flex;
}

.embed-preview-discord .ep-footer {
    margin-top: 10px;
    font-size: 0.78rem;
    color: #72767d;
    display: flex;
    align-items: center;
    gap: 6px;
}

.embed-preview-discord .ep-footer img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.embed-preview-discord .ep-image {
    margin-top: 12px;
    border-radius: 4px;
    overflow: hidden;
}

.embed-preview-discord .ep-image img {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
}

.embed-preview-discord .ep-thumbnail {
    position: absolute;
    right: 16px;
    top: 16px;
    width: 60px;
    height: 60px;
    border-radius: 4px;
    object-fit: cover;
}

/* Embed Actions */
.embed-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.embed-actions .btn {
    flex: 1;
    min-width: 140px;
}

/* Templates Section */
.embed-templates-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.embed-templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.embed-template-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.embed-template-card:hover {
    border-color: rgba(0, 229, 255, 0.4);
    background: rgba(0, 229, 255, 0.04);
    transform: translateY(-2px);
}

.embed-template-card .template-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.embed-template-card .template-name i {
    color: var(--accent-cyan);
}

.embed-template-card .template-preview {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.embed-template-card .template-meta {
    display: flex;
    gap: 8px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.embed-template-card .template-meta span {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 4px;
}

.embed-template-card .template-actions {
    margin-top: 10px;
    display: flex;
    gap: 6px;
}

.embed-template-card .template-actions .btn {
    flex: 1;
    font-size: 0.78rem;
    padding: 6px 10px;
}

/* Empty States */
.embed-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.embed-empty-state i {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.4;
}

.embed-empty-state h4 {
    font-size: 1rem;
    margin-bottom: 6px;
    color: #e8e8ec;
}

.embed-empty-state p {
    font-size: 0.85rem;
}

/* Verlauf */
.embed-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.embed-history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    transition: border-color 0.15s, background 0.15s;
}

.embed-history-item:hover {
    border-color: rgba(0, 229, 255, 0.4);
    background: rgba(0, 229, 255, 0.04);
}

.embed-history-item .history-swatch {
    flex-shrink: 0;
    width: 10px;
    height: 42px;
    border-radius: 4px;
}

.embed-history-item .history-info {
    flex: 1;
    min-width: 0;
}

.embed-history-item .history-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: #e8e8ec;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.embed-history-item .history-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.embed-history-item .history-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    opacity: 0.8;
    margin-top: 2px;
}

.embed-history-item .btn {
    flex-shrink: 0;
    font-size: 0.78rem;
    padding: 6px 10px;
}

/* Responsive */
@media (max-width: 960px) {
    .embed-editor-grid {
        grid-template-columns: 1fr;
    }

    .embed-preview-col {
        position: static;
        order: -1;
    }

    .embed-preview-box {
        min-height: 150px;
    }
}

@media (max-width: 600px) {
    .embed-section {
        padding: 12px;
    }

    .embed-actions {
        flex-direction: column;
    }

    .embed-actions .btn {
        min-width: 0;
        width: 100%;
    }

    .embed-templates-grid {
        grid-template-columns: 1fr;
    }
}

/* ────────────────────────────────────────────────────────────────────────
   Cortex Studio: Tool-Auswahl (Chooser)
   ──────────────────────────────────────────────────────────────────────── */

.studio-chooser {
    margin-top: 2.5rem;
    border-color: rgba(124, 58, 237, 0.25);
    background: linear-gradient(160deg, rgba(124, 58, 237, 0.07) 0%, rgba(6, 182, 212, 0.04) 60%, rgba(14, 14, 18, 0.6) 100%);
}

.studio-chooser-inner {
    max-width: 880px;
    margin: 0 auto;
    padding: 1.5rem 0.5rem 2rem;
}

.studio-chooser-head {
    text-align: center;
    margin-bottom: 2rem;
}

.studio-chooser-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: var(--accent-cyan);
    background: rgba(0, 229, 255, 0.08);
    border: 1px solid rgba(0, 229, 255, 0.25);
    margin-bottom: 1rem;
}

.studio-chooser-head h2 {
    font-size: clamp(1.4rem, 3vw, 2rem);
    margin: 0 0 0.5rem;
}

.studio-chooser-head .muted {
    max-width: 560px;
    margin: 0 auto;
}

.studio-chooser-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

.studio-tool-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: 0.8rem;
    padding: 1.5rem 1.4rem 1.4rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--bg-surface-glass);
    color: var(--text-main);
    font: inherit;
    cursor: pointer;
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.studio-tool-card:hover,
.studio-tool-card:focus-visible {
    transform: translateY(-3px);
    border-color: rgba(0, 229, 255, 0.45);
    box-shadow: 0 14px 34px -14px rgba(124, 58, 237, 0.55);
    background: rgba(26, 24, 40, 0.9);
    outline: none;
}

.studio-tool-icon {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 1.35rem;
    margin-bottom: 0.2rem;
}

.studio-tool-icon.glow-cyan {
    color: var(--accent-cyan);
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.16), rgba(0, 229, 255, 0.04));
    border: 1px solid rgba(0, 229, 255, 0.35);
}

.studio-tool-icon.glow-purple {
    color: var(--accent-purple);
    background: linear-gradient(135deg, rgba(157, 0, 255, 0.16), rgba(157, 0, 255, 0.04));
    border: 1px solid rgba(157, 0, 255, 0.35);
}

.studio-tool-card h3 {
    font-size: 1.15rem;
    margin: 0;
}

.studio-tool-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.55;
}

.studio-tool-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.studio-tool-tags span {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
}

.studio-tool-cta {
    margin-top: auto;
    padding-top: 0.6rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-cyan);
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.studio-tool-cta i {
    transition: transform 160ms ease;
}

.studio-tool-card:hover .studio-tool-cta i {
    transform: translateX(3px);
}

/* ────────────────────────────────────────────────────────────────────────
   Cortex Studio: Quick-Switch (subtil, unten links)
   ──────────────────────────────────────────────────────────────────────── */

.studio-switch {
    position: fixed;
    left: 16px;
    bottom: 16px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.studio-switch-pill {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 0.85rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    background: rgba(14, 14, 18, 0.72);
    color: var(--text-muted);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(10px);
    opacity: 0.65;
    transition: opacity 160ms ease, border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.studio-switch-pill:hover {
    opacity: 1;
    border-color: rgba(0, 229, 255, 0.35);
    color: var(--text-main);
    background: rgba(14, 14, 18, 0.9);
}

.studio-switch-logo {
    color: var(--accent-cyan);
    font-size: 0.9rem;
}

.studio-switch-chevron {
    font-size: 0.62rem;
    transition: transform 160ms ease;
}

.studio-switch-pill[aria-expanded="true"] .studio-switch-chevron {
    transform: rotate(180deg);
}

.studio-switch-menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 190px;
    padding: 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: rgba(16, 16, 22, 0.96);
    box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
}

.studio-switch-menu button {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-main);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    text-align: left;
    transition: background 140ms ease, border-color 140ms ease;
}

.studio-switch-menu button i {
    width: 18px;
    text-align: center;
    color: var(--text-muted);
}

.studio-switch-menu button:hover,
.studio-switch-menu button:focus-visible {
    background: rgba(0, 229, 255, 0.08);
    border-color: rgba(0, 229, 255, 0.25);
    outline: none;
}

.studio-switch-menu button:hover i {
    color: var(--accent-cyan);
}

/* ────────────────────────────────────────────────────────────────────────
   Cortex Studio: Embed Builder V2 (Text & Formatierung)
   ──────────────────────────────────────────────────────────────────────── */

.embed-hint {
    margin: 0 0 12px;
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.5;
}

.embed-section h3.subhead {
    font-size: 0.92rem;
}

.field-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 6px;
}

.field-label-row label {
    margin-bottom: 0;
}

.char-count {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.char-count.muted {
    opacity: 0.7;
}

.field-count {
    margin-left: auto;
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
}

.embed-input-with-btn {
    display: flex;
    gap: 8px;
}

.embed-input-with-btn .input-dark {
    flex: 1;
}

.embed-input-with-btn .btn {
    white-space: nowrap;
}

.embed-section-actions {
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.05), rgba(157, 0, 255, 0.05));
    border-color: rgba(0, 229, 255, 0.15);
}

@media (max-width: 600px) {
    .embed-input-with-btn {
        flex-direction: column;
    }

    .embed-input-with-btn .btn {
        width: 100%;
    }
}