/* ==========================================
   FlowStack Platform - Industrial Light Theme
   Not your typical AI website. Built for operators.
   ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800;900&family=Inter:wght@300;400;500;600;700&display=swap');

/* ==========================================
   ACCENT COLOR THEMES
   User selectable. Saved to localStorage.
   Default: Industrial Blue
   ========================================== */
:root,
:root[data-accent="blue"] {
    --accent: #0891b2;
    /* cyan-600 */
    --accent-hover: #0e7490;
    --accent-light: rgba(8, 145, 178, 0.10);
    --accent-lighter: rgba(8, 145, 178, 0.06);
    --accent-border: rgba(8, 145, 178, 0.25);
    --accent-text: #0891b2;
}

:root[data-accent="amber"] {
    --accent: #d97706;
    --accent-hover: #b45309;
    --accent-light: rgba(217, 119, 6, 0.10);
    --accent-lighter: rgba(217, 119, 6, 0.06);
    --accent-border: rgba(217, 119, 6, 0.25);
    --accent-text: #d97706;
}

:root[data-accent="green"] {
    --accent: #059669;
    --accent-hover: #047857;
    --accent-light: rgba(5, 150, 105, 0.10);
    --accent-lighter: rgba(5, 150, 105, 0.06);
    --accent-border: rgba(5, 150, 105, 0.25);
    --accent-text: #059669;
}

:root[data-accent="violet"] {
    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --accent-light: rgba(124, 58, 237, 0.10);
    --accent-lighter: rgba(124, 58, 237, 0.06);
    --accent-border: rgba(124, 58, 237, 0.25);
    --accent-text: #7c3aed;
}

:root[data-accent="red"] {
    --accent: #dc2626;
    --accent-hover: #b91c1c;
    --accent-light: rgba(220, 38, 38, 0.10);
    --accent-lighter: rgba(220, 38, 38, 0.06);
    --accent-border: rgba(220, 38, 38, 0.25);
    --accent-text: #dc2626;
}

/* ==========================================
   Design Tokens
   ========================================== */
:root {
    /* Surfaces */
    --bg: #ede8df;
    /* warm industrial beige */
    --surface: #ffffff;
    --surface-2: #faf7f3;
    --surface-3: #f5f0e8;
    --sidebar-bg: #ffffff;

    /* Text */
    --text: #1c1917;
    /* stone-950 */
    --text-2: #44403c;
    /* stone-700 */
    --muted: #78716c;
    /* stone-500 */
    --muted-2: #a8a29e;
    /* stone-400 */

    /* Borders */
    --border: #e7e0d4;
    --border-2: #d6cfc5;

    /* Fixed functional colors */
    --emerald: #059669;
    --amber: #d97706;
    --red: #dc2626;
    --violet: #7c3aed;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.10), 0 4px 8px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12), 0 3px 6px rgba(0, 0, 0, 0.06);

    /* Layout */
    --sidebar-w: 260px;
    --topbar-h: 60px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 18px;
    --radius-pill: 999px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input,
textarea,
select {
    font-family: inherit;
}

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

h1,
h2,
h3,
h4,
h5 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--text);
}

/* ==========================================
   App Shell
   ========================================== */
.fs-shell {
    display: flex;
    min-height: 100vh;
}

/* ==========================================
   Sidebar
   ========================================== */
.fs-sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 200;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-sm);
}

.fs-sidebar-logo {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.fs-sidebar-logo img {
    width: 34px;
    height: 34px;
    border-radius: 8px;
}

.logo-text {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 900;
    font-size: 1.3rem;
    color: var(--accent);
    letter-spacing: -0.03em;
    display: block;
    line-height: 1;
}

.logo-tag {
    font-size: 0.6rem;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: block;
    margin-top: 2px;
}

.fs-nav {
    padding: 0.75rem 0;
    flex: 1;
}

.fs-nav-section {
    padding: 0.75rem 1.25rem 0.25rem;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--muted-2);
}

.fs-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    margin: 0.1rem 0.625rem;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-size: 0.875rem;
    font-weight: 600;
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
}

.fs-nav-item:hover {
    background: var(--surface-3);
    color: var(--text);
}

.fs-nav-item.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 700;
}

.nav-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 800;
    padding: 0.1rem 0.45rem;
    border-radius: var(--radius-pill);
}

.nav-badge-pts {
    margin-left: auto;
    color: var(--amber);
    font-size: 0.78rem;
    font-weight: 800;
}

/* Theme Switcher in sidebar */
.theme-picker {
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.theme-picker-label {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted-2);
    margin-bottom: 0.5rem;
    display: block;
}

.theme-dots {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.theme-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition);
    position: relative;
}

.theme-dot:hover {
    transform: scale(1.15);
}

.theme-dot.active {
    border-color: var(--text);
    box-shadow: 0 0 0 2px var(--surface);
}

.theme-dot[data-t="blue"] {
    background: #0891b2;
}

.theme-dot[data-t="amber"] {
    background: #d97706;
}

.theme-dot[data-t="green"] {
    background: #059669;
}

.theme-dot[data-t="violet"] {
    background: #7c3aed;
}

.theme-dot[data-t="red"] {
    background: #dc2626;
}

/* Sidebar user */
.fs-sidebar-user {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.fs-sidebar-user:hover {
    background: var(--surface-3);
}

.user-avatar-sm {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.user-name-sm {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
}

.user-role-sm {
    font-size: 0.72rem;
    color: var(--muted);
}

.user-info-sm {
    flex: 1;
    min-width: 0;
}

/* ==========================================
   Topbar
   ========================================== */
.fs-topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    z-index: 100;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}

.fs-topbar-title {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 800;
    font-size: 1rem;
    color: var(--text);
    white-space: nowrap;
}

.fs-topbar-search {
    flex: 1;
    max-width: 420px;
    position: relative;
}

.fs-topbar-search input {
    width: 100%;
    background: var(--surface-3);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    color: var(--text);
    font-size: 0.875rem;
    outline: none;
    transition: var(--transition);
}

.fs-topbar-search input:focus {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--accent-lighter);
}

.fs-topbar-search input::placeholder {
    color: var(--muted-2);
}

.search-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-2);
    font-size: 0.9rem;
    pointer-events: none;
}

.fs-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.topbar-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--muted);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.topbar-icon-btn:hover {
    background: var(--border);
    color: var(--text);
}

.topbar-notif-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 7px;
    height: 7px;
    background: var(--red);
    border-radius: 50%;
    border: 2px solid var(--surface);
}

.fs-topbar-streak {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    background: #fef3c7;
    border: 1.5px solid #fde68a;
    border-radius: var(--radius-pill);
    padding: 0.3rem 0.875rem;
    font-size: 0.82rem;
    font-weight: 800;
    color: #92400e;
}

.fs-sidebar-toggle {
    display: none;
    font-size: 1.2rem;
    color: var(--text);
}

/* ==========================================
   Main Content
   ========================================== */
.fs-main {
    margin-left: var(--sidebar-w);
    margin-top: var(--topbar-h);
    flex: 1;
    background: var(--bg);
    min-height: calc(100vh - var(--topbar-h));
}

.fs-content {
    padding: 2rem;
    max-width: 1280px;
}

.fs-content-wide {
    padding: 2rem;
}

/* ==========================================
   Page Header
   ========================================== */
.fs-page-header {
    margin-bottom: 1.5rem;
}

.fs-page-header h1 {
    font-size: clamp(1.4rem, 3vw, 1.875rem);
    margin-bottom: 0.3rem;
}

.fs-page-header p {
    color: var(--muted);
    font-size: 0.9rem;
}

.fs-page-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--accent-light);
    border: 1px solid var(--accent-border);
    color: var(--accent);
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-pill);
    margin-bottom: 0.6rem;
}

/* ==========================================
   Cards
   ========================================== */
.fs-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.fs-card:hover {
    box-shadow: var(--shadow-md);
}

.fs-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.875rem;
    border-bottom: 1px solid var(--border);
}

.fs-card-header h3 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
}

.fs-card-link {
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 600;
}

.fs-card-link:hover {
    text-decoration: underline;
}

/* ==========================================
   Layout Grids
   ========================================== */
.fs-grid-2 {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
    align-items: start;
}

.fs-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
}

.fs-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.fs-sidebar-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: sticky;
    top: calc(var(--topbar-h) + 1.5rem);
}

/* ==========================================
   Buttons
   ========================================== */
.fs-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.375rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    border: none;
    font-family: 'Inter', sans-serif;
}

.fs-btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.fs-btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    color: #fff;
}

.fs-btn-outline {
    background: transparent;
    border: 1.5px solid var(--accent-border);
    color: var(--accent);
}

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

.fs-btn-ghost {
    background: var(--surface-3);
    border: 1.5px solid var(--border);
    color: var(--text-2);
}

.fs-btn-ghost:hover {
    background: var(--border);
    border-color: var(--border-2);
}

.fs-btn-amber {
    background: #d97706;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.fs-btn-amber:hover {
    background: #b45309;
    transform: translateY(-1px);
    color: #fff;
}

.fs-btn-sm {
    padding: 0.4rem 0.875rem;
    font-size: 0.8rem;
}

.fs-btn-lg {
    padding: 0.8rem 2rem;
    font-size: 1rem;
}

/* ==========================================
   Form Controls
   ========================================== */
.fs-input {
    width: 100%;
    background: var(--surface-3);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 1rem;
    color: var(--text);
    font-size: 0.875rem;
    outline: none;
    transition: var(--transition);
    font-family: 'Inter', sans-serif;
}

.fs-input:focus {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--accent-lighter);
}

.fs-input::placeholder {
    color: var(--muted-2);
}

select.fs-input {
    cursor: pointer;
}

/* ==========================================
   Stat Row
   ========================================== */
.fs-stat-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.fs-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    text-align: center;
    transition: var(--transition);
}

.fs-stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.fs-stat-value {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.75rem;
    font-weight: 800;
    display: block;
    line-height: 1;
    margin-bottom: 0.2rem;
}

.fs-stat-label {
    font-size: 0.7rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
}

/* ==========================================
   Topic Cards
   ========================================== */
.fs-topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
}

.fs-topic-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 1.125rem 0.875rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.fs-topic-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}

.fs-topic-card.active {
    border-color: var(--accent);
    background: var(--accent-lighter);
    box-shadow: var(--shadow-md);
}

.fs-topic-icon {
    font-size: 1.75rem;
    display: block;
    margin-bottom: 0.4rem;
}

.fs-topic-name {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.2rem;
}

.fs-topic-count {
    font-size: 0.7rem;
    color: var(--muted);
}

.fs-progress-bar {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: var(--radius-pill);
    overflow: hidden;
    margin-top: 0.5rem;
}

.fs-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: var(--radius-pill);
    transition: width 1s ease;
}

/* ==========================================
   Quiz Panel
   ========================================== */
.fs-quiz-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.fs-quiz-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.875rem;
    background: var(--surface-2);
}

.fs-quiz-topic-label {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
}

.fs-quiz-bar {
    flex: 1;
    height: 5px;
    background: var(--border);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.fs-quiz-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: var(--radius-pill);
    transition: width 0.4s ease;
}

.fs-quiz-counter {
    font-size: 0.78rem;
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
}

.fs-quiz-body {
    padding: 1.75rem 1.5rem;
}

.fs-quiz-question {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.5;
    margin-bottom: 1.25rem;
}

.fs-quiz-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.fs-quiz-option {
    background: var(--surface-3);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.8rem 1rem;
    text-align: left;
    cursor: pointer;
    color: var(--text-2);
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: var(--transition);
}

.fs-quiz-option:hover {
    border-color: var(--accent);
    background: var(--accent-lighter);
    transform: translateX(3px);
    color: var(--text);
}

.fs-quiz-option.correct {
    background: #f0fdf4;
    border-color: #16a34a;
    color: #14532d;
}

.fs-quiz-option.incorrect {
    background: #fef2f2;
    border-color: #dc2626;
    color: #7f1d1d;
}

.option-letter {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--border);
    border: 1px solid var(--border-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--muted);
    flex-shrink: 0;
}

.fs-quiz-option.correct .option-letter {
    background: #16a34a;
    border-color: #16a34a;
    color: #fff;
}

.fs-quiz-option.incorrect .option-letter {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

.randy-explain {
    display: none;
    margin-top: 1rem;
    padding: 1.125rem;
    background: #f5f3ff;
    border: 1.5px solid #c4b5fd;
    border-radius: var(--radius);
    gap: 0.75rem;
    align-items: flex-start;
}

.randy-explain.show {
    display: flex;
}

.randy-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    color: #fff;
}

.randy-text {
    font-size: 0.875rem;
    line-height: 1.7;
    color: var(--text-2);
}

.randy-text strong {
    color: #5b21b6;
    font-weight: 700;
}

.fs-quiz-footer {
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface-2);
}

/* ==========================================
   Chat
   ========================================== */
.fs-chat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    height: 520px;
    box-shadow: var(--shadow-sm);
}

.fs-chat-header {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--surface-2);
    flex-shrink: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.randy-status {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #16a34a;
    box-shadow: 0 0 6px rgba(22, 163, 74, 0.5);
    animation: status-pulse 2s ease-in-out infinite;
    margin-left: auto;
}

@keyframes status-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.fs-chat-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.fs-msg {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    animation: msg-pop 0.2s ease;
}

.fs-msg.user {
    flex-direction: row-reverse;
}

@keyframes msg-pop {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

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

.msg-av {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    flex-shrink: 0;
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.fs-msg.user .msg-av {
    background: #78716c;
}

.msg-bub {
    max-width: 72%;
    padding: 0.7rem 0.875rem;
    font-size: 0.875rem;
    line-height: 1.6;
    border-radius: 16px;
}

.fs-msg.randy .msg-bub {
    background: var(--surface-3);
    border: 1px solid var(--border);
    color: var(--text-2);
    border-radius: 4px 16px 16px 16px;
}

.fs-msg.user .msg-bub {
    background: var(--accent);
    color: #fff;
    border-radius: 16px 4px 16px 16px;
}

.fs-chat-typing {
    padding: 0 1rem 0.625rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted-2);
    animation: tdot 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: .2s;
}

.typing-dot:nth-child(3) {
    animation-delay: .4s;
}

@keyframes tdot {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: .3;
    }

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

.fs-chat-input-row {
    padding: 0.875rem 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}

.fs-chat-send {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    flex-shrink: 0;
}

.fs-chat-send:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

/* ==========================================
   Feed Posts  (Instagram / Facebook feel)
   ========================================== */
.fs-post {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: var(--transition);
}

.fs-post:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
    border-color: var(--border-2);
}

.fs-post-top {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.fs-tag {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.15rem 0.55rem;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
}

.tag-pumps {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.tag-blowers {
    background: #ecfeff;
    border-color: #a5f3fc;
    color: #155e75;
}

.tag-scada {
    background: #f5f3ff;
    border-color: #c4b5fd;
    color: #5b21b6;
}

.tag-instrumentation {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.tag-treatment {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #14532d;
}

.tag-maintenance {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #9a3412;
}

.fs-solved-badge {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #15803d;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    padding: 0.15rem 0.55rem;
    border-radius: var(--radius-pill);
}

.fs-post-title {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    font-size: 0.975rem;
    color: var(--text);
    margin-bottom: 0.35rem;
    line-height: 1.4;
}

.fs-post-body {
    font-size: 0.84rem;
    color: var(--muted);
    line-height: 1.65;
    margin-bottom: 0.875rem;
}

.fs-post-footer {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding-top: 0.625rem;
    border-top: 1px solid var(--border);
}

.fs-author-chip {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--muted);
}

.fs-author-av {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.58rem;
    font-weight: 800;
    color: #fff;
}

.fs-vote-btn {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    color: var(--muted);
    background: var(--surface-3);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 0.25rem 0.625rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Inter', sans-serif;
}

.fs-vote-btn:hover,
.fs-vote-btn.voted {
    background: #f0fdf4;
    border-color: #86efac;
    color: #15803d;
}

.fs-reply-count {
    font-size: 0.78rem;
    color: var(--muted);
    margin-left: auto;
}

/* ==========================================
   Filter Tabs
   ========================================== */
.fs-tabs {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.fs-tab {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 0.35rem 0.875rem;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    color: var(--muted);
    font-family: 'Inter', sans-serif;
    box-shadow: var(--shadow-sm);
}

.fs-tab:hover,
.fs-tab.active {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: none;
}

/* ==========================================
   Widgets (Streak, Earn)
   ========================================== */
.streak-display {
    text-align: center;
    padding: 0.25rem 0;
}

.streak-flame {
    font-size: 2.25rem;
    display: block;
    animation: flame 2s ease-in-out infinite;
}

@keyframes flame {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.streak-num {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 2rem;
    font-weight: 900;
    color: #d97706;
    display: block;
    line-height: 1;
    margin: .2rem 0;
}

.streak-label {
    font-size: 0.68rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .1em;
    font-weight: 700;
}

.streak-days {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    margin-top: .75rem;
}

.s-day {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: var(--surface-3);
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.58rem;
    font-weight: 700;
    color: var(--muted-2);
}

.s-day.done {
    background: #fef3c7;
    border-color: #fde68a;
    color: #92400e;
}

.s-day.today {
    background: #d97706;
    border-color: #d97706;
    color: #fff;
    box-shadow: 0 2px 8px rgba(217, 119, 6, .4);
}

.earn-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
}

.earn-line:last-child {
    border-bottom: none;
}

.earn-action-label {
    color: var(--muted);
}

.earn-pts {
    color: var(--amber);
    font-weight: 800;
}

/* ==========================================
   Leaderboard
   ========================================== */
.lb-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem .5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-size: .82rem;
}

.lb-item:hover {
    background: var(--surface-3);
}

.lb-rank {
    width: 18px;
    font-weight: 800;
    text-align: center;
    font-size: .72rem;
    color: var(--muted);
}

.lb-item:nth-child(1) .lb-rank {
    color: #d97706;
}

.lb-item:nth-child(2) .lb-rank {
    color: #9ca3af;
}

.lb-item:nth-child(3) .lb-rank {
    color: #cd7f32;
}

.lb-av {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .62rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.lb-name {
    flex: 1;
    color: var(--text);
    font-weight: 600;
    font-size: .82rem;
}

.lb-pts {
    color: var(--amber);
    font-weight: 800;
    font-size: .78rem;
}

/* ==========================================
   Guild Cards
   ========================================== */
.fs-guild-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.fs-guild-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-2);
}

.guild-stripe {
    height: 6px;
}

.guild-body-inner {
    padding: 1.25rem;
}

.guild-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: .75rem;
}

.guild-icon-box {
    font-size: 2rem;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .375rem;
    display: inline-flex;
}

.guild-invite-pill {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
    font-size: .62rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .1em;
    padding: .175rem .5rem;
    border-radius: var(--radius-pill);
}

.guild-name {
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: .25rem;
    color: var(--text);
}

.guild-desc {
    font-size: .8rem;
    color: var(--muted);
    line-height: 1.6;
    margin-bottom: .875rem;
}

.guild-stats {
    display: flex;
    gap: 1rem;
    margin-bottom: .875rem;
}

.guild-stat-val {
    font-weight: 800;
    font-size: .9rem;
    color: var(--text);
    display: block;
}

.guild-stat-lbl {
    font-size: .68rem;
    color: var(--muted);
}

.guild-req-box {
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .625rem;
    font-size: .76rem;
    color: var(--muted);
    line-height: 1.5;
    margin-bottom: 1rem;
}

.guild-req-box strong {
    color: var(--text);
}

/* ==========================================
   Profile
   ========================================== */
.fs-profile-header {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.profile-av-wrap {
    position: relative;
    flex-shrink: 0;
}

.profile-av {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    border: 3px solid var(--border);
    box-shadow: var(--shadow-md);
}

.profile-cert {
    position: absolute;
    bottom: -4px;
    right: -4px;
    background: var(--amber);
    color: #fff;
    font-size: .56rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: .15rem .4rem;
    border-radius: 5px;
    box-shadow: var(--shadow-sm);
}

.profile-info {
    flex: 1;
}

.profile-info h2 {
    font-size: 1.5rem;
    margin-bottom: .25rem;
}

.profile-meta-row {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    margin: .4rem 0 .7rem;
}

.profile-meta-item {
    display: flex;
    align-items: center;
    gap: .3rem;
    font-size: .8rem;
    color: var(--muted);
}

.spec-chips {
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
}

.spec-chip {
    background: var(--accent-light);
    border: 1px solid var(--accent-border);
    color: var(--accent);
    font-size: .68rem;
    font-weight: 700;
    padding: .175rem .55rem;
    border-radius: var(--radius-pill);
}

.topic-progress-row {
    display: flex;
    justify-content: space-between;
    font-size: .8rem;
    margin-bottom: .25rem;
}

.topic-pct {
    color: var(--accent);
    font-weight: 700;
}

.topic-bar {
    width: 100%;
    height: 7px;
    background: var(--border);
    border-radius: var(--radius-pill);
    overflow: hidden;
    margin-bottom: .75rem;
}

.topic-bar-fill {
    height: 100%;
    border-radius: var(--radius-pill);
    background: var(--accent);
    transition: width 1.2s ease;
}

.badge-grid {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

.badge-pill {
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .625rem .75rem;
    text-align: center;
    min-width: 78px;
    transition: var(--transition);
}

.badge-pill:hover {
    border-color: var(--accent-border);
    background: var(--accent-lighter);
}

.badge-pill.locked {
    opacity: .35;
}

.badge-emoji {
    font-size: 1.4rem;
    display: block;
    margin-bottom: .2rem;
}

.badge-lbl {
    font-size: .62rem;
    color: var(--muted);
    font-weight: 700;
}

.contrib-row {
    display: flex;
    gap: .5rem;
    padding: .625rem 0;
    border-bottom: 1px solid var(--border);
    align-items: flex-start;
}

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

.contrib-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: .35rem;
    flex-shrink: 0;
}

.contrib-text {
    font-size: .84rem;
    color: var(--text-2);
    line-height: 1.4;
}

.contrib-meta {
    font-size: .72rem;
    color: var(--muted);
    margin-top: .1rem;
}

/* ==========================================
   Auth / Landing
   ========================================== */
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2.25rem;
    box-shadow: var(--shadow-lg);
}

.auth-tabs {
    display: flex;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 1.5rem;
}

.auth-tab {
    flex: 1;
    text-align: center;
    padding: .45rem;
    border-radius: 6px;
    font-size: .85rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--muted);
    border: none;
    background: none;
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
}

.auth-tab.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.form-label {
    font-size: .72rem;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: .2rem;
    display: block;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: .875rem 0;
    color: var(--muted-2);
    font-size: .75rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ==========================================
   Utility classes
   ========================================== */
.text-accent {
    color: var(--accent);
}

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

.text-green {
    color: #059669;
}

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

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

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

/* alias */
.text-gradient {
    color: var(--accent);
}

.badge-powered {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: var(--accent-lighter);
    border: 1px solid var(--accent-border);
    color: var(--accent);
    font-size: .7rem;
    font-weight: 700;
    padding: .2rem .65rem;
    border-radius: var(--radius-pill);
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 1.5rem 0;
}

/* ==========================================
   Responsive
   ========================================== */
@media(max-width:1024px) {
    .fs-grid-2 {
        grid-template-columns: 1fr;
    }

    .fs-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .fs-stat-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .fs-sidebar-panel {
        position: static;
    }
}

@media(max-width:768px) {
    .fs-sidebar {
        transform: translateX(-100%);
    }

    .fs-sidebar.open {
        transform: translateX(0);
    }

    .fs-main {
        margin-left: 0;
    }

    .fs-topbar {
        left: 0;
    }

    .fs-sidebar-toggle {
        display: flex;
    }

    .fs-content,
    .fs-content-wide {
        padding: 1rem;
    }

    .fs-grid-3 {
        grid-template-columns: 1fr;
    }

    .fs-stat-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .fs-profile-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .profile-meta-row {
        justify-content: center;
    }

    .spec-chips {
        justify-content: center;
    }

    .fs-topic-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}