/* fratm dashboard — minimal dark/light theme */

:root {
    --bg: #1a1a2e;
    --bg-sidebar: #16213e;
    --bg-topbar: #0f3460;
    --bg-hover: #1a1a3e;
    --bg-active: #0f346080;
    --text: #e0e0e0;
    --text-muted: #8a8a9a;
    --border: #2a2a4a;
    --accent: #e94560;
    --accent-soft: #e9456020;
    --link: #53a8e2;
    --code-bg: #0d1117;
    --code-border: #2a2a4a;
    --scrollbar: #2a2a4a;
    --scrollbar-hover: #3a3a5a;
}

[data-theme="light"] {
    --bg: #ffffff;
    --bg-sidebar: #f5f5f7;
    --bg-topbar: #ffffff;
    --bg-hover: #eaeaef;
    --bg-active: #dde4f0;
    --text: #1a1a2e;
    --text-muted: #6a6a7a;
    --border: #d0d0d8;
    --accent: #d63851;
    --accent-soft: #d6385115;
    --link: #2563eb;
    --code-bg: #f4f4f8;
    --code-border: #d0d0d8;
    --scrollbar: #c0c0c8;
    --scrollbar-hover: #a0a0a8;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

/* Layout */
.layout {
    display: grid;
    grid-template-areas:
        "topbar topbar"
        "sidebar content";
    grid-template-columns: 280px 1fr;
    grid-template-rows: 48px 1fr;
    height: 100vh;
}

/* Topbar */
.topbar {
    grid-area: topbar;
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 10;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.topbar-icon {
    color: var(--accent);
    margin-right: 6px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-count {
    font-size: 12px;
    color: var(--text-muted);
}

.sidebar-toggle, .theme-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
}

.sidebar-toggle:hover, .theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text);
}

/* Sidebar */
.sidebar {
    grid-area: sidebar;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: margin-left 0.2s ease;
}

.sidebar.collapsed {
    margin-left: -280px;
}

.sidebar-header {
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

.search-input {
    width: 100%;
    padding: 6px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    outline: none;
}

.search-input:focus {
    border-color: var(--accent);
}

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

/* File tree */
.file-tree {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.file-tree::-webkit-scrollbar { width: 6px; }
.file-tree::-webkit-scrollbar-track { background: transparent; }
.file-tree::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 3px; }
.file-tree::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

.tree-item {
    display: flex;
    align-items: center;
    padding: 3px 8px 3px calc(8px + var(--depth, 0) * 16px);
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    text-decoration: none;
    border-radius: 0;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.tree-item.active {
    background: var(--bg-active);
    color: var(--accent);
}

.tree-item.hidden {
    display: none;
}

.tree-icon {
    width: 16px;
    height: 16px;
    margin-right: 6px;
    flex-shrink: 0;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.tree-icon.dir { color: var(--link); }

.tree-children {
    overflow: hidden;
}

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

.loading {
    padding: 16px;
    color: var(--text-muted);
    font-size: 13px;
}

/* Content */
.content {
    grid-area: content;
    overflow-y: auto;
    padding: 32px 48px;
    max-width: 100%;
}

.content::-webkit-scrollbar { width: 8px; }
.content::-webkit-scrollbar-track { background: transparent; }
.content::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 4px; }
.content::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

/* Welcome screen */
.welcome {
    max-width: 500px;
    margin: 80px auto;
    text-align: center;
}

.welcome h2 {
    font-size: 24px;
    margin-bottom: 8px;
}

.welcome p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.shortcuts {
    text-align: left;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
}

.shortcuts h3 {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.shortcuts ul {
    list-style: none;
}

.shortcuts li {
    padding: 4px 0;
}

.shortcuts a {
    color: var(--link);
    text-decoration: none;
    font-size: 13px;
    font-family: "SF Mono", "Fira Code", monospace;
}

.shortcuts a:hover {
    text-decoration: underline;
}

/* Breadcrumb */
.breadcrumb {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
    font-family: "SF Mono", "Fira Code", monospace;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* Frontmatter badge */
.frontmatter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.fm-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--accent-soft);
    color: var(--accent);
    font-family: "SF Mono", "Fira Code", monospace;
}

/* Rendered markdown */
.markdown-body {
    line-height: 1.7;
    max-width: 860px;
}

.markdown-body h1 { font-size: 28px; margin: 24px 0 12px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.markdown-body h2 { font-size: 22px; margin: 20px 0 10px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.markdown-body h3 { font-size: 18px; margin: 16px 0 8px; }
.markdown-body h4 { font-size: 15px; margin: 12px 0 6px; }

.markdown-body p { margin: 8px 0; }

.markdown-body a { color: var(--link); text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }

.markdown-body code {
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 13px;
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--code-border);
}

.markdown-body pre {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin: 12px 0;
}

.markdown-body pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 13px;
    line-height: 1.5;
}

.markdown-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
    font-size: 14px;
}

.markdown-body th, .markdown-body td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
}

.markdown-body th {
    background: var(--bg-sidebar);
    font-weight: 600;
}

.markdown-body ul, .markdown-body ol {
    padding-left: 24px;
    margin: 8px 0;
}

.markdown-body li { margin: 4px 0; }

.markdown-body blockquote {
    border-left: 3px solid var(--accent);
    padding: 8px 16px;
    margin: 12px 0;
    color: var(--text-muted);
    background: var(--accent-soft);
    border-radius: 0 6px 6px 0;
}

.markdown-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

.markdown-body img {
    max-width: 100%;
    border-radius: 8px;
}

/* Responsive */
@media (max-width: 768px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: 0; top: 48px; bottom: 0; width: 280px; z-index: 20; }
    .sidebar.collapsed { margin-left: -280px; }
    .content { padding: 20px 16px; }
}
