/* Second Brain Vault - Styles */

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

:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-tertiary: #1a1a1a;
    --bg-elevated: #222222;
    --text-primary: #e5e5e5;
    --text-secondary: #a3a3a3;
    --text-tertiary: #6b6b6b;
    --border: #2a2a2a;
    --border-light: #333333;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-subtle: rgba(59, 130, 246, 0.08);
    --accent-glow: rgba(59, 130, 246, 0.15);
    --success: #22c55e;
    --warning: #eab308;
    --error: #ef4444;
    --tag-bg: rgba(59, 130, 246, 0.1);
    --tag-text: #60a5fa;
    --radius: 8px;
    --radius-sm: 6px;
    --radius-lg: 12px;
    --sidebar-width: 260px;
    --sidebar-collapsed: 0px;
    --header-height: 48px;
    --font-mono: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

html {
    font-family: var(--font-sans);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9375rem;
}

.sidebar-logo svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
}

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

.sidebar-toggle svg {
    width: 16px;
    height: 16px;
}

/* Sidebar scroll area */
.sidebar-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.sidebar-body::-webkit-scrollbar {
    width: 4px;
}

.sidebar-body::-webkit-scrollbar-track {
    background: transparent;
}

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

/* Sidebar sections */
.sidebar-section {
    padding: 0 12px;
    margin-bottom: 4px;
}

.sidebar-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    padding: 8px 4px 6px;
    user-select: none;
}

/* Sidebar navigation */
.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    margin: 1px 0;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s;
}

.sidebar-nav li a:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-nav li a.active {
    background: var(--accent-subtle);
    color: var(--accent);
}

.sidebar-nav li a svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-nav li a.active svg {
    opacity: 1;
}

.sidebar-nav li a .nav-badge {
    margin-left: auto;
    font-size: 0.6875rem;
    padding: 1px 6px;
    background: var(--bg-elevated);
    border-radius: 10px;
    color: var(--text-tertiary);
    font-weight: 500;
}

.sidebar-nav li a.active .nav-badge {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent);
}

/* Sidebar tag cloud */
.sidebar-tags {
    padding: 0 12px;
}

.sidebar-tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0;
}

.sidebar-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.15s;
}

.sidebar-tag:hover {
    background: var(--accent-subtle);
    color: var(--accent);
    border-color: rgba(59, 130, 246, 0.3);
}

.sidebar-tag.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.sidebar-tag .tag-count {
    font-size: 0.625rem;
    opacity: 0.6;
}

/* Sidebar footer */
.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 10px 16px;
    flex-shrink: 0;
}

.sidebar-footer-info {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 199;
    opacity: 0;
    transition: opacity 0.25s;
}

.sidebar-overlay.visible {
    opacity: 1;
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */

.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* When sidebar is collapsed */
.sidebar.collapsed ~ .sidebar-overlay ~ .main-wrapper,
.app.sidebar-collapsed .main-wrapper {
    margin-left: 0;
}

.app.sidebar-collapsed .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
}

/* ============================================
   TOP HEADER BAR
   ============================================ */

.topbar {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 var(--spacing-lg);
    gap: var(--spacing-md);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.topbar-mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.topbar-mobile-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.topbar-mobile-toggle svg {
    width: 20px;
    height: 20px;
}

.topbar-search {
    flex: 1;
    max-width: 480px;
    position: relative;
}

.topbar-search input {
    width: 100%;
    padding: 6px 12px 6px 34px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.8125rem;
    outline: none;
    transition: all 0.2s;
}

.topbar-search input:focus {
    border-color: var(--accent);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.topbar-search svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    color: var(--text-tertiary);
    pointer-events: none;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-left: auto;
}

.topbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.topbar-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.topbar-btn svg {
    width: 14px;
    height: 14px;
}

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

.topbar-btn.primary:hover {
    background: var(--accent-hover);
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.main {
    flex: 1;
    padding: var(--spacing-lg) var(--spacing-lg) var(--spacing-xl);
}

.content {
    width: 100%;
}

/* Reading width for wiki pages */
.content.reading {
    max-width: 760px;
    margin: 0 auto;
}

/* Full width for browsing */
.content.browsing {
    max-width: 960px;
    margin: 0 auto;
}

/* ============================================
   PAGE HEADER
   ============================================ */

.page-header {
    margin-bottom: var(--spacing-lg);
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.filter-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 4px 12px;
    background: var(--accent-subtle);
    border-radius: var(--radius);
    font-size: 0.8125rem;
    color: var(--accent);
}

.clear-filter {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.clear-filter:hover {
    text-decoration: underline;
}

/* ============================================
   PAGE CARDS (Wiki list)
   ============================================ */

.pages {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.page-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.15s;
    overflow: hidden;
}

.page-card:hover {
    border-color: var(--border-light);
    background: var(--bg-tertiary);
}

.page-card-content {
    padding: 14px 20px;
}

.page-title {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 4px;
}

.page-title a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.15s;
}

.page-title a:hover {
    color: var(--accent);
}

.page-snippet {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    margin-bottom: 8px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.page-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.page-meta .tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: var(--tag-bg);
    color: var(--tag-text);
    border-radius: 10px;
    font-size: 0.6875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s;
}

.page-meta .tag:hover {
    background: var(--accent);
    color: white;
}

.page-meta .date {
    color: var(--text-tertiary);
    font-size: 0.6875rem;
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    color: var(--text-tertiary);
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.125rem;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.empty-state p {
    margin-bottom: 16px;
    font-size: 0.875rem;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    background: var(--accent);
    color: white;
    text-decoration: none;
    border: none;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.btn:hover {
    background: var(--accent-hover);
}

.btn svg {
    width: 14px;
    height: 14px;
}

.btn-save {
    background: var(--success);
}

.btn-save:hover {
    background: #16a34a;
}

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

.btn-secondary:hover {
    background: var(--bg-elevated);
    border-color: var(--border-light);
}

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

.btn-ghost:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.75rem;
}

/* ============================================
   WIKI PAGE VIEW
   ============================================ */

.wiki-page {
    padding: 4px 0;
}

.wiki-meta {
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.wiki-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.wiki-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.wiki-tags .tag {
    padding: 3px 10px;
    background: var(--tag-bg);
    color: var(--tag-text);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s;
}

.wiki-tags .tag:hover {
    background: var(--accent);
    color: white;
}

.wiki-dates {
    color: var(--text-tertiary);
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}

/* Wiki rendered content */
.wiki-content {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.wiki-content h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 32px 0 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    letter-spacing: -0.01em;
}

.wiki-content h2 {
    font-size: 1.375rem;
    font-weight: 600;
    margin: 28px 0 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.wiki-content h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 24px 0 8px;
}

.wiki-content h4 {
    font-size: 1rem;
    font-weight: 600;
    margin: 20px 0 8px;
    color: var(--text-secondary);
}

.wiki-content p {
    margin-bottom: 16px;
}

.wiki-content a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s;
}

.wiki-content a:hover {
    border-bottom-color: var(--accent);
}

.wiki-content strong {
    font-weight: 600;
}

.wiki-content em {
    font-style: italic;
}

.wikilink {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.875em;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--accent-subtle);
    text-decoration: none;
    transition: all 0.15s;
}

.wikilink:hover {
    background: var(--accent);
    color: white;
}

.wiki-content code {
    font-family: var(--font-mono);
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.875em;
}

.wiki-content pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 16px 0;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.6;
}

.wiki-content pre code {
    background: none;
    padding: 0;
}

.wiki-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 16px;
    margin: 16px 0;
    color: var(--text-secondary);
}

.wiki-content ul, .wiki-content ol {
    margin: 8px 0 8px 24px;
}

.wiki-content li {
    margin-bottom: 4px;
}

.wiki-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.875rem;
}

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

.wiki-content th {
    font-weight: 600;
    background: var(--bg-tertiary);
    font-size: 0.8125rem;
}

.wiki-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    margin: 16px 0;
}

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

/* Wiki source info */
.wiki-source {
    margin-top: 40px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.wiki-source strong {
    color: var(--text-primary);
}

/* Wiki links (backlinks/outgoing) */
.wiki-links {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.wiki-links-section {
    margin-bottom: 24px;
}

.wiki-links-section:last-child {
    margin-bottom: 0;
}

.wiki-links-section h3 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.wiki-links-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.wiki-links-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.wiki-links-list li:last-child {
    border-bottom: none;
}

.wiki-links-list a {
    color: var(--accent);
    font-weight: 500;
    text-decoration: none;
    font-size: 0.875rem;
}

.wiki-links-list a:hover {
    text-decoration: underline;
}

.backlink-snippet {
    display: block;
    margin-top: 4px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ============================================
   FILE BROWSER
   ============================================ */

.file-browser {
    max-width: 960px;
    margin: 0 auto;
}

/* Breadcrumbs */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: var(--spacing-md);
    flex-wrap: wrap;
}

.breadcrumb {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8125rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

.breadcrumb:hover {
    color: var(--accent);
    background: var(--accent-subtle);
}

.breadcrumb-sep {
    color: var(--text-tertiary);
    font-size: 0.8125rem;
    user-select: none;
}

/* Upload form */
.upload-form {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px dashed var(--border-light);
    border-radius: var(--radius);
}

.upload-form label {
    flex: 1;
    color: var(--text-tertiary);
    font-size: 0.8125rem;
    cursor: pointer;
}

.upload-form label:hover {
    color: var(--text-secondary);
}

.upload-form input[type="file"] {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

/* File list */
.file-list {
    display: flex;
    flex-direction: column;
}

.file-row {
    display: grid;
    grid-template-columns: 40px 1fr 80px 120px;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    transition: all 0.15s;
}

.file-row:first-child {
    border-radius: var(--radius) var(--radius) 0 0;
}

.file-row:last-child {
    border-radius: 0 0 var(--radius) var(--radius);
}

.file-row:only-child {
    border-radius: var(--radius);
}

.file-row + .file-row {
    border-top: none;
    margin-top: -1px;
}

.file-row:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-light);
}

.file-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 1rem;
}

.file-thumbnail {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.file-name {
    font-size: 0.875rem;
    font-weight: 500;
    min-width: 0;
}

.file-name a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-name a:hover {
    color: var(--accent);
}

.file-size {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.file-date {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
}

.file-view-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.file-view-meta {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

/* ============================================
   EDITOR
   ============================================ */

.editor-page {
    max-width: 960px;
    margin: 0 auto;
}

.editor-form {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-height) - 80px);
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
    flex-shrink: 0;
}

.editor-header h1 {
    font-size: 1.125rem;
    font-weight: 600;
}

.editor-content {
    flex: 1;
    min-height: 0;
}

.editor-textarea {
    width: 100%;
    height: 100%;
    min-height: 300px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.7;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}

.editor-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.editor-footer {
    margin-top: var(--spacing-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.editor-help {
    color: var(--text-tertiary);
    font-size: 0.75rem;
}

/* ============================================
   HISTORY PAGE
   ============================================ */

.history-page {
    max-width: 700px;
    margin: 0 auto;
}

.history-header {
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border);
}

.history-header h2 {
    margin: 0 0 4px 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.history-header p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.version-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.version-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    transition: all 0.15s;
}

.version-item:first-child {
    border-radius: var(--radius) var(--radius) 0 0;
}

.version-item:last-child {
    border-radius: 0 0 var(--radius) var(--radius);
}

.version-item:only-child {
    border-radius: var(--radius);
}

.version-item + .version-item {
    border-top: none;
    margin-top: -1px;
}

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

.version-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.version-date {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--text-primary);
}

.version-size {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.version-restore {
    flex-shrink: 0;
}

.btn-restore {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-restore:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.btn-history {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-history:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.history-footer {
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border);
}

.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
}

.back-link:hover {
    color: var(--accent);
}

/* ============================================
   KNOWLEDGE GRAPH
   ============================================ */

.graph-page {
    max-width: 960px;
    margin: 0 auto;
}

.graph-container {
    position: relative;
    width: 100%;
}

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

.graph-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.graph-controls {
    display: flex;
    gap: var(--spacing-sm);
}

.graph-legend {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.legend-node {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
}

.legend-edge {
    display: inline-block;
    width: 20px;
    height: 2px;
    background: var(--border);
}

.legend-hint {
    margin-left: auto;
    opacity: 0.5;
    font-size: 0.75rem;
}

.graph-svg {
    width: 100%;
    height: 600px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.graph-link {
    transition: stroke 0.2s, stroke-width 0.2s;
}

.graph-node {
    cursor: pointer;
}

.graph-node-circle {
    transition: r 0.2s, stroke 0.2s;
}

.graph-node:hover .graph-node-label {
    fill: var(--accent);
    font-weight: 600;
}

.graph-tooltip {
    position: fixed;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8125rem;
    color: var(--text-primary);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 1000;
    max-width: 250px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ============================================
   ERROR STATE
   ============================================ */

.error-state {
    text-align: center;
    padding: 60px 20px;
}

.error-state h1 {
    font-size: 3rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
}

.error-state p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ============================================
   DAILY NOTE
   ============================================ */

.daily-note {
    max-width: 760px;
    margin: 0 auto;
}

.daily-header {
    margin-bottom: var(--spacing-lg);
}

.daily-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.daily-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

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

@media (max-width: 1024px) {
    .file-row {
        grid-template-columns: 40px 1fr 70px 100px;
    }
}

@media (max-width: 768px) {
    /* Mobile: sidebar becomes overlay */
    .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }

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

    .sidebar-overlay {
        display: block;
    }

    .main-wrapper {
        margin-left: 0 !important;
    }

    .topbar-mobile-toggle {
        display: flex;
    }

    .topbar {
        padding: 0 var(--spacing-md);
    }

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

    .file-row {
        grid-template-columns: 36px 1fr 60px;
    }

    .file-date {
        display: none;
    }

    .upload-form {
        flex-direction: column;
        align-items: stretch;
    }

    .upload-form label {
        text-align: center;
    }

    .wiki-title {
        font-size: 1.5rem;
    }

    .wiki-content h1 {
        font-size: 1.375rem;
    }

    .page-header h1 {
        font-size: 1.25rem;
    }

    .breadcrumbs {
        gap: 2px;
    }

    .breadcrumb {
        font-size: 0.75rem;
        padding: 2px 4px;
    }
}

@media (max-width: 480px) {
    .file-row {
        grid-template-columns: 36px 1fr;
    }

    .file-size {
        display: none;
    }

    .file-date {
        display: none;
    }

    .topbar-actions .topbar-btn span {
        display: none;
    }

    .graph-svg {
        height: 400px;
    }
}
