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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #fff;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

button {
    transition: background-color 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid #0366d6;
    outline-offset: 2px;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid #eee;
    margin-bottom: 2rem;
}

nav a {
    color: #0366d6;
    text-decoration: none;
    margin-right: 1rem;
}

nav a:hover {
    text-decoration: underline;
}

.logout-btn {
    background: none;
    border: 1px solid #ddd;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    color: #666;
}

.logout-btn:hover {
    border-color: #999;
    color: #333;
}

/* Login page */

.login-page {
    text-align: center;
    margin-top: 4rem;
}

.login-page h1 {
    margin-bottom: 0.5rem;
}

.login-page > p {
    margin-bottom: 2rem;
    color: #666;
}

.login-options {
    max-width: 400px;
    margin: 0 auto;
}

.github-btn {
    background: #24292e;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
}

.github-btn:hover {
    background: #444;
}

.dev-login {
    margin-top: 2rem;
}

.dev-login details {
    text-align: left;
}

.dev-login summary {
    cursor: pointer;
    color: #666;
    font-size: 0.9rem;
}

.dev-login form {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.dev-login input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.dev-login button {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

/* Dashboard */

.dashboard {
    max-width: 800px;
}

.dashboard-header {
    margin-bottom: 1.5rem;
}


.breadcrumbs {
    font-size: 0.9rem;
    color: #666;
}

.breadcrumb-link {
    color: #0366d6;
    cursor: pointer;
    text-decoration: none;
}

.breadcrumb-link:hover {
    text-decoration: underline;
}

.breadcrumb-sep {
    margin: 0 0.25rem;
    color: #999;
}

.breadcrumb-current {
    color: #333;
    font-weight: 600;
}

.navigate-up {
    margin-bottom: 1rem;
}

.up-link {
    color: #0366d6;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.9rem;
}

.up-link:hover {
    text-decoration: underline;
}

.content-list {
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    overflow: hidden;
}

.content-entry {
    display: flex;
    align-items: center;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid #e1e4e8;
    cursor: pointer;
    transition: background-color 0.1s;
}

.content-entry:last-child {
    border-bottom: none;
}

.content-entry:hover {
    background-color: #f6f8fa;
}

.content-entry.is-dir .entry-name {
    font-weight: 600;
}

.entry-icon {
    width: 1.5rem;
    text-align: center;
    color: #666;
    font-size: 0.9rem;
}

.entry-name {
    flex: 1;
    color: #333;
}

.entry-size {
    color: #999;
    font-size: 0.85rem;
    margin-left: 1rem;
}

.empty {
    color: #666;
    text-align: center;
    padding: 2rem;
}

/* Dashboard header */

.dashboard-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.new-post-btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid #0366d6;
    border-radius: 4px;
    background: #0366d6;
    color: white;
    cursor: pointer;
    font-size: 0.85rem;
}

.new-post-btn:hover {
    background: #0256b9;
}

/* New post form */

.new-post-form {
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
    background: #f6f8fa;
}

.form-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.form-row label {
    width: 5rem;
    font-size: 0.9rem;
    color: #555;
}

.form-row input {
    flex: 1;
    padding: 0.4rem 0.6rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.create-btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid #28a745;
    border-radius: 4px;
    background: #28a745;
    color: white;
    cursor: pointer;
    font-size: 0.85rem;
}

.create-btn:hover {
    background: #22863a;
}

.create-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.new-post-preview {
    margin-left: 0.75rem;
    font-size: 0.8rem;
    color: #999;
    font-family: monospace;
}

/* Editor page */

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

.editor-nav {
    margin-bottom: 0.5rem;
}

.back-link {
    color: #0366d6;
    text-decoration: none;
    font-size: 0.9rem;
}

.back-link:hover {
    text-decoration: underline;
}

.editor-header {
    margin-bottom: 1rem;
}

.editor-path {
    font-size: 1.1rem;
    word-break: break-all;
}

.editor-meta {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.25rem;
    font-size: 0.85rem;
}

.editor-branch {
    color: #6f42c1;
    font-family: monospace;
}

.editor-badge {
    padding: 0.1rem 0.5rem;
    border-radius: 3px;
    font-size: 0.8rem;
}

.new-badge {
    background: #28a745;
    color: white;
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    align-items: center;
}

.save-btn {
    padding: 0.5rem 1.2rem;
    border: none;
    border-radius: 4px;
    background: #0366d6;
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
}

.save-btn:hover {
    background: #0256b9;
}

.save-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.delete-btn {
    padding: 0.5rem 1.2rem;
    border: 1px solid #d73a49;
    border-radius: 4px;
    background: white;
    color: #d73a49;
    cursor: pointer;
    font-size: 0.9rem;
}

.delete-btn:hover {
    background: #d73a49;
    color: white;
}

.delete-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.upload-btn {
    padding: 0.5rem 1.2rem;
    border: 1px solid #6f42c1;
    border-radius: 4px;
    background: white;
    color: #6f42c1;
    cursor: pointer;
    font-size: 0.9rem;
}

.upload-btn:hover {
    background: #6f42c1;
    color: white;
}

.upload-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.hidden-file-input {
    display: none;
}

/* Publish bar */

.publish-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: #f6f8fa;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
}

.publish-btn {
    padding: 0.5rem 1.2rem;
    border: none;
    border-radius: 4px;
    background: #28a745;
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
}

.publish-btn:hover {
    background: #22863a;
}

.publish-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.discard-btn {
    padding: 0.5rem 1.2rem;
    border: 1px solid #d73a49;
    border-radius: 4px;
    background: white;
    color: #d73a49;
    cursor: pointer;
    font-size: 0.9rem;
}

.discard-btn:hover {
    background: #d73a49;
    color: white;
}

.discard-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.publish-hint {
    color: #6a737d;
    font-size: 0.85rem;
    margin-left: 0.5rem;
}

.editor-textarea {
    width: 100%;
    min-height: 60vh;
    padding: 1rem;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    tab-size: 4;
}

.editor-textarea:focus {
    outline: none;
    border-color: #0366d6;
    box-shadow: 0 0 0 3px rgba(3, 102, 214, 0.15);
}

.save-msg {
    color: #22863a;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: #dcffe4;
    border: 1px solid #bef5cb;
    border-radius: 4px;
}

/* View toggle */

.view-toggle {
    display: flex;
    margin-left: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.toggle-btn {
    padding: 0.35rem 0.75rem;
    border: none;
    background: white;
    color: #555;
    cursor: pointer;
    font-size: 0.85rem;
    border-right: 1px solid #ddd;
}

.toggle-btn:last-child {
    border-right: none;
}

.toggle-btn:hover {
    background: #f6f8fa;
}

.toggle-btn.active {
    background: #0366d6;
    color: white;
}

/* Editor container & split layout */

.editor-container {
    display: flex;
    gap: 1rem;
    transition: outline 0.15s, background-color 0.15s;
}

.editor-container.drag-over {
    outline: 2px dashed #6f42c1;
    outline-offset: -2px;
    background: rgba(111, 66, 193, 0.05);
}

.editor-container .editor-textarea {
    flex: 1;
    min-width: 0;
}

.editor-container .preview-pane {
    flex: 1;
    min-width: 0;
}

.editor-page-wide {
    max-width: 100%;
}

/* Preview pane */

.preview-pane {
    padding: 1rem;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    min-height: 60vh;
    overflow-y: auto;
}

/* Preview page (standalone) */

.preview-page {
    max-width: 800px;
}

.preview-nav {
    margin-bottom: 0.5rem;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.preview-header h2 {
    font-size: 1.1rem;
    word-break: break-all;
}

.edit-link {
    color: #0366d6;
    text-decoration: none;
    font-size: 0.9rem;
}

.edit-link:hover {
    text-decoration: underline;
}

/* Markdown body typography */

.markdown-body {
    font-size: 1rem;
    line-height: 1.7;
    word-wrap: break-word;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
    line-height: 1.25;
}

.markdown-body h1 { font-size: 1.8em; border-bottom: 1px solid #eee; padding-bottom: 0.3em; }
.markdown-body h2 { font-size: 1.4em; border-bottom: 1px solid #eee; padding-bottom: 0.3em; }
.markdown-body h3 { font-size: 1.2em; }
.markdown-body h4 { font-size: 1em; }

.markdown-body p {
    margin-bottom: 1em;
}

.markdown-body a {
    color: #0366d6;
    text-decoration: none;
}

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

.markdown-body ul,
.markdown-body ol {
    margin-bottom: 1em;
    padding-left: 2em;
}

.markdown-body li {
    margin-bottom: 0.25em;
}

.markdown-body blockquote {
    margin: 0 0 1em;
    padding: 0.5em 1em;
    border-left: 4px solid #dfe2e5;
    color: #6a737d;
}

.markdown-body pre {
    background: #f6f8fa;
    border-radius: 4px;
    padding: 1rem;
    overflow-x: auto;
    margin-bottom: 1em;
    font-size: 0.9em;
}

.markdown-body code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.9em;
}

.markdown-body :not(pre) > code {
    background: #f0f0f0;
    padding: 0.15em 0.3em;
    border-radius: 3px;
}

.markdown-body img {
    max-width: 100%;
    height: auto;
}

.markdown-body table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 1em;
}

.markdown-body th,
.markdown-body td {
    border: 1px solid #dfe2e5;
    padding: 0.5em 0.75em;
    text-align: left;
}

.markdown-body th {
    background: #f6f8fa;
    font-weight: 600;
}

.markdown-body hr {
    border: none;
    border-top: 1px solid #eee;
    margin: 1.5em 0;
}

.markdown-body del {
    color: #999;
}

/* Diff panel */

.diff-panel {
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.diff-header {
    padding: 0.75rem 1rem;
    background: #f6f8fa;
    border-bottom: 1px solid #e1e4e8;
}

.diff-header h3 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.diff-summary {
    font-size: 0.85rem;
    color: #586069;
}

.diff-additions {
    color: #22863a;
    font-weight: 600;
}

.diff-deletions {
    color: #cb2431;
    font-weight: 600;
}

.diff-empty {
    padding: 1rem;
    color: #586069;
    text-align: center;
}

.diff-files {
    max-height: 50vh;
    overflow-y: auto;
}

.diff-file {
    border-bottom: 1px solid #e1e4e8;
}

.diff-file:last-child {
    border-bottom: none;
}

.diff-file-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #fafbfc;
    border-bottom: 1px solid #e1e4e8;
    font-size: 0.85rem;
}

.diff-file-status {
    display: inline-block;
    width: 1.4rem;
    height: 1.4rem;
    line-height: 1.4rem;
    text-align: center;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
}

.diff-file-status.added { background: #28a745; }
.diff-file-status.removed { background: #cb2431; }
.diff-file-status.modified { background: #dbab09; }
.diff-file-status.renamed { background: #0366d6; }

.diff-file-name {
    flex: 1;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    word-break: break-all;
}

.diff-file-stats {
    font-size: 0.8rem;
    white-space: nowrap;
}

.diff-patch {
    margin: 0;
    padding: 0;
    font-size: 0.8rem;
    line-height: 1.5;
    overflow-x: auto;
    background: white;
}

.diff-line {
    padding: 0 1rem;
    white-space: pre;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.diff-line-add {
    background: #e6ffed;
    color: #22863a;
}

.diff-line-del {
    background: #ffeef0;
    color: #cb2431;
}

.diff-line-hunk {
    background: #f1f8ff;
    color: #0366d6;
    font-weight: 600;
}

.diff-line-ctx {
    color: #24292e;
}

.diff-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #f6f8fa;
    border-top: 1px solid #e1e4e8;
}

/* Placeholder pages */

.placeholder {
    text-align: center;
    margin-top: 4rem;
    color: #666;
}

.placeholder h2 {
    color: #333;
    margin-bottom: 0.5rem;
}

/* Utilities */

.error {
    color: #86181d;
    margin-bottom: 1rem;
    padding: 0.5rem 0.75rem;
    background: #ffeef0;
    border: 1px solid #fdaeb7;
    border-radius: 4px;
    font-size: 0.9rem;
}

.loading {
    color: #666;
    font-style: italic;
}
