:root {
    /* Material 3 Color Tokens - Dark Theme */
    --md-sys-color-background: #141218;
    --md-sys-color-on-background: #e6e0e9;
    --md-sys-color-surface: #2b2930;
    --md-sys-color-on-surface: #e6e0e9;
    --md-sys-color-surface-variant: #49454f;
    --md-sys-color-on-surface-variant: #cac4d0;
    --md-sys-color-primary: #d0bcff;
    --md-sys-color-on-primary: #381e72;
    --md-sys-color-error: #f2b8b5;
    --md-sys-color-on-error: #601410;
    --md-sys-color-outline: #938f99;
    --md-sys-color-outline-variant: #49454f;

    /* Base Font */
    --md-ref-typeface-plain: 'Roboto', system-ui, -apple-system, sans-serif;
    
    /* Set Material Web component theme variables */
    --md-sys-color-primary-container: #4f378b;
    --md-sys-color-on-primary-container: #eaddff;
}

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

body {
    font-family: var(--md-ref-typeface-plain);
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    line-height: 1.5;
    min-height: 100vh;
    overflow: hidden;
}

/* Layout */
#app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background-color: var(--md-sys-color-surface);
    border-right: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    flex-direction: column;
    padding: 24px;
    z-index: 10;
}

.sidebar-header {
    margin-bottom: 40px;
}

.logo-container {
    display: flex;
    justify-content: center;
    width: 100%;
}

.app-logo {
    width: 100%;
    max-width: 240px;
    height: auto;
    border-radius: 12px;
    object-fit: contain;
}

#auth-section, #file-explorer-section {
    margin-bottom: 24px;
    flex-grow: 1;
    overflow-y: auto;
}

#file-explorer-section h3 {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 16px;
    color: var(--md-sys-color-on-surface);
}

.auth-status {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.875rem;
    margin-bottom: 16px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

md-outlined-text-field {
    width: 100%;
    /* Apply custom theme colors if needed */
    --md-outlined-text-field-outline-color: var(--md-sys-color-outline);
    --md-outlined-text-field-input-text-color: var(--md-sys-color-on-surface);
}

md-filled-button {
    width: 100%;
}

md-text-button {
    width: 100%;
}

.hint {
    font-size: 0.75rem;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 12px;
}

/* File Explorer Tree */
md-list {
    background-color: transparent;
    --md-list-container-color: transparent;
}

md-list-item {
    cursor: pointer;
    border-radius: 8px;
    margin-bottom: 4px;
}

.nested-list {
    margin-left: 16px;
    border-left: 1px solid var(--md-sys-color-outline-variant);
}

.folder-icon {
    color: var(--md-sys-color-primary);
}

.doc-icon {
    color: var(--md-sys-color-on-surface-variant);
}

.image-icon {
    color: #ffb4ab;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
}

/* Main Content */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 48px;
    position: relative;
    background-color: var(--md-sys-color-background);
}

.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--md-sys-color-on-surface-variant);
    text-align: center;
}

.welcome-icon {
    font-size: 4rem;
    margin-bottom: 24px;
    color: var(--md-sys-color-primary);
}

.welcome-screen h1 {
    color: var(--md-sys-color-on-surface);
    margin-bottom: 12px;
    font-weight: 500;
}

/* Image Viewer */
.image-viewer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    height: 100%;
}

.image-viewer h2 {
    color: var(--md-sys-color-on-surface);
    margin-bottom: 24px;
    font-weight: 500;
}

.image-viewer img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

/* Loading & Errors */
#loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--md-sys-color-on-surface-variant);
}

.error-banner {
    background-color: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
    padding: 16px 24px;
    border-radius: 8px;
    margin-bottom: 24px;
}

/* Action Bar */
.action-bar {
    display: flex;
    justify-content: flex-end;
    max-width: 800px;
    margin: 0 auto 16px auto;
}

#edit-doc-link {
    text-decoration: none;
}

/* Markdown Rendering Styles */
.markdown-body {
    max-width: 800px;
    margin: 0 auto;
    font-size: 1rem;
    background-color: var(--md-sys-color-surface);
    border-radius: 12px;
    padding: 48px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}

.markdown-body h1, 
.markdown-body h2, 
.markdown-body h3, 
.markdown-body h4 {
    color: var(--md-sys-color-on-surface);
    margin-top: 2em;
    margin-bottom: 0.75em;
    font-weight: 500;
}

.markdown-body h1 { font-size: 2.125rem; margin-top: 0; }
.markdown-body h2 { font-size: 1.5rem; border-bottom: 1px solid var(--md-sys-color-outline-variant); padding-bottom: 0.3em; }
.markdown-body h3 { font-size: 1.25rem; }

.markdown-body p {
    margin-bottom: 1.5em;
    color: var(--md-sys-color-on-surface-variant);
}

.markdown-body a {
    color: var(--md-sys-color-primary);
    text-decoration: none;
}

.markdown-body a:hover {
    text-decoration: underline;
}

.markdown-body ul, .markdown-body ol {
    margin-bottom: 1.5em;
    padding-left: 2em;
    color: var(--md-sys-color-on-surface-variant);
}

.markdown-body code {
    font-family: 'Courier New', Courier, monospace;
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.875em;
}

.markdown-body pre {
    background-color: var(--md-sys-color-surface-variant);
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1.5em;
}

.markdown-body pre code {
    background: transparent;
    padding: 0;
    color: var(--md-sys-color-on-surface-variant);
}

.markdown-body blockquote {
    border-left: 4px solid var(--md-sys-color-primary);
    padding-left: 1em;
    color: var(--md-sys-color-on-surface-variant);
    margin: 1.5em 0;
    font-style: italic;
    background-color: var(--md-sys-color-surface-variant);
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
}

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

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5em;
    background-color: var(--md-sys-color-surface-variant);
    border-radius: 8px;
    overflow: hidden;
}

.markdown-body th, .markdown-body td {
    border: 1px solid var(--md-sys-color-outline-variant);
    padding: 12px 16px;
    text-align: left;
    color: var(--md-sys-color-on-surface);
}

.markdown-body th {
    background-color: var(--md-sys-color-surface);
    font-weight: 500;
    color: var(--md-sys-color-primary);
    border-bottom: 2px solid var(--md-sys-color-outline);
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    #app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--md-sys-color-outline-variant);
        padding: 16px;
    }
    
    .content-area {
        padding: 24px;
    }
    
    .markdown-body {
        padding: 24px;
    }
}
