/**
 * portal.css — Base styles for Glimpse portal
 * 
 * This is a minimal functional stylesheet. It will be replaced
 * or augmented when the Cruip theme is integrated.
 */

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

:root {
    /* Colors */
    --color-primary: #6366f1;
    --color-primary-hover: #4f46e5;
    --color-secondary: #64748b;
    --color-danger: #ef4444;
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    
    --color-bg: #0f172a;
    --color-bg-secondary: #1e293b;
    --color-bg-elevated: #334155;
    
    --color-text: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-text-faint: #64748b;
    
    --color-border: #334155;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.15);
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.container-narrow {
    max-width: 720px;
}

/* Logo */
.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
    text-decoration: none;
}

.logo:hover {
    text-decoration: none;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-hover);
    text-decoration: none;
}

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

.btn-secondary:hover:not(:disabled) {
    background: #475569;
    text-decoration: none;
}

.btn-danger {
    background: var(--color-danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
    text-decoration: none;
}

.btn-oauth {
    background: white;
    color: #333;
    width: 100%;
    margin-bottom: var(--space-sm);
}

.btn-oauth:hover {
    background: #f5f5f5;
    text-decoration: none;
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1.0625rem;
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-icon {
    padding: 0.375rem;
    min-width: 32px;
}

.oauth-icon {
    width: 20px;
    height: 20px;
}

/* Site Header (Landing) */
.site-header {
    padding: var(--space-md) 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    z-index: 100;
    border-bottom: 1px solid var(--color-border);
}

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

.main-nav {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

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

.main-nav a:hover {
    color: var(--color-text);
    text-decoration: none;
}

/* App Header (Dashboard, etc.) */
.app-header {
    padding: var(--space-md) 0;
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header .container {
    display: flex;
    align-items: center;
    gap: var(--space-xl);
}

.app-nav {
    display: flex;
    gap: var(--space-md);
    flex: 1;
}

.app-nav a {
    color: var(--color-text-muted);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
}

.app-nav a:hover {
    color: var(--color-text);
    background: var(--color-bg-elevated);
    text-decoration: none;
}

.app-nav a.active {
    color: var(--color-text);
    background: var(--color-bg-elevated);
}

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

/* User Menu */
.user-menu {
    position: relative;
    display: flex;
    align-items: center;
}

.user-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    font-weight: 600;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.user-avatar.loaded {
    opacity: 1;
    pointer-events: auto;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: var(--space-sm);
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    min-width: 200px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.15s ease;
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: var(--space-md);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.dropdown-menu hr {
    border: none;
    border-top: 1px solid var(--color-border);
}

.dropdown-menu a {
    display: block;
    padding: var(--space-sm) var(--space-md);
    color: var(--color-text-muted);
}

.dropdown-menu a:hover {
    background: var(--color-bg);
    color: var(--color-text);
    text-decoration: none;
}

/* Plan Badge */
.plan-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
}

.plan-free    { background: var(--color-secondary); color: white; }
.plan-builder { background: #0ea5e9; color: white; }
.plan-pro     { background: var(--color-primary); color: white; }
.plan-team    { background: var(--color-success); color: white; }

/* type-* classes mirror plan-* but also include role-based variants (admin, support) */
.type-free    { background: var(--color-secondary); color: white; }
.type-builder { background: #0ea5e9; color: white; }
.type-pro     { background: var(--color-primary); color: white; }
.type-team    { background: var(--color-success); color: white; }
.type-admin   { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.type-support { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }

/* Hero Section */
.hero {
    padding: calc(80px + var(--space-2xl)) 0 var(--space-2xl);
    text-align: center;
}

.hero h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: var(--space-md);
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--color-text-muted);
    max-width: 600px;
    margin: 0 auto var(--space-xl);
}

.hero-cta {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
}

/* Sections */
section {
    padding: var(--space-2xl) 0;
}

section h2 {
    font-size: 2rem;
    margin-bottom: var(--space-lg);
    text-align: center;
}

/* Feature Grid */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-lg);
}

.feature-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    text-align: center;
}

.feature-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-md);
}

.feature-card h3 {
    font-size: 1.25rem;
    margin-bottom: var(--space-sm);
}

.feature-card p {
    color: var(--color-text-muted);
    font-size: 0.9375rem;
}

/* Demo Section */
.demo {
    background: var(--color-bg-secondary);
}

.demo-placeholder {
    background: var(--color-bg);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    text-align: center;
    color: var(--color-text-muted);
}

/* Pricing Grid */
.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-lg);
    max-width: 100%;
    margin: 0 auto;
}

.pricing-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    position: relative;
}

.pricing-card.featured {
    border-color: var(--color-primary);
}

.featured-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.pricing-card h3 {
    font-size: 1.5rem;
    margin-bottom: var(--space-sm);
}

.price {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: var(--space-lg);
}

.price span {
    font-size: 1rem;
    font-weight: 400;
    color: var(--color-text-muted);
}

.pricing-card ul {
    list-style: none;
    margin-bottom: var(--space-lg);
}

.pricing-card li {
    padding: var(--space-sm) 0;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
}

.pricing-card li:last-child {
    border-bottom: none;
}

.pricing-card .btn {
    width: 100%;
}

/* Footer */
.site-footer {
    background: var(--color-bg-secondary);
    border-top: 1px solid var(--color-border);
    padding: var(--space-2xl) 0 var(--space-xl);
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: var(--space-xl);
    margin-bottom: var(--space-xl);
}

.footer-brand p {
    color: var(--color-text-muted);
    margin-top: var(--space-sm);
}

.footer-links h4 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: var(--space-md);
}

.footer-links a {
    display: block;
    color: var(--color-text-muted);
    padding: var(--space-xs) 0;
}

.footer-links a:hover {
    color: var(--color-text);
}

.footer-bottom {
    text-align: center;
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* Auth Pages */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-lg);
}

.auth-container {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.auth-container .logo {
    display: inline-block;
    margin-bottom: var(--space-xl);
}

.auth-form {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    text-align: left;
}

.auth-form h1 {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: var(--space-xs);
}

.auth-subtitle {
    text-align: center;
    color: var(--color-text-muted);
    margin-bottom: var(--space-lg);
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: var(--space-lg) 0;
}

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

.auth-divider span {
    padding: 0 var(--space-md);
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.auth-links {
    margin-top: var(--space-lg);
    text-align: center;
    font-size: 0.875rem;
}

.auth-links a {
    color: var(--color-primary);
}

.auth-switch {
    display: block;
    margin-top: var(--space-sm);
    color: var(--color-text-muted);
}

/* Forms */
.form-group {
    margin-bottom: var(--space-md);
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: var(--space-xs);
}

.form-group input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: var(--space-xs);
}

.form-error {
    color: var(--color-danger);
    font-size: 0.875rem;
    margin-bottom: var(--space-md);
}

.form-success {
    color: var(--color-success);
    font-size: 0.875rem;
    margin-bottom: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: rgba(34, 197, 94, 0.1);
    border-radius: var(--radius-md);
}

/* Main Content */
.main-content {
    padding: var(--space-xl) 0;
    min-height: calc(100vh - 70px);
}

.page-header {
    margin-bottom: var(--space-xl);
}

.page-header h1 {
    font-size: 1.75rem;
    margin-bottom: var(--space-xs);
}

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

.section {
    margin-bottom: var(--space-2xl);
}

.section h2 {
    font-size: 1.25rem;
    text-align: left;
    margin-bottom: var(--space-md);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.section-link {
    font-size: 0.875rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: var(--space-xs);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
}

.stat-sublabel {
    font-size: 0.75rem;
    color: var(--color-text-faint);
    margin-top: var(--space-xs);
}

.stat-link {
    font-size: 0.875rem;
    margin-top: var(--space-sm);
    display: inline-block;
}

/* Action Grid */
.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
}

.action-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.action-card:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
}

.action-icon {
    font-size: 2rem;
    margin-bottom: var(--space-sm);
}

.action-title {
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.action-desc {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

/* Activity List */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.activity-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
}

.activity-thumbnail {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.activity-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.activity-icon {
    font-size: 1.5rem;
}

.activity-info {
    flex: 1;
}

.activity-name {
    font-weight: 500;
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--color-text-muted);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
}

.empty-state h3 {
    font-size: 1.25rem;
    color: var(--color-text);
    margin-bottom: var(--space-sm);
}

.empty-state p {
    margin-bottom: var(--space-lg);
}

.loading-state,
.error-state {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--color-text-muted);
}

.error-state {
    color: var(--color-danger);
}

/* Library */
.library-usage-bar {
    margin-bottom: var(--space-lg);
    padding: var(--space-md) var(--space-lg);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.library-usage-row {
    margin-bottom: var(--space-sm);
}

.library-usage-footer {
    margin-top: var(--space-sm);
}

.library-usage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.usage-track {
    height: 6px;
    background: var(--color-border);
    border-radius: 999px;
    overflow: hidden;
}

.usage-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--color-primary);
    transition: width 0.4s ease, background-color 0.4s ease;
    width: 0%;
}

.usage-fill.warn  { background: #f59e0b; }
.usage-fill.full  { background: #ef4444; }

.library-filters {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    gap: var(--space-md);
}

.filter-tabs {
    display: flex;
    gap: var(--space-xs);
}

.filter-tab {
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 0.875rem;
}

.filter-tab:hover {
    background: var(--color-bg-elevated);
}

.filter-tab.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

.search-box input {
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: 0.875rem;
    width: 200px;
}

.search-box input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-md);
}

.library-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-border);
}

.library-pagination .page-indicator {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    min-width: 7rem;
    text-align: center;
}

.library-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-thumbnail {
    height: 160px;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-icon {
    font-size: 3rem;
}

.card-info {
    padding: var(--space-md);
}

.card-name {
    font-weight: 500;
    margin-bottom: var(--space-xs);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-meta {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    display: flex;
    justify-content: space-between;
}

.card-actions {
    padding: 0 var(--space-md) var(--space-md);
    display: flex;
    gap: var(--space-sm);
}

/* Billing */
.plan-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    display: flex;
    align-items: center;
    gap: var(--space-xl);
}

.plan-details {
    flex: 1;
}

.plan-name {
    font-size: 1.5rem;
    font-weight: 700;
}

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

.plan-features {
    flex: 2;
}

.plan-features ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm) var(--space-lg);
}

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

.usage-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.usage-bar-container {
    height: 8px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: var(--space-md);
}

.usage-bar {
    height: 100%;
    background: var(--color-primary);
    border-radius: var(--radius-sm);
    transition: width 0.3s ease;
}

.usage-bar.warning {
    background: var(--color-warning);
}

.usage-bar.exceeded {
    background: var(--color-danger);
}

.usage-stats {
    font-size: 1.25rem;
    font-weight: 600;
}

.usage-label {
    font-weight: 400;
    color: var(--color-text-muted);
    margin-left: var(--space-xs);
}

.usage-reset {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-top: var(--space-sm);
}

.payment-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#payment-info {
    display: flex;
    gap: var(--space-md);
}

.card-brand {
    font-weight: 600;
}

.card-last4,
.card-expiry {
    color: var(--color-text-muted);
}

.billing-history {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.history-empty {
    text-align: center;
    color: var(--color-text-muted);
}

.billing-hint {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    border-top: 1px dashed var(--color-border);
    padding-top: var(--space-md);
    margin-bottom: var(--space-md);
}

/* Settings */
.settings-section {
    margin-bottom: var(--space-xl);
}

.settings-section h2 {
    font-size: 1.125rem;
    margin-bottom: var(--space-md);
}

.settings-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--color-border);
}

.settings-row:first-child {
    padding-top: 0;
}

.settings-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.settings-row label {
    font-weight: 500;
}

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

.settings-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: var(--space-xs);
}

.settings-description {
    color: var(--color-text-muted);
    margin-bottom: var(--space-lg);
}

.toggle-row > div {
    flex: 1;
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--color-bg-elevated);
    transition: 0.2s;
    border-radius: 24px;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.2s;
    border-radius: 50%;
}

.toggle input:checked + .toggle-slider {
    background-color: var(--color-primary);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* Smaller toggle variant for sub-rows */
.toggle-sm {
    width: 36px;
    height: 20px;
}
.toggle-sm .toggle-slider::before {
    height: 14px;
    width: 14px;
}
.toggle-sm input:checked + .toggle-slider::before {
    transform: translateX(16px);
}

/* Onboarding per-plan sub-rows */
.tour-sub-rows {
    border-left: 2px solid var(--color-border);
    margin-left: 4px;
    padding-left: 16px;
    overflow: hidden;
}
.tour-sub-rows .tour-sub-row {
    padding-top: 10px;
    padding-bottom: 10px;
}
.tour-sub-rows .tour-sub-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.tour-sub-rows .tour-sub-row label:not(.toggle) {
    font-size: 0.85rem;
    font-weight: 500;
}
/* Dimmed + non-interactive when master toggle is off */
.tour-sub-rows.tour-sub-disabled {
    opacity: 0.38;
    pointer-events: none;
}

/* Danger Zone */
.danger-zone h2 {
    color: var(--color-danger);
}

.danger-zone .settings-card {
    border-color: var(--color-danger);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
}

.modal-content {
    position: relative;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    max-width: 400px;
    width: 90%;
}

.modal-content h3 {
    font-size: 1.25rem;
    margin-bottom: var(--space-sm);
}

.modal-content p {
    color: var(--color-text-muted);
    margin-bottom: var(--space-md);
}

.modal-content ul {
    margin-left: var(--space-lg);
    margin-bottom: var(--space-md);
    color: var(--color-text-muted);
}

.modal-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
    margin-top: var(--space-lg);
}

/* Responsive */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 2rem;
    }
    
    .hero-cta {
        flex-direction: column;
    }
    
    .main-nav {
        display: none;
    }
    
    .app-header .container {
        flex-wrap: wrap;
    }
    
    .app-nav {
        order: 3;
        width: 100%;
        justify-content: center;
        margin-top: var(--space-md);
    }
    
    .footer-grid {
        grid-template-columns: 1fr;
    }
    
    .plan-card {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .plan-features ul {
        flex-direction: column;
    }
    
    .library-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box input {
        width: 100%;
    }
}

/* ============================================================
   Cruip-style app header helpers
   ============================================================ */

/* Frosted glass header background */
.app-header-blur {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background-color: rgba(15, 23, 42, 0.95);
}

/* Header inner row: logo | nav | actions (actions anchored right) */
.app-header-inner {
    display: flex;
    align-items: center;
    height: 4rem; /* h-16 */
    gap: 1rem; /* ~20% of a nav pill width between logo and nav */
}

/* Logo area */
.app-logo-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}
.app-logo-link:hover { text-decoration: none; }

.app-logo-icon {
    width: 1.75rem;   /* 28px */
    height: 1.75rem;
    flex-shrink: 0;
}

.app-logo-text {
    font-size: 1.0625rem;
    line-height: 1;
}

/* Nav container */
.app-nav-cruip {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Nav pill links */
.app-nav-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    text-decoration: none;
    transition: color 0.15s ease, background-color 0.15s ease;
}
.app-nav-pill:hover { text-decoration: none; }

/* Header right-side actions gap */
.app-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

/* ============================================================
   Accessibility: skip-to-content link
   ============================================================ */

.skip-nav {
    position: absolute;
    top: -9999px;
    left: 1rem;
    z-index: 9999;
    background: #4f46e5;
    color: #fff;
    padding: 0.6rem 1rem;
    border-radius: 0 0 0.375rem 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
}
.skip-nav:focus { top: 0; }

/* Character counter for textareas */
.char-counter {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-align: right;
    margin-top: 0.25rem;
}
.char-counter.near-limit { color: #f59e0b; }
.char-counter.at-limit    { color: #ef4444; }

/* ============================================================
   Mobile nav hamburger + drawer (portal pages)
   ============================================================ */
.mobile-nav-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    border-radius: 0.375rem;
    flex-shrink: 0;
}
.mobile-nav-btn:hover { color: #e2e8f0; }

.mobile-nav-drawer {
    display: none;
    position: absolute;
    top: 100%; /* positioned below the sticky header */
    left: 0;
    right: 0;
    z-index: 40;
    background: rgba(15, 23, 42, 0.98);
    border-bottom: 1px solid #1e293b;
    padding: 1rem 1.5rem 1.25rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.mobile-nav-drawer.open { display: block; }

.mobile-nav-drawer a {
    display: block;
    padding: 0.65rem 0;
    color: #94a3b8;
    font-size: 0.925rem;
    border-bottom: 1px solid #1e293b;
    text-decoration: none;
}
.mobile-nav-drawer a:last-child { border-bottom: none; }
.mobile-nav-drawer a:hover { color: #e2e8f0; text-decoration: none; }
.mobile-nav-drawer a.active { color: #818cf8; }

@media (max-width: 639px) { /* below sm: */
    .mobile-nav-btn { display: flex; }
    .app-nav-cruip { display: none !important; }
}
