/* Dev-Journal Styles - Enhanced Dark Theme with Mobile-First Responsive Design */

/* ========================================
   CSS VARIABLES - Design Tokens
   ======================================== */
:root {
    /* Colors */
    --bg: #0f172a;
    --bg-secondary: #1e293b;
    --card: #111827;
    --card-bg: #111827;
    --card-hover: #1a2332;
    --border: #1f2933;
    --border-hover: #374151;
    --done: #22c55e;
    --done-hover: #16a34a;
    --todo: #f59e0b;
    --text: #e5e7eb;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --purple: #a855f7;
    --navbar-bg: #020617;

    /* Spacing Scale */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Typography Scale */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;

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

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.3);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;

    /* Animation Timing (Fluent Design) */
    --anim-fast: 150ms;
    --anim-normal: 200ms;
    --anim-slow: 300ms;
    --anim-slower: 400ms;
    --anim-easing: cubic-bezier(0.1, 0.9, 0.2, 1.0);
    --anim-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --anim-smooth: cubic-bezier(0.4, 0, 0.2, 1);

    /* Layout */
    --header-height: 70px;
    --nav-height: 60px;
    --sidebar-width: 280px;
    --content-max-width: 1400px;

    /* Accessibility - WCAG 2.2 */
    --min-touch-target: 44px;
    --focus-ring: 0 0 0 3px rgba(59, 130, 246, 0.5);
    --focus-outline-width: 2px;
    --success: #22c55e;
}

/* ========================================
   WCAG 2.2 ACCESSIBILITY
   ======================================== */

/* Skip Link - for keyboard navigation */
.skip-link {
    position: absolute;
    top: -100px;
    left: var(--space-md);
    background: var(--primary);
    color: white;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    z-index: 10000;
    text-decoration: none;
    font-weight: 600;
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: var(--space-md);
    outline: none;
}

/* Focus Indicators - visible for all interactive elements */
*:focus-visible {
    outline: var(--focus-outline-width) solid var(--primary);
    outline-offset: 2px;
}

/* Remove default outline for mouse users */
*:focus:not(:focus-visible) {
    outline: none;
}

/* Enhanced focus for buttons and links */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: var(--focus-outline-width) solid var(--primary);
    outline-offset: 2px;
    box-shadow: var(--focus-ring);
}

/* Minimum Touch Targets - 44x44px for mobile */
button,
.btn-primary,
.btn-secondary,
.btn-danger,
a.nav-link,
input[type="checkbox"],
input[type="radio"] {
    min-height: var(--min-touch-target);
}

/* Reduced Motion - respect user preferences */
@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;
    }
}

/* ========================================
   BASE STYLES
   ======================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   HEADER
   ======================================== */
header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, var(--bg) 0%, var(--bg-secondary) 100%);
}

header .header-content {
    max-width: var(--content-max-width);
    margin: 0 auto;
}

header h1 {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

header h1 .logo-icon {
    font-size: var(--text-xl);
}

header p {
    margin-top: var(--space-sm);
    color: var(--text-muted);
    font-size: var(--text-sm);
}

/* ========================================
   NAVIGATION
   ======================================== */
nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--navbar-bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-lg);
    height: var(--nav-height);
    max-width: var(--content-max-width);
    margin: 0 auto;
}

.nav-brand {
    font-weight: 700;
    font-size: var(--text-lg);
    color: var(--done);
    text-decoration: none;
    transition: color var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.nav-brand:hover {
    color: #4ade80;
}

.nav-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    margin-left: var(--space-lg);
    gap: var(--space-lg);
    min-width: 0;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    flex-wrap: wrap;
    min-width: 0;
}

.nav-link,
.nav-link:visited {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}

.nav-link:hover {
    color: var(--text);
    background: var(--bg-secondary);
    transform: translateY(-1px);
}

.nav-link.active,
.nav-link.active:visited {
    color: var(--primary);
    background: rgba(59, 130, 246, 0.15);
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.mobile-menu-btn:hover {
    background: var(--bg-secondary);
}

.mobile-menu-btn .hamburger-line {
    width: 24px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: all var(--transition-normal);
}

.mobile-menu-btn.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-btn.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

.btn-sm {
    min-height: 38px;
    padding: 6px 12px;
}

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

/* Search Box */
.search-box {
    display: flex;
    align-items: center;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.search-box input {
    background: transparent;
    border: none;
    padding: var(--space-sm) var(--space-md);
    color: var(--text);
    width: 220px;
    outline: none;
    font-size: var(--text-sm);
}

.search-box input::placeholder {
    color: var(--text-dim);
}

.search-box button {
    background: transparent;
    border: none;
    padding: var(--space-sm) var(--space-md);
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition-fast), background var(--transition-fast);
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-box button:hover {
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

/* ========================================
   BUTTONS
   ======================================== */
.btn-new, .btn-primary {
    background: linear-gradient(135deg, var(--done) 0%, var(--done-hover) 100%);
    color: white;
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: 600;
    font-size: var(--text-sm);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    min-height: 44px;
    min-width: 44px;
    box-shadow: var(--shadow-sm);
    /* Animation: Smooth hover lift + scale */
    transition: transform var(--anim-fast) var(--anim-easing),
                box-shadow var(--anim-fast) var(--anim-easing),
                background var(--anim-normal) var(--anim-easing);
}

.btn-new:hover, .btn-primary:hover {
    background: linear-gradient(135deg, var(--done-hover) 0%, #15803d 100%);
    transform: translateY(-2px) scale(1.02);
    box-shadow: var(--shadow-md), 0 0 20px rgba(34, 197, 94, 0.3);
}

.btn-new:active, .btn-primary:active {
    transform: translateY(0) scale(0.98);
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    background: var(--card);
    color: var(--text);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-md);
    text-decoration: none;
    border: 1px solid var(--border);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    font-weight: 500;
    font-size: var(--text-sm);
    min-height: 44px;
    min-width: 44px;
    /* Animation: Smooth hover transitions */
    transition: transform var(--anim-fast) var(--anim-easing),
                background var(--anim-fast) var(--anim-easing),
                border-color var(--anim-fast) var(--anim-easing),
                color var(--anim-fast) var(--anim-easing),
                box-shadow var(--anim-fast) var(--anim-easing);
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px) scale(1.01);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.btn-secondary:active {
    transform: translateY(0) scale(0.98);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, var(--danger-hover) 100%);
    color: white;
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: var(--text-sm);
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    /* Animation: Smooth hover transitions */
    transition: transform var(--anim-fast) var(--anim-easing),
                box-shadow var(--anim-fast) var(--anim-easing),
                background var(--anim-normal) var(--anim-easing);
}

.btn-danger:hover {
    background: linear-gradient(135deg, var(--danger-hover) 0%, #b91c1c 100%);
    transform: translateY(-2px) scale(1.02);
    box-shadow: var(--shadow-md), 0 0 20px rgba(239, 68, 68, 0.3);
}

.btn-danger:active {
    transform: translateY(0) scale(0.98);
    box-shadow: var(--shadow-sm);
}

.btn-ai {
    background: rgba(167, 139, 250, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(167, 139, 250, 0.3);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--text-base);
    transition: all var(--transition-base);
}

.btn-ai:hover {
    background: rgba(167, 139, 250, 0.25);
    color: #c4b5fd;
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(167, 139, 250, 0.2);
}

.btn-ai:active {
    transform: translateY(0) scale(0.98);
}

/* ========================================
   MAIN CONTAINER & LAYOUT
   ======================================== */
.container {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    gap: var(--space-lg);
    padding: var(--space-lg);
    max-width: var(--content-max-width);
    margin: 0 auto;
}

.page-main {
    display: block;
    width: min(100%, var(--content-max-width));
    margin: 0 auto;
    padding: var(--space-lg);
}

.form-container {
    display: block;
    max-width: 800px;
    padding: var(--space-lg);
    margin: 0 auto;
}

.auth-page {
    padding-top: var(--space-lg);
    padding-bottom: var(--space-lg);
}

.entry-view-container {
    grid-template-columns: 1fr 320px;
    min-width: 0;
}

.entry-view-container > .entry-view,
.entry-view-container > .entry-sidebar {
    min-width: 0;
    max-width: 100%;
}

/* ========================================
   SIDEBAR
   ======================================== */
.sidebar {
    position: sticky;
    top: calc(var(--nav-height) + var(--space-lg));
    height: fit-content;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.sidebar-section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    transition: border-color var(--transition-fast);
}

.sidebar-section:hover {
    border-color: var(--border-hover);
}

.sidebar-section h3 {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.category-list {
    list-style: none;
}

.category-list li {
    margin-bottom: var(--space-xs);
}

.category-list li a {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    color: var(--text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    font-size: var(--text-sm);
    min-height: 40px;
}

.category-list li a:hover {
    background: var(--bg-secondary);
    color: var(--primary);
    transform: translateX(4px);
}

.category-list li a.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: white;
    font-weight: 500;
}

/* Tag Cloud */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.tag {
    background: var(--bg-secondary);
    color: var(--text-muted);
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    font-weight: 500;
}

.tag:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.05);
}

/* Stats */
.stats-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
    border-bottom: 1px dashed var(--border);
    font-size: var(--text-sm);
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-count {
    font-weight: 700;
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
}

/* ========================================
   FILE EXPLORER TREE VIEW
   ======================================== */
.file-tree-section h3 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.file-tree {
    font-family: system-ui, -apple-system, sans-serif;
    font-size: var(--text-sm);
}

.tree-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    list-style: none;
}

.tree-item:hover {
    background: var(--bg-secondary);
}

.tree-item.root {
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.tree-toggle {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 10px;
    cursor: pointer;
    user-select: none;
    transition: transform var(--transition-fast);
}

.tree-toggle:not(.expanded) {
    transform: rotate(-90deg);
}

.tree-icon {
    font-size: var(--text-base);
    flex-shrink: 0;
}

.tree-label {
    flex: 1;
    color: var(--text);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.tree-label:hover {
    color: var(--primary);
}

.tree-label.active {
    color: var(--primary);
    font-weight: 600;
}

.tree-count {
    font-size: var(--text-xs);
    color: var(--text-dim);
    background: var(--bg);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    min-width: 24px;
    text-align: center;
}

.tree-children {
    margin: 0;
    padding: 0;
    padding-left: var(--space-lg);
}

.tree-children.collapsed {
    display: none;
}

/* ========================================
   BREADCRUMB NAVIGATION
   ======================================== */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) 0;
    margin-bottom: var(--space-md);
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.breadcrumb-item {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.breadcrumb-item:hover {
    color: var(--primary);
}

.breadcrumb-separator {
    color: var(--text-dim);
}

.breadcrumb-current {
    color: var(--text);
    font-weight: 500;
}

/* ========================================
   VIEW TOGGLE
   ======================================== */
.content-title-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.view-toggle {
    display: flex;
    gap: var(--space-xs);
    background: var(--card);
    padding: var(--space-xs);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.view-btn {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: var(--text-lg);
}

.view-btn:hover {
    color: var(--text);
    background: var(--bg-secondary);
}

.view-btn.active {
    color: var(--primary);
    background: rgba(59, 130, 246, 0.15);
}

/* ========================================
   LIST VIEW MODE
   ======================================== */
.entries-grid.list-view {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.entries-grid.list-view .entry-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
}

.entries-grid.list-view .entry-card-header {
    flex-shrink: 0;
    margin-bottom: 0;
}

.entries-grid.list-view .entry-card h3 {
    flex: 1;
    margin: 0;
    font-size: var(--text-base);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.entries-grid.list-view .entry-preview {
    display: none;
}

.entries-grid.list-view .entry-card-footer {
    flex-shrink: 0;
    margin-top: 0;
    gap: var(--space-md);
}

.entries-grid.list-view .entry-tags {
    display: none;
}

/* Entry Icon */
.entry-icon {
    font-size: var(--text-lg);
}

/* Entry Meta */
.entry-meta {
    font-size: var(--text-xs);
    color: var(--text-dim);
}

/* ========================================
   CONTENT AREA
   ======================================== */
.content {
    min-height: 400px;
}

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

.content-header h2 {
    font-size: var(--text-xl);
    font-weight: 700;
}

.entry-count {
    color: var(--text-muted);
    font-size: var(--text-sm);
    background: var(--card);
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-full);
}

/* ========================================
   ENTRIES GRID
   ======================================== */
.entries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-lg);
}

.entry-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: all var(--transition-normal);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.entry-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--purple));
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.entry-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.entry-card:hover::before {
    opacity: 1;
}

.entry-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-md);
    gap: var(--space-sm);
}

.entry-category {
    font-size: var(--text-xs);
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
    text-transform: capitalize;
}

.entry-category.daily-learning {
    background: rgba(34, 197, 94, 0.15);
    color: var(--done);
    border: 1px solid rgba(34, 197, 94, 0.3);
}
.entry-category.project-note {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary);
    border: 1px solid rgba(59, 130, 246, 0.3);
}
.entry-category.bug-fix {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.entry-category.code-snippet {
    background: rgba(168, 85, 247, 0.15);
    color: var(--purple);
    border: 1px solid rgba(168, 85, 247, 0.3);
}
.entry-category.concept {
    background: rgba(245, 158, 11, 0.15);
    color: var(--todo);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.entry-card h3 {
    font-size: var(--text-lg);
    margin-bottom: var(--space-sm);
    color: var(--text);
    line-height: 1.4;
    font-weight: 600;
}

.entry-card p {
    color: var(--text-muted);
    font-size: var(--text-sm);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
}

.entry-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border);
    gap: var(--space-sm);
}

.entry-date {
    font-size: var(--text-xs);
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.entry-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    justify-content: flex-end;
}

.entry-tag {
    font-size: var(--text-xs);
    padding: 2px var(--space-sm);
    background: var(--bg);
    border-radius: var(--radius-full);
    color: var(--text-dim);
    border: 1px solid var(--border);
}

/* ========================================
   LOADING STATE
   ======================================== */
.loading {
    text-align: center;
    padding: var(--space-3xl);
    color: var(--text-muted);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto var(--space-md);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* No Entries */
.no-entries {
    text-align: center;
    padding: var(--space-3xl) var(--space-lg);
    color: var(--text-muted);
    background: var(--card);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border);
}

.no-entries p {
    font-size: var(--text-lg);
    margin-bottom: var(--space-lg);
}

/* ========================================
   FORMS
   ======================================== */
.entry-form {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
}

.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label {
    display: block;
    margin-bottom: var(--space-sm);
    font-weight: 600;
    color: var(--text);
    font-size: var(--text-sm);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    color: var(--text);
    font-size: var(--text-base);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-dim);
}

.form-group textarea {
    resize: vertical;
    min-height: 180px;
    line-height: 1.7;
}

.form-group small {
    display: block;
    margin-top: var(--space-xs);
    color: var(--text-dim);
    font-size: var(--text-xs);
}

.editor-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.editor-toolbar-divider {
    width: 1px;
    height: 20px;
    background: var(--border);
}

.editor-mode-btn,
.editor-tool-btn {
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text);
    border-radius: var(--radius-sm);
    min-height: 36px;
    padding: 6px 12px;
    font-size: var(--text-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.editor-mode-btn:hover,
.editor-tool-btn:hover {
    border-color: var(--primary);
    color: #dbeafe;
}

.editor-mode-btn.active {
    background: rgba(59, 130, 246, 0.22);
    border-color: rgba(59, 130, 246, 0.65);
    color: #bfdbfe;
}

.editor-tool-btn.is-uploading {
    opacity: 0.85;
    cursor: wait;
}

.code-section {
    border-top: 1px solid var(--border);
    padding-top: var(--space-lg);
    margin-top: var(--space-lg);
}

.code-section h4 {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-md);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.code-inputs {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.code-inputs input {
    max-width: 250px;
}

.code-inputs textarea {
    font-family: 'Consolas', 'Monaco', 'Fira Code', monospace;
    font-size: var(--text-sm);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-md);
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.form-message {
    margin-top: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    text-align: center;
    font-weight: 500;
}

.form-message.success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--done);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.form-message.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ========================================
   ENTRY VIEW
   ======================================== */
.entry-view {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    overflow: hidden;
}

.entry-view h2 {
    font-size: var(--text-2xl);
    margin-bottom: var(--space-md);
    line-height: 1.3;
}

.entry-md-shell {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    min-width: 0;
}

.entry-md-toolbar {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    width: fit-content;
    max-width: 100%;
}

.entry-md-mode-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    min-height: 36px;
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: 600;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.entry-md-mode-btn:hover {
    background: var(--bg);
    color: var(--text);
}

.entry-md-mode-btn.active {
    background: var(--primary);
    color: #fff;
}

.entry-md-preview {
    width: 100%;
    max-width: 920px;
    margin: 0 auto;
    padding: var(--space-lg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, rgba(20, 30, 52, 0.95) 0%, rgba(14, 25, 46, 0.95) 100%);
    min-width: 0;
}

.entry-md-raw {
    margin: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: var(--space-lg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg);
    color: var(--text);
    overflow: auto;
}

.entry-md-raw code {
    display: block;
    font-family: 'Consolas', 'Monaco', 'Fira Code', monospace;
    font-size: var(--text-sm);
    line-height: 1.6;
    white-space: pre;
}

.entry-md-empty {
    color: var(--text-muted);
    font-style: italic;
}

.entry-md-warning {
    border: 1px solid rgba(250, 204, 21, 0.45);
    background: rgba(234, 179, 8, 0.12);
    color: #fde68a;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
}

.entry-md-preview h1,
.entry-md-preview h2,
.entry-md-preview h3,
.entry-md-preview h4,
.entry-md-preview h5,
.entry-md-preview h6 {
    line-height: 1.35;
    letter-spacing: 0.01em;
    scroll-margin-top: calc(var(--nav-height) + var(--space-lg));
}

.entry-md-preview h1,
.entry-md-preview h2 {
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.entry-md-preview h1 {
    font-size: clamp(1.55rem, 2.4vw, 2rem);
}

.entry-md-preview h2 {
    font-size: clamp(1.3rem, 2vw, 1.6rem);
}

.entry-md-preview h3 {
    font-size: clamp(1.15rem, 1.7vw, 1.35rem);
}

.entry-md-preview blockquote {
    margin: var(--space-md) 0;
    padding: var(--space-sm) var(--space-md);
    border-left: 3px solid rgba(96, 165, 250, 0.8);
    background: rgba(59, 130, 246, 0.08);
    color: #cbd5e1;
}

.entry-md-preview hr {
    border: none;
    border-top: 1px solid rgba(148, 163, 184, 0.25);
    margin: var(--space-lg) 0;
}

.entry-md-preview ul,
.entry-md-preview ol {
    margin: var(--space-md) 0;
    padding-left: calc(var(--space-xl) + 2px);
}

.entry-md-preview ul.contains-task-list,
.entry-md-preview ol.contains-task-list,
.entry-md-preview ul.entry-task-list,
.entry-md-preview ol.entry-task-list {
    list-style: none;
    padding-left: 0;
}

.entry-md-preview li.task-list-item,
.entry-md-preview li.entry-task-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.entry-md-preview li.task-list-item > input[type="checkbox"],
.entry-md-preview li.entry-task-item > input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 3px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.entry-md-preview a {
    color: #93c5fd;
    text-decoration-color: rgba(147, 197, 253, 0.45);
}

.entry-md-preview a:hover {
    color: #bfdbfe;
    text-decoration-color: #bfdbfe;
}

.entry-md-preview .md-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    border: 1px solid rgba(71, 85, 105, 0.5);
    border-radius: var(--radius-md);
    margin: var(--space-md) 0;
    background: rgba(15, 23, 42, 0.55);
}

.entry-md-preview table,
.entry-md-preview .entry-md-table {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
    display: table;
    margin: 0;
    table-layout: auto;
    border-left: 1px solid rgba(71, 85, 105, 0.45);
    border-right: 1px solid rgba(71, 85, 105, 0.45);
}

.entry-md-preview thead {
    background: rgba(59, 130, 246, 0.12);
}

.entry-md-preview th,
.entry-md-preview td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(71, 85, 105, 0.55);
    border-right: 1px solid rgba(71, 85, 105, 0.35);
    text-align: left;
    vertical-align: top;
    white-space: normal;
    word-break: break-word;
}

.entry-md-preview th:last-child,
.entry-md-preview td:last-child {
    border-right: none;
}

.entry-md-preview th {
    color: #dbeafe;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.entry-md-preview tbody tr:nth-child(even) {
    background: rgba(30, 41, 59, 0.35);
}

.entry-md-preview tbody tr:hover {
    background: rgba(59, 130, 246, 0.1);
}

.entry-view .content-body {
    line-height: 1.9;
    color: var(--text);
    font-size: var(--text-base);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.entry-view .content-body > * {
    min-width: 0;
    max-width: 100%;
}

.entry-view .content-body p {
    margin-bottom: var(--space-md);
}

.entry-view .content-body h1,
.entry-view .content-body h2,
.entry-view .content-body h3,
.entry-view .content-body h4 {
    margin-top: var(--space-xl);
    margin-bottom: var(--space-md);
    color: var(--text);
}

.entry-view .content-body ul,
.entry-view .content-body ol {
    margin: var(--space-md) 0;
    padding-left: var(--space-xl);
}

.entry-view .content-body li {
    margin-bottom: var(--space-sm);
}

.entry-view .content-body p,
.entry-view .content-body li,
.entry-view .content-body h1,
.entry-view .content-body h2,
.entry-view .content-body h3,
.entry-view .content-body h4,
.entry-view .content-body a,
.entry-view .content-body blockquote {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.entry-view .content-body code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    color: var(--purple);
}

.entry-view .content-body pre {
    background: var(--bg);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    max-width: 100%;
    overflow-x: auto;
    margin: var(--space-md) 0;
}

.entry-view .content-body pre code {
    background: none;
    padding: 0;
    white-space: pre;
}

.entry-view .content-body a {
    word-break: break-word;
}

.entry-view .content-body img,
.entry-view .content-body video,
.entry-view .content-body audio,
.entry-view .content-body iframe {
    max-width: 100%;
    height: auto;
}

.entry-md-preview video,
.entry-md-preview img {
    border-radius: var(--radius-md);
    border: 1px solid rgba(71, 85, 105, 0.45);
    display: block;
    margin: var(--space-md) auto;
    max-width: 100%;
    height: auto;
}

.entry-md-preview audio {
    width: 100%;
    max-width: 100%;
    margin: var(--space-sm) 0 var(--space-md);
    border-radius: var(--radius-md);
}

.entry-view .content-body table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
}

.code-block-wrapper pre.code-block,
#entryCodeBlock {
    max-width: 100%;
    overflow-x: auto;
}

.entry-sidebar {
    position: sticky;
    top: calc(var(--nav-height) + var(--space-lg));
    height: fit-content;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.entry-accordion-section {
    padding: 0;
    overflow: hidden;
}

.entry-accordion-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    border: none;
    background: transparent;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: var(--text-xs);
    font-weight: 700;
    padding: var(--space-md);
    border-bottom: 1px solid transparent;
    cursor: pointer;
}

.entry-accordion-trigger:hover {
    color: #dbeafe;
    background: rgba(30, 41, 59, 0.35);
}

.entry-accordion-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    color: #bfdbfe;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    opacity: 0.95;
    transform: rotate(0deg);
    transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.entry-accordion-chevron::before {
    content: '\25BE';
}

.entry-accordion-section.is-open .entry-accordion-chevron {
    transform: rotate(180deg);
    opacity: 1;
}

.entry-accordion-panel {
    padding: 0 var(--space-md) var(--space-md);
    border-top: 1px solid rgba(51, 65, 85, 0.55);
}

.entry-accordion-panel[hidden] {
    display: none !important;
}

.entry-history-meta {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
}

.version-count-badge {
    min-width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.22);
    border: 1px solid rgba(59, 130, 246, 0.45);
    color: #bfdbfe;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    padding: 0 6px;
}

.entry-details-toggle,
.entry-sidebar-close {
    display: none;
}

.entry-sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 8, 23, 0.65);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    z-index: 920;
}

.entry-sidebar-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.entry-details {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
    border-bottom: 1px dashed var(--border);
}

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

.detail-label {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.detail-value {
    font-weight: 600;
    font-size: var(--text-sm);
    text-align: right;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.version-list {
    margin-top: var(--space-sm);
    display: grid;
    gap: var(--space-sm);
}

.version-item-btn {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(15, 23, 42, 0.7);
    color: var(--text);
    text-align: left;
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.version-item-btn:hover {
    border-color: var(--primary);
    background: rgba(30, 58, 138, 0.24);
}

.version-item-title {
    font-size: var(--text-sm);
    font-weight: 600;
}

.version-item-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.version-loading,
.version-empty,
.version-error {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin: var(--space-xs) 0;
}

.version-error {
    color: #fca5a5;
}

.version-preview-modal .modal-content {
    max-width: min(860px, 96vw);
}

.version-preview-meta {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

.version-preview-content .entry-md-raw {
    max-height: min(52vh, 480px);
}

/* ========================================
   CODE BLOCK
   ======================================== */
.code-block-container {
    margin-top: var(--space-lg);
}

.code-block {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.code-lang {
    font-size: var(--text-xs);
    color: var(--text-muted);
    background: var(--bg);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-weight: 600;
    text-transform: uppercase;
}

.copy-btn {
    background: var(--card);
    border: 1px solid var(--border);
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-size: var(--text-xs);
    transition: all var(--transition-fast);
    font-weight: 500;
    min-height: 32px;
    position: relative;
    z-index: 2;
    pointer-events: auto;
}

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

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

.copy-btn:disabled {
    opacity: 0.9;
    cursor: wait;
}

.copy-btn.is-copying {
    border-color: var(--primary);
    color: #bfdbfe;
}

.copy-btn.copied {
    background: var(--done);
    border-color: var(--done);
    color: white;
}

.copy-btn.copy-failed {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger);
    color: #fecaca;
}

.toast-region {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast-notice {
    min-width: 220px;
    max-width: min(92vw, 360px);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.95);
    color: #e2e8f0;
    padding: 10px 14px;
    font-size: var(--text-sm);
    box-shadow: 0 16px 28px rgba(2, 6, 23, 0.45);
    transform: translateY(8px);
    opacity: 0;
    transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.toast-notice.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-notice.toast-success {
    border-color: rgba(34, 197, 94, 0.55);
    background: rgba(15, 64, 38, 0.94);
}

.toast-notice.toast-error {
    border-color: rgba(239, 68, 68, 0.55);
    background: rgba(69, 19, 19, 0.95);
}

.code-content {
    padding: var(--space-md);
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', 'Fira Code', monospace;
    font-size: var(--text-sm);
    line-height: 1.6;
    color: #c7d2fe;
}

.code-content pre {
    margin: 0;
}

/* Auto-detected Code Block Wrapper (in content) */
.code-block-wrapper {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin: var(--space-md) 0;
    overflow: hidden;
}

.code-block-wrapper .code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    background: var(--navbar-bg);
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 1;
}

.code-block-wrapper pre.code-block {
    margin: 0;
    padding: var(--space-md);
    overflow-x: auto;
    background: var(--bg);
    border: none;
    border-radius: 0;
}

.code-block-wrapper pre.code-block code {
    font-family: 'Consolas', 'Monaco', 'Fira Code', monospace;
    font-size: var(--text-sm);
    line-height: 1.6;
    color: #c7d2fe;
    white-space: pre;
}

/* Inline code */
.inline-code {
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Fira Code', monospace;
    font-size: 0.9em;
    color: var(--primary);
    border: 1px solid var(--border);
}

/* Content body paragraphs */
.content-body p {
    margin-bottom: var(--space-md);
    line-height: 1.8;
}

.content-body p:last-child {
    margin-bottom: 0;
}

/* ========================================
   MODAL
   ======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--space-md);
    animation: fadeIn var(--transition-fast);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    max-width: 420px;
    width: 100%;
    animation: slideUp var(--transition-normal);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content h3 {
    margin-bottom: var(--space-md);
    color: var(--danger);
    font-size: var(--text-lg);
}

.modal-content p {
    color: var(--text-muted);
    line-height: 1.6;
}

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

/* ========================================
   FOOTER
   ======================================== */
footer {
    background: var(--navbar-bg);
    border-top: 1px solid var(--border);
    padding: var(--space-xl);
    margin-top: var(--space-3xl);
}

.footer-content {
    max-width: var(--content-max-width);
    margin: 0 auto;
    text-align: center;
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.footer-content p + p {
    margin-top: var(--space-sm);
}

.footer-content a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer-content a:hover {
    color: var(--done);
}

/* ========================================
   RESPONSIVE BREAKPOINTS
   ======================================== */

/* Large Tablets & Small Laptops (1024px and below) */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
    }

    .container {
        grid-template-columns: var(--sidebar-width) 1fr;
        gap: var(--space-md);
    }

    .entry-view-container {
        grid-template-columns: 1fr 280px;
    }

    .entries-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

/* Tablets Portrait (768px and below) */
@media (max-width: 768px) {
    :root {
        --space-lg: 20px;
        --space-xl: 28px;
    }

    /* Show mobile menu button */
    .mobile-menu-btn {
        display: flex;
    }

    /* Navigation mobile layout */
    .nav-container {
        flex-wrap: wrap;
        height: auto;
        padding: var(--space-md);
        gap: var(--space-md);
    }

    .nav-content {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-md);
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        margin-left: 0;
        transition: max-height var(--transition-normal), opacity var(--transition-normal);
    }

    .nav-content.open {
        max-height: 560px;
        opacity: 1;
        padding-top: var(--space-md);
        border-top: 1px solid var(--border);
    }

    .nav-links {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-xs);
    }

    .nav-link,
    .nav-link:visited {
        width: 100%;
        justify-content: flex-start;
    }

    .nav-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-md);
        max-height: 0;
        overflow: hidden;
        transition: max-height var(--transition-normal), opacity var(--transition-normal);
        opacity: 0;
    }

    .nav-content .nav-actions {
        max-height: none;
        opacity: 1;
        overflow: visible;
        padding-top: 0;
        border-top: 0;
    }

    .nav-container > .nav-actions {
        max-height: 0;
    }

    .nav-actions.open {
        max-height: 560px;
        opacity: 1;
        padding-top: var(--space-md);
        border-top: 1px solid var(--border);
    }

    .search-box {
        width: 100%;
    }

    .search-box input {
        width: 100%;
    }

    .btn-new {
        width: 100%;
        justify-content: center;
    }

    /* Main layout - single column */
    .container {
        grid-template-columns: 1fr;
        padding: var(--space-md);
    }

    .page-main {
        padding: var(--space-md);
    }

    /* Sidebar becomes horizontal scroll or grid */
    .sidebar {
        position: static;
        flex-direction: row;
        overflow-x: auto;
        gap: var(--space-md);
        padding-bottom: var(--space-sm);
        -webkit-overflow-scrolling: touch;
    }

    .sidebar-section {
        min-width: 200px;
        flex-shrink: 0;
    }

    /* Entry view - single column */
    .entry-view-container {
        grid-template-columns: 1fr;
        min-width: 0;
    }

    .entry-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(86vw, 340px);
        max-width: 340px;
        transform: translateX(-105%);
        transition: transform var(--transition-normal);
        border-right: 1px solid var(--border);
        border-radius: 0;
        padding: calc(var(--nav-height) + var(--space-md)) var(--space-md) var(--space-lg);
        overflow-y: auto;
        gap: var(--space-md);
        z-index: 930;
        background: var(--card);
        min-width: 0;
    }

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

    .entry-sidebar-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border: 1px solid var(--border);
        background: var(--bg-secondary);
        color: var(--text);
        border-radius: var(--radius-sm);
        margin-left: auto;
        margin-bottom: var(--space-sm);
        cursor: pointer;
        font-size: 1.25rem;
    }

    .entry-details-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: var(--space-xs);
        position: fixed;
        left: var(--space-md);
        bottom: calc(var(--space-lg) + 10px);
        z-index: 910;
        border: 1px solid var(--border);
        background: rgba(15, 23, 42, 0.95);
        color: #e2e8f0;
        border-radius: var(--radius-full);
        min-height: 44px;
        padding: 10px 16px;
        box-shadow: 0 12px 24px rgba(2, 6, 23, 0.45);
    }

    .entry-view {
        min-width: 0;
    }

    .entry-view .content-body {
        min-width: 0;
    }

    .entry-md-toolbar {
        width: 100%;
    }

    .entry-md-mode-btn {
        flex: 1;
        text-align: center;
        justify-content: center;
    }

    .entry-md-preview {
        max-width: 100%;
        padding: var(--space-md);
    }

    .entry-md-raw {
        padding: var(--space-md);
    }

    .entry-md-preview table,
    .entry-md-preview .entry-md-table {
        min-width: 460px;
    }

    .entry-sidebar .sidebar-section {
        min-width: 0;
        width: 100%;
        flex-shrink: 1;
    }

    .entry-accordion-trigger {
        padding: var(--space-sm) var(--space-md);
    }

    .entry-accordion-panel {
        padding: 0 var(--space-sm) var(--space-sm);
    }

    .editor-toolbar {
        gap: var(--space-xs);
    }

    .editor-toolbar-divider {
        display: none;
    }

    .editor-mode-btn,
    .editor-tool-btn {
        flex: 1 1 auto;
        min-height: 40px;
    }

    /* Entries grid */
    .entries-grid {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }

    /* Header - hide on mobile (nav-brand already shows branding) */
    header {
        display: none;
    }

    /* Forms */
    .form-container {
        padding: var(--space-md);
    }

    .entry-form {
        padding: var(--space-md);
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn-secondary,
    .form-actions .btn-primary {
        width: 100%;
    }

    /* Entry view */
    .entry-view {
        padding: var(--space-md);
    }

    .entry-view h2 {
        font-size: var(--text-xl);
    }

    /* Modal */
    .modal-content {
        padding: var(--space-lg);
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-actions button {
        width: 100%;
    }
}

/* Large Phones (640px and below) */
@media (max-width: 640px) {
    :root {
        --space-md: 14px;
        --space-lg: 18px;
    }

    header h1 {
        font-size: var(--text-lg);
    }

    header p {
        font-size: var(--text-xs);
    }

    .content-header h2 {
        font-size: var(--text-lg);
    }

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

    .entry-card h3 {
        font-size: var(--text-base);
    }

    .sidebar-section {
        min-width: 160px;
        padding: var(--space-sm);
    }

    .category-list li a {
        padding: var(--space-sm);
        font-size: var(--text-xs);
        min-height: 36px;
    }

    .tag {
        font-size: 10px;
        padding: 2px var(--space-sm);
    }
}

/* Small Phones (480px and below) */
@media (max-width: 480px) {
    :root {
        --space-sm: 6px;
        --space-md: 12px;
        --space-lg: 16px;
    }

    .nav-brand {
        font-size: var(--text-base);
    }

    header {
        padding: var(--space-sm) var(--space-md);
    }

    header h1 {
        font-size: var(--text-base);
        gap: var(--space-xs);
    }

    header h1 .logo-icon {
        font-size: var(--text-base);
    }

    .container {
        padding: var(--space-sm);
    }

    .page-main {
        padding: var(--space-sm);
    }

    .sidebar {
        gap: var(--space-sm);
    }

    .sidebar-section {
        min-width: 140px;
    }

    .entry-view {
        padding: var(--space-sm);
    }

    .entry-md-preview {
        padding: var(--space-sm);
    }

    .entry-md-raw {
        padding: var(--space-sm);
    }

    .entry-md-preview table,
    .entry-md-preview .entry-md-table {
        min-width: 360px;
    }

    .entry-sidebar .sidebar-section {
        min-width: 0;
        max-width: 100%;
    }

    .entry-card-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    .entry-tags {
        justify-content: flex-start;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: var(--space-sm);
        font-size: var(--text-sm);
    }

    .btn-new, .btn-primary, .btn-secondary, .btn-danger {
        padding: var(--space-sm) var(--space-md);
        font-size: var(--text-sm);
    }

    .toast-region {
        right: 10px;
        left: 10px;
        bottom: 12px;
    }

    .toast-notice {
        max-width: 100%;
        min-width: 0;
    }
}

/* Very Small Phones (320px and below) */
@media (max-width: 320px) {
    :root {
        --text-base: 0.9rem;
        --text-sm: 0.8rem;
        --text-xs: 0.7rem;
    }

    .nav-container {
        padding: var(--space-sm);
    }

    .modal-content {
        padding: var(--space-md);
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.text-center {
    text-align: center;
}

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

/* Focus visible for accessibility */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* Selection styling */
::selection {
    background: var(--primary);
    color: white;
}

/* ========================================
   AUTH PAGES (Login/Register)
   ======================================== */

.auth-container {
    max-width: 520px;
    width: 100%;
    margin: 0 auto;
    padding: 0;
}

.auth-form {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
}

.auth-form .form-group {
    margin-bottom: var(--space-lg);
}

.auth-link {
    text-align: center;
    margin-top: var(--space-lg);
    color: var(--text-dim);
    font-size: var(--text-sm);
}

.auth-link a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-link a:hover {
    text-decoration: underline;
}

.btn-full {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    font-size: var(--text-base);
}

/* User display in nav */
.user-display {
    color: var(--text-dim);
    font-size: var(--text-sm);
    padding: 0 var(--space-sm);
    display: inline-block;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Logout button */
.btn-logout {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
}

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

/* Responsive auth */
@media (max-width: 480px) {
    .auth-container {
        margin: 0 auto;
    }

    .auth-form {
        padding: var(--space-lg);
    }
}

/* Mobile nav links (visible only inside hamburger menu on mobile) */
.mobile-nav-links {
    display: none;
}

@media (max-width: 768px) {
    .mobile-nav-links {
        display: flex;
        flex-direction: column;
        gap: var(--space-xs);
        width: 100%;
    }

    .mobile-nav-links a {
        color: var(--text);
        text-decoration: none;
        padding: var(--space-sm) var(--space-md);
        border-radius: var(--radius-sm);
        min-height: 44px;
        display: flex;
        align-items: center;
        transition: background var(--transition-fast);
    }

    .mobile-nav-links a:hover {
        background: var(--bg-secondary);
    }

    .mobile-nav-links a:visited {
        color: var(--text);
    }

    .nav-actions.open {
        max-height: 560px;
    }

    .user-display {
        max-width: none;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        padding: 0;
    }
}
