:root {
    --bg: #0f1510;
    --bg-elevated: #151d17;
    --panel: rgba(23, 31, 25, 0.94);
    --panel-soft: rgba(30, 41, 33, 0.9);
    --line: rgba(170, 193, 161, 0.14);
    --line-strong: rgba(170, 193, 161, 0.24);
    --text: #edf3ea;
    --muted: #a1b09d;
    --accent: #7fb86a;
    --accent-strong: #9bd283;
    --accent-soft: rgba(127, 184, 106, 0.14);
    --danger: #ef8d7a;
    --radius: 20px;
    --radius-sm: 14px;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
    --font-sans: "Aptos", "Candara", "Trebuchet MS", "Segoe UI", sans-serif;
    --font-mono: "Iosevka", "Cascadia Mono", "Consolas", monospace;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at top left, rgba(127, 184, 106, 0.1), transparent 34%),
        linear-gradient(160deg, #0e140f 0%, #111812 48%, #151e17 100%);
    color: var(--text);
    font-family: var(--font-sans);
}

body {
    overflow-x: hidden;
}

button,
input,
textarea {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(10, 14, 11, 0.74);
    color: var(--text);
    padding: 0.9rem 1rem;
    outline: none;
    transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

input:focus,
textarea:focus {
    border-color: rgba(127, 184, 106, 0.36);
    background: rgba(11, 15, 12, 0.92);
    transform: translateY(-1px);
}

input:disabled,
textarea:disabled,
button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

textarea {
    resize: vertical;
}

a {
    color: inherit;
}

code,
pre {
    font-family: var(--font-mono);
}

.hidden {
    display: none !important;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.72rem;
    color: var(--muted);
}

.panel-surface,
.login-card,
.login-form {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.primary-button,
.secondary-button,
.ghost-button {
    border-radius: 999px;
    padding: 0.78rem 1rem;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.file-item:hover {
    transform: translateY(-1px);
}

.primary-button {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #102011;
    font-weight: 700;
}

.secondary-button {
    background: rgba(127, 184, 106, 0.1);
    color: var(--text);
    border: 1px solid rgba(127, 184, 106, 0.22);
}

.ghost-button {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text);
    border: 1px solid var(--line);
}

.workspace-body {
    padding: 1rem;
}

.workspace-shell {
    display: grid;
    grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
    gap: 1rem;
    min-height: calc(100vh - 2rem);
}

.file-rail,
.viewer-stage {
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

.sidebar-brand h1,
.login-copy h1,
.login-form h2,
.viewer-header h2,
.empty-viewer h3 {
    margin: 0.35rem 0 0.7rem;
}

.sidebar-brand p,
.login-copy p,
.feature-list,
.markdown-preview,
.pdf-note-summary,
.empty-viewer {
    line-height: 1.65;
}

.search-label,
.muted-meta,
.empty-list,
.empty-pane,
.login-help,
.file-meta,
.feature-list {
    color: var(--muted);
}

.search-input {
    margin-top: 0.55rem;
}

.explorer-toolbar {
    margin-top: 1rem;
}

.explorer-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.7rem;
    margin-top: 1rem;
}

.stat-pill {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 0.8rem 0.85rem;
    background: rgba(255, 255, 255, 0.02);
}

.stat-pill span {
    display: block;
    font-size: 0.76rem;
    color: var(--muted);
    margin-bottom: 0.2rem;
}

.stat-pill strong {
    font-size: 1.05rem;
}

.file-explorer {
    margin-top: 1rem;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-right: 0.2rem;
}

.explorer-section {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.explorer-section-title {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
}

.folder-group {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.02);
    overflow: hidden;
}

.folder-group summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1rem;
    cursor: pointer;
}

.folder-group summary::-webkit-details-marker {
    display: none;
}

.folder-group summary span {
    font-weight: 600;
}

.folder-group summary strong {
    color: var(--accent-strong);
}

.folder-items {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0 0.5rem 0.6rem;
}

.file-item {
    width: 100%;
    text-align: left;
    border-radius: 12px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    padding: 0.72rem 0.85rem;
    display: grid;
    gap: 0.15rem;
}

.file-item:hover {
    border-color: var(--line-strong);
    background: rgba(255, 255, 255, 0.03);
}

.file-item.is-active {
    border-color: rgba(127, 184, 106, 0.3);
    background: linear-gradient(135deg, rgba(127, 184, 106, 0.12), rgba(255, 255, 255, 0.03));
}

.file-name {
    font-weight: 600;
    word-break: break-word;
}

.file-meta {
    font-size: 0.82rem;
    word-break: break-word;
}

.viewer-stage {
    overflow: hidden;
}

.viewer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--line);
}

.kind-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.36rem 0.7rem;
    background: rgba(127, 184, 106, 0.12);
    color: var(--accent-strong);
    border: 1px solid rgba(127, 184, 106, 0.18);
    font-size: 0.8rem;
    font-weight: 600;
}

.viewer-panel {
    flex: 1;
    min-height: 0;
    padding-top: 1rem;
    overflow: hidden;
}

.markdown-preview,
.pdf-note-summary {
    height: 100%;
    overflow: auto;
    padding-right: 0.2rem;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4,
.markdown-preview h5,
.markdown-preview h6 {
    margin: 1.5rem 0 0.7rem;
    line-height: 1.25;
}

.markdown-preview h1:first-child,
.markdown-preview h2:first-child,
.markdown-preview h3:first-child {
    margin-top: 0;
}

.markdown-preview p,
.markdown-preview ul,
.markdown-preview ol,
.markdown-preview blockquote,
.markdown-preview pre,
.markdown-preview .table-scroll,
.pdf-note-summary p,
.pdf-note-summary ul,
.pdf-note-summary ol,
.pdf-note-summary blockquote,
.pdf-note-summary pre,
.pdf-note-summary .table-scroll {
    margin: 0 0 1rem;
}

.markdown-preview ul,
.markdown-preview ol,
.pdf-note-summary ul,
.pdf-note-summary ol {
    padding-left: 1.35rem;
}

.markdown-preview li,
.pdf-note-summary li {
    margin: 0.32rem 0;
}

.markdown-preview hr,
.pdf-note-summary hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 1.3rem 0;
}

.markdown-preview blockquote,
.pdf-note-summary blockquote {
    border-left: 3px solid rgba(127, 184, 106, 0.32);
    padding: 0.2rem 0 0.2rem 1rem;
    color: #d9e4d4;
    background: rgba(127, 184, 106, 0.04);
    border-radius: 0 12px 12px 0;
}

.markdown-preview code,
.pdf-note-summary code,
.login-help code {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    padding: 0.12rem 0.4rem;
    color: #f6f8f3;
}

.markdown-preview pre,
.pdf-note-summary pre {
    background: #0d130e;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 1rem;
    overflow: auto;
}

.markdown-preview pre code,
.pdf-note-summary pre code {
    background: transparent;
    border: 0;
    padding: 0;
}

.table-scroll {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
}

.markdown-table {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.02);
}

.markdown-table th,
.markdown-table td {
    padding: 0.78rem 0.9rem;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.markdown-table th:last-child,
.markdown-table td:last-child {
    border-right: 0;
}

.markdown-table tbody tr:last-child td {
    border-bottom: 0;
}

.markdown-table thead th {
    text-align: left;
    background: rgba(127, 184, 106, 0.08);
}

.markdown-table tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.015);
}

.wikilink {
    color: var(--accent-strong);
    text-decoration: none;
    border-bottom: 1px dashed rgba(155, 210, 131, 0.34);
}

.wikilink:hover {
    color: #c5e8b7;
}

.wikilink.is-embedded {
    font-weight: 600;
}

.markdown-image {
    display: block;
    max-width: 100%;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #111713;
    margin: 0.5rem 0;
}

.task-item {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}

.missing-link {
    color: #f4baac;
}

.pdf-note-summary {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    margin-bottom: 1rem;
    max-height: 32vh;
}

.pdf-pane {
    height: 100%;
    min-height: 0;
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    background: rgba(12, 16, 13, 0.82);
}

.pdf-frame {
    width: 100%;
    height: 100%;
    border: 0;
    background: white;
}

.empty-viewer,
.empty-pane,
.empty-list {
    display: grid;
    place-items: center;
    text-align: center;
}

.empty-viewer {
    height: 100%;
    border: 1px dashed var(--line-strong);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.02);
    padding: 2rem;
}

.empty-pane {
    min-height: 100%;
    padding: 2rem;
}

.toast {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 20;
    max-width: 360px;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    background: rgba(18, 27, 20, 0.96);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow);
}

.toast.is-error {
    background: rgba(50, 23, 20, 0.96);
    border-color: rgba(239, 141, 122, 0.3);
}

.login-body {
    display: grid;
    place-items: center;
    padding: 1rem;
}

.login-shell {
    width: min(980px, 100%);
}

.login-card {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 1rem;
    padding: 1rem;
}

.login-copy,
.login-form {
    padding: 1rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    background: var(--panel-soft);
}

.login-form-header {
    margin-bottom: 0.3rem;
}

.feature-list {
    margin: 1rem 0 0;
    padding-left: 1.2rem;
}

.form-alert {
    padding: 0.8rem 0.9rem;
    border-radius: 12px;
    background: rgba(239, 141, 122, 0.1);
    border: 1px solid rgba(239, 141, 122, 0.2);
    color: #ffc5b8;
}

@media (max-width: 960px) {
    .workspace-shell {
        grid-template-columns: 1fr;
    }

    .file-rail {
        min-height: auto;
    }

    .viewer-stage {
        min-height: 65vh;
    }

    .login-card {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .workspace-body,
    .login-body {
        padding: 0.75rem;
    }

    .workspace-shell {
        gap: 0.75rem;
        min-height: calc(100vh - 1.5rem);
    }

    .file-rail,
    .viewer-stage,
    .login-card,
    .login-form,
    .login-copy {
        padding: 0.9rem;
    }

    .explorer-stats {
        grid-template-columns: 1fr;
    }

    .viewer-header {
        flex-direction: column;
    }

    .markdown-table {
        min-width: 460px;
    }
}
