:root {
  --background: 0 0% 100%;
  --sidebar-bg: 0 0% 98%;
  --foreground: 240 10% 15%;
  --muted: 240 5% 96%;
  --muted-foreground: 240 4% 46%;
  --border: 240 6% 90%;
  --accent: 240 5% 92%;
  --accent-foreground: 240 10% 10%;
  --primary: 240 6% 10%;
  --primary-foreground: 0 0% 100%;
  --red: 0 72% 51%;
  --radius: 4px;
}

.dark {
  --background: 240 10% 4%;
  --sidebar-bg: 240 6% 7%;
  --foreground: 0 0% 98%;
  --muted: 240 4% 15%;
  --muted-foreground: 240 5% 65%;
  --border: 240 4% 20%;
  --accent: 240 4% 15%;
  --accent-foreground: 0 0% 98%;
  --primary: 0 0% 98%;
  --primary-foreground: 240 6% 10%;
  --red: 0 70% 60%;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
}

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

button {
    font-family: inherit;
}

/* App Shell */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}



.icon-btn {
    background: transparent;
    border: none;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.icon-btn:hover {
    background-color: hsl(var(--accent));
    color: hsl(var(--foreground));
}

.icon-sm { width: 14px; height: 14px; stroke-width: 2px; }
.icon-md { width: 18px; height: 18px; stroke-width: 2px; }



/* Workspace */
.workspace {
    display: flex;
    flex: 1;
    min-height: 0; /* Important for scrollable children */
}

/* Left Sidebar */
.left-sidebar {
    width: 240px;
    background-color: hsl(var(--sidebar-bg));
    border-right: 1px solid hsl(var(--border));
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.left-sidebar.hidden {
    display: none;
}

.sidebar-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 1px solid hsl(var(--border));
}
.sidebar-dropdown-trigger:hover {
    background-color: hsl(var(--accent));
}

.dropdown-icon-red {
    background-color: hsl(var(--red));
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.flex-1 {
    flex: 1;
}

.sidebar-search-container {
    padding: 16px 16px 4px 16px;
}

.sidebar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: hsl(var(--muted));
    padding: 8px 12px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    transition: border-color 0.2s;
    color: hsl(var(--muted-foreground));
}

.sidebar-search:focus-within {
    border-color: hsl(var(--border));
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
}

.sidebar-search input {
    background: transparent;
    border: none;
    outline: none;
    font-size: 13px;
    color: hsl(var(--foreground));
    width: 100%;
}

.sidebar-search input::placeholder {
    color: hsl(var(--muted-foreground));
}

.sidebar-nav {
    padding: 12px 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    font-size: 13px;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
}
.sidebar-link:hover {
    background-color: hsl(var(--accent));
    color: hsl(var(--foreground));
}

.nav-section {
    margin-top: 16px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: hsl(var(--muted-foreground));
    padding: 4px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-section-title .actions {
    display: flex;
    gap: 4px;
}
.nav-section-title svg {
    cursor: pointer;
}
.nav-section-title svg:hover {
    color: hsl(var(--foreground));
}

.tree-nav {
    padding-top: 4px;
}

.tree-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 16px;
    font-size: 13px;
    cursor: pointer;
    color: hsl(var(--foreground));
    user-select: none;
}
.tree-item:hover {
    background-color: hsl(var(--accent));
}
.tree-item.active {
    background-color: hsl(var(--accent));
    font-weight: 500;
}

.tree-chevron {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: hsl(var(--muted-foreground));
    transition: transform 0.2s;
}
.tree-item.expanded .tree-chevron {
    transform: rotate(90deg);
}

.emoji {
    font-size: 14px;
}

.tree-indent {
    width: 16px; /* Match chevron width for alignment */
    display: inline-block;
}

.tree-children {
    display: none;
}
.tree-item.expanded + .tree-children {
    display: block;
}

/* Main Content Area */
.main-content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent flex overflow */
    overflow-y: auto;
    background-color: hsl(var(--background));
}

.content-header {
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 32px;
    position: sticky;
    top: 0;
    background-color: hsl(var(--background) / 0.9);
    backdrop-filter: blur(8px);
    z-index: 10;
    border-bottom: 1px solid hsl(var(--border));
}

.breadcrumbs {
    font-size: 13px;
    color: hsl(var(--muted-foreground));
    display: flex;
    align-items: center;
    gap: 6px;
}

.content-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.segmented-control {
    display: flex;
    background-color: hsl(var(--muted));
    padding: 2px;
    border-radius: var(--radius);
}
.segmented-control button {
    background: transparent;
    border: none;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    border-radius: calc(var(--radius) - 1px);
    cursor: pointer;
}
.segmented-control button.active {
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.icon-text-btn {
    background: transparent;
    border: none;
    color: hsl(var(--muted-foreground));
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.icon-text-btn:hover {
    color: hsl(var(--foreground));
}

.content-body {
    padding: 32px 64px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

/* Markdown-like Styles */
.prose {
    font-size: 15px;
    color: hsl(var(--foreground));
}
.prose h1 {
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.prose .lead {
    font-size: 1.125rem;
    color: hsl(var(--muted-foreground));
    margin-bottom: 2rem;
}
.prose h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid hsl(var(--border));
    padding-bottom: 0.5rem;
}
.prose h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}
.prose p {
    margin-bottom: 1rem;
    line-height: 1.7;
}
.prose a {
    color: hsl(var(--foreground));
    text-decoration: underline;
    text-underline-offset: 4px;
}
.prose ul, .prose ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}
.prose li {
    margin-bottom: 0.25rem;
}
.prose code {
    background-color: hsl(var(--muted));
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-size: 0.85em;
    font-family: monospace;
}
.prose pre {
    background-color: hsl(var(--muted));
    padding: 1.25rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin-bottom: 1.5rem;
    border: 1px solid hsl(var(--border));
}
.prose pre code {
    background-color: transparent;
    padding: 0;
    font-size: 0.85em;
}

/* Components */
.alert {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    background-color: hsl(var(--sidebar-bg));
}
.alert-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.alert-desc {
    font-size: 0.9rem;
    color: hsl(var(--muted-foreground));
}

/* Loader */
.loader {
    padding: 2rem;
    text-align: center;
    color: hsl(var(--muted-foreground));
}

@media (max-width: 768px) {
    .left-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 50;
        transform: translateX(-100%);
    }
    .left-sidebar.open {
        transform: translateX(0);
        box-shadow: 0 0 0 100vw rgba(0,0,0,0.5);
    }
    .content-body {
        padding: 24px;
    }
    .content-actions {
        display: none;
    }
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 24px;
    margin-bottom: 40px;
}

.card {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 20px;
    background-color: hsl(var(--sidebar-bg));
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-decoration: none !important;
    color: hsl(var(--foreground)) !important;
}

.card:hover {
    border-color: hsl(var(--muted-foreground));
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.dark .card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.card-title {
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-desc {
    font-size: 13px;
    color: hsl(var(--muted-foreground));
    line-height: 1.5;
}

.mobile-bottom-search {
    display: none;
}

@media (max-width: 768px) {
    .mobile-bottom-search {
        display: block;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background-color: hsl(var(--background));
        border-top: 1px solid hsl(var(--border));
        padding: 12px 24px;
        z-index: 40;
        box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
    }
    
    .mobile-bottom-search .sidebar-search {
        margin-bottom: 0;
    }
    
    .content-body {
        padding-bottom: 80px; /* Make room for bottom bar */
    }
}

/* Search Modal */
.search-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 10vh;
}

.search-modal.hidden {
    display: none;
}

.search-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: hsl(var(--background) / 0.8);
    backdrop-filter: blur(4px);
}

.search-modal-content {
    position: relative;
    width: 90%;
    max-width: 600px;
    background-color: hsl(var(--sidebar-bg));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) * 2);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    overflow: hidden;
}

.dark .search-modal-content {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.search-modal-header {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid hsl(var(--border));
    gap: 12px;
}

.search-modal-header i[data-lucide="search"] {
    color: hsl(var(--muted-foreground));
}

.search-modal-header input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 16px;
    color: hsl(var(--foreground));
}

.search-modal-results {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.search-result-item {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    margin-bottom: 4px;
    text-decoration: none !important;
    color: hsl(var(--foreground)) !important;
}

.search-result-item:hover, .search-result-item.selected {
    background-color: hsl(var(--accent));
}

.search-result-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-result-desc {
    font-size: 13px;
    color: hsl(var(--muted-foreground));
}

.search-no-results {
    padding: 32px;
    text-align: center;
    color: hsl(var(--muted-foreground));
    font-size: 14px;
}
