/* ==========================================================================
   Minecraft Enchanting Calculator - Design System & Stylesheet
   Theme: Obsidian & Enchanting Amethyst / XP Neon
   ========================================================================== */

:root {
    /* Color Palette (Obsidian & Amethyst Dark Default) */
    --bg-base: #0a0b10;
    --bg-surface: #12131c;
    --bg-surface-elevated: #1a1b28;
    --bg-surface-hover: #222434;
    
    --border-subtle: #242738;
    --border-highlight: #3e4360;
    --border-focus: #7c3aed;
    
    --text-primary: #f1f3f9;
    --text-secondary: #9ea4be;
    --text-muted: #656b85;
    
    /* Minecraft Accents */
    --accent-purple: #9333ea;
    --accent-purple-glow: rgba(147, 51, 234, 0.25);
    --accent-amethyst: #c084fc;
    --accent-lapis: #38bdf8;
    --accent-xp: #4ade80;
    --accent-xp-glow: rgba(74, 222, 128, 0.25);
    --accent-gold: #fbbf24;
    --accent-red: #f43f5e;
    
    /* Layout & Spacing */
    --container-max: min(94vw, 1750px);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(124, 58, 237, 0.2);

    /* Dynamic Theme Overlays */
    --header-bg: rgba(10, 11, 16, 0.85);
    --body-bg-radial-1: rgba(124, 58, 237, 0.15);
    --body-bg-radial-2: rgba(56, 189, 248, 0.05);
}

/* Light Theme - Clean Daylight & High Contrast Accents */
[data-theme="light"] {
    --bg-base: #f4f5f8;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #f8fafc;
    --bg-surface-hover: #edf2f7;
    
    --border-subtle: #dbe1ea;
    --border-highlight: #b9c3d5;
    --border-focus: #7c3aed;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    
    --accent-purple: #7e22ce;
    --accent-purple-glow: rgba(126, 34, 206, 0.18);
    --accent-amethyst: #6b21a8;
    --accent-lapis: #0284c7;
    --accent-xp: #16a34a;
    --accent-xp-glow: rgba(22, 163, 74, 0.2);
    --accent-gold: #b45309;
    --accent-red: #e11d48;
    
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.04);
    --shadow-glow: 0 0 18px rgba(126, 34, 206, 0.12);

    --header-bg: rgba(255, 255, 255, 0.9);
    --body-bg-radial-1: rgba(126, 34, 206, 0.06);
    --body-bg-radial-2: rgba(2, 132, 199, 0.05);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
    background-image: 
        radial-gradient(ellipse at 50% -20%, var(--body-bg-radial-1), transparent 70%),
        radial-gradient(ellipse at 80% 80%, var(--body-bg-radial-2), transparent 60%);
    background-attachment: fixed;
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* Header */
.site-header {
    border-bottom: 1px solid var(--border-subtle);
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-fast);
}

.header-container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: padding var(--transition-fast);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    transition: gap var(--transition-fast);
}

.brand-rune {
    font-size: 1.8rem;
    color: var(--accent-amethyst);
    text-shadow: 0 0 12px var(--accent-purple);
    user-select: none;
    line-height: 1;
    transition: font-size var(--transition-fast);
}

.brand-title {
    font-family: 'Cinzel', serif;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-primary);
    transition: font-size var(--transition-fast);
}

.brand-subtitle {
    font-size: 0.78rem;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    transition: opacity var(--transition-fast), max-height var(--transition-fast), margin var(--transition-fast);
    overflow: hidden;
    max-height: 1.5rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

/* Scrolled Compact Header State */
.site-header.is-scrolled {
    box-shadow: var(--shadow-sm);
}

.site-header.is-scrolled .header-container {
    padding: 0.35rem 1.5rem;
}

.site-header.is-scrolled .brand {
    gap: 0.6rem;
}

.site-header.is-scrolled .brand-rune {
    font-size: 1.25rem;
}

.site-header.is-scrolled .brand-title {
    font-size: 1.05rem;
}

.site-header.is-scrolled .brand-subtitle {
    opacity: 0;
    max-height: 0;
    margin: 0;
    pointer-events: none;
}

.site-header.is-scrolled .header-actions {
    display: none;
}

/* Game Edition Switcher */
.edition-toggle-group {
    display: inline-flex;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.2rem;
    gap: 0.25rem;
}

.btn-edition {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.btn-edition.active {
    background: linear-gradient(180deg, rgba(56, 189, 248, 0.2), rgba(124, 58, 237, 0.12));
    border-color: var(--accent-lapis);
    color: var(--text-primary);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

.edition-icon {
    font-size: 0.95rem;
    line-height: 1;
}

.edition-label {
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.02em;
}

.version-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--accent-lapis);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
}

.btn-ghost {
    background: none;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-ghost:hover {
    border-color: var(--border-highlight);
    background: var(--bg-surface-hover);
}

/* Main Layout */
.main-container {
    max-width: var(--container-max);
    margin: 1.5rem auto;
    padding: 0 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
}

/* Card Foundations */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: border-color var(--transition-fast);
}

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

.card-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

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

.step-badge {
    background: linear-gradient(135deg, var(--accent-purple), #6d28d9);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.9rem;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 0 10px var(--accent-purple-glow);
}

.card-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.selected-count-badge {
    font-size: 0.8rem;
    font-family: 'JetBrains Mono', monospace;
    padding: 0.25rem 0.75rem;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    color: var(--accent-amethyst);
}

/* Optimization Mode Toggle */
.mode-toggle-group {
    display: inline-flex;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.25rem;
    gap: 0.35rem;
}

.btn-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.btn-toggle.active {
    background: linear-gradient(180deg, rgba(147, 51, 234, 0.2), rgba(124, 58, 237, 0.08));
    border-color: var(--accent-purple);
    color: var(--text-primary);
    box-shadow: 0 0 10px var(--accent-purple-glow);
}

/* Item Categories Grid */
.item-categories {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.65rem;
    margin-bottom: 1.25rem;
}

.item-btn {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 0.75rem 0.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.item-btn .item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-size: 1.4rem;
}

/* Authentic Pixel Art Rendering */
.pixel-icon {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    object-fit: contain;
    display: inline-block;
    vertical-align: middle;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
    transition: transform var(--transition-fast), filter var(--transition-fast);
}

.item-btn .pixel-icon {
    width: 32px;
    height: 32px;
}

.item-btn:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-highlight);
    color: var(--text-primary);
}

.item-btn:hover .pixel-icon {
    transform: scale(1.15) translateY(-2px);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.6));
}

.item-btn.active {
    background: linear-gradient(180deg, rgba(147, 51, 234, 0.15), rgba(124, 58, 237, 0.05));
    border-color: var(--accent-purple);
    color: var(--text-primary);
    box-shadow: 0 0 12px var(--accent-purple-glow);
}

.item-btn.active .pixel-icon {
    transform: scale(1.18);
    filter: drop-shadow(0 0 8px rgba(168, 85, 247, 0.75));
}

.item-chip .chip-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-right: 0.15rem;
}

/* Presets Strip */
.preset-strip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-subtle);
}

.preset-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-right: 0.25rem;
}

.btn-pill {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-pill:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    border-color: var(--border-highlight);
}

.btn-reset:hover {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

/* Starting Item State Accordion */
.starting-state-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-subtle);
}

.btn-accordion {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.9rem;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-accordion:hover {
    border-color: var(--border-highlight);
    background: var(--bg-surface-hover);
}

.accordion-left {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.accordion-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.accordion-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.starting-badge {
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.3);
    color: var(--accent-lapis);
    font-weight: 500;
}

.starting-badge.active {
    background: rgba(74, 222, 128, 0.15);
    border-color: rgba(74, 222, 128, 0.4);
    color: var(--accent-xp);
}

.accordion-chevron {
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

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

.starting-state-body {
    margin-top: 0.75rem;
    padding: 1rem;
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.starting-state-body.hidden {
    display: none;
}

.starting-state-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.starting-controls-grid {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
    min-width: 260px;
}

.form-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.select-field {
    padding: 0.45rem 0.75rem;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
}

.select-field:focus {
    outline: none;
    border-color: var(--accent-purple);
}

.starting-actions {
    display: flex;
    align-items: center;
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
}

.starting-enchants-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.starting-enchants-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.starting-enchants-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 0.5rem;
}

.starting-ench-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.7rem;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.starting-ench-card.active {
    border-color: var(--accent-lapis);
    background: rgba(56, 189, 248, 0.08);
}

.starting-ench-name {
    font-size: 0.82rem;
    color: var(--text-primary);
    font-weight: 500;
}

.starting-ench-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.badge-preexisting {
    font-size: 0.68rem;
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-sm);
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.35);
    color: var(--accent-lapis);
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    display: inline-block;
    margin-left: 0.35rem;
}

.complete-card {
    padding: 1.75rem;
    background: rgba(74, 222, 128, 0.08);
    border: 1px solid rgba(74, 222, 128, 0.3);
    border-radius: var(--radius-md);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.complete-icon {
    font-size: 2rem;
}

.complete-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-xp);
}

.complete-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    max-width: 550px;
}

/* Conflict Alert */
.conflict-alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.3);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    font-size: 0.85rem;
    color: #fecdd3;
}

.conflict-alert.hidden {
    display: none;
}

.alert-icon {
    font-size: 1.1rem;
}

/* Enchantment Grid */
.enchantment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.75rem;
}

.enchant-card {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all var(--transition-fast);
    user-select: none;
}

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

.enchant-card.active {
    background: rgba(147, 51, 234, 0.08);
    border-color: var(--accent-purple);
}

.enchant-card.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--bg-base);
}

.enchant-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.enchant-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.enchant-category {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.enchant-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.level-select {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    cursor: pointer;
}

.level-select:focus {
    outline: none;
    border-color: var(--border-focus);
}

.enchant-checkbox {
    width: 1.15rem;
    height: 1.15rem;
    accent-color: var(--accent-purple);
    cursor: pointer;
}

/* Rename Item Card in Desired Enchantments Grid */
.enchant-card.rename-card {
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.05);
}

.enchant-card.rename-card:hover {
    border-color: rgba(239, 68, 68, 0.8);
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.2);
    transform: translateY(-2px);
}

.enchant-card.rename-card.active {
    background: rgba(239, 68, 68, 0.12);
    border-color: #ef4444;
    box-shadow: 0 0 14px rgba(239, 68, 68, 0.3);
}

.rename-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.enchant-name.rename-name {
    color: #f87171;
    font-weight: 700;
}

.rename-fee-badge {
    background: rgba(239, 68, 68, 0.25);
    border: 1px solid rgba(239, 68, 68, 0.6);
    color: #fca5a5;
    font-size: 0.72rem;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: var(--radius-sm);
    letter-spacing: 0.02em;
}

.enchant-desc.rename-desc {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.rename-checkbox {
    accent-color: #ef4444 !important;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-box {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.text-xp {
    color: var(--accent-xp);
    text-shadow: 0 0 10px var(--accent-xp-glow);
}

.stat-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.badge-safe {
    color: var(--accent-xp);
}

.badge-danger {
    color: var(--accent-red);
}

/* Steps Container & Empty State */
.empty-state {
    padding: 3rem 1.5rem;
    text-align: center;
    background: var(--bg-surface-elevated);
    border: 1px dashed var(--border-subtle);
    border-radius: var(--radius-md);
}

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.8;
}

.empty-state h3 {
    font-size: 1.1rem;
    margin-bottom: 0.35rem;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 480px;
    margin: 0 auto;
}

.steps-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.steps-list.hidden {
    display: none;
}

#card-steps .card-collapse-body {
    background: var(--bg-base);
    border-top: 1px solid var(--border-subtle);
}

.step-card {
    background: linear-gradient(180deg, rgba(147, 51, 234, 0.16), rgba(26, 27, 40, 0.95));
    border: 1px solid var(--accent-purple);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1.25rem;
    box-shadow: 0 0 12px var(--accent-purple-glow);
    transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast), opacity var(--transition-fast), filter var(--transition-fast);
    cursor: pointer;
}

.step-card:hover {
    transform: translateX(4px);
    border-color: var(--accent-amethyst);
    box-shadow: 0 0 18px rgba(147, 51, 234, 0.45);
}

.step-num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-amethyst);
    background: rgba(147, 51, 234, 0.2);
    border: 1px solid rgba(147, 51, 234, 0.4);
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-details {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.step-formula {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.95rem;
    font-weight: 500;
}

.item-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-primary);
}

.item-chip.book {
    border-color: rgba(147, 51, 234, 0.4);
    color: var(--accent-amethyst);
}

.item-chip.tool {
    border-color: rgba(56, 189, 248, 0.4);
    color: var(--accent-lapis);
}

.step-operator {
    color: var(--text-muted);
    font-weight: 700;
}

.step-breakdown {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

/* Step-by-Step Rename Elements */
.step-rename-banner {
    background: rgba(239, 68, 68, 0.15);
    border-left: 3px solid #ef4444;
    color: #fca5a5;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.35rem 0.65rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin: 0.35rem 0 0.15rem 0;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.15);
}

.rename-fee-metric {
    color: #f87171 !important;
    font-weight: 600;
}

.step-rename-reminder {
    color: var(--accent-emerald, #34d399);
    font-size: 0.76rem;
    font-weight: 600;
    margin: 0.2rem 0;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.step-cost-box {
    text-align: right;
    display: flex;
    flex-direction: column;
}

.step-cost-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent-xp);
}

.step-cost-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Instructions Wrapper & View Controls Toolbar */
.instructions-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-top: 1.5rem;
}

.instructions-wrapper.hidden {
    display: none;
}

.view-controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.6rem 1rem;
}

.view-controls-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.controls-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.control-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.control-toggle-btn:hover {
    border-color: var(--border-highlight);
    color: var(--text-primary);
}

.control-toggle-btn.active {
    background: rgba(147, 51, 234, 0.15);
    border-color: var(--accent-amethyst);
    color: var(--text-primary);
}

.toggle-indicator {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
}

.control-toggle-btn.active .toggle-indicator {
    color: var(--accent-emerald);
}

.btn-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.82rem;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all var(--transition-fast);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border-color: var(--border-subtle);
}

.layout-toggle-group {
    display: inline-flex;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.15rem;
    gap: 0.15rem;
}

.btn-layout-opt {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    padding: 0.2rem 0.55rem;
    font-size: 0.76rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-layout-opt:hover {
    color: var(--text-primary);
}

.btn-layout-opt.active {
    background: rgba(147, 51, 234, 0.2);
    border-color: var(--accent-amethyst);
    color: var(--text-primary);
}

.expand-collapse-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

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

/* Collapsible Instruction Cards */
.instruction-card {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color var(--transition-fast);
}

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

.card-collapse-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.25rem;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    user-select: none;
}

.card-collapse-header:hover {
    background: rgba(255, 255, 255, 0.04);
}

.collapse-header-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.collapse-header-title h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.collapse-icon {
    font-size: 1.15rem;
}

.collapse-badge {
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    font-weight: 500;
}

.btn-collapse {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    width: 1.75rem;
    height: 1.75rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    font-weight: 700;
    transition: all var(--transition-fast);
}

.btn-collapse:hover {
    border-color: var(--border-highlight);
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.card-collapse-body {
    padding: 1.25rem;
    transition: all var(--transition-fast);
}

.instruction-card.collapsed .card-collapse-body {
    display: none;
}

.instruction-card.collapsed .card-collapse-header {
    border-bottom: none;
}

/* Visual Models Grid: Side-by-Side vs Stacked Layout Modes */
.visual-models-grid {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

@media (min-width: 1100px) {
    .visual-models-grid.layout-side-by-side {
        display: grid;
        grid-template-columns: minmax(320px, 420px) 1fr;
        gap: 1.25rem;
        align-items: start;
    }

    .visual-models-grid.layout-stacked {
        display: flex;
        flex-direction: column;
        gap: 1.25rem;
    }

    /* When in stacked layout, keep Compact View centered and comfortably sized */
    .visual-models-grid.layout-stacked #card-compact .compact-card {
        max-width: 650px;
        margin: 0 auto;
    }
}

/* Compact View Styles */
.compact-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.compact-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border-subtle);
}

.compact-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.compact-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.compact-levels-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(163, 230, 53, 0.12);
    border: 1px solid rgba(163, 230, 53, 0.3);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
}

.compact-levels-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.compact-levels-val {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--accent-xp);
}

.compact-grid {
    display: grid;
    grid-template-columns: minmax(130px, 1fr) repeat(var(--compact-stages, 3), 48px);
    gap: 6px;
    align-items: stretch;
}

.compact-row-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    min-height: 2.2rem;
    overflow: hidden;
}

.compact-row-item.is-base-item {
    background: rgba(56, 189, 248, 0.08);
    border-color: rgba(56, 189, 248, 0.3);
}

.compact-leaf-name {
    font-size: 0.8rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.compact-bracket {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--stage-bg, rgba(56, 189, 248, 0.18));
    border: 2px solid var(--stage-border, #38bdf8);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    padding: 0.25rem;
    user-select: none;
}

.compact-bracket:hover {
    filter: brightness(1.2);
    transform: scale(1.02);
}

.bracket-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    text-align: center;
}

.bracket-step-num {
    font-size: 0.65rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-muted);
    font-weight: 600;
}

.bracket-cost {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--stage-text, var(--text-primary));
}

.bracket-pwp {
    font-size: 0.65rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-muted);
}

.bracket-rename-badge {
    background: #ef4444;
    color: #ffffff;
    font-size: 0.55rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    padding: 0.08rem 0.35rem;
    border-radius: 3px;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
    margin: 1px 0;
    text-transform: uppercase;
    text-align: center;
    line-height: 1.1;
}

.bracket-done-check {
    font-size: 0.75rem;
    color: var(--accent-emerald);
    font-weight: 700;
}

.compact-bracket.completed {
    opacity: 0.45;
    filter: grayscale(0.6);
}

/* Workflow View Styles */
.workflow-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.workflow-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border-subtle);
}

.workflow-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.workflow-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

.workflow-canvas {
    overflow-x: auto;
    overflow-y: auto;
    padding: 1.25rem 0.5rem;
    display: flex;
    justify-content: safe center;
    scrollbar-width: thin;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    box-sizing: border-box;
    transition: min-height var(--transition-fast);
}

.wf-tree-wrapper {
    display: block;
    margin: 0 auto;
    position: relative;
    flex-shrink: 0;
}

.wf-tree-inner {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    min-width: max-content;
    transform-origin: top left;
    transition: transform var(--transition-fast);
}

/* Workflow Orientation Banner (Mobile Portrait) */
.wf-orientation-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    background: linear-gradient(135deg, rgba(147, 51, 234, 0.15), rgba(56, 189, 248, 0.08));
    border: 1px solid rgba(147, 51, 234, 0.35);
    border-radius: var(--radius-sm);
    animation: fadeIn 0.25s ease-out;
}

.wf-orientation-banner.hidden {
    display: none;
}

.wf-banner-left {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.wf-phone-icon {
    font-size: 1.25rem;
    display: inline-block;
    animation: rotatePhone 2.6s infinite ease-in-out;
}

@keyframes rotatePhone {
    0%, 15% { transform: rotate(0deg); }
    45%, 70% { transform: rotate(90deg); }
    90%, 100% { transform: rotate(0deg); }
}

.wf-banner-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.wf-banner-text strong {
    font-size: 0.8rem;
    color: var(--accent-amethyst);
}

.wf-banner-text span {
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.25;
}

.wf-banner-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.btn-wf-banner-zen {
    font-size: 0.72rem;
    padding: 0.25rem 0.6rem;
    background: var(--accent-purple);
    color: #ffffff !important;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.btn-wf-banner-zen:hover {
    background: var(--accent-amethyst);
}

.btn-wf-banner-dismiss {
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.15rem 0.35rem;
    color: var(--text-muted);
}

/* Fullscreen / Zen Flowchart Mode */
.workflow-card.is-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    z-index: 99999 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    margin: 0 !important;
    padding: 0.75rem !important;
    box-sizing: border-box !important;
    background: var(--bg-base) !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

.workflow-card.is-fullscreen .workflow-header {
    flex-shrink: 0;
    padding: 0.5rem 1rem;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.workflow-card.is-fullscreen .workflow-canvas {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: calc(100vh - 75px) !important;
    max-height: calc(100vh - 75px) !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    padding: 1rem 0.5rem 5rem 0.5rem !important;
    align-items: flex-start;
}

body.wf-fullscreen-active {
    overflow: hidden !important;
}

/* Inverted Tree Layout */
.wf-branch {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.wf-children {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    position: relative;
}

.wf-node {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.65rem;
    min-width: 110px;
    max-width: 150px;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.wf-node.is-base-item {
    border-color: rgba(56, 189, 248, 0.4);
    background: rgba(56, 189, 248, 0.06);
}

.wf-node-top {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.wf-node-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wf-node-enchants {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
}

.wf-ench-pill {
    font-size: 0.68rem;
    background: rgba(147, 51, 234, 0.15);
    color: var(--accent-amethyst);
    padding: 0.1rem 0.35rem;
    border-radius: 2px;
    white-space: nowrap;
}

.wf-node-meta {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

/* Connectors & Junctions */
.wf-junction {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0.5rem 0;
    position: relative;
    width: 100%;
}

.wf-fork-line {
    width: 60%;
    height: 12px;
    border-bottom: 2px solid var(--border-highlight);
    border-left: 2px solid var(--border-highlight);
    border-right: 2px solid var(--border-highlight);
    margin-bottom: 0;
    flex-shrink: 0;
}

.wf-fork-stem {
    width: 2px;
    height: 10px;
    background: var(--border-highlight);
    flex-shrink: 0;
}

.wf-step-pill {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--accent-amethyst);
    border-radius: 12px;
    padding: 0.2rem 0.55rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 600;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    margin: 2px 0;
    position: relative;
    z-index: 5;
}

.wf-step-pill:hover {
    transform: scale(1.05);
    border-color: var(--accent-xp);
}

.wf-step-badge {
    color: var(--accent-amethyst);
    font-weight: 700;
}

.wf-cost-badge {
    color: var(--accent-xp);
    font-family: 'JetBrains Mono', monospace;
}

.wf-pwp-badge {
    color: var(--text-muted);
    font-size: 0.65rem;
    font-family: 'JetBrains Mono', monospace;
}

.wf-stem-line {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 14px;
    color: var(--border-highlight);
    font-size: 0.85rem;
    line-height: 1;
    margin-top: 1px;
}

.wf-arrow-down {
    color: var(--accent-amethyst);
}

.wf-junction.completed, .wf-node.completed {
    opacity: 0.45;
    filter: grayscale(0.6);
}

.wf-done-check {
    color: var(--accent-emerald);
    font-weight: 700;
}

/* Workflow View Rename Elements */
.wf-rename-badge {
    background: rgba(239, 68, 68, 0.25);
    border: 1px solid #ef4444;
    color: #fca5a5;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 9999px;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    letter-spacing: 0.02em;
}

.wf-rename-tag {
    color: #f87171 !important;
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.wf-rename-confirmed {
    color: var(--accent-emerald, #34d399) !important;
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

/* Step-by-Step Checklist Styles */
.step-check-col {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.step-check-btn {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    border: 2px solid var(--border-highlight);
    background: var(--bg-surface);
    color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 700;
    transition: all var(--transition-fast);
    padding: 0;
}

.step-check-btn:hover {
    border-color: var(--accent-emerald);
}

.step-check-btn.checked {
    background: var(--accent-emerald);
    border-color: var(--accent-emerald);
    color: #000;
}

.step-card.completed {
    opacity: 0.38;
    filter: grayscale(0.85);
    background: rgba(18, 19, 28, 0.65);
    border-color: var(--border-subtle);
    box-shadow: none;
}

.step-card.completed:hover {
    opacity: 0.65;
    border-color: var(--border-highlight);
    box-shadow: none;
}

.step-card.completed .step-formula {
    text-decoration: line-through;
}

/* Stage Colors for Synchronized Selection Highlighting */
:root {
    --stage-1-color: #38bdf8;
    --stage-1-glow: rgba(56, 189, 248, 0.45);
    --stage-2-color: #34d399;
    --stage-2-glow: rgba(52, 211, 153, 0.45);
    --stage-3-color: #fbbf24;
    --stage-3-glow: rgba(251, 191, 36, 0.45);
    --stage-4-color: #f43f5e;
    --stage-4-glow: rgba(244, 63, 94, 0.45);
    --stage-5-color: #a855f7;
    --stage-5-glow: rgba(168, 85, 247, 0.45);
    --stage-6-color: #818cf8;
    --stage-6-glow: rgba(129, 140, 248, 0.45);
}

/* Cross-View Highlighting Glow */
.step-highlight {
    outline: 2px solid var(--accent-xp) !important;
    box-shadow: 0 0 14px var(--accent-xp-glow) !important;
    transform: scale(1.02);
    z-index: 10;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), outline-color var(--transition-fast);
}

.step-highlight[data-stage="1"] {
    outline-color: var(--stage-1-color) !important;
    box-shadow: 0 0 16px var(--stage-1-glow) !important;
}

.step-highlight[data-stage="2"] {
    outline-color: var(--stage-2-color) !important;
    box-shadow: 0 0 16px var(--stage-2-glow) !important;
}

.step-highlight[data-stage="3"] {
    outline-color: var(--stage-3-color) !important;
    box-shadow: 0 0 16px var(--stage-3-glow) !important;
}

.step-highlight[data-stage="4"] {
    outline-color: var(--stage-4-color) !important;
    box-shadow: 0 0 16px var(--stage-4-glow) !important;
}

.step-highlight[data-stage="5"] {
    outline-color: var(--stage-5-color) !important;
    box-shadow: 0 0 16px var(--stage-5-glow) !important;
}

.step-highlight[data-stage="6"] {
    outline-color: var(--stage-6-color) !important;
    box-shadow: 0 0 16px var(--stage-6-glow) !important;
}

.wf-step-pill.step-highlight {
    border-color: transparent !important;
}

.wf-step-pill.step-highlight[data-stage="1"] .wf-step-badge { color: var(--stage-1-color); }
.wf-step-pill.step-highlight[data-stage="2"] .wf-step-badge { color: var(--stage-2-color); }
.wf-step-pill.step-highlight[data-stage="3"] .wf-step-badge { color: var(--stage-3-color); }
.wf-step-pill.step-highlight[data-stage="4"] .wf-step-badge { color: var(--stage-4-color); }
.wf-step-pill.step-highlight[data-stage="5"] .wf-step-badge { color: var(--stage-5-color); }
.wf-step-pill.step-highlight[data-stage="6"] .wf-step-badge { color: var(--stage-6-color); }

/* Workflow Junction Connector Highlighting */
.wf-junction.step-highlight-junction .wf-fork-line {
    border-color: var(--accent-xp) !important;
    box-shadow: 0 0 10px var(--accent-xp-glow);
}
.wf-junction.step-highlight-junction .wf-fork-stem {
    background: var(--accent-xp) !important;
    box-shadow: 0 0 8px var(--accent-xp-glow);
}
.wf-junction.step-highlight-junction .wf-arrow-down {
    color: var(--accent-xp) !important;
    text-shadow: 0 0 8px var(--accent-xp-glow);
}

.wf-junction.step-highlight-junction[data-stage="1"] .wf-fork-line {
    border-color: var(--stage-1-color) !important;
    box-shadow: 0 0 12px var(--stage-1-glow);
}
.wf-junction.step-highlight-junction[data-stage="1"] .wf-fork-stem {
    background: var(--stage-1-color) !important;
    box-shadow: 0 0 10px var(--stage-1-glow);
}
.wf-junction.step-highlight-junction[data-stage="1"] .wf-arrow-down {
    color: var(--stage-1-color) !important;
    text-shadow: 0 0 8px var(--stage-1-glow);
}

.wf-junction.step-highlight-junction[data-stage="2"] .wf-fork-line {
    border-color: var(--stage-2-color) !important;
    box-shadow: 0 0 12px var(--stage-2-glow);
}
.wf-junction.step-highlight-junction[data-stage="2"] .wf-fork-stem {
    background: var(--stage-2-color) !important;
    box-shadow: 0 0 10px var(--stage-2-glow);
}
.wf-junction.step-highlight-junction[data-stage="2"] .wf-arrow-down {
    color: var(--stage-2-color) !important;
    text-shadow: 0 0 8px var(--stage-2-glow);
}

.wf-junction.step-highlight-junction[data-stage="3"] .wf-fork-line {
    border-color: var(--stage-3-color) !important;
    box-shadow: 0 0 12px var(--stage-3-glow);
}
.wf-junction.step-highlight-junction[data-stage="3"] .wf-fork-stem {
    background: var(--stage-3-color) !important;
    box-shadow: 0 0 10px var(--stage-3-glow);
}
.wf-junction.step-highlight-junction[data-stage="3"] .wf-arrow-down {
    color: var(--stage-3-color) !important;
    text-shadow: 0 0 8px var(--stage-3-glow);
}

.wf-junction.step-highlight-junction[data-stage="4"] .wf-fork-line {
    border-color: var(--stage-4-color) !important;
    box-shadow: 0 0 12px var(--stage-4-glow);
}
.wf-junction.step-highlight-junction[data-stage="4"] .wf-fork-stem {
    background: var(--stage-4-color) !important;
    box-shadow: 0 0 10px var(--stage-4-glow);
}
.wf-junction.step-highlight-junction[data-stage="4"] .wf-arrow-down {
    color: var(--stage-4-color) !important;
    text-shadow: 0 0 8px var(--stage-4-glow);
}

.wf-junction.step-highlight-junction[data-stage="5"] .wf-fork-line {
    border-color: var(--stage-5-color) !important;
    box-shadow: 0 0 12px var(--stage-5-glow);
}
.wf-junction.step-highlight-junction[data-stage="5"] .wf-fork-stem {
    background: var(--stage-5-color) !important;
    box-shadow: 0 0 10px var(--stage-5-glow);
}
.wf-junction.step-highlight-junction[data-stage="5"] .wf-arrow-down {
    color: var(--stage-5-color) !important;
    text-shadow: 0 0 8px var(--stage-5-glow);
}

.wf-junction.step-highlight-junction[data-stage="6"] .wf-fork-line {
    border-color: var(--stage-6-color) !important;
    box-shadow: 0 0 12px var(--stage-6-glow);
}
.wf-junction.step-highlight-junction[data-stage="6"] .wf-fork-stem {
    background: var(--stage-6-color) !important;
    box-shadow: 0 0 10px var(--stage-6-glow);
}
.wf-junction.step-highlight-junction[data-stage="6"] .wf-arrow-down {
    color: var(--stage-6-color) !important;
    text-shadow: 0 0 8px var(--stage-6-glow);
}

/* Vertical Drop Lines for shallower leaves / ingredients */
.wf-drop-line {
    width: 2px;
    flex-grow: 1;
    min-height: 0;
    background: var(--border-highlight);
    margin: 0 auto;
    transition: background var(--transition-fast), box-shadow var(--transition-fast);
}

.wf-drop-line.step-highlight-stem {
    background: var(--accent-xp) !important;
    box-shadow: 0 0 8px var(--accent-xp-glow);
}

.wf-drop-line.step-highlight-stem[data-stage="1"] {
    background: var(--stage-1-color) !important;
    box-shadow: 0 0 10px var(--stage-1-glow);
}

.wf-drop-line.step-highlight-stem[data-stage="2"] {
    background: var(--stage-2-color) !important;
    box-shadow: 0 0 10px var(--stage-2-glow);
}

.wf-drop-line.step-highlight-stem[data-stage="3"] {
    background: var(--stage-3-color) !important;
    box-shadow: 0 0 10px var(--stage-3-glow);
}

.wf-drop-line.step-highlight-stem[data-stage="4"] {
    background: var(--stage-4-color) !important;
    box-shadow: 0 0 10px var(--stage-4-glow);
}

.wf-drop-line.step-highlight-stem[data-stage="5"] {
    background: var(--stage-5-color) !important;
    box-shadow: 0 0 10px var(--stage-5-glow);
}

.wf-drop-line.step-highlight-stem[data-stage="6"] {
    background: var(--stage-6-color) !important;
    box-shadow: 0 0 10px var(--stage-6-glow);
}

/* Toggle Visibility Utilities */
.pwp-hidden, .levels-hidden {
    display: none !important;
}

/* Footer */
.site-footer {
    margin-top: auto;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    padding: 1.25rem 1.5rem;
    text-align: center;
}

.footer-disclaimer {
    font-size: 0.72rem;
    color: var(--text-muted);
    opacity: 0.85;
    line-height: 1.6;
    letter-spacing: 0.02em;
}

/* ==========================================================================
   Light Theme Component Refinements
   ========================================================================== */

[data-theme="light"] .card {
    background: var(--bg-surface);
    border-color: var(--border-subtle);
    box-shadow: var(--shadow-md);
}

[data-theme="light"] .card:hover {
    border-color: var(--border-highlight);
}

[data-theme="light"] .btn-ghost {
    border-color: var(--border-subtle);
    color: var(--text-secondary);
}

[data-theme="light"] .btn-ghost:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: var(--border-highlight);
    color: var(--text-primary);
}

[data-theme="light"] .edition-toggle-group {
    background: var(--bg-surface-elevated);
    border-color: var(--border-subtle);
}

[data-theme="light"] .btn-edition {
    color: var(--text-secondary);
}

[data-theme="light"] .btn-edition:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-primary);
}

[data-theme="light"] .btn-edition.active {
    background: linear-gradient(180deg, rgba(2, 132, 199, 0.12), rgba(126, 34, 206, 0.06));
    border-color: var(--accent-lapis);
    color: var(--accent-lapis);
    box-shadow: 0 1px 4px rgba(2, 132, 199, 0.15);
}

[data-theme="light"] .version-badge {
    background: var(--bg-surface-elevated);
    border-color: var(--border-subtle);
    color: var(--accent-lapis);
}

[data-theme="light"] .item-btn {
    background: var(--bg-surface);
    border-color: var(--border-subtle);
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
}

[data-theme="light"] .item-btn:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-highlight);
    color: var(--text-primary);
}

[data-theme="light"] .item-btn.active {
    background: linear-gradient(180deg, rgba(126, 34, 206, 0.1), rgba(126, 34, 206, 0.03));
    border-color: var(--accent-purple);
    color: var(--accent-purple);
    box-shadow: 0 2px 8px var(--accent-purple-glow);
}

[data-theme="light"] .item-btn .pixel-icon {
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.18));
}

[data-theme="light"] .item-btn:hover .pixel-icon {
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.25));
}

[data-theme="light"] .item-btn.active .pixel-icon {
    filter: drop-shadow(0 0 6px rgba(126, 34, 206, 0.45));
}

[data-theme="light"] .btn-pill {
    background: var(--bg-surface);
    border-color: var(--border-subtle);
    color: var(--text-secondary);
}

[data-theme="light"] .btn-pill:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-highlight);
    color: var(--text-primary);
}

[data-theme="light"] .btn-accordion {
    background: var(--bg-surface);
    border-color: var(--border-subtle);
}

[data-theme="light"] .btn-accordion:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-highlight);
}

[data-theme="light"] .starting-badge {
    background: rgba(2, 132, 199, 0.08);
    border-color: rgba(2, 132, 199, 0.25);
    color: var(--accent-lapis);
}

[data-theme="light"] .starting-badge.active {
    background: rgba(22, 163, 74, 0.1);
    border-color: rgba(22, 163, 74, 0.3);
    color: var(--accent-xp);
}

[data-theme="light"] .starting-state-body {
    background: var(--bg-surface-elevated);
    border-color: var(--border-subtle);
}

[data-theme="light"] .starting-ench-card {
    background: var(--bg-surface);
    border-color: var(--border-subtle);
}

[data-theme="light"] .starting-ench-card.active {
    border-color: var(--accent-lapis);
    background: rgba(2, 132, 199, 0.06);
}

[data-theme="light"] .mode-toggle-group {
    background: var(--bg-surface-elevated);
    border-color: var(--border-subtle);
}

[data-theme="light"] .btn-toggle {
    color: var(--text-secondary);
}

[data-theme="light"] .btn-toggle:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-primary);
}

[data-theme="light"] .btn-toggle.active {
    background: linear-gradient(180deg, rgba(126, 34, 206, 0.12), rgba(126, 34, 206, 0.04));
    border-color: var(--accent-purple);
    color: var(--accent-purple);
    box-shadow: 0 1px 4px rgba(126, 34, 206, 0.15);
}

[data-theme="light"] .enchant-card {
    background: var(--bg-surface);
    border-color: var(--border-subtle);
    box-shadow: var(--shadow-sm);
}

[data-theme="light"] .enchant-card:hover {
    border-color: var(--border-highlight);
    background: var(--bg-surface-elevated);
}

[data-theme="light"] .enchant-card.active {
    background: rgba(126, 34, 206, 0.05);
    border-color: var(--accent-purple);
}

[data-theme="light"] .enchant-card.disabled {
    background: var(--bg-surface-elevated);
    opacity: 0.5;
}

[data-theme="light"] .level-select {
    background: var(--bg-surface);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}

[data-theme="light"] .conflict-alert {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #9f1239;
}

[data-theme="light"] .enchant-card.rename-card {
    border-color: rgba(225, 29, 72, 0.25);
    background: rgba(225, 29, 72, 0.03);
}

[data-theme="light"] .enchant-card.rename-card:hover {
    border-color: rgba(225, 29, 72, 0.6);
    box-shadow: 0 2px 8px rgba(225, 29, 72, 0.1);
}

[data-theme="light"] .enchant-card.rename-card.active {
    background: rgba(225, 29, 72, 0.08);
    border-color: #e11d48;
}

[data-theme="light"] .enchant-name.rename-name {
    color: #be123c;
}

[data-theme="light"] .rename-fee-badge {
    background: rgba(225, 29, 72, 0.12);
    border-color: rgba(225, 29, 72, 0.35);
    color: #9f1239;
}

[data-theme="light"] .stat-box {
    background: var(--bg-surface);
    border-color: var(--border-subtle);
    box-shadow: var(--shadow-sm);
}

[data-theme="light"] .text-xp {
    text-shadow: none;
}

[data-theme="light"] .empty-state {
    background: var(--bg-surface);
    border-color: var(--border-subtle);
}

[data-theme="light"] .complete-card {
    background: rgba(22, 163, 74, 0.08);
    border-color: rgba(22, 163, 74, 0.3);
}

[data-theme="light"] #card-steps .card-collapse-body {
    background: #edf1f7;
    border-top: 1px solid var(--border-subtle);
}

[data-theme="light"] .step-card {
    background: linear-gradient(180deg, #ffffff, rgba(243, 232, 255, 0.7));
    border: 1px solid var(--accent-purple);
    box-shadow: 0 2px 10px var(--accent-purple-glow);
}

[data-theme="light"] .step-card:hover {
    border-color: var(--accent-purple);
    box-shadow: 0 4px 16px rgba(126, 34, 206, 0.25);
}

[data-theme="light"] .step-card.completed {
    background: rgba(255, 255, 255, 0.6);
    border-color: var(--border-subtle);
    box-shadow: none;
    opacity: 0.42;
    filter: grayscale(0.85);
}

[data-theme="light"] .step-card.completed:hover {
    opacity: 0.65;
    border-color: var(--border-highlight);
    box-shadow: none;
}

[data-theme="light"] .step-num {
    background: rgba(126, 34, 206, 0.1);
    border: 1px solid rgba(126, 34, 206, 0.3);
    color: var(--accent-purple);
}

[data-theme="light"] .item-chip {
    background: var(--bg-surface-elevated);
    border-color: var(--border-subtle);
}

[data-theme="light"] .item-chip.book {
    border-color: rgba(126, 34, 206, 0.3);
    color: var(--accent-amethyst);
}

[data-theme="light"] .item-chip.tool {
    border-color: rgba(2, 132, 199, 0.3);
    color: var(--accent-lapis);
}

[data-theme="light"] .step-rename-banner {
    background: #fff1f2;
    border-left-color: #e11d48;
    color: #9f1239;
    box-shadow: 0 1px 4px rgba(225, 29, 72, 0.08);
}

[data-theme="light"] .rename-fee-metric {
    color: #be123c !important;
}

[data-theme="light"] .step-rename-reminder {
    color: #15803d;
}

[data-theme="light"] .view-controls-bar {
    background: var(--bg-surface);
    border-color: var(--border-subtle);
    box-shadow: var(--shadow-sm);
}

[data-theme="light"] .layout-toggle-group {
    background: var(--bg-surface-elevated);
    border-color: var(--border-subtle);
}

[data-theme="light"] .btn-layout-opt:hover {
    color: var(--text-primary);
}

[data-theme="light"] .btn-layout-opt.active {
    background: rgba(126, 34, 206, 0.12);
    border-color: var(--accent-purple);
    color: var(--accent-purple);
}

[data-theme="light"] .instruction-card {
    background: var(--bg-surface);
    border-color: var(--border-subtle);
    box-shadow: var(--shadow-sm);
}

[data-theme="light"] .card-collapse-header {
    background: rgba(0, 0, 0, 0.015);
    border-bottom-color: var(--border-subtle);
}

[data-theme="light"] .card-collapse-header:hover {
    background: rgba(0, 0, 0, 0.035);
}

[data-theme="light"] .collapse-badge {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
}

[data-theme="light"] .btn-collapse {
    background: rgba(0, 0, 0, 0.04);
    border-color: var(--border-subtle);
}

[data-theme="light"] .btn-collapse:hover {
    background: rgba(0, 0, 0, 0.08);
    border-color: var(--border-highlight);
    color: var(--text-primary);
}

[data-theme="light"] .compact-card {
    background: transparent;
}

[data-theme="light"] .compact-header {
    border-bottom-color: var(--border-subtle);
}

[data-theme="light"] .compact-row-item {
    background: var(--bg-surface-elevated);
    border-color: var(--border-subtle);
}

[data-theme="light"] .compact-row-item.is-base-item {
    background: rgba(2, 132, 199, 0.08);
    border-color: rgba(2, 132, 199, 0.3);
}

[data-theme="light"] .compact-bracket {
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .compact-bracket:hover {
    box-shadow: 0 3px 8px rgba(15, 23, 42, 0.12);
}

[data-theme="light"] .compact-bracket .bracket-cost {
    color: var(--text-primary);
}

[data-theme="light"] .wf-node {
    background: var(--bg-surface);
    border-color: var(--border-subtle);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .wf-node.is-base-item {
    border-color: rgba(2, 132, 199, 0.4);
    background: rgba(2, 132, 199, 0.05);
}

[data-theme="light"] .wf-ench-pill {
    background: rgba(126, 34, 206, 0.1);
    color: var(--accent-amethyst);
}

[data-theme="light"] .wf-fork-line {
    border-color: var(--border-highlight);
}

[data-theme="light"] .wf-fork-stem {
    background: var(--border-highlight);
}

[data-theme="light"] .wf-drop-line {
    background: var(--border-highlight);
}

[data-theme="light"] .wf-step-pill {
    background: #ffffff;
    border-color: var(--accent-purple);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.1);
}

[data-theme="light"] .wf-step-badge {
    color: var(--accent-purple);
}

[data-theme="light"] .wf-cost-badge {
    color: var(--accent-xp);
}

[data-theme="light"] .site-footer {
    background: var(--bg-surface);
    border-top-color: var(--border-subtle);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .site-header.is-scrolled .header-container {
        flex-direction: row;
        align-items: center;
        padding: 0.35rem 1rem;
        gap: 0;
    }
    .header-actions {
        width: 100%;
        justify-content: space-between;
    }
    .card-header-flex {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .mode-toggle-group {
        width: 100%;
    }
    .btn-toggle {
        flex: 1;
        justify-content: center;
    }
    .step-card {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    .step-cost-box {
        text-align: left;
    }

    /* Mobile Workflow Diagram Optimizations */
    #card-workflow.instruction-card {
        padding: 0.75rem 0.5rem;
    }
    .workflow-header {
        flex-wrap: wrap;
        gap: 0.4rem;
    }
    .workflow-header-left {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
    }
    .workflow-sub {
        display: none; /* Save header space on mobile */
    }
    .workflow-canvas {
        padding: 0.75rem 0.2rem;
    }
    .wf-children {
        gap: 0.75rem;
    }
    .wf-node {
        min-width: 95px;
        max-width: 135px;
        padding: 0.35rem 0.5rem;
        gap: 0.2rem;
    }
    .wf-node-title {
        font-size: 0.74rem;
    }
    .wf-ench-pill {
        font-size: 0.64rem;
        padding: 0.08rem 0.25rem;
    }
    .wf-step-pill {
        font-size: 0.68rem;
        padding: 0.15rem 0.45rem;
    }
    .wf-pwp-badge {
        display: none; /* Hide verbose breakdown on mobile tree to save space */
    }
}

/* Very narrow phones (<= 480px) */
@media (max-width: 480px) {
    .workflow-header .wf-btn-label {
        display: none; /* Icon only for buttons to avoid header wrap */
    }
    .wf-orientation-banner {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .wf-banner-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* Mobile Landscape Orientation Real-Estate Maximizer */
@media (max-height: 520px) and (orientation: landscape) {
    .site-header {
        position: relative !important;
    }
    .site-header .header-container {
        padding: 0.25rem 1rem;
    }
    .brand-subtitle {
        display: none;
    }
    #card-workflow.instruction-card {
        margin: 0.25rem 0;
        padding: 0.5rem;
    }
    .workflow-canvas {
        padding: 0.5rem 0.25rem;
    }
    .workflow-card.is-fullscreen {
        padding: 0.25rem 0.5rem !important;
    }
    .workflow-card.is-fullscreen .workflow-header {
        padding: 0.35rem 0.75rem;
    }
    .workflow-card.is-fullscreen .workflow-canvas {
        height: calc(100vh - 55px) !important;
        max-height: calc(100vh - 55px) !important;
        padding: 0.5rem 0.25rem 5rem 0.25rem !important;
        overflow-x: auto !important;
        overflow-y: auto !important;
    }
}
