/* ═══════════════════════════════════════════════════
   README FORGE — Cosmic Dark UI
   Design: Deep space black + neon purple + cyan glow
   Grid: 8px base unit
   Fonts: Space Grotesk + JetBrains Mono
═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ── CSS Variables ──────────────────────────────── */
:root {
    /* Colors */
    --bg-base: #07070e;
    --bg-panel: rgba(14, 14, 28, 0.85);
    --bg-surface: rgba(22, 20, 42, 0.9);
    --bg-input: rgba(255, 255, 255, 0.04);
    --bg-hover: rgba(155, 48, 255, 0.12);
    --bg-card: rgba(30, 26, 58, 0.7);

    --accent-primary: #9b30ff;
    --accent-secondary: #6a0dad;
    --accent-cyan: #00d4ff;
    --accent-magenta: #f000b8;
    --accent-gradient: linear-gradient(135deg, #6a0dad 0%, #9b30ff 50%, #00d4ff 100%);
    --accent-glow: 0 0 20px rgba(155, 48, 255, 0.4), 0 0 40px rgba(155, 48, 255, 0.15);
    --cyan-glow: 0 0 20px rgba(0, 212, 255, 0.35), 0 0 40px rgba(0, 212, 255, 0.1);

    --text-primary: #f0eeff;
    --text-secondary: #a89bc8;
    --text-muted: #5e5278;
    --text-accent: #c084fc;

    --border: rgba(155, 48, 255, 0.2);
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-focus: rgba(155, 48, 255, 0.7);

    --success: #22d07a;
    --error: #ff4d6d;
    --warning: #ffbe0b;

    /* Sizing */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-pill: 999px;

    /* Spacing (8px grid) */
    --sp-1: 8px;
    --sp-2: 16px;
    --sp-3: 24px;
    --sp-4: 32px;
    --sp-5: 40px;
    --sp-6: 48px;

    /* Typography */
    --font-body: 'Space Grotesk', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Layout */
    --header-h: 64px;
    --panel-w: 420px;
    --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light theme override */
[data-theme="light"] {
    --bg-base: #f0eeff;
    --bg-panel: rgba(255, 255, 255, 0.92);
    --bg-surface: rgba(240, 235, 255, 0.95);
    --bg-input: rgba(106, 13, 173, 0.05);
    --bg-hover: rgba(106, 13, 173, 0.08);
    --bg-card: rgba(230, 220, 255, 0.7);
    --text-primary: #1a0d33;
    --text-secondary: #4a3068;
    --text-muted: #9b82c0;
    --text-accent: #6a0dad;
    --border: rgba(106, 13, 173, 0.2);
    --border-subtle: rgba(106, 13, 173, 0.08);
}

/* ── Reset & Base ───────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-base);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Animated Background ────────────────────────── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(106, 13, 173, 0.18) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 80% 80%, rgba(0, 212, 255, 0.1) 0%, transparent 55%),
        radial-gradient(ellipse 70% 70% at 50% 50%, rgba(155, 48, 255, 0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

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

.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.35;
    animation: orbFloat 12s ease-in-out infinite alternate;
}

.bg-orb:nth-child(1) {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #9b30ff, transparent 70%);
    top: -120px;
    left: -100px;
    animation-delay: 0s;
}

.bg-orb:nth-child(2) {
    width: 380px;
    height: 380px;
    background: radial-gradient(circle, #00d4ff, transparent 70%);
    bottom: -80px;
    right: -80px;
    animation-delay: -4s;
}

.bg-orb:nth-child(3) {
    width: 280px;
    height: 280px;
    background: radial-gradient(circle, #f000b8, transparent 70%);
    top: 50%;
    right: 30%;
    animation-delay: -8s;
    opacity: 0.2;
}

@keyframes orbFloat {
    from {
        transform: translate(0, 0) scale(1);
    }

    to {
        transform: translate(30px, 20px) scale(1.08);
    }
}

@media (prefers-reduced-motion: reduce) {
    .bg-orb {
        animation: none;
    }

    body::before {
        animation: none;
    }
}

/* ── Screen Reader Utility ──────────────────────── */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Header ─────────────────────────────────────── */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    background: rgba(7, 7, 14, 0.8);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    box-shadow: 0 1px 32px rgba(155, 48, 255, 0.08);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 var(--sp-3);
    max-width: 100%;
    gap: var(--sp-2);
}

/* Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.brand-icon {
    width: 32px;
    height: 32px;
    filter: drop-shadow(0 0 8px var(--accent-primary));
}

.brand-name {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.brand-accent {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Header Nav */
.header-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    flex-wrap: wrap;
}

/* Select Wrapper */
.select-wrapper {
    position: relative;
}

.select-wrapper::after {
    content: '▾';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-accent);
    font-size: 11px;
}

.select-wrapper select,
select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    padding: 7px 28px 7px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

select:focus,
.select-wrapper select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(155, 48, 255, 0.15);
}

select option {
    background: #12121a;
}

/* ── Buttons ─────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    padding: 8px 16px;
    transition: all var(--transition);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    outline: none;
}

.btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(155, 48, 255, 0.4);
}

/* Shimmer on hover */
.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.08) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.5s ease;
}

.btn:hover::after {
    transform: translateX(100%);
}

.btn-primary {
    background: linear-gradient(135deg, #6a0dad, #9b30ff);
    color: #fff;
    box-shadow: 0 4px 18px rgba(155, 48, 255, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #7b15ca, #aa3fff);
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(155, 48, 255, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-accent);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--accent-primary);
    background: var(--bg-hover);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--bg-hover);
}

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

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-icon {
    padding: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
}

.btn-icon:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--bg-hover);
}

.btn-icon svg {
    width: 17px;
    height: 17px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

/* AI Generate button — cyan glow */
.btn-ai {
    background: linear-gradient(135deg, #0084a5, #00d4ff);
    color: #000;
    box-shadow: 0 4px 18px rgba(0, 212, 255, 0.3);
    font-weight: 700;
}

.btn-ai:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(0, 212, 255, 0.5);
}

/* ── Main Layout ─────────────────────────────────── */
.workspace {
    display: flex;
    height: 100vh;
    padding-top: var(--header-h);
    position: relative;
    z-index: 1;
}

/* ── Panel (Left Form) ───────────────────────────── */
.panel-form {
    width: var(--panel-w);
    min-width: 340px;
    max-width: var(--panel-w);
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    overflow: hidden;
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    flex-shrink: 0;
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.4);
}

/* ── Tab Bar ─────────────────────────────────────── */
.tab-bar {
    display: flex;
    gap: 2px;
    padding: 8px var(--sp-2) 0;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(0, 0, 0, 0.2);
    overflow-x: auto;
    scrollbar-width: none;
    flex-shrink: 0;
}

.tab-bar::-webkit-scrollbar {
    display: none;
}

.tab {
    position: relative;
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    white-space: nowrap;
    transition: color var(--transition), background var(--transition);
    letter-spacing: 0.2px;
}

.tab:hover {
    color: var(--text-secondary);
    background: var(--bg-hover);
}

.tab.active {
    color: var(--accent-primary);
    background: var(--bg-surface);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 8px;
    right: 8px;
    height: 2px;
    background: var(--accent-gradient);
    border-radius: 2px 2px 0 0;
}

/* ── Tab Panels ──────────────────────────────────── */
.tab-panel {
    display: none;
    flex-direction: column;
    gap: var(--sp-2);
    padding: var(--sp-2);
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-secondary) transparent;
}

.tab-panel::-webkit-scrollbar {
    width: 4px;
}

.tab-panel::-webkit-scrollbar-track {
    background: transparent;
}

.tab-panel::-webkit-scrollbar-thumb {
    background: var(--accent-secondary);
    border-radius: 4px;
}

.tab-panel.active {
    display: flex;
}

/* ── Form Elements ───────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.hint-inline {
    font-weight: 400;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0;
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="number"],
textarea {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13px;
    padding: 9px 12px;
    resize: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    width: 100%;
}

input[type="text"]:hover,
input[type="email"]:hover,
input[type="url"]:hover,
textarea:hover {
    border-color: var(--border);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(155, 48, 255, 0.12), 0 0 16px rgba(155, 48, 255, 0.08);
    background: rgba(155, 48, 255, 0.04);
}

textarea {
    resize: vertical;
    min-height: 72px;
    line-height: 1.5;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
    font-size: 13px;
}

/* Input with prefix */
.input-prefix {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input-prefix:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(155, 48, 255, 0.12);
}

.prefix {
    background: rgba(155, 48, 255, 0.1);
    border-right: 1px solid var(--border-subtle);
    padding: 9px 10px;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-accent);
    white-space: nowrap;
    flex-shrink: 0;
}

.input-prefix input {
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    flex: 1;
}

/* ── Card Section ─────────────────────────────────── */
.card-section {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--sp-2);
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.card-section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-accent);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

/* ── Options Section (GitHub Stats / Profile Options) */
.options-section {
    gap: 0;
    padding: 0;
    overflow: hidden;
}

.options-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: var(--sp-2);
    border-bottom: 1px solid var(--border-subtle);
}

.options-section-icon {
    font-size: 16px;
}

.options-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

/* ── PILL SLIDE TOGGLES ───────────────────────────── */
.slide-toggle-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.slide-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px var(--sp-2);
    cursor: pointer;
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition);
    gap: 8px;
}

.slide-toggle:nth-child(odd) {
    border-right: 1px solid var(--border-subtle);
}

.slide-toggle:hover {
    background: var(--bg-hover);
}

.slide-toggle-info {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.slide-toggle-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.slide-toggle-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Pill toggle switch */
.slide-toggle input[type="checkbox"] {
    display: none;
}

.slide-switch {
    position: relative;
    width: 32px;
    height: 18px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    flex-shrink: 0;
    transition: background var(--transition), border-color var(--transition);
    cursor: pointer;
}

.slide-switch::after {
    content: '';
    position: absolute;
    left: 2px;
    top: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform var(--transition), background var(--transition);
}

.slide-toggle input:checked+.slide-switch {
    background: rgba(155, 48, 255, 0.25);
    border-color: var(--accent-primary);
}

.slide-toggle input:checked+.slide-switch::after {
    transform: translateX(14px);
    background: var(--accent-primary);
    box-shadow: 0 0 8px rgba(155, 48, 255, 0.6);
}

/* ── Divider ──────────────────────────────────────── */
.divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 0;
}

/* ── Hint ─────────────────────────────────────────── */
.hint {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    padding: 8px 12px;
    background: rgba(155, 48, 255, 0.06);
    border-left: 2px solid var(--accent-secondary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ── Skills Grid ─────────────────────────────────── */
.skills-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.skill-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(155, 48, 255, 0.12);
    border: 1px solid rgba(155, 48, 255, 0.3);
    border-radius: var(--radius-pill);
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-accent);
    cursor: default;
    transition: all var(--transition);
}

.skill-tag:hover {
    background: rgba(155, 48, 255, 0.2);
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(155, 48, 255, 0.25);
}

.skill-tag button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    padding: 0;
    line-height: 1;
    transition: color var(--transition);
}

.skill-tag button:hover {
    color: var(--error);
}

/* Skill adder */
.skill-adder {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.skill-adder input {
    flex: 1;
}

/* Quick add chips */
.quick-skills {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.quick-skill-chip {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.quick-skill-chip:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    background: rgba(0, 212, 255, 0.08);
}

/* ── Projects ──────────────────────────────────────── */
.project-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--sp-2);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color var(--transition);
}

.project-card:hover {
    border-color: var(--border);
}

.project-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.project-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Badge Builder ─────────────────────────────────── */
.badge-color-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

input[type="color"] {
    width: 40px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    cursor: pointer;
}

.badge-preview-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    min-height: 52px;
}

.badge-preview-row img {
    max-height: 28px;
    border-radius: 4px;
}

.badge-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.badge-list-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-size: 12px;
}

.badge-list-item img {
    max-height: 20px;
}

.badge-list-item button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    transition: color var(--transition);
}

.badge-list-item button:hover {
    color: var(--error);
}

/* ── GIF Picker ─────────────────────────────────────── */
.gif-picker {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.gif-option {
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    padding: 0;
    cursor: pointer;
    background: var(--bg-card);
    overflow: hidden;
    aspect-ratio: 1;
    transition: all var(--transition);
}

.gif-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gif-option:hover {
    border-color: var(--accent-secondary);
    transform: scale(1.03);
}

.gif-option.active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 16px rgba(155, 48, 255, 0.45);
}

/* ── Sections Sortable ─────────────────────────────── */
.sections-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.section-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    cursor: grab;
    transition: all var(--transition);
    user-select: none;
}

.section-item:hover {
    border-color: var(--border);
    background: var(--bg-hover);
}

.section-item.sortable-ghost {
    opacity: 0.4;
    border-color: var(--accent-primary);
}

.section-item.sortable-chosen {
    cursor: grabbing;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.drag-handle {
    color: var(--text-muted);
    cursor: grab;
    font-size: 14px;
    user-select: none;
}

.section-toggle {
    display: flex;
    align-items: center;
}

.section-toggle input[type="checkbox"] {
    display: none;
}

.section-switch {
    width: 28px;
    height: 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    position: relative;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}

.section-switch::after {
    content: '';
    position: absolute;
    left: 2px;
    top: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform var(--transition), background var(--transition);
}

.section-toggle input:checked+.section-switch {
    background: rgba(155, 48, 255, 0.25);
    border-color: var(--accent-primary);
}

.section-toggle input:checked+.section-switch::after {
    transform: translateX(12px);
    background: var(--accent-primary);
}

.section-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    flex: 1;
}

/* ── RIGHT PANEL: Preview ──────────────────────────── */
.panel-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: rgba(5, 5, 12, 0.6);
    backdrop-filter: blur(12px);
    overflow: hidden;
}

/* Preview Header */
.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px var(--sp-3);
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

.preview-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border-radius: var(--radius-pill);
    padding: 3px;
}

.preview-tab {
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px 16px;
    border-radius: var(--radius-pill);
    transition: all var(--transition);
}

.preview-tab.active {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 2px 10px rgba(155, 48, 255, 0.4);
}

.preview-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Preview Body */
.preview-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-4);
    scrollbar-width: thin;
    scrollbar-color: var(--accent-secondary) transparent;
}

.preview-body::-webkit-scrollbar {
    width: 5px;
}

.preview-body::-webkit-scrollbar-track {
    background: transparent;
}

.preview-body::-webkit-scrollbar-thumb {
    background: var(--accent-secondary);
    border-radius: 4px;
}

.preview-body.hidden {
    display: none;
}

/* Markdown body render */
.markdown-body {
    max-width: 780px;
    margin: 0 auto;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
}

.markdown-body h1 {
    font-size: 2em;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.markdown-body h2 {
    font-size: 1.4em;
    font-weight: 700;
    margin: 28px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-accent);
}

.markdown-body h3 {
    font-size: 1.15em;
    font-weight: 600;
    margin: 20px 0 8px;
    color: var(--text-primary);
}

.markdown-body p {
    margin-bottom: 12px;
}

.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
}

.markdown-body a {
    color: var(--accent-cyan);
    text-decoration: none;
}

.markdown-body a:hover {
    text-decoration: underline;
}

.markdown-body code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    background: rgba(155, 48, 255, 0.1);
    border-radius: 4px;
    padding: 2px 6px;
    color: var(--accent-cyan);
}

.markdown-body pre {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    overflow-x: auto;
    margin-bottom: 16px;
}

.markdown-body pre code {
    background: none;
    padding: 0;
    color: #c9d1d9;
}

.markdown-body ul,
.markdown-body ol {
    padding-left: 24px;
    margin-bottom: 12px;
}

.markdown-body li {
    margin-bottom: 4px;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}

.markdown-body th {
    background: var(--bg-surface);
    font-weight: 700;
    color: var(--text-accent);
    padding: 10px 14px;
    text-align: left;
    border: 1px solid var(--border-subtle);
}

.markdown-body td {
    padding: 8px 14px;
    border: 1px solid var(--border-subtle);
}

.markdown-body blockquote {
    border-left: 3px solid var(--accent-primary);
    padding: 8px 16px;
    margin: 12px 0;
    background: var(--bg-hover);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
    font-style: italic;
}

.markdown-body hr {
    border: none;
    border-top: 1px solid var(--border-subtle);
    margin: 24px 0;
}

/* Raw view */
#raw-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    padding: 0;
}

.raw-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px var(--sp-3);
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 8px;
}

.raw-toolbar-label {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

.raw-toolbar-actions {
    display: flex;
    gap: 8px;
}

.raw-editor {
    flex: 1;
    background: var(--bg-base);
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.7;
    padding: var(--sp-3) var(--sp-4);
    resize: none;
    outline: none;
    width: 100%;
    height: 100%;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-secondary) transparent;
    tab-size: 2;
}

.raw-editor:focus {
    background: rgba(155, 48, 255, 0.02);
}

.raw-editor::selection {
    background: rgba(155, 48, 255, 0.25);
}

/* ── Toast ──────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: var(--sp-3);
    right: var(--sp-3);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: 12px 20px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), var(--accent-glow);
    z-index: 9999;
    transform: translateY(120%);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    max-width: 320px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

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

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

/* ── AI Tab Styles ──────────────────────────────────── */
.ai-panel-intro {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: var(--sp-2);
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.06), rgba(155, 48, 255, 0.06));
    border: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: var(--radius-lg);
}

.ai-panel-intro-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.ai-panel-intro-text h4 {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-cyan);
    margin-bottom: 4px;
}

.ai-panel-intro-text p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.readme-type-selector {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}

.readme-type-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-card);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
}

.readme-type-card:hover {
    border-color: var(--border);
}

.readme-type-card input[type="radio"] {
    display: none;
}

.readme-type-card.active,
.readme-type-card:has(input:checked) {
    border-color: var(--accent-primary);
    background: rgba(155, 48, 255, 0.08);
    box-shadow: 0 0 16px rgba(155, 48, 255, 0.15);
}

.readme-type-icon {
    font-size: 22px;
    flex-shrink: 0;
}

.readme-type-info {
    flex: 1;
}

.readme-type-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.readme-type-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* AI Output area */
.ai-output-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-output-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-output-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-accent);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.ai-output-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text-secondary);
    white-space: pre-wrap;
    max-height: 280px;
    overflow-y: auto;
    line-height: 1.6;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-secondary) transparent;
}

.ai-output-box.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    color: var(--text-muted);
    font-family: var(--font-body);
}

.ai-loading-spinner {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.spinner-ring {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .spinner-ring {
        animation: none;
    }
}

/* Apply AI button row */
.ai-apply-row {
    display: flex;
    gap: 8px;
}

/* mt utility */
.mt-8 {
    margin-top: 8px;
}

.mt-16 {
    margin-top: 16px;
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 768px) {
    :root {
        --panel-w: 100%;
    }

    .workspace {
        flex-direction: column;
    }

    .panel-form {
        width: 100%;
        max-width: 100%;
        min-width: unset;
        height: 50vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .panel-preview {
        height: 50vh;
    }

    .header-inner {
        padding: 0 var(--sp-2);
        gap: 8px;
    }

    .brand-name {
        font-size: 15px;
    }

    .gif-picker {
        grid-template-columns: repeat(4, 1fr);
    }

    .slide-toggle-list {
        grid-template-columns: 1fr;
    }

    .slide-toggle:nth-child(odd) {
        border-right: none;
    }

    .copy-raw-btn {
        right: var(--sp-2);
    }
}