/* ── Theme variables ─────────────────────────────────────────────────────── */

/* Dark theme (default) */
:root,
body.theme-dark {
    --bg-color: #13141c;
    --panel-bg: #21222c;
    --border-color: #52B69A;
    --text-color: #cdd6f4;
    --text-muted: #7a8aa8;
    --accent-color: #52B69A;
    --accent-hover: #34A0A4;
    --link-color: #7ecfb6;
    --success-color: #76C893;
    --input-bg: #282a36;
    --input-border: #44475a;
    --surface-bg: #2a2b3a;
    --sidebar-bg: #0d2840;
    --sidebar-text: #fefefe;
    --sidebar-border: rgba(255, 255, 255, 0.2);
    --sidebar-hover: rgba(255, 255, 255, 0.1);
    --editor-header-bg: #1e1f2b;
    --editor-header-border: #383a4e;
    --save-indicator-bg: #1e1f2b;
    --save-indicator-border: #383a4e;
    /* Preview — warm dark ink */
    --preview-bg: #1a1612;
    --preview-text: #d9cfc0;
    --preview-heading: #f0e8d5;
    --preview-link: #7ecfb6;
    --preview-link-hover: #a8e6d4;
    --preview-link-underline: rgba(126, 207, 182, 0.35);
    --preview-code-bg: rgba(255, 255, 255, 0.07);
    --preview-code-text: #e8a87c;
    --preview-pre-bg: #0e0c09;
    --preview-pre-text: #c9bfb0;
    --preview-pre-border: rgba(255, 255, 255, 0.06);
    --preview-blockquote-bg: rgba(82, 182, 154, 0.07);
    --preview-blockquote-text: #b8ac9c;
    --preview-hr: rgba(255, 255, 255, 0.1);
    --preview-img-border: rgba(255, 255, 255, 0.08);
    --preview-img-shadow: rgba(0, 0, 0, 0.45);
    --preview-img-shadow-hover: rgba(0, 0, 0, 0.65);
    --preview-caption: #8a7f70;
}

/* Light theme */
body.theme-light {
    --bg-color: #e8edf2;
    --panel-bg: #ffffff;
    --border-color: #2e8b72;
    --text-color: #111;
    --text-muted: #666;
    --accent-color: #2e8b72;
    --accent-hover: #246b58;
    --link-color: #1A759F;
    --success-color: #4aae6b;
    --input-bg: #fff;
    --input-border: #bbb;
    --surface-bg: #f5f5f5;
    --sidebar-bg: #2c3e50;
    --sidebar-text: #ecf0f1;
    --sidebar-border: rgba(255, 255, 255, 0.15);
    --sidebar-hover: rgba(255, 255, 255, 0.1);
    --editor-header-bg: #f4f7f9;
    --editor-header-border: #d0d7de;
    --save-indicator-bg: #f4f7f9;
    --save-indicator-border: #d0d7de;
    /* Preview — warm cream paper */
    --preview-bg: #faf7f2;
    --preview-text: #2c2210;
    --preview-heading: #1a1208;
    --preview-link: #1a6fa0;
    --preview-link-hover: #0f4f75;
    --preview-link-underline: rgba(26, 111, 160, 0.35);
    --preview-code-bg: #ede8df;
    --preview-code-text: #9a3a2a;
    --preview-pre-bg: #2a241c;
    --preview-pre-text: #c8bfb0;
    --preview-pre-border: transparent;
    --preview-blockquote-bg: rgba(44, 34, 16, 0.04);
    --preview-blockquote-text: #5a4d3c;
    --preview-hr: rgba(44, 34, 16, 0.15);
    --preview-img-border: rgba(44, 34, 16, 0.12);
    --preview-img-shadow: rgba(44, 34, 16, 0.1);
    --preview-img-shadow-hover: rgba(44, 34, 16, 0.2);
    --preview-caption: #7a6e5c;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.25s ease;
}

.sidebar, .editor-panel, .preview-panel, .preview-content {
    transition: background-color 0.25s ease, color 0.25s ease;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */

.container {
    display: grid;
    grid-template-columns: 260px 4px 1fr 4px 1fr;
    height: 100vh;
}

.resize-handle {
    background: var(--border-color);
    cursor: col-resize;
    z-index: 10;
    transition: background 0.15s;
}

.resize-handle:hover,
.resize-handle.dragging {
    background: var(--accent-hover);
}

body.resizing {
    user-select: none;
    cursor: col-resize;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.sidebar {
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    flex-shrink: 0;
    padding: 16px;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.sidebar-header h1 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-bottom: 0;
    color: var(--border-color);
    text-transform: uppercase;
}

/* ── Theme Toggle ─────────────────────────────────────────────────────────── */

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--sidebar-border);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.07);
    color: var(--sidebar-text);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-color);
    transform: rotate(20deg);
}

.theme-toggle svg {
    width: 14px;
    height: 14px;
}

/* Sun shown in dark mode (click to go light), moon in light mode (click to go dark) */
body.theme-dark .theme-toggle .icon-sun { display: block; }
body.theme-dark .theme-toggle .icon-moon { display: none; }
body.theme-light .theme-toggle .icon-sun { display: none; }
body.theme-light .theme-toggle .icon-moon { display: block; }

.btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

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

.btn-danger {
    background: #dc3545;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-new {
    width: 100%;
    margin-bottom: 12px;
}

.search-input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--sidebar-border);
    border-radius: 4px;
    color: var(--sidebar-text);
    font-size: 14px;
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.45);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.15);
}

/* ── File list ───────────────────────────────────────────────────────────── */

.file-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 8px;
}

.file-item {
    padding: 10px 12px;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 2px;
    transition: background 0.15s;
    color: var(--sidebar-text);
}

.file-item:hover {
    background: var(--sidebar-hover);
}

.file-item.active {
    background: var(--accent-color);
}

.file-item-name {
    font-size: 13px;
    font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.empty-list {
    padding: 16px 12px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
    text-align: center;
}

/* ── Image Gallery ───────────────────────────────────────────────────────── */

.image-gallery-section {
    flex-shrink: 0;
    border-top: 1px solid var(--sidebar-border);
    padding: 12px;
    max-height: 200px;
    overflow-y: auto;
}

.image-gallery-header {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.image-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.gallery-image {
    aspect-ratio: 1;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s;
    background: rgba(255, 255, 255, 0.1);
}

.gallery-image:hover {
    border-color: var(--accent-color);
}

.gallery-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.empty-gallery {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.35);
    text-align: center;
    padding: 8px;
}

/* ── Editor Panel ────────────────────────────────────────────────────────── */

.editor-panel {
    display: flex;
    flex-direction: column;
    background: var(--panel-bg);
    overflow: hidden;
}

#editorContent {
    flex: 1;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.editor-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--editor-header-border);
    background: var(--editor-header-bg);
}

.editor-filename {
    flex: 1;
    font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.editor-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
    min-height: 0;
    overflow: hidden;
}

/* Hide original textarea (CodeMirror takes over) */
.editor-textarea {
    display: none;
}

/* ── CodeMirror ──────────────────────────────────────────────────────────── */

.CodeMirror {
    flex: 1;
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    color: var(--text-color);
    font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
    font-size: 14px;
    line-height: 1.6;
}

.CodeMirror-focused {
    border-color: var(--accent-color);
}

.cm-header { color: #1A759F; font-weight: bold; }
.cm-header-1 { font-size: 1.3em; }
.cm-header-2 { font-size: 1.2em; }
.cm-header-3 { font-size: 1.1em; }
.cm-strong { font-weight: bold; color: #333; }
.cm-em { font-style: italic; color: #555; }
.cm-link { color: var(--link-color); text-decoration: underline; }
.cm-url { color: var(--accent-color); }
.cm-comment { color: #888; }
.cm-quote { color: #666; font-style: italic; }
.cm-keyword { color: #d73a49; }
.cm-atom { color: #005cc5; }
.cm-string { color: #22863a; }
.cm-tag { color: #22863a; }
.cm-attribute { color: #6f42c1; }

.cm-comment.cm-formatting-code,
.cm-comment.cm-formatting-code-block {
    color: #e36209;
    background: #f6f8fa;
    border-radius: 3px;
}

body.theme-light .CodeMirror-selected {
    background: rgba(82, 182, 154, 0.3) !important;
}

.CodeMirror-cursor {
    border-left-color: var(--text-color);
}

.CodeMirror-gutters {
    background: #f7f7f7;
    border-right: 1px solid var(--input-border);
}

/* ── Drop Zone ───────────────────────────────────────────────────────────── */

.drop-zone {
    flex-shrink: 0;
    margin-top: 12px;
    padding: 12px 16px;
    border: 2px dashed var(--input-border);
    border-radius: 8px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    transition: all 0.2s;
    cursor: pointer;
}

.drop-zone:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.drop-zone.drag-over {
    border-color: var(--accent-color);
    background: rgba(82, 182, 154, 0.1);
    color: var(--accent-color);
}

/* ── Save indicator ──────────────────────────────────────────────────────── */

.save-indicator {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: var(--save-indicator-bg);
    border-top: 1px solid var(--save-indicator-border);
    font-size: 12px;
    color: var(--text-muted);
}

.save-indicator.saved { color: var(--success-color); }
.save-indicator.saving { color: var(--link-color); }

/* ── Preview Panel ───────────────────────────────────────────────────────── */

.preview-panel {
    background: var(--preview-bg);
    overflow-y: auto;
    padding: 0;
    font-family: 'Lora', Georgia, 'Times New Roman', serif;
}

/* Reading column — max-width for optimal line length */
.preview-content {
    max-width: 700px;
    margin: 0 auto;
    padding: 56px 48px 100px;
    color: var(--preview-text);
    font-size: 17.5px;
    line-height: 1.82;
    letter-spacing: 0.008em;
}

/* ── Preview Headings — Fraunces display serif ────────────────────────────── */

.preview-content h1,
.preview-content h2,
.preview-content h3,
.preview-content h4,
.preview-content h5,
.preview-content h6 {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 600;
    color: var(--preview-heading);
    line-height: 1.2;
    letter-spacing: -0.025em;
    text-decoration: none;
}

.preview-content h1 {
    font-size: 2.5em;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 0.3em;
    letter-spacing: -0.03em;
}

.preview-content h1:first-child { margin-top: 0; }

.preview-content h2 {
    font-size: 1.6em;
    font-weight: 600;
    margin-top: 2.4em;
    margin-bottom: 0.5em;
    padding-bottom: 0.3em;
    border-bottom: 1px solid var(--preview-hr);
}

.preview-content h3 {
    font-size: 1.2em;
    font-weight: 600;
    margin-top: 2em;
    margin-bottom: 0.4em;
}

.preview-content h4 {
    font-size: 0.9em;
    font-weight: 700;
    margin-top: 1.6em;
    margin-bottom: 0.4em;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--preview-caption);
}

.preview-content h5,
.preview-content h6 {
    font-size: 0.85em;
    font-weight: 600;
    margin-top: 1.4em;
    margin-bottom: 0.3em;
    color: var(--preview-caption);
}

/* ── Preview Body Elements ────────────────────────────────────────────────── */

.preview-content p { margin-bottom: 1.1em; }

.preview-content a {
    color: var(--preview-link);
    text-decoration: underline;
    text-decoration-color: var(--preview-link-underline);
    text-underline-offset: 3px;
    transition: color 0.15s, text-decoration-color 0.15s;
}

.preview-content a:visited { color: var(--preview-link); }

.preview-content a:hover {
    color: var(--preview-link-hover);
    text-decoration-color: var(--preview-link-hover);
}

/* Inline code */
.preview-content code {
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    background: var(--preview-code-bg);
    color: var(--preview-code-text);
    padding: 0.1em 0.45em;
    border-radius: 4px;
    font-size: 0.83em;
    letter-spacing: -0.01em;
}

/* Code blocks */
.preview-content pre {
    background: var(--preview-pre-bg);
    color: var(--preview-pre-text);
    border: 1px solid var(--preview-pre-border);
    border-radius: 8px;
    padding: 1.2em 1.5em;
    overflow-x: auto;
    white-space: pre;
    word-break: normal;
    word-wrap: normal;
    line-height: 1.65;
    margin: 1.8em 0;
    font-size: 0.84em;
}

.preview-content pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    font-size: 1em;
    border-radius: 0;
    letter-spacing: 0;
}

/* Blockquotes */
.preview-content blockquote {
    background: var(--preview-blockquote-bg);
    border-left: 3px solid var(--accent-color);
    margin: 2em 0;
    padding: 0.9em 1.5em;
    border-radius: 0 6px 6px 0;
    font-style: italic;
    color: var(--preview-blockquote-text);
}

.preview-content blockquote p { margin: 0; }
.preview-content blockquote p + p { margin-top: 0.7em; }

/* Lists */
.preview-content ul,
.preview-content ol {
    margin-bottom: 1.2em;
    padding-left: 1.9em;
}

.preview-content li {
    margin-bottom: 0.45em;
    line-height: 1.72;
}

.preview-content li > ul,
.preview-content li > ol {
    margin-top: 0.35em;
    margin-bottom: 0.35em;
}

/* Horizontal rules */
.preview-content hr {
    border: none;
    border-top: 1px solid var(--preview-hr);
    margin: 3em auto;
    width: 75%;
}

/* Tables */
.preview-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.6em 0;
    font-size: 0.92em;
}

.preview-content th {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 600;
    text-align: left;
    padding: 0.65em 1em;
    border-bottom: 2px solid var(--preview-hr);
    color: var(--preview-heading);
    letter-spacing: 0.01em;
}

.preview-content td {
    padding: 0.6em 1em;
    border-bottom: 1px solid var(--preview-hr);
}

.preview-content tr:last-child td { border-bottom: none; }

.preview-content tr:hover td { background: var(--preview-blockquote-bg); }

/* Images */
.preview-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    border: 1px solid var(--preview-img-border);
    margin: 1.4em 1em 1.4em 0;
    box-shadow: 0 3px 14px var(--preview-img-shadow);
    cursor: pointer;
    display: block;
    transition: box-shadow 0.2s, transform 0.2s;
}

.preview-content img:hover {
    box-shadow: 0 5px 22px var(--preview-img-shadow-hover);
    transform: translateY(-2px);
}

/* Figure styles */
.preview-content .figure {
    border: 1px solid var(--preview-img-border);
    border-radius: 8px;
    padding: 5px;
    margin: 1.6em 1em 1.6em 0;
    box-shadow: 0 3px 14px var(--preview-img-shadow);
    max-width: 100%;
    display: inline-block;
    vertical-align: top;
}

.preview-content .figure.align-left { float: left; }
.preview-content .figure.align-right { float: right; margin: 1.6em 0 1.6em 1em; }
.preview-content .figure.align-center {
    display: block;
    float: none;
    margin-left: auto !important;
    margin-right: auto !important;
}

.preview-content .figure img {
    border: none;
    border-radius: 4px;
    margin: 0;
    padding: 0;
    box-shadow: none;
    display: block;
    transform: none;
}

.preview-content .figure img:hover {
    transform: none;
    box-shadow: none;
}

.preview-content .figure .caption {
    margin: 0;
    padding: 6px 4px 2px;
    font-size: 0.78em;
    color: var(--preview-caption);
    font-style: italic;
    text-align: center;
    font-family: 'Lora', Georgia, serif;
    letter-spacing: 0.01em;
}

.preview-content img.align-left { float: left; }
.preview-content img.align-right { float: right; margin: 1.4em 0 1.4em 1em; }
.preview-content .align-center {
    display: block;
    float: none;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    color: var(--text-muted);
    text-align: center;
    padding: 32px;
}

.preview-panel > .empty-state {
    height: 100%;
}

.empty-state p { margin-bottom: 16px; }

/* ── Upload progress ─────────────────────────────────────────────────────── */

.upload-progress {
    margin-top: 8px;
    font-size: 12px;
    color: var(--link-color);
}

/* ── Context Menu ────────────────────────────────────────────────────────── */

.context-menu {
    display: none;
    position: fixed;
    background: var(--panel-bg);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    min-width: 120px;
    padding: 4px 0;
}

.context-menu.active { display: block; }

.context-menu-item {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-color);
}

.context-menu-item:hover {
    background: var(--accent-color);
    color: white;
}

/* ── Modals ──────────────────────────────────────────────────────────────── */

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--panel-bg);
    border-radius: 8px;
    border: 4px solid var(--border-color);
    padding: 24px;
    width: 480px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal h2 {
    margin-bottom: 16px;
    color: var(--accent-color);
}

.modal-preview {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 4px;
    margin-bottom: 16px;
    background: var(--surface-bg);
    border: 1px solid var(--input-border);
}

.modal-field { margin-bottom: 16px; }

.modal-field label {
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
    color: var(--text-color);
}

.modal-field input[type="text"],
.modal-field input[type="number"] {
    width: 100%;
    padding: 8px 12px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    color: var(--text-color);
    font-size: 14px;
}

.modal-field input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.radio-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.width-field {
    display: flex;
    gap: 12px;
    align-items: center;
}

.width-toggle {
    display: flex;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    overflow: hidden;
}

.width-toggle button {
    padding: 8px 16px;
    border: none;
    background: var(--input-bg);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.width-toggle button.active {
    background: var(--accent-color);
    color: white;
}

.width-toggle button:hover:not(.active) { background: var(--surface-bg); }

.width-input-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
}

.width-input-wrapper input { width: 80px; }
.width-input-wrapper input:disabled { background: var(--surface-bg); color: var(--text-muted); }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

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

.btn-secondary:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: transparent;
}

/* ── Rename Modal specifics ──────────────────────────────────────────────── */

.current-filename {
    padding: 8px 12px;
    background: var(--surface-bg);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    font-family: "JetBrains Mono", "Fira Code", monospace;
    font-size: 13px;
    color: var(--text-muted);
}

.rename-input-wrapper {
    display: flex;
    align-items: center;
}

.rename-input-wrapper input {
    flex: 1;
    padding: 8px 12px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 4px 0 0 4px;
    color: var(--text-color);
    font-size: 14px;
    font-family: "JetBrains Mono", "Fira Code", monospace;
}

.rename-input-wrapper input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.rename-extension {
    padding: 8px 12px;
    background: var(--surface-bg);
    border: 1px solid var(--input-border);
    border-left: none;
    border-radius: 0 4px 4px 0;
    font-family: "JetBrains Mono", "Fira Code", monospace;
    font-size: 14px;
    color: var(--text-muted);
}

.affected-posts {
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background: var(--surface-bg);
}

.affected-posts .loading,
.affected-posts .no-refs {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.affected-post-item {
    padding: 8px 12px;
    border-bottom: 1px solid var(--input-border);
    font-size: 13px;
}

.affected-post-item:last-child { border-bottom: none; }

.affected-post-item .post-title { color: var(--text-color); }
.affected-post-item .ref-count { color: var(--text-muted); font-size: 12px; margin-left: 8px; }

/* ── Server Down Modal ───────────────────────────────────────────────────── */

.server-down-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.server-down-overlay.hidden {
    display: none;
}

.server-down-modal {
    background: var(--panel-bg);
    border: 4px solid var(--border-color);
    border-radius: 8px;
    padding: 28px 32px;
    width: 480px;
    max-width: 90vw;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
    color: var(--text-color);
}

.server-down-modal h2 {
    margin-bottom: 14px;
    color: var(--accent-color);
    font-size: 18px;
}

.server-down-modal p {
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-color);
}

.server-down-modal pre {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    padding: 10px 14px;
    font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
    font-size: 13px;
    color: var(--accent-color);
    margin-bottom: 20px;
    white-space: pre-wrap;
    word-break: break-all;
}

.server-down-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.server-down-actions button {
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid var(--input-border);
    background: transparent;
    color: var(--text-color);
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.server-down-actions button:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.server-down-actions button.primary {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.server-down-actions button.primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: white;
}
