:root {
    /* --- 1. Elite-Tier Design Tokens --- */
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Density Scale */
    --text-xs: 0.75rem;     /* 12px */
    --text-sm: 0.8125rem;   /* 13px */
    --text-base: 0.9375rem; /* 15px */
    
    /* Colors */
    --bg-app: #F7F8FA; 
    --bg-gradient: linear-gradient(135deg, #F7F8FA 0%, #E2E8F0 100%);
    --surface-card: #FFFFFF;
    
    --border-subtle: #E2E8F0; /* Slate 200 */
    --border-hover: #CBD5E1;  /* Slate 300 */
    
    --text-main: #0F172A;     /* Slate 900 */
    --text-secondary: #64748B; /* Slate 500 */
    --text-tertiary: #94A3B8;  /* Slate 400 */
    --text-danger: #EF4444;    /* Red 500 */

    /* Semantic Tints */
    --tint-blue: #EFF6FF;
    --tint-green: #F0FDF4;
    --tint-amber: #FFFBEB;
    --tint-gray: #F8FAFC;
    --tint-danger: #FEF2F2;

    /* Brand - HIGH CONTRAST THEME */
    --brand-primary: #000000; /* Solid Black */
    --brand-hover: #1A1A1A;   /* Off Black */
    --brand-focus: #2563EB;   /* Focus Blue */

    /* Shadows */
    --shadow-card: 0 1px 2px -1px rgba(0,0,0,0.05);
    --shadow-hover: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --shadow-modal: 0 25px 50px -12px rgba(0,0,0,0.25);

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-6: 24px;
    --space-8: 32px;

    /* Layout */
    --sidebar-width: 240px;
    --timeline-width: 68px;
    --media-gallery-height: 140px;
}

/* --- Global Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: var(--font-sans);
    background-color: var(--bg-app);
    background-image: var(--bg-gradient);
    color: var(--text-main);
    font-size: var(--text-base);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    display: flex;
}
button { cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; color: var(--text-main); }
a { color: inherit; text-decoration: none; }

/* --- App Shell --- */
.app-shell {
    display: grid; grid-template-columns: var(--sidebar-width) 1fr;
    width: 100%; height: 100%;
}

/* Sidebar */
.sidebar {
    background: var(--surface-card);
    border-right: 1px solid var(--border-subtle);
    padding: var(--space-4);
    display: flex; flex-direction: column; justify-content: space-between; z-index: 20;
}
.brand-area { padding: var(--space-2) var(--space-2) var(--space-6); }
.brand-logo { height: 24px; width: auto; opacity: 0.9; }

.nav-menu { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
    display: flex; align-items: center; gap: var(--space-3);
    padding: 10px 12px;
    border-radius: 6px; color: var(--text-secondary);
    font-weight: 500; font-size: var(--text-sm);
    transition: all 0.15s; text-decoration: none;
}
.nav-item:hover { background: var(--bg-app); color: var(--text-main); }
.nav-item.active { background: var(--bg-app); color: var(--text-main); font-weight: 600; }

/* Main Content */
.main-viewport {
    display: flex; flex-direction: column;
    position: relative; overflow: hidden;
    background: transparent;
}

/* Header */
.app-header {
    height: 64px;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 var(--space-6);
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    position: sticky; top: 0; z-index: 30;
}
.header-title { font-weight: 700; font-size: var(--text-lg); color: var(--text-main); letter-spacing: -0.02em; }

/* Toolbar */
.toolbar {
    display: flex; align-items: center; gap: var(--space-3);
    background: white; padding: 6px 10px;
    border-radius: 8px; border: 1px solid var(--border-subtle);
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.search-input {
    border: none; outline: none; width: 200px; font-size: var(--text-sm);
}
.search-input::placeholder { color: var(--text-tertiary); }
.filter-select {
    border: none; outline: none; background: transparent;
    font-size: 12px; font-weight: 600; color: var(--text-secondary);
    cursor: pointer; text-transform: uppercase; letter-spacing: 0.02em;
}

/* Buttons (High Contrast Black) */
.action-primary {
    background: var(--brand-primary); color: white;
    padding: 0 16px; height: 36px; border-radius: 6px;
    font-size: var(--text-sm); font-weight: 500;
    display: flex; align-items: center; justify-content: center; gap: var(--space-2);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.15s ease-out; text-decoration: none;
}
.action-primary:hover { background: var(--brand-hover); transform: translateY(-1px); box-shadow: 0 4px 6px -1px rgba(0,0,0,0.15); }
.action-primary:active { transform: scale(0.98); }
.action-primary:focus-visible { outline: 2px solid var(--brand-focus); outline-offset: 2px; }

/* --- Feed --- */
.feed-container {
    flex: 1; overflow-y: auto;
    padding: var(--space-6);
    display: flex; flex-direction: column; gap: var(--space-6);
}

.date-group-header {
    display: flex; align-items: center; gap: var(--space-4);
    margin: var(--space-2) 0; opacity: 0; animation: fadeIn 0.4s forwards;
}
.date-label {
    font-family: var(--font-mono); font-size: 11px; font-weight: 700;
    color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em;
    background: var(--tint-gray); padding: 4px 8px; border-radius: 4px; border: 1px solid var(--border-subtle);
}
.date-line { flex: 1; height: 1px; background: var(--border-subtle); }

/* Card */
.card {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: var(--space-4);
    display: grid; grid-template-columns: 1fr 200px; /* Fixed width for media gallery */
    gap: var(--space-6);
    box-shadow: var(--shadow-card);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    opacity: 0;
    min-height: 180px; /* Minimum height for consistency */
}
.card.animate-in { animation: fadeInUp 0.4s ease-out forwards; }
.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    border-color: var(--border-hover);
}

/* Card Content */
.card-main { display: flex; flex-direction: column; gap: var(--space-3); }
.card-meta { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.card-title { font-size: var(--text-base); font-weight: 700; color: var(--text-main); margin-right: 8px; letter-spacing: -0.01em; }

.badge {
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    padding: 4px 8px; border-radius: 4px; letter-spacing: 0.03em;
    height: 20px; display: flex; align-items: center;
}
.badge-region { background: var(--tint-gray); color: var(--text-secondary); border: 1px solid rgba(0,0,0,0.05); }
.badge-pillar { background: var(--tint-blue); color: #2563EB; border: 1px solid rgba(37, 99, 235, 0.1); }

.card-body p {
    font-size: var(--text-sm); color: var(--text-secondary);
    line-height: 1.6; margin: 0;
    display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.concept-text { font-style: italic; color: var(--text-main) !important; font-weight: 500; }

/* Card Aside (Media & Actions) */
.card-aside {
    display: flex; flex-direction: column; justify-content: space-between;
    height: 100%; gap: var(--space-3);
}

/* Media Gallery (Fixed Grid) */
.media-gallery {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Always dual slots */
    gap: 8px;
    width: 100%;
    height: 100px; /* Fixed height for consistency */
}

/* Media Slot (Standardized) */
.media-slot {
    width: 100%;
    height: 100%;
    border-radius: 6px;
    background-color: var(--bg-app);
    border: 1px solid var(--border-subtle);
    background-size: cover;
    background-position: center;
    position: relative;
    overflow: hidden;
    cursor: default;
    transition: border-color 0.2s;
    aspect-ratio: 1 / 1;
}
.media-slot:hover { border-color: var(--text-tertiary); }

/* Overlays & Actions */
.media-overlay {
    position: absolute; inset: 0; background: rgba(0,0,0,0.65);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    opacity: 0; transition: opacity 0.2s ease;
    backdrop-filter: blur(2px);
}
.media-slot:hover .media-overlay { opacity: 1; }

.action-chip {
    background: rgba(255,255,255,0.95); color: var(--text-main);
    font-size: 9px; font-weight: 700; text-transform: uppercase;
    padding: 4px 8px; border-radius: 4px; border: none;
    display: flex; align-items: center; gap: 4px;
    cursor: pointer; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.15s, background 0.15s;
    width: 80%; justify-content: center;
}
.action-chip:hover { transform: scale(1.05); background: white; color: var(--brand-focus); }
.action-chip svg { width: 12px; height: 12px; stroke-width: 2px; }

/* Video Badge */
.video-badge {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    pointer-events: none; color: white; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
.media-slot:hover .video-badge { opacity: 0; }

/* Empty State (Dashed) */
.media-slot.empty {
    border: 1px dashed var(--text-tertiary);
    background-color: white;
    display: flex; align-items: center; justify-content: center;
}
.media-slot.empty:hover { border-color: var(--brand-focus); background-color: var(--tint-gray); }
.empty-icon { color: var(--text-tertiary); transition: opacity 0.2s; }
.media-slot.empty:hover .empty-icon { opacity: 0; display: none; }

/* Actions */
.card-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: auto; }

.btn-icon-sm {
    width: 32px; height: 32px; border-radius: 6px;
    color: var(--text-tertiary); display: flex; align-items: center; justify-content: center;
    transition: all 0.15s; cursor: pointer;
}
.btn-icon-sm:hover { background: var(--bg-app); color: var(--text-main); }
.btn-icon-sm:active { transform: scale(0.95); }

/* --- Toggles --- */

/* Publication Toggle */
.pub-toggle {
    display: flex; align-items: center; gap: 8px; cursor: pointer;
}
.pub-toggle input { display: none; }
.pub-track {
    width: 32px; height: 18px; background: var(--border-hover);
    border-radius: 99px; position: relative; transition: background 0.2s ease;
}
.pub-thumb {
    width: 14px; height: 14px; background: white; border-radius: 50%;
    position: absolute; top: 2px; left: 2px; transition: transform 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.pub-toggle input:checked + .pub-track { background: #059669; }
.pub-toggle input:checked + .pub-track .pub-thumb { transform: translateX(14px); }
.status-text { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--text-secondary); width: 60px; }

/* Completion Checkbox */
.done-wrapper { cursor: pointer; display: flex; align-items: center; }
.done-checkbox { display: none; }
.done-box {
    width: 18px; height: 18px; border: 2px solid var(--border-hover);
    border-radius: 4px; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; background: white;
}
.done-checkbox:checked + .done-box {
    background: var(--text-main); border-color: var(--text-main);
}

/* --- Modals --- */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
    z-index: 1000; opacity: 0; visibility: hidden; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.modal-backdrop.active { opacity: 1; visibility: visible; }

.modal-panel {
    background: white; width: 100%; max-width: 600px;
    border-radius: 12px; box-shadow: var(--shadow-modal);
    transform: scale(0.98); transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex; flex-direction: column; max-height: 90vh;
}
.modal-backdrop.active .modal-panel { transform: scale(1); }

.modal-header {
    padding: var(--space-6); border-bottom: 1px solid var(--border-subtle);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { font-size: var(--text-lg); font-weight: 700; color: var(--text-main); }

.modal-body { padding: var(--space-6); overflow-y: auto; }

.form-grid { display: flex; flex-direction: column; gap: 24px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

.modal-footer {
    padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border-subtle);
    display: flex; justify-content: flex-end; gap: var(--space-3); background: var(--tint-gray);
    border-radius: 0 0 12px 12px;
}

.input-label {
    display: block; font-size: 11px; font-weight: 700; color: var(--text-secondary);
    text-transform: uppercase; margin-bottom: 8px; letter-spacing: 0.04em;
}
.form-input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border-hover);
    border-radius: 6px; font-size: var(--text-sm); color: var(--text-main);
    transition: border-color 0.15s, box-shadow 0.15s; background: white;
}
.form-input:focus { outline: none; border-color: var(--text-main); box-shadow: 0 0 0 1px var(--text-main); }
textarea.form-input { resize: vertical; min-height: 80px; line-height: 1.5; }

.btn-secondary {
    padding: 0 16px; height: 36px; background: white; border: 1px solid var(--border-hover);
    border-radius: 6px; color: var(--text-main); font-weight: 500; font-size: var(--text-sm);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.1s;
}
.btn-secondary:hover { background: var(--bg-app); border-color: var(--text-secondary); }

/* Utilities */
.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Toast */
.toast {
    position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: #171717; color: white; padding: 10px 20px; border-radius: 99px;
    font-weight: 500; font-size: 13px; opacity: 0; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); z-index: 2000;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); display: flex; align-items: center; gap: 8px;
}
.toast.active { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #EF4444; }

/* Loading */
.loading-overlay {
    position: absolute; inset: 0; background: rgba(255,255,255,0.8);
    display: flex; align-items: center; justify-content: center; z-index: 50;
    backdrop-filter: blur(2px);
}
.spinner {
    width: 24px; height: 24px; border: 2px solid var(--border-hover);
    border-top-color: var(--brand-primary); border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- LOGIN PAGE STYLES --- */
.login-body {
    display: flex; align-items: center; justify-content: center;
    height: 100vh; background-color: var(--bg-app);
    background-image: radial-gradient(circle at 50% 50%, #F1F5F9 0%, #E2E8F0 100%);
}

.login-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    padding: 48px;
    width: 100%; max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.15);
    display: flex; flex-direction: column; align-items: center; text-align: center;
}

.login-brand { margin-bottom: 24px; }
.login-brand img { height: 32px; width: auto; }

.login-title { font-size: 1.5rem; font-weight: 700; color: var(--text-main); margin-bottom: 8px; letter-spacing: -0.02em; }
.login-subtitle { font-size: var(--text-sm); color: var(--text-secondary); margin-bottom: 32px; }

.login-btn {
    background: var(--brand-primary); color: white;
    width: 100%; height: 44px; border-radius: 8px;
    font-weight: 600; font-size: var(--text-sm);
    display: flex; align-items: center; justify-content: center; gap: 12px;
    transition: all 0.15s ease;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}
.login-btn:hover { background: var(--brand-hover); transform: translateY(-1px); }
.login-btn:active { transform: scale(0.98); }