/* ===================================================================
   Sazandeha Design System (Multi-Theme & Component System)
   Persian RTL-First, Maker Workbench Identity, 4 Selectable Themes
   Theme 01 Redesign: Light Industrial Cutting-Mat & Floating Panels
   =================================================================== */

@import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');

/* -------------------------------------------------------------------
   1. Shared Design Tokens (Spacing, Radii, Typography)
   ------------------------------------------------------------------- */
:root {
    /* Global Layout Dimensions */
    --navbar-height: 64px;
    --homepage-edge-gap: var(--space-4); /* 16px: exact match with header-container padding */
    --homepage-column-gap: var(--space-6); /* 24px: consistent column separation */
    --homepage-sidebar-width: 340px; /* controlled readable hero sidebar width */

    /* Spacing Scale (8pt Grid) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;

    /* Border Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;

    /* Typography */
    --font-sans: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

/* -------------------------------------------------------------------
   Accessible Skip-Link Utility (Visually hidden until focused)
   ------------------------------------------------------------------- */
.skip-link,
.sr-only:not(:focus):not(:focus-visible) {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border-width: 0 !important;
}

.skip-link:focus,
.skip-link:focus-visible {
    position: fixed !important;
    top: var(--space-4) !important;
    right: var(--space-4) !important;
    width: auto !important;
    height: auto !important;
    padding: var(--space-2) var(--space-4) !important;
    margin: 0 !important;
    overflow: visible !important;
    clip: auto !important;
    clip-path: none !important;
    white-space: normal !important;
    z-index: 10000 !important;
    background-color: var(--primary) !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    border-radius: var(--radius-md) !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25) !important;
    outline: 2px solid var(--primary-hover) !important;
    text-decoration: none !important;
}

/* -------------------------------------------------------------------
   Theme 1: light-industrial (Redesigned Maker Cutting-Mat Workbench)
   Mood: Warm concrete, desaturated industrial green, restrained copper.
   Floating precision work panels on an authentic cutting mat.
   ------------------------------------------------------------------- */
:root,
html[data-theme="light-industrial"] {
    --bg-app: #F1EFE8;
    --bg-subtle: #E8E5DC;
    --surface: #FFFDF8;
    --surface-2: #F5F5EF;
    --surface-elevated: #FFFFFF;
    --text-primary: #1C2927;
    --text-secondary: #52635F;
    --text-muted: #647570;
    --border-subtle: #C9D2C9;
    --border-strong: #91AA9F;
    --primary: #176B61;
    --primary-hover: #11564E;
    --primary-active: #0D453E;
    --primary-contrast: #FFFFFF;
    --accent: #B45C32;
    --accent-2: #BD935C;
    --success: #24734F;
    --warning: #98630C;
    --danger: #B43E38;
    --info: #285B96;
    --focus-ring: rgba(23, 107, 97, 0.35);

    /* Diffused gray-green soft elevation shadows */
    --shadow-sm: 0 1px 3px rgba(28, 41, 39, 0.05), 0 1px 2px rgba(28, 41, 39, 0.03);
    --shadow-md: 0 4px 16px rgba(28, 41, 39, 0.07), 0 2px 4px rgba(28, 41, 39, 0.04);
    --shadow-lg: 0 12px 28px rgba(28, 41, 39, 0.10), 0 4px 8px rgba(28, 41, 39, 0.05);

    /* Cutting Mat Grid Specifics (28px Minor Green + 140px Major Copper) - Subtle workbench contrast */
    --grid-minor: rgba(123, 156, 145, 0.11);
    --grid-major: rgba(189, 147, 92, 0.12);
    --card-glow: rgba(23, 107, 97, 0.06);
    --hero-pattern: radial-gradient(circle at 50% 0%, rgba(23, 107, 97, 0.05) 0%, transparent 70%);

    /* Backward compatibility aliases */
    --color-canvas-bg: var(--bg-app);
    --color-surface-bg: var(--surface);
    --color-surface-hover: var(--surface-2);
    --color-elevated-bg: var(--surface-elevated);
    --color-border-subtle: var(--border-subtle);
    --color-border-strong: var(--border-strong);
    --color-text-primary: var(--text-primary);
    --color-text-secondary: var(--text-secondary);
    --color-text-muted: var(--text-muted);
    --color-brand-cyan: var(--primary);
    --color-brand-hover: var(--primary-hover);
    --color-brand-glow: var(--card-glow);
    --color-success: var(--success);
    --color-warning: var(--warning);
    --color-danger: var(--danger);
    --shadow-subtle: var(--shadow-sm);
    --shadow-card: var(--shadow-md);
}

/* -------------------------------------------------------------------
   Theme 2: professional-workshop (Preserved without changes)
   Mood: maker-workshop, tactile, distinctive, branded green-slate
   ------------------------------------------------------------------- */
html[data-theme="professional-workshop"] {
    --bg-app: #EEF3ED;
    --bg-subtle: #E1EADF;
    --surface: #FCFFFC;
    --surface-2: #F3F8F2;
    --surface-elevated: #FFFFFF;
    --text-primary: #223127;
    --text-secondary: #4A5D50;
    --text-muted: #708070;
    --border-subtle: #C9D8C9;
    --border-strong: #AFC4AF;
    --primary: #207567;
    --primary-hover: #185E52;
    --primary-active: #12493F;
    --primary-contrast: #FFFFFF;
    --accent: #D9B949;
    --accent-2: #6F8F72;
    --success: #2B9348;
    --warning: #D98E04;
    --danger: #C44536;
    --info: #277DA1;
    --focus-ring: rgba(32, 117, 103, 0.4);
    --shadow-sm: 0 1px 3px rgba(34, 49, 39, 0.06);
    --shadow-md: 0 4px 14px rgba(34, 49, 39, 0.09);
    --shadow-lg: 0 12px 28px rgba(34, 49, 39, 0.13);
    --hero-pattern: radial-gradient(circle at 50% 0%, rgba(32, 117, 103, 0.11) 0%, transparent 75%);
    --grid-line: rgba(32, 117, 103, 0.06);
    --grid-minor: rgba(32, 117, 103, 0.08);
    --grid-major: rgba(26, 77, 68, 0.11);
    --card-glow: rgba(32, 117, 103, 0.12);

    --color-canvas-bg: var(--bg-app);
    --color-surface-bg: var(--surface);
    --color-surface-hover: var(--surface-2);
    --color-elevated-bg: var(--surface-elevated);
    --color-border-subtle: var(--border-subtle);
    --color-border-strong: var(--border-strong);
    --color-text-primary: var(--text-primary);
    --color-text-secondary: var(--text-secondary);
    --color-text-muted: var(--text-muted);
    --color-brand-cyan: var(--primary);
    --color-brand-hover: var(--primary-hover);
    --color-brand-glow: var(--card-glow);
    --color-success: var(--success);
    --color-warning: var(--warning);
    --color-danger: var(--danger);
    --shadow-subtle: var(--shadow-sm);
    --shadow-card: var(--shadow-md);
}

/* -------------------------------------------------------------------
   Theme 3: modern-soft (Preserved without changes)
   Mood: modern, minimal, polished, startup-like, soft light UI
   ------------------------------------------------------------------- */
html[data-theme="modern-soft"] {
    --bg-app: #F6F8FB;
    --bg-subtle: #EEF2F7;
    --surface: #FFFFFF;
    --surface-2: #F8FAFC;
    --surface-elevated: #FFFFFF;
    --text-primary: #1F2A37;
    --text-secondary: #52606D;
    --text-muted: #8A94A6;
    --border-subtle: #E5EAF1;
    --border-strong: #CBD5E1;
    --primary: #2F80ED;
    --primary-hover: #2568C7;
    --primary-active: #1C4FA1;
    --primary-contrast: #FFFFFF;
    --accent: #14B8A6;
    --accent-2: #F4B740;
    --success: #16A34A;
    --warning: #F59E0B;
    --danger: #DC2626;
    --info: #0EA5E9;
    --focus-ring: rgba(47, 128, 237, 0.4);
    --shadow-sm: 0 1px 3px rgba(31, 42, 55, 0.05);
    --shadow-md: 0 4px 14px rgba(31, 42, 55, 0.08);
    --shadow-lg: 0 10px 24px rgba(31, 42, 55, 0.12);
    --hero-pattern: radial-gradient(circle at 50% 0%, rgba(47, 128, 237, 0.09) 0%, transparent 70%);
    --grid-line: rgba(47, 128, 237, 0.04);
    --grid-minor: rgba(47, 128, 237, 0.05);
    --grid-major: rgba(37, 99, 235, 0.08);
    --card-glow: rgba(47, 128, 237, 0.1);

    --color-canvas-bg: var(--bg-app);
    --color-surface-bg: var(--surface);
    --color-surface-hover: var(--surface-2);
    --color-elevated-bg: var(--surface-elevated);
    --color-border-subtle: var(--border-subtle);
    --color-border-strong: var(--border-strong);
    --color-text-primary: var(--text-primary);
    --color-text-secondary: var(--text-secondary);
    --color-text-muted: var(--text-muted);
    --color-brand-cyan: var(--primary);
    --color-brand-hover: var(--primary-hover);
    --color-brand-glow: var(--card-glow);
    --color-success: var(--success);
    --color-warning: var(--warning);
    --color-danger: var(--danger);
    --shadow-subtle: var(--shadow-sm);
    --shadow-card: var(--shadow-md);
}

/* -------------------------------------------------------------------
   Theme 4: dark-maker (Preserved without changes)
   Mood: dark, focused, technical, refined, maker-night mode
   ------------------------------------------------------------------- */
html[data-theme="dark-maker"] {
    --bg-app: #0D1117;
    --bg-subtle: #111827;
    --surface: #161B22;
    --surface-2: #1C2330;
    --surface-elevated: #1F2937;
    --text-primary: #E5EDF5;
    --text-secondary: #B7C3D0;
    --text-muted: #8B98A8;
    --border-subtle: #2C3A4B;
    --border-strong: #3C4B5D;
    --primary: #2DD4BF;
    --primary-hover: #21B8A5;
    --primary-active: #179586;
    --primary-contrast: #091E1B;
    --accent: #E7D14A;
    --accent-2: #60A5FA;
    --success: #22C55E;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #38BDF8;
    --focus-ring: rgba(45, 212, 191, 0.4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.65);
    --hero-pattern: radial-gradient(circle at 50% 0%, rgba(45, 212, 191, 0.1) 0%, transparent 70%);
    --grid-line: rgba(45, 212, 191, 0.05);
    --grid-minor: rgba(45, 212, 191, 0.05);
    --grid-major: rgba(45, 212, 191, 0.09);
    --card-glow: rgba(45, 212, 191, 0.15);

    --color-canvas-bg: var(--bg-app);
    --color-surface-bg: var(--surface);
    --color-surface-hover: var(--surface-2);
    --color-elevated-bg: var(--surface-elevated);
    --color-border-subtle: var(--border-subtle);
    --color-border-strong: var(--border-strong);
    --color-text-primary: var(--text-primary);
    --color-text-secondary: var(--text-secondary);
    --color-text-muted: var(--text-muted);
    --color-brand-cyan: var(--primary);
    --color-brand-hover: var(--primary-hover);
    --color-brand-glow: var(--card-glow);
    --color-success: var(--success);
    --color-warning: var(--warning);
    --color-danger: var(--danger);
    --shadow-subtle: var(--shadow-sm);
    --shadow-card: var(--shadow-md);
}

/* -------------------------------------------------------------------
   2. Base Reset & Full-Page Cutting-Mat Background
   ------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    direction: rtl;
    text-align: start;
    font-size: 16px;
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    scroll-behavior: smooth;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Universal Full-Page Cutting-Mat & Workshop Grid Background across all 4 themes */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-app);
    color: var(--text-primary);
    overflow-x: hidden;
    transition: background-color 0.2s ease, color 0.2s ease;

    /* Universal 28px Minor Grid + 140px Major Grid Lines */
    background-image: 
        linear-gradient(to right, var(--grid-major) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-major) 1px, transparent 1px),
        linear-gradient(to right, var(--grid-minor) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-minor) 1px, transparent 1px);
    background-size: 
        140px 140px,
        140px 140px,
        28px 28px,
        28px 28px;
    background-position: 0 0;
    background-attachment: fixed;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.15s ease-in-out, border-color 0.15s ease;
}

a:hover {
    color: var(--primary-hover);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Accessible focus ring for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--primary) !important;
    outline-offset: 2px !important;
}

/* -------------------------------------------------------------------
   3. Layout Container
   ------------------------------------------------------------------- */
.container {
    width: 100%;
    max-width: 1240px;
    margin-inline: auto;
    padding-inline: var(--space-4);
}

@media (min-width: 768px) {
    .container {
        padding-inline: var(--space-6);
    }
}

/* Homepage Full-Width Layout Container (Uses available viewport width) */
.homepage-container {
    width: 100%;
    max-width: 100%;
    margin-inline: 0;
    padding-inline: var(--homepage-edge-gap);
    box-sizing: border-box;
}

/* -------------------------------------------------------------------
   4. Header & Navigation Bar
   Polished, consistent GitHub-inspired navigation adapted for Persian RTL
   ------------------------------------------------------------------- */
.site-header {
    background-color: var(--surface);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
    box-shadow: 0 1px 4px rgba(28, 41, 39, 0.04);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.site-header .header-container,
.header-container,
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 100%;
    margin-inline: 0;
    padding-inline: var(--space-4);
    min-height: var(--navbar-height, 64px);
    gap: var(--space-4);
    padding-block: var(--space-2);
    box-sizing: border-box;
}

/* -------------------------------------------------------------------
   Desktop (>= 1024px): Symmetrical 3-Region Layout with Viewport Centered Center (Change 4)
   ------------------------------------------------------------------- */
@media (min-width: 1024px) {
    .site-header .header-container,
    .header-container {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        justify-content: normal;
        gap: var(--space-4);
        padding-inline: var(--space-4);
        width: 100%;
        max-width: 100%;
        margin-inline: 0;
        box-sizing: border-box;
    }

    .header-section-start {
        justify-self: start;
        display: flex;
        align-items: center;
        gap: var(--space-3);
    }

    .header-section-center {
        justify-self: center;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        max-width: 560px;
        margin-inline: auto;
    }

    .header-section-end {
        justify-self: end;
        display: flex;
        align-items: center;
        gap: var(--space-3);
    }

    .header-search-box {
        width: 100%;
        max-width: 560px;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .site-header .header-container,
    .header-container {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-2);
        padding-inline: var(--space-3);
    }

    .header-section-start,
    .header-section-end {
        min-width: 0;
        flex-shrink: 0;
        gap: var(--space-2);
    }

    .header-section-center {
        display: flex;
        align-items: center;
        gap: var(--space-2);
        flex: 1 1 0%;
        min-width: 0;
        max-width: 280px;
        justify-content: center;
        margin-inline: 0;
    }

    .header-search-box {
        flex: 1 1 0%;
        min-width: 0;
    }

    .user-account-name {
        max-width: 96px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (max-width: 1199px) {
    .header-nav-link.header-nav-link-knowledge,
    .header-nav-link-knowledge {
        display: none !important; /* Preserved and accessible inside the main-nav hamburger dropdown */
    }
}

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

/* Right Section (Start in RTL) */
.header-section-start {
    gap: var(--space-3);
    flex-shrink: 0;
}

/* Brand Logo & Text */
.navbar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    white-space: nowrap;
    text-decoration: none;
    flex-shrink: 0;
    transition: color 0.15s ease;
}

.brand-text-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.2;
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 900;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    transition: color 0.15s ease;
}

.brand-subtitle {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0;
    transition: color 0.15s ease;
}

.header-brand-link:hover .brand-title {
    color: var(--primary);
}

.header-brand-link:hover .brand-subtitle {
    color: var(--text-secondary);
}

.navbar-brand:hover {
    color: var(--primary);
}

.brand-badge {
    background-color: var(--primary);
    color: var(--primary-contrast);
    font-size: 0.72rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    letter-spacing: 0.5px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Visible Projects link */
.header-nav-link {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s ease, background-color 0.15s ease;
    white-space: nowrap;
}

.header-nav-link:hover,
.header-nav-link.active {
    color: var(--primary);
    background-color: var(--surface-2);
}

.header-nav-link:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Center Section: Global Project Search */
.header-section-center {
    flex: 1;
    max-width: 440px;
    min-width: 160px;
}

.header-search-box,
.navbar-search {
    width: 100%;
}

.header-search-form,
.navbar-search form {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.search-icon-prefix {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-search-input,
.search-input {
    width: 100%;
    height: 38px;
    padding-block: 6px;
    padding-right: 36px;
    padding-left: 72px;
    background-color: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    transition: all 0.18s ease;
}

.header-search-input::placeholder,
.search-input::placeholder {
    color: var(--text-muted);
    font-size: 0.84rem;
}

.header-search-input:hover,
.search-input:hover {
    border-color: var(--border-strong);
    background-color: var(--surface);
}

.header-search-input:focus,
.search-input:focus {
    outline: none;
    border-color: var(--primary);
    background-color: var(--surface);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.search-kbd-hint {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 4px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    background-color: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    pointer-events: none;
    user-select: none;
}

/* Left Section: Switcher & Auth */
.header-section-end,
.navbar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
}

/* Compact Icon Buttons */
.header-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background-color: var(--surface-2);
    color: var(--text-primary);
    cursor: pointer;
    padding: 0;
    transition: all 0.15s ease;
}

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

.header-icon-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Authenticated User Account Menu Button */
.main-menu-wrapper,
.user-account-wrapper {
    position: relative;
}

.user-account-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    height: 38px;
    padding: 4px 10px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    background-color: var(--surface);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.user-account-btn:hover {
    border-color: var(--primary);
    background-color: var(--surface-2);
}

.user-account-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.user-avatar-badge {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background-color: var(--primary);
    color: var(--primary-contrast);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
}

.user-account-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-chevron {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

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

/* Dropdown Panels */
.header-dropdown-panel {
    position: absolute;
    top: calc(100% + 8px);
    z-index: 150;
    min-width: 240px;
    background-color: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--space-2);
    animation: dropdownFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.header-dropdown-panel[hidden] {
    display: none !important;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.main-nav-dropdown {
    right: 0;
    left: auto;
}

.user-account-dropdown {
    left: 0;
    right: auto;
}

.dropdown-header {
    padding: var(--space-2) var(--space-3);
}

.dropdown-header-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-info-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-info-name {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.92rem;
}

.user-info-username {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border-subtle);
    margin: var(--space-1) 0;
}

.dropdown-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    padding: 6px var(--space-3) 2px;
}

.dropdown-nav-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 8px var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    border: none;
    background: transparent;
    width: 100%;
    cursor: pointer;
    text-align: right;
    transition: background-color 0.12s ease, color 0.12s ease;
    font-family: var(--font-sans);
}

.dropdown-item:hover,
.dropdown-item:focus-visible {
    background-color: var(--surface-2);
    color: var(--primary);
    outline: none;
}

.dropdown-item-danger {
    color: var(--danger);
}

.dropdown-item-danger:hover,
.dropdown-item-danger:focus-visible {
    background-color: rgba(180, 62, 56, 0.08);
    color: var(--danger);
}

.dropdown-logout-form {
    margin: 0;
    padding: 0;
}

.header-auth-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.header-auth-btn {
    padding: 6px 14px;
    font-size: 0.85rem;
}

/* -------------------------------------------------------------------
   Hardware Four-Position Sliding Segmented Theme Switcher
   Physical device / oscilloscope / multimeter mode switch metaphor
   ------------------------------------------------------------------- */
.theme-segmented-switch {
    border: none;
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.segmented-track {
    position: relative;
    display: inline-flex;
    align-items: center;
    background-color: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    padding: 3px;
    height: 38px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.07);
    user-select: none;
    direction: rtl;
    gap: 2px;
    box-sizing: border-box;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Individual option pill with expanding label (Change 4) */
.segmented-option {
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 7px;
    border-radius: var(--radius-full);
    cursor: pointer;
    margin: 0;
    box-sizing: border-box;
    overflow: hidden;
    transition: background-color 0.18s ease, color 0.15s ease, box-shadow 0.18s ease;
}

.segmented-radio {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
    pointer-events: none;
}

.segmented-label {
    display: inline-flex;
    align-items: center;
    position: relative;
    height: 100%;
    color: var(--text-secondary);
    line-height: 1;
    transition: color 0.15s ease;
}

.segmented-icon {
    font-size: 1.25rem; /* ~20px readable emoji */
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    pointer-events: none;
}

/* Short Label: In-container inline text, hidden by default, expands to the physical left */
.segmented-text {
    display: inline-block;
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    white-space: nowrap;
    font-size: 0.82rem;
    font-weight: 700;
    font-family: var(--font-sans);
    color: var(--text-primary);
    padding-inline: 0;
    transform: translateX(10px); /* Starts behind the icon, slides out toward the physical left */
    transition: max-width 450ms cubic-bezier(0.16, 1, 0.3, 1), opacity 450ms ease, transform 450ms cubic-bezier(0.16, 1, 0.3, 1), padding 450ms ease;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .segmented-text {
        transition: none !important;
    }
}

/* Active checked theme state (Pill highlight on the active option) */
.segmented-option.active,
.segmented-option:has(.segmented-radio:checked) {
    background-color: var(--surface);
    box-shadow: 0 1px 4px rgba(28, 41, 39, 0.12), 0 0 0 1px var(--border-subtle);
}

.segmented-option.active .segmented-label,
.segmented-radio:checked + .segmented-label {
    color: var(--primary);
    font-weight: 700;
}

/* Hover & Focus state: Container expands and reveals label to the physical left */
.segmented-option:hover,
.segmented-option:focus-within {
    background-color: var(--surface);
}

.segmented-option:hover .segmented-label,
.segmented-option:focus-within .segmented-label {
    color: var(--text-primary);
}

.segmented-option:hover .segmented-text,
.segmented-radio:focus-visible ~ .segmented-label .segmented-text,
.segmented-option:focus-within .segmented-text {
    max-width: 70px;
    opacity: 1;
    transform: translateX(0);
    padding-inline-start: 6px;
    padding-inline-end: 6px;
}

/* Keyboard focus state (WCAG AA focus indicator) */
.segmented-radio:focus-visible + .segmented-label {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-full);
}

@media (prefers-reduced-motion: reduce) {
    .segmented-track,
    .segmented-option,
    .segmented-text {
        transition: none !important;
    }
}

/* Mobile Navbar & Global Header Styles (< 768px) */
@media (max-width: 767px) {
    .header-container,
    .navbar {
        flex-wrap: wrap;
        gap: var(--space-2);
        min-height: auto;
        padding-block: var(--space-2);
    }

    .header-section-start {
        order: 1;
        gap: var(--space-2);
    }

    .header-section-end,
    .navbar-actions {
        order: 2;
        gap: var(--space-2);
    }

    .header-section-center,
    .navbar-search {
        order: 3;
        flex-basis: 100%;
        max-width: 100%;
        margin-top: 2px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-2);
    }

    .header-nav-link {
        display: none; /* Accessible in the prominent main menu */
    }

    .main-nav-dropdown {
        right: 0;
        left: auto;
        max-width: calc(100vw - 32px);
        width: 260px;
    }

    .user-account-dropdown {
        left: 0;
        right: auto;
        max-width: calc(100vw - 32px);
        width: 260px;
    }

    .navbar-actions .btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .navbar-actions .hide-on-mobile {
        display: none !important;
    }
}

@media (min-width: 768px) and (max-width: 920px) {
    .header-nav-link,
    .search-kbd-hint {
        display: none;
    }
}

@media (max-width: 640px) {
    .segmented-track {
        height: 36px;
        padding: 2px;
    }

    .segmented-option {
        height: 30px;
        padding: 0 5px;
    }

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

    /* Compact avatar-only button for user account */
    .user-account-name,
    .user-chevron {
        display: none;
    }

    .user-account-btn {
        padding: 4px;
        width: 36px;
        height: 36px;
        justify-content: center;
    }

    .navbar-brand span {
        font-size: 1.15rem;
    }

    .header-auth-actions .btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .search-kbd-hint {
        display: none;
    }

    .header-search-input,
    .search-input {
        padding-left: 14px;
    }
}

@media (max-width: 380px) {
    .header-section-end {
        gap: var(--space-1);
    }

    .header-section-start {
        gap: var(--space-1);
    }

    .navbar-brand span {
        font-size: 1.05rem;
    }

    .segmented-option {
        padding: 2px 4px;
    }
}

/* -------------------------------------------------------------------
   5. Buttons & Badges
   ------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
    user-select: none;
}

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

.btn-primary {
    background-color: var(--primary);
    color: var(--primary-contrast);
    border-color: var(--primary);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    color: var(--primary-contrast);
}

.btn-primary:active {
    background-color: var(--primary-active);
    border-color: var(--primary-active);
}

.btn-secondary {
    background-color: var(--surface-2);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: var(--surface-elevated);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

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

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

.btn-outline {
    background-color: transparent;
    border-color: var(--border-strong);
    color: var(--text-primary);
}

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

.btn-danger {
    background-color: rgba(180, 62, 56, 0.1);
    border-color: rgba(180, 62, 56, 0.3);
    color: var(--danger);
}

.btn-danger:hover {
    background-color: var(--danger);
    border-color: var(--danger);
    color: #FFFFFF;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn-block {
    width: 100%;
}

/* Semantic Badges & Pills */
/* -------------------------------------------------------------------
   Lucide SVG Icon System (Curated Subset, ISC License)
   ------------------------------------------------------------------- */
.lucide-icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    line-height: 1;
    transition: stroke 0.15s ease, transform 0.15s ease;
}

/* Directional RTL flipping when needed */
[dir="rtl"] .lucide-flip-rtl {
    transform: scaleX(-1);
}

.pill-item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
    background-color: var(--surface);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(28, 41, 39, 0.04);
    transition: all 0.15s ease;
}

.pill-item:hover, .pill-item.active {
    background-color: var(--surface-2);
    color: var(--primary);
    border-color: var(--primary);
    font-weight: 600;
}

/* -------------------------------------------------------------------
   Industrial Equipment Status Badges with Pulsing LED Indicators
   ------------------------------------------------------------------- */
.badge-status {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.4;
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
    letter-spacing: 0.2px;
}

.status-indicator-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.badge-published {
    background-color: rgba(36, 115, 79, 0.12);
    color: var(--success);
    border: 1px solid rgba(36, 115, 79, 0.35);
}

.badge-published .status-indicator-dot {
    background-color: var(--success);
    box-shadow: 0 0 6px var(--success);
    animation: led-pulse 2.2s infinite ease-in-out;
}

.badge-draft {
    background-color: rgba(152, 99, 12, 0.12);
    color: var(--warning);
    border: 1px solid rgba(152, 99, 12, 0.35);
}

.badge-draft .status-indicator-dot {
    background-color: var(--warning);
    box-shadow: 0 0 5px var(--warning);
}

@keyframes led-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.45;
        transform: scale(0.85);
    }
}

/* -------------------------------------------------------------------
   6. Main Content & Floating Work Panels (Cards)
   ------------------------------------------------------------------- */
.main-content {
    flex: 1;
    padding-block: var(--space-8);
}

.card {
    background-color: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.2s ease;
}

.card-hoverable:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-elevated {
    background-color: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-md);
}

.card-body {
    padding: var(--space-5);
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: var(--space-2);
    color: var(--text-primary);
    line-height: 1.45;
    overflow-wrap: break-word;
    word-break: break-word;
}

.card-text {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
    line-height: 1.6;
    flex: 1;
    overflow-wrap: break-word;
}

.card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-subtle);
    padding-top: var(--space-3);
    gap: var(--space-2);
    flex-wrap: wrap;
}

/* -------------------------------------------------------------------
   7. Hero Section (Floating Precision Panel)
   ------------------------------------------------------------------- */
.hero {
    background-color: var(--surface);
    background-image: var(--hero-pattern);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-8) var(--space-6);
    margin-bottom: var(--space-8);
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* -------------------------------------------------------------------
   7B. Responsive Homepage Layout & Asymmetric Hero (Stage 6 Refinement)
   - Desktop (>= 1024px): Asymmetric 2-column layout (Right Sidebar ~340px, Left Showcase 1fr)
   - Mobile (< 1024px): Natural top-to-bottom reading order with compact hero (< 50% height)
   ------------------------------------------------------------------- */
.homepage-layout-container {
    width: 100%;
}

/* Mobile & Tablet (< 1024px): Stacked single-column layout */
@media (max-width: 1023px) {
    .homepage-layout-container {
        display: flex;
        flex-direction: column;
        gap: var(--space-4);
    }

    .homepage-hero-sidebar {
        width: 100%;
    }

    /* Compact Hero on Mobile (< 1024px) */
    .guest-landing-hero {
        background-color: var(--surface);
        border: 1px solid var(--border-subtle);
        border-radius: var(--radius-lg);
        padding: var(--space-4);
        margin-bottom: var(--space-4);
        box-shadow: var(--shadow-sm);
        transition: background-color 0.2s ease, border-color 0.2s ease;
    }

    .guest-hero-badge {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 3px 10px;
        border-radius: var(--radius-full);
        font-size: 0.74rem;
        font-weight: 700;
        color: var(--primary);
        background-color: var(--surface-2);
        border: 1px solid var(--border-subtle);
        margin-bottom: var(--space-2);
    }

    .guest-hero-title {
        font-size: 1.25rem;
        font-weight: 800;
        color: var(--text-primary);
        margin-bottom: var(--space-1);
        line-height: 1.35;
        text-align: center;
    }

    .guest-hero-subtitle {
        font-size: 0.84rem;
        color: var(--text-secondary);
        max-width: 640px;
        margin-inline: auto;
        margin-bottom: var(--space-3);
        line-height: 1.55;
        text-align: center;
    }

    .landing-pillars-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        gap: var(--space-2);
        margin-bottom: var(--space-3);
    }

    .landing-pillar-card {
        background-color: var(--surface-2);
        border: 1px solid var(--border-subtle);
        border-radius: var(--radius-md);
        padding: var(--space-3);
        display: flex;
        align-items: flex-start;
        gap: var(--space-3);
        text-align: start;
        transition: border-color 0.15s ease, transform 0.15s ease;
    }

    .landing-pillar-card:hover {
        border-color: var(--border-strong);
        transform: translateY(-1px);
    }

    .pillar-icon {
        color: var(--primary);
        flex-shrink: 0;
        padding-top: 2px;
        margin-bottom: 0;
    }

    .pillar-title {
        font-size: 0.88rem;
        font-weight: 700;
        color: var(--text-primary);
        margin-bottom: 2px;
    }

    .pillar-text {
        font-size: 0.76rem;
        color: var(--text-muted);
        line-height: 1.45;
        margin: 0;
    }

    .guest-hero-actions {
        display: flex;
        gap: var(--space-2);
        justify-content: center;
        flex-wrap: wrap;
    }

    .guest-hero-btn {
        padding: 6px 12px;
        font-size: 0.82rem;
    }
}

@media (max-width: 640px) {
    .landing-pillars-grid {
        grid-template-columns: 1fr;
    }
}

/* Desktop (>= 1024px): Full-width asymmetric 2-column layout */
@media (min-width: 1024px) {
    .homepage-layout-container.has-sidebar {
        display: grid;
        grid-template-columns: var(--homepage-sidebar-width) minmax(0, 1fr); /* In RTL dir="rtl": Track 1 = Right Column (start), Track 2 = Left Column (end) */
        gap: var(--homepage-column-gap);
        align-items: start;
        width: 100%;
    }

    .homepage-hero-sidebar {
        position: sticky;
        top: calc(var(--navbar-height, 64px) + var(--space-4));
        max-height: calc(100vh - var(--navbar-height, 64px) - var(--space-8));
        overflow-y: auto;
        scrollbar-width: thin;
        scrollbar-color: var(--border-subtle) transparent;
        width: var(--homepage-sidebar-width);
    }

    .homepage-hero-sidebar::-webkit-scrollbar {
        width: 4px;
    }

    .homepage-hero-sidebar::-webkit-scrollbar-thumb {
        background: var(--border-subtle);
        border-radius: var(--radius-full);
    }

    .homepage-showcase-main {
        min-width: 0; /* Prevents CSS Grid blowout */
        width: 100%;
    }

    .guest-landing-hero {
        background-color: var(--surface);
        border: 1px solid var(--border-subtle);
        border-radius: var(--radius-lg);
        padding: var(--space-5) var(--space-4);
        margin-bottom: 0;
        box-shadow: var(--shadow-sm);
        transition: background-color 0.2s ease, border-color 0.2s ease;
    }

    .guest-hero-badge {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 3px 10px;
        border-radius: var(--radius-full);
        font-size: 0.74rem;
        font-weight: 700;
        color: var(--primary);
        background-color: var(--surface-2);
        border: 1px solid var(--border-subtle);
        margin-bottom: var(--space-2);
    }

    .guest-hero-title {
        font-size: 1.25rem;
        font-weight: 800;
        color: var(--text-primary);
        margin-bottom: var(--space-2);
        line-height: 1.35;
        text-align: start;
    }

    .guest-hero-subtitle {
        font-size: 0.84rem;
        color: var(--text-secondary);
        margin-bottom: var(--space-4);
        line-height: 1.55;
        text-align: start;
        max-width: none;
        margin-inline: 0;
    }

    .landing-pillars-grid {
        display: flex;
        flex-direction: column;
        gap: var(--space-3);
        margin-bottom: var(--space-4);
    }

    .landing-pillar-card {
        background-color: var(--surface-2);
        border: 1px solid var(--border-subtle);
        border-radius: var(--radius-md);
        padding: var(--space-3);
        display: flex;
        align-items: flex-start;
        gap: var(--space-3);
        text-align: start;
        transition: border-color 0.15s ease, transform 0.15s ease;
    }

    .landing-pillar-card:hover {
        border-color: var(--border-strong);
        transform: translateY(-1px);
    }

    .pillar-icon {
        color: var(--primary);
        flex-shrink: 0;
        padding-top: 2px;
        margin-bottom: 0;
    }

    .pillar-title {
        font-size: 0.88rem;
        font-weight: 700;
        color: var(--text-primary);
        margin-bottom: 2px;
    }

    .pillar-text {
        font-size: 0.76rem;
        color: var(--text-muted);
        line-height: 1.45;
        margin: 0;
    }

    .guest-hero-actions {
        display: flex;
        flex-direction: column;
        gap: var(--space-2);
    }

    .guest-hero-btn {
        width: 100%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 8px 12px;
        font-size: 0.85rem;
    }
}

/* Authenticated Showcase Header (Stage 6) */
.auth-showcase-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-6);
    padding: var(--space-4) var(--space-5);
    background-color: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    flex-wrap: wrap;
    gap: var(--space-3);
    box-shadow: var(--shadow-sm);
}

.auth-showcase-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
}

.auth-showcase-subtitle {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin: var(--space-1) 0 0 0;
}

/* Category Filter Bar (Responsive horizontal scroll on mobile, aligned on desktop) */
.category-filter-bar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    overflow-x: auto;
    padding-bottom: var(--space-2);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--border-subtle) transparent;
    width: 100%;
}

@media (min-width: 768px) {
    .category-filter-bar {
        flex-wrap: wrap;
        justify-content: flex-start; /* Start-aligned in RTL: aligns with showcase boundary */
        overflow-x: visible;
    }
}

/* -------------------------------------------------------------------
   Custom Accessible Theme-Consistent Sort Dropdown (Change 1)
   ------------------------------------------------------------------- */
.custom-sort-dropdown {
    position: relative;
    display: inline-block;
}

.custom-sort-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    height: 34px;
    padding: 4px 12px;
    background-color: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    min-width: 125px;
}

.custom-sort-trigger:hover {
    background-color: var(--surface);
    border-color: var(--border-strong);
}

.custom-sort-trigger:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.custom-sort-chevron {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

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

.custom-sort-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 150px;
    background-color: var(--surface-elevated, var(--surface));
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg, 0 8px 24px rgba(0, 0, 0, 0.18));
    padding: 4px;
    margin: 0;
    list-style: none;
    z-index: 200;
    direction: rtl;
    animation: dropdownFadeIn 0.12s ease-out;
}

.custom-sort-menu[hidden] {
    display: none !important;
}

.custom-sort-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
    user-select: none;
}

.custom-sort-option:hover,
.custom-sort-option:focus,
.custom-sort-option:focus-visible {
    outline: none;
    background-color: var(--surface-2);
    color: var(--primary);
}

.custom-sort-option.selected {
    font-weight: 700;
    color: var(--primary);
    background-color: var(--surface-2);
}

.sort-check {
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: bold;
}

/* -------------------------------------------------------------------
   8. Adaptive Project Showcase Grid (Responsive auto-fill)
   ------------------------------------------------------------------- */
.showcase-grid {
    display: grid;
    gap: var(--space-6);
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
    width: 100%;
}

@media (max-width: 640px) {
    .showcase-grid {
        gap: var(--space-4);
    }
}

/* Card Aspect Ratio (Canonical 16:9) */
.card-cover-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background-color: var(--surface-2);
}

.card-cover-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.25s ease;
}

.card-hoverable:hover .card-cover-wrapper img {
    transform: scale(1.03);
}

/* Accessible Full-Card Stretched Link Pattern (Stage 6) */
.card-clickable {
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

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

.stretched-link::after {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1;
    pointer-events: auto;
    content: "";
    border-radius: inherit;
}

.stretched-link:focus-visible::after {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

/* Independent interactive elements within clickable card */
.card-interactive-element {
    position: relative;
    z-index: 2;
    pointer-events: auto;
}

/* -------------------------------------------------------------------
   9. Form Controls, Labels, Errors & Autofill Fixes
   ------------------------------------------------------------------- */
.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-label .required-star {
    color: var(--primary);
    margin-inline-start: 2px;
}

.form-label .optional-hint {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-inline-start: 4px;
}

.form-control {
    width: 100%;
    background-color: var(--surface-2);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.92rem;
    outline: none;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out, background-color 0.2s ease;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.form-control.is-invalid {
    border-color: var(--danger);
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(180, 62, 56, 0.2);
}

.form-error {
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.form-hint {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 4px;
    line-height: 1.5;
}

/* Custom Select Dropdowns */
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23647570' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 12px center;
    background-size: 16px;
    padding-inline-end: 14px;
    padding-inline-start: 36px;
    cursor: pointer;
}

select.form-control option {
    background-color: var(--surface);
    color: var(--text-primary);
}

/* Textarea auto-sizing & vertical resize */
textarea.form-control {
    resize: vertical;
    min-height: 90px;
    line-height: 1.6;
}

/* Browser Autofill Support across themes */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus, 
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-text-fill-color: var(--text-primary) !important;
    -webkit-box-shadow: 0 0 0px 1000px var(--surface-2) inset !important;
    caret-color: var(--text-primary) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* -------------------------------------------------------------------
   10. Reusable Persian File Upload Component
   ------------------------------------------------------------------- */
.custom-file-upload {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    background-color: var(--surface-2);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.custom-file-upload:hover,
.custom-file-upload:focus-within {
    border-color: var(--primary);
    background-color: var(--surface);
}

.custom-file-upload input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.custom-file-upload .upload-btn-label {
    background-color: var(--surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    pointer-events: none;
    box-shadow: var(--shadow-sm);
}

.custom-file-upload .upload-status-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
    flex: 1;
}

/* -------------------------------------------------------------------
   11. Project Detail Reading Experience
   ------------------------------------------------------------------- */
.project-detail-container {
    max-width: 980px;
    margin-inline: auto;
}

.project-meta-pills {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: var(--space-3);
}

.project-detail-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.35;
    margin-bottom: var(--space-4);
    overflow-wrap: break-word;
}

@media (max-width: 640px) {
    .project-detail-title {
        font-size: 1.6rem;
    }
}

.author-attribution-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-3);
    padding-block: var(--space-3);
    border-block: 1px solid var(--border-subtle);
    margin-bottom: var(--space-6);
}

/* Code & Pinout Boxes (dir=ltr with horizontal scroll, Maker Terminal look) */
.code-block-wrapper {
    direction: ltr;
    text-align: left;
    background-color: #0D141C;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-block: var(--space-3);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    line-height: 1.5;
    color: #E2E8F0;
    box-shadow: var(--shadow-sm);
}

/* Bill of Materials (BOM) Technical Specification Card */
.bom-card {
    background-color: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-top: var(--space-6);
    overflow: hidden;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.bom-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}

.bom-header {
    background-color: var(--surface-2);
    border-bottom: 1px solid var(--border-subtle);
    padding: var(--space-3) var(--space-5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.bom-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.bom-meta-tag {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 2px 8px;
    background-color: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.bom-body {
    padding: var(--space-5);
    background-color: var(--surface);
    color: var(--text-secondary);
    line-height: 1.9;
    font-size: 0.98rem;
    position: relative;
}

.bom-copy-btn {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    background-color: var(--surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.bom-copy-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background-color: var(--surface-2);
}

/* Fallback for legacy .bom-box */
.bom-box {
    background-color: var(--bg-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    color: var(--text-secondary);
    line-height: 1.8;
    font-size: 0.95rem;
    border: 1px solid var(--border-subtle);
}

/* -------------------------------------------------------------------
   Industrial Assembly Timeline & Step Cards
   ------------------------------------------------------------------- */
.assembly-timeline {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
    margin-top: var(--space-4);
}

/* Vertical engineering connecting ruler line */
.assembly-timeline::before {
    content: '';
    position: absolute;
    top: 24px;
    bottom: 24px;
    right: 23px; /* In native RTL, timeline runs on the right */
    width: 2px;
    background: repeating-linear-gradient(
        to bottom,
        var(--border-strong) 0px,
        var(--border-strong) 6px,
        transparent 6px,
        transparent 12px
    );
    z-index: 0;
}

.step-timeline-item {
    position: relative;
    display: flex;
    gap: var(--space-5);
    align-items: flex-start;
}

/* Precision Step Number Badge (Floating Marker) */
.step-marker {
    position: relative;
    z-index: 1;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background-color: var(--surface);
    border: 2px solid var(--primary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.step-marker-label {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1;
}

.step-marker-num {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.1;
}

/* Step Card Container */
.step-card-panel {
    flex: 1;
    background-color: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-6);
    position: relative;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.step-card-panel:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}

.step-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: var(--space-3);
}

.step-panel-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.35;
    margin: 0;
}

/* Technical Image Framing with Corner Calipers */
.step-photo-frame {
    position: relative;
    margin-block: var(--space-5);
    border-radius: var(--radius-md);
    overflow: hidden;
    max-height: 480px;
    border: 1px solid var(--border-subtle);
    background-color: var(--surface-2);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.step-photo-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.step-photo-badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background-color: rgba(28, 41, 39, 0.8);
    color: #FFFFFF;
    font-size: 0.72rem;
    font-family: var(--font-mono);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    backdrop-filter: blur(4px);
    pointer-events: none;
    letter-spacing: 0.5px;
}

.step-text-body {
    color: var(--text-secondary);
    line-height: 1.85;
    font-size: 0.98rem;
    overflow-wrap: break-word;
}

/* Responsive adjustment for small screens */
@media (max-width: 640px) {
    .assembly-timeline::before {
        display: none;
    }

    .step-timeline-item {
        flex-direction: column;
        gap: var(--space-3);
    }

    .step-marker {
        width: 38px;
        height: 38px;
    }

    .step-marker-num {
        font-size: 0.95rem;
    }

    .step-card-panel {
        width: 100%;
        padding: var(--space-4);
    }
}

/* Subtle millimeter tick ruler for engineering step headers */
.step-ruler-ticks {
    height: 4px;
    background: repeating-linear-gradient(
        to left,
        var(--border-strong) 0px,
        var(--border-strong) 1px,
        transparent 1px,
        transparent 8px
    );
    margin-bottom: var(--space-3);
    opacity: 0.7;
}

/* -------------------------------------------------------------------
   GLightbox Custom Styling (Light Industrial Theme-Aware)
   ------------------------------------------------------------------- */
.glightbox-container .goverlay {
    background-color: rgba(18, 26, 25, 0.88) !important;
    backdrop-filter: blur(8px);
}

.glightbox-container .gprev,
.glightbox-container .gnext,
.glightbox-container .gclose {
    background-color: var(--surface) !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: var(--radius-md) !important;
    color: var(--text-primary) !important;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease !important;
}

.glightbox-container .gprev:hover,
.glightbox-container .gnext:hover,
.glightbox-container .gclose:hover {
    border-color: var(--primary) !important;
    color: var(--primary) !important;
    background-color: var(--surface-2) !important;
}

.glightbox-container .gdesc {
    background-color: var(--surface) !important;
    border-top: 1px solid var(--border-subtle) !important;
    direction: rtl;
    text-align: right;
    font-family: var(--font-base) !important;
}

.glightbox-container .gslide-title {
    color: var(--text-primary) !important;
    font-weight: 700 !important;
    font-size: 1.05rem !important;
}

.glightbox-container .gslide-desc {
    color: var(--text-secondary) !important;
    font-size: 0.9rem !important;
}

/* -------------------------------------------------------------------
   Author Control Panel & 2-Column Workspace Grid
   Right-aligned column for author toolbox + Left-aligned overview
   ------------------------------------------------------------------- */
.project-workspace-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: var(--space-6);
    margin-bottom: var(--space-8);
    align-items: start;
}

.project-workspace-grid.no-author-sidebar {
    grid-template-columns: 1fr;
}

.author-control-panel {
    background-color: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    position: sticky;
    top: calc(var(--navbar-height, 68px) + var(--space-4));
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.author-control-panel:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}

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

.author-panel-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.author-panel-tag {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 7px;
    background-color: var(--surface-2);
    color: var(--primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    letter-spacing: 0.5px;
}

.author-panel-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.author-panel-actions .btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--space-2);
    text-align: right;
    font-size: 0.88rem;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    transition: all 0.15s ease;
}

.author-panel-divider {
    height: 1px;
    background-color: var(--border-subtle);
    margin-block: var(--space-1);
}

.project-overview-main {
    min-width: 0; /* Prevents CSS grid blowout with long text */
}

@media (max-width: 880px) {
    .project-workspace-grid {
        grid-template-columns: 1fr;
    }

    .author-control-panel {
        position: static;
    }
}

/* Legacy Sequential Step Card (Retained for backward compatibility) */
.step-card {
    padding: var(--space-6);
    border-inline-start: 4px solid var(--primary);
    margin-bottom: var(--space-6);
    background-color: var(--surface);
}

.step-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
    flex-wrap: wrap;
}

.step-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.4;
}

.step-image-wrapper {
    margin-block: var(--space-4);
    border-radius: var(--radius-md);
    overflow: hidden;
    max-height: 460px;
    border: 1px solid var(--border-subtle);
    background-color: var(--surface-2);
}

.step-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.step-content {
    color: var(--text-secondary);
    line-height: 1.8;
    font-size: 0.96rem;
    overflow-wrap: break-word;
}

/* Attachment download item */
.attachment-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    flex-wrap: wrap;
    gap: var(--space-3);
    transition: background-color 0.15s ease;
}

.attachment-row:last-child {
    border-bottom: none;
}

.attachment-row:hover {
    background-color: var(--surface-2);
}

/* Comment Item */
.comment-card {
    padding: var(--space-4);
    border-color: var(--border-subtle);
    margin-bottom: var(--space-3);
    background-color: var(--surface);
}

.comment-author-badge {
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--primary);
    color: var(--primary);
    font-weight: 600;
}

/* -------------------------------------------------------------------
   12. Dashboard & Maker Profile Layout
   ------------------------------------------------------------------- */
.panel-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: var(--space-6);
    align-items: start;
}

@media (max-width: 900px) {
    .panel-layout {
        grid-template-columns: 1fr;
    }

    .panel-layout aside {
        order: -1;
    }
}

.dashboard-project-card {
    padding: var(--space-4) var(--space-5);
    display: flex;
    gap: var(--space-5);
    align-items: stretch;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.dashboard-thumb {
    width: 210px;
    aspect-ratio: 16 / 10;
    border-radius: var(--radius-md);
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid var(--border-subtle);
    background-color: var(--surface-2);
    box-shadow: var(--shadow-sm);
}

.dashboard-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s ease;
}

.dashboard-project-card:hover .dashboard-thumb img {
    transform: scale(1.03);
}

@media (max-width: 640px) {
    .dashboard-project-card {
        flex-direction: column;
        padding: var(--space-4);
        gap: var(--space-3);
    }

    .dashboard-thumb {
        width: 100%;
        aspect-ratio: 16 / 9;
    }
}

/* -------------------------------------------------------------------
   13. System Messages, Alerts & Floating Toast Notifications
   ------------------------------------------------------------------- */
.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-3);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    border: 1px solid transparent;
}

.alert-success {
    background-color: rgba(36, 115, 79, 0.1);
    border-color: rgba(36, 115, 79, 0.3);
    color: var(--success);
}

.alert-error, .alert-danger {
    background-color: rgba(180, 62, 56, 0.1);
    border-color: rgba(180, 62, 56, 0.3);
    color: var(--danger);
}

.alert-warning {
    background-color: rgba(152, 99, 12, 0.1);
    border-color: rgba(152, 99, 12, 0.3);
    color: var(--warning);
}

.alert-info {
    background-color: rgba(40, 91, 150, 0.1);
    border-color: rgba(40, 91, 150, 0.3);
    color: var(--info);
}

/* Floating Toast Notifications Container */
.toast-notification-container {
    position: fixed;
    top: 76px;
    inset-inline-end: 24px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 440px;
    width: calc(100% - 32px);
    pointer-events: none;
}

.toast-message {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background-color: var(--surface-1);
    border: 1px solid var(--border-strong);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
    animation: toastSlideIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast-message.toast-fade-out {
    opacity: 0;
    transform: translateY(-8px);
}

.toast-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    margin-top: 1px;
}

.toast-text {
    flex: 1;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--text-primary);
    overflow-wrap: break-word;
}

.toast-close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color 0.15s ease, background-color 0.15s ease;
    flex-shrink: 0;
}

.toast-close-btn:hover {
    color: var(--text-primary);
    background-color: var(--surface-2);
}

.toast-success {
    border-color: var(--success);
    background-color: var(--surface-1);
}
.toast-success .toast-icon {
    color: var(--success);
}

.toast-danger, .toast-error {
    border-color: var(--danger);
    background-color: var(--surface-1);
}
.toast-danger .toast-icon, .toast-error .toast-icon {
    color: var(--danger);
}

.toast-warning {
    border-color: var(--warning);
    background-color: var(--surface-1);
}
.toast-warning .toast-icon {
    color: var(--warning);
}

.toast-info {
    border-color: var(--info);
    background-color: var(--surface-1);
}
.toast-info .toast-icon {
    color: var(--info);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* -------------------------------------------------------------------
   14. Footer
   ------------------------------------------------------------------- */
.site-footer {
    background-color: var(--surface);
    border-top: 1px solid var(--border-subtle);
    padding-block: var(--space-6);
    margin-top: auto;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.site-footer a {
    color: var(--text-secondary);
}

.site-footer a:hover {
    color: var(--primary);
}

/* -------------------------------------------------------------------
   15. Accessibility & Reduced Motion
   ------------------------------------------------------------------- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* -------------------------------------------------------------------
   16. Engineering Project System (Stage 2: Subnav, README Overview & Technical Panels)
   ------------------------------------------------------------------- */

/* Sticky Anchor Scroll Offset (Prevents fixed navbar & sticky subnav overlap) */
article.project-detail-container section[id],
article.project-detail-container div[id] {
    scroll-margin-top: calc(var(--navbar-height, 68px) + 56px + var(--space-4));
}

/* Internal Project Sub-Navigation Bar */
.project-subnav {
    background-color: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-2) var(--space-3);
    margin-bottom: var(--space-6);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: calc(var(--navbar-height, 68px) + var(--space-2));
    z-index: 20;
    backdrop-filter: blur(8px);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.project-subnav-inner {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    padding-block: 2px;
}

.project-subnav-inner::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.subnav-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: var(--radius-full);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.subnav-link:hover,
.subnav-link:focus-visible {
    color: var(--primary);
    background-color: var(--surface-2);
    border-color: var(--border-subtle);
}

.subnav-link.active {
    color: var(--primary);
    background-color: var(--surface-2);
    border-color: var(--primary);
}

.subnav-badge {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    background-color: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
}

/* README Technical Overview Styling */
.readme-overview-card {
    background-color: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
    transition: border-color 0.15s ease;
}

.readme-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: var(--space-4);
}

.readme-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.readme-tag {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background-color: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
    letter-spacing: 0.5px;
}

.readme-body {
    color: var(--text-secondary);
    line-height: 1.85;
    font-size: 1.02rem;
    overflow-wrap: break-word;
    margin-bottom: var(--space-5);
}

.readme-quick-specs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-3);
    padding: var(--space-4);
    background-color: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-5);
}

.readme-spec-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.readme-spec-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.readme-spec-value {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Three Technical Modules - Vertically Stacked Sequence across Desktop, Tablet & Mobile */
.tech-modules-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
    margin-bottom: var(--space-12);
    width: 100%;
}

/* Technical Documentation Panel */
.tech-panel {
    background-color: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    width: 100%;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.tech-panel:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* Distinct Top Technical Accent Accents */
.cad-panel {
    border-top: 4px solid var(--accent, #B45C32);
}

.electronics-panel {
    border-top: 4px solid var(--primary, #176B61);
}

.programming-panel {
    border-top: 4px solid var(--info, #285B96);
}

.tech-panel-header {
    padding: var(--space-4) var(--space-6);
    background-color: var(--surface-2);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.tech-panel-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.cad-panel .tech-panel-title {
    color: var(--accent, #B45C32);
}

.electronics-panel .tech-panel-title {
    color: var(--primary, #176B61);
}

.programming-panel .tech-panel-title {
    color: var(--info, #285B96);
}

.tech-spec-tag {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    background-color: var(--surface);
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
    letter-spacing: 0.5px;
}

.tech-panel-body {
    padding: var(--space-6);
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.tech-description {
    font-size: 0.98rem;
    color: var(--text-secondary);
    line-height: 1.85;
    overflow-wrap: break-word;
}

.tech-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
}

.tech-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    background-color: var(--surface-2);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

.tech-badge-primary {
    background-color: rgba(23, 107, 97, 0.08);
    border-color: var(--primary);
    color: var(--primary);
}

.tech-file-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-top: var(--space-2);
    padding: var(--space-4);
    background-color: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.tech-file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2) var(--space-3);
    background-color: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    gap: var(--space-3);
    flex-wrap: wrap;
    transition: border-color 0.15s ease;
}

.tech-file-item:hover {
    border-color: var(--border-strong);
}
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-2);
    padding: 6px 10px;
    background-color: var(--surface-2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    font-size: 0.82rem;
}

.tech-file-info {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
}

.tech-file-name {
    direction: ltr;
    text-align: start;
    unicode-bidi: isolate;
    font-family: var(--font-mono);
    color: var(--text-primary);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 240px;
}

.tech-file-size {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.code-instructions-block {
    background-color: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.6;
    white-space: pre-wrap;
    color: var(--text-primary);
    direction: ltr;
    text-align: start;
    max-height: 180px;
    overflow-y: auto;
}

/* Author Empty Prompt State - Compact Workbench Action Row */
.tech-panel-empty {
    border: 1px dashed var(--border-subtle);
    background-color: var(--surface);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    width: 100%;
    min-height: unset;
    transition: all 0.2s ease;
    flex-wrap: wrap;
}

.tech-panel-empty:hover {
    border-color: var(--primary);
    background-color: var(--surface-2);
}

.tech-panel-empty-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
}

.tech-panel-empty-icon {
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s ease, color 0.2s ease;
}

.tech-panel-empty:hover .tech-panel-empty-icon {
    transform: scale(1.1);
}

.tech-panel-empty-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.tech-panel-empty-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    max-width: none;
    line-height: 1.4;
    margin: 2px 0 0 0;
}

@media (max-width: 640px) {
    .tech-panel-empty {
        flex-direction: column;
        align-items: stretch;
        text-align: start;
        gap: var(--space-3);
    }

    .tech-panel-empty a.btn {
        width: 100%;
        justify-content: center;
    }
}

/* -------------------------------------------------------------------
   Stage 3: Engineering Build Steps, Project Gallery & Technical Files
   ------------------------------------------------------------------- */

/* 1. Step Technical Tag */
.step-tech-tag {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--primary);
    background-color: var(--surface-2);
    border: 1px solid var(--border-subtle);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* 2. Project Gallery Grid & Zoom Card */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-4);
}

.gallery-card {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-lg);
    background-color: var(--surface);
    border: 1px solid var(--border-subtle);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.gallery-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}

.gallery-image-link {
    display: block;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background-color: var(--surface-2);
    position: relative;
}

.gallery-image-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.25s ease;
    display: block;
}

.gallery-image-link:hover img {
    transform: scale(1.03);
}

.gallery-zoom-badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background-color: rgba(28, 41, 39, 0.85);
    color: #FFFFFF;
    font-size: 0.72rem;
    font-family: var(--font-sans);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    backdrop-filter: blur(4px);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    pointer-events: none;
}

.gallery-card-footer {
    padding: var(--space-3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-2);
    border-top: 1px solid var(--border-subtle);
    background-color: var(--surface);
}

.gallery-caption {
    font-size: 0.85rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

/* 3. Categorized Technical Files */
.technical-files-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.files-category-group {
    border-radius: var(--radius-lg);
    background-color: var(--surface);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s ease;
}

.files-category-group:hover {
    border-color: var(--border-strong);
}

.files-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    background-color: var(--surface-2);
    border-bottom: 1px solid var(--border-subtle);
    gap: var(--space-2);
    flex-wrap: wrap;
}

.files-category-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.files-category-code {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.attachment-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1;
}

.attachment-name {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 6px;
    direction: ltr;
    text-align: left;
}

.attachment-filename {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 440px;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    direction: ltr;
    text-align: start;
    unicode-bidi: isolate;
}

.attachment-meta {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 0.78rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.attachment-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.attachment-reclassify-form {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.reclassify-select {
    padding: 3px 8px;
    font-size: 0.78rem;
    font-family: var(--font-sans);
    background-color: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.15s ease;
}

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

@media (max-width: 640px) {
    .attachment-filename {
        max-width: 200px;
    }

    .attachment-actions {
        width: 100%;
        justify-content: flex-start;
        margin-top: var(--space-2);
    }
}

/* -------------------------------------------------------------------
   Print Stylesheet for BOM and Technical Documentation (Phase 2)
   ------------------------------------------------------------------- */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }

    .site-header,
    .site-footer,
    .theme-picker,
    .cutting-mat-grid,
    .grid-overlay,
    .author-control-panel,
    .project-subnav,
    .project-actions-bar,
    .bom-header button,
    .bom-header a,
    .tech-modules-grid,
    .assembly-timeline,
    .project-gallery-grid,
    .project-attachments-section,
    .comments-section,
    .btn,
    .bom-copy-btn,
    form {
        display: none !important;
    }

    .bom-card {
        border: 1px solid #000000 !important;
        box-shadow: none !important;
        background: #ffffff !important;
        page-break-inside: avoid;
        margin: 0 !important;
        padding: 0 !important;
    }

    .bom-header {
        background: #f3f4f6 !important;
        color: #000000 !important;
        border-bottom: 1px solid #000000 !important;
    }

    .bom-table {
        width: 100% !important;
        border-collapse: collapse !important;
        color: #000000 !important;
    }

    .bom-table th,
    .bom-table td {
        border: 1px solid #cccccc !important;
        padding: 6px !important;
        color: #000000 !important;
    }
}



