/* ============================================
   Digital Garden Builder — Forest Theme
   Primary: #10B981 | Secondary: #34D399
   Accent: #F59E0B | Background: #0A1A14
   ============================================ */

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

:root {
    --primary: #10B981;
    --primary-glow: rgba(16, 185, 129, 0.15);
    --secondary: #34D399;
    --accent: #F59E0B;
    --accent-glow: rgba(245, 158, 11, 0.12);
    --bg: #0A1A14;
    --bg-card: #112822;
    --bg-card-hover: #183832;
    --bg-input: #0d1f18;
    --border: #1e3a30;
    --border-focus: #10B981;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --success: #34d399;
    --error: #f87171;
    --warning: #fbbf24;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 24px rgba(16, 185, 129, 0.1);
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    overflow: hidden
}

/* Header */
.header {
    position: relative;
    z-index: 100;
    background: rgba(10, 26, 20, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border)
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 100%;
    padding: 0.625rem 1.25rem
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 0.75rem
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary-glow), var(--accent-glow));
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-sm);
    color: var(--primary);
    transition: var(--transition)
}

.logo-icon:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-glow)
}

.logo-title {
    font-size: 1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2
}

.logo-subtitle {
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.375rem
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.875rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    background: none;
    color: var(--text)
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #059669);
    color: white;
    border-color: rgba(16, 185, 129, 0.3);
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.25)
}

.btn-primary:hover {
    box-shadow: 0 4px 18px rgba(16, 185, 129, 0.35);
    transform: translateY(-1px)
}

.btn-primary:active {
    transform: translateY(0)
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted)
}

.btn-ghost:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05)
}

.btn-ghost.active {
    color: var(--primary);
    background: var(--primary-glow)
}

.btn-sm {
    padding: 0.35rem 0.625rem;
    font-size: 0.75rem
}

.btn-lg {
    padding: 0.75rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600
}

/* App Layout */
.main {
    height: calc(100vh - 53px)
}

.app-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 100%
}

/* Sidebar */
.sidebar {
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden
}

.sidebar-header {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    transition: var(--transition)
}

.search-box:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12)
}

.search-box svg {
    color: var(--text-dim);
    flex-shrink: 0
}

.search-box input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.8125rem;
    outline: none
}

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

.sidebar-stats {
    font-size: 0.6875rem;
    color: var(--text-dim);
    padding: 0 0.25rem
}

.note-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.375rem
}

.empty-sidebar {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    gap: 0.25rem;
    color: var(--text-dim);
    text-align: center
}

.empty-icon {
    font-size: 2rem;
    opacity: 0.3;
    margin-bottom: 0.25rem
}

.empty-sidebar p {
    font-size: 0.8125rem
}

.hint {
    font-size: 0.6875rem;
    opacity: 0.6
}

.note-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 2px
}

.note-item:hover {
    background: rgba(255, 255, 255, 0.03)
}

.note-item.active {
    background: var(--primary-glow);
    border-left: 2px solid var(--primary)
}

.note-item-title {
    flex: 1;
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.note-item-date {
    font-size: 0.625rem;
    color: var(--text-dim);
    flex-shrink: 0
}

.note-item-links {
    font-size: 0.625rem;
    color: var(--text-dim);
    flex-shrink: 0;
    padding: 0.125rem 0.375rem;
    background: rgba(16, 185, 129, 0.08);
    border-radius: 9999px
}

/* Content Area */
.content-area {
    overflow: hidden;
    position: relative
}

/* Empty State */
.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem
}

.empty-hero {
    text-align: center;
    max-width: 420px
}

.empty-hero-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    opacity: 0.3
}

.empty-hero h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--text), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text
}

.empty-hero p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    line-height: 1.6
}

.empty-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    text-align: left
}

.feature {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-muted)
}

.feature-icon {
    font-size: 1.125rem
}

/* Editor View */
.editor-view {
    display: flex;
    flex-direction: column;
    height: 100%
}

.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.015);
    gap: 0.5rem
}

.note-title-input {
    flex: 1;
    padding: 0.5rem 0;
    background: none;
    border: none;
    color: var(--text);
    font-family: var(--font);
    font-size: 1.125rem;
    font-weight: 700;
    outline: none
}

.note-title-input::placeholder {
    color: var(--text-dim);
    opacity: 0.4
}

.toolbar-actions {
    display: flex;
    gap: 0.25rem
}

.editor-body {
    flex: 1;
    overflow: hidden
}

.editor-panes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: 100%
}

.editor-pane {
    display: flex;
    flex-direction: column;
    overflow: hidden
}

.preview-pane {
    border-left: 1px solid var(--border)
}

.pane-label {
    padding: 0.375rem 1rem;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between
}

.hint-text {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    opacity: 0.6
}

.note-editor {
    flex: 1;
    padding: 1rem;
    background: transparent;
    border: none;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.8125rem;
    line-height: 1.7;
    resize: none;
    outline: none;
    tab-size: 2;
    overflow: auto
}

.note-editor::placeholder {
    color: var(--text-dim);
    opacity: 0.4
}

.note-preview {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    font-size: 0.8125rem;
    line-height: 1.7;
    color: var(--text-muted)
}

.note-preview h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem
}

.note-preview h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--secondary);
    margin: 1.25rem 0 0.5rem
}

.note-preview h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
    margin: 1rem 0 0.375rem
}

.note-preview p {
    margin-bottom: 0.625rem
}

.note-preview ul,
.note-preview ol {
    margin: 0.375rem 0 0.625rem 1.25rem
}

.note-preview li {
    margin-bottom: 0.25rem
}

.note-preview code {
    padding: 0.1rem 0.35rem;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.15);
    border-radius: 3px;
    font-size: 0.8em;
    color: var(--secondary)
}

.note-preview pre {
    padding: 0.75rem;
    margin: 0.5rem 0;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    overflow-x: auto
}

.note-preview pre code {
    padding: 0;
    background: none;
    border: none;
    color: var(--text);
    font-size: 0.8125rem
}

.note-preview blockquote {
    border-left: 3px solid var(--primary);
    padding: 0.5rem 0.75rem;
    margin: 0.5rem 0;
    background: rgba(16, 185, 129, 0.04);
    border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
    font-style: italic
}

.note-preview strong {
    color: var(--text);
    font-weight: 600
}

.note-preview em {
    color: var(--text-muted)
}

.note-preview a,
.wikilink {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px dashed rgba(16, 185, 129, 0.3);
    cursor: pointer;
    transition: var(--transition)
}

.note-preview a:hover,
.wikilink:hover {
    color: var(--secondary);
    border-bottom-color: var(--secondary)
}

/* Backlinks */
.editor-footer {
    border-top: 1px solid var(--border);
    max-height: 180px;
    overflow-y: auto
}

.backlinks-section {
    padding: 0.75rem 1rem
}

.backlinks-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.375rem
}

.backlink-count {
    background: rgba(16, 185, 129, 0.1);
    color: var(--primary);
    padding: 0.1rem 0.4rem;
    border-radius: 9999px;
    font-size: 0.625rem;
    font-weight: 700
}

.backlinks-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem
}

.backlink-item {
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius-xs);
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.375rem
}

.backlink-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text)
}

.backlink-icon {
    color: var(--primary);
    font-size: 0.875rem
}

/* Graph View */
.graph-view {
    position: absolute;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center
}

.graph-view canvas {
    width: 100%;
    height: 100%
}

.graph-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.25rem
}

.graph-legend {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    display: flex;
    gap: 1rem;
    font-size: 0.6875rem;
    color: var(--text-dim)
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.375rem
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%
}

.active-dot {
    background: var(--accent)
}

.linked-dot {
    background: var(--primary)
}

.other-dot {
    background: var(--text-dim)
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    font-size: 0.8125rem;
    color: var(--text);
    animation: toast-in 0.3s ease
}

.toast.success {
    border-color: rgba(52, 211, 153, 0.3)
}

.toast.error {
    border-color: rgba(248, 113, 113, 0.3)
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(12px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

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

::-webkit-scrollbar-track {
    background: transparent
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.12)
}

/* Responsive */
@media(max-width:768px) {
    .app-layout {
        grid-template-columns: 1fr
    }

    .sidebar {
        display: none
    }

    .sidebar.open {
        display: flex;
        position: fixed;
        inset: 53px 0 0 0;
        z-index: 90;
        width: 100%
    }

    .editor-panes {
        grid-template-columns: 1fr
    }

    .preview-pane {
        display: none
    }

    .empty-features {
        grid-template-columns: 1fr
    }

    .header-inner {
        padding: 0.5rem 1rem
    }
}