/* ── Editor Page Layout ── */

.editor-page { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

/* ── Top Bar ── */
.editor-topbar {
    height: var(--topbar-height); background: rgba(255,255,255,.78); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border); display: flex; align-items: center;
    padding: 0 16px; gap: 8px; z-index: 200; flex-shrink: 0;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 4px; }
.topbar-center { flex: 1; display: flex; justify-content: center; }
.topbar-sep { width: 1px; height: 24px; background: var(--border); margin: 0 8px; }

.topbar-brand {
    display: flex; align-items: center; gap: 6px; color: var(--fg); text-decoration: none;
    margin-right: 8px;
}
.topbar-brand .brand-logo { font-size: 20px; color: var(--accent); }
.topbar-brand .brand-name { font-family: var(--font-serif); font-size: 16px; font-weight: 700; }

.export-group { display: flex; align-items: center; gap: 2px; }

.topbar-btn {
    display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px;
    background: transparent; border: none; border-radius: var(--radius-sm);
    font-size: 13px; font-family: inherit; color: var(--fg-muted); cursor: pointer;
    transition: all var(--transition-fast);
}
.topbar-btn:hover { background: var(--accent-soft); color: var(--accent); }
.topbar-btn-text { font-weight: 500; }
.topbar-btn-accent { color: var(--accent); font-weight: 600; }

.topbar-style-btn { padding: 6px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-full); color: var(--fg); }
.topbar-style-btn:hover { border-color: var(--accent); background: var(--accent-soft); }

.login-hint-tag {
    font-size: 10px; font-weight: 600; color: var(--accent); background: var(--accent-soft);
    padding: 1px 6px; border-radius: var(--radius-full);
}

/* ── Doc Title ── */
.topbar-filename {
    font-size: 14px; font-weight: 500; color: var(--fg); cursor: pointer;
    padding: 4px 12px; border-radius: var(--radius-sm); transition: background var(--transition-fast);
    max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    border: 1.5px solid transparent; display: inline-flex; align-items: center; gap: 6px;
}
.topbar-filename .ph-pencil-simple {
    font-size: 12px; color: var(--fg-muted); opacity: .5; transition: opacity var(--transition-fast); flex-shrink: 0;
}
.topbar-filename:hover .ph-pencil-simple { opacity: 1; }
.topbar-filename:hover { background: var(--accent-soft); border-color: rgba(99,102,241,.15); }
.topbar-filename-input {
    font-size: 14px; font-weight: 500; font-family: inherit; color: var(--fg);
    padding: 4px 12px; border-radius: var(--radius-sm);
    max-width: 220px; outline: none;
    border: 1.5px solid var(--accent); background: var(--bg-card);
    box-shadow: 0 0 0 3px rgba(99,102,241,.12);
    text-align: center; display: none;
}
.topbar-center-right { display: flex; align-items: center; gap: 4px; }
.style-label { font-size: 12px; color: var(--fg-muted); margin-right: 2px; }

/* ── User Dropdown ── */
.topbar-user {
    position: relative; display: flex; align-items: center; gap: 8px; cursor: pointer;
    padding: 4px 8px; border-radius: var(--radius-sm);
}
.topbar-user:hover { background: var(--accent-soft); }
.user-avatar {
    width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600;
}
.user-name { font-size: 13px; font-weight: 500; color: var(--fg); }
.user-dropdown {
    display: none; position: absolute; top: 100%; right: 0; margin-top: 8px;
    background: var(--bg-card); border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
    min-width: 160px; padding: 6px; z-index: 300; border: 1px solid var(--border);
}
.topbar-user:hover .user-dropdown { display: block; }
.user-dropdown a, .user-dropdown button {
    display: block; width: 100%; padding: 8px 12px; font-size: 13px; color: var(--fg);
    text-decoration: none; background: none; border: none; text-align: left;
    font-family: inherit; cursor: pointer; border-radius: var(--radius-sm);
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--accent-soft); color: var(--accent); }

/* ── Workspace ── */
.editor-workspace {
    flex: 1; display: flex; overflow: hidden;
}

/* ── Editor Pane ── */
.editor-pane {
    width: 50%; display: flex; flex-direction: column; background: var(--bg-dark);
    min-width: 280px;
}

/* ── Toolbar ── */
.editor-toolbar {
    display: flex; align-items: center; gap: 2px; padding: 6px 12px;
    background: var(--bg-darker); border-bottom: 1px solid var(--border-on-dark);
    flex-shrink: 0; flex-wrap: wrap;
}
.editor-toolbar button {
    padding: 5px 8px; background: transparent; border: none; border-radius: var(--radius-sm);
    color: var(--fg-on-dark); font-size: 14px; font-family: var(--font-sans); font-weight: 600;
    cursor: pointer; transition: all var(--transition-fast);
}
.editor-toolbar button:hover { background: rgba(255,255,255,.08); color: #fff; }
.toolbar-sep { width: 1px; height: 18px; background: var(--border-on-dark); margin: 0 4px; }

/* ── Editor Content ── */
.editor-content { flex: 1; overflow: auto; position: relative; }

#editor {
    width: 100%; min-height: 100%; padding: 20px 24px; background: var(--bg-dark);
    color: #e0e0ee; font-family: var(--font-mono); font-size: 14px; line-height: 1.7;
    border: none; outline: none; resize: none; tab-size: 4;
}
#editor::placeholder { color: rgba(255,255,255,.25); }

/* ── Divider ── */
.editor-divider {
    width: 5px; cursor: col-resize; background: var(--border);
    transition: background var(--transition-fast); flex-shrink: 0; position: relative;
}
.editor-divider:hover, .editor-divider.dragging { background: var(--accent); }
.editor-divider::after {
    content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 3px; height: 32px; border-radius: 2px; background: rgba(255,255,255,.2);
}

/* ── Preview Pane ── */
.preview-pane {
    width: 50%; overflow-y: auto; min-width: 280px;
    background: #fff;
}
.preview-pane:has(.markdown-body[style*="background"]) {
    background: inherit;
}
.preview-content {
    min-height: 100%;
}
.preview-content .markdown-body {
    padding: 40px 48px;
    min-height: 100%;
}

/* ── Status Bar ── */
.editor-statusbar {
    height: var(--statusbar-height); background: var(--bg-card); border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
    font-size: 12px; color: var(--fg-muted); flex-shrink: 0;
}
.statusbar-left { display: flex; align-items: center; gap: 10px; }
.statusbar-right { display: flex; align-items: center; gap: 6px; }
.statusbar-brand { font-weight: 400; color: #9d9fb2; }
.statusbar-sep { color: #b0b2c0; font-size: 11px; }
.statusbar-org { color: #9d9fb2; text-decoration: none; cursor: default; }
.statusbar-org:hover { color: #9d9fb2; }

/* ── Style Panel ── */
.style-panel {
    position: fixed; top: var(--topbar-height); left: 0; right: 0; z-index: 180;
    background: var(--bg-card); border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg); padding: 20px 24px;
    transform: translateY(-100%); opacity: 0; transition: all .3s ease;
    max-height: 420px; overflow-y: auto;
}
.style-panel.open { transform: translateY(0); opacity: 1; }
.style-panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.style-panel-header h3 { font-size: 16px; font-weight: 600; }
.style-panel-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--fg-muted); padding: 4px; }

.style-panel-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px;
}
.style-card {
    cursor: pointer; text-align: center; padding: 8px; border-radius: var(--radius-md);
    border: 2px solid transparent; transition: all var(--transition-fast);
}
.style-card:hover { border-color: var(--accent); box-shadow: var(--shadow-glow); }
.style-card.active { border-color: var(--accent); background: var(--accent-soft); }
.style-card-img {
    width: 100%; aspect-ratio: 4/3; border-radius: var(--radius-sm);
    background: var(--bg); display: flex; align-items: center; justify-content: center;
    font-size: 24px; margin-bottom: 6px; overflow: hidden;
}
.style-card-img img { width: 100%; height: 100%; object-fit: cover; }
.style-card-name { font-size: 12px; font-weight: 500; color: var(--fg); }

.style-panel-custom { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

.style-panel-overlay {
    position: fixed; inset: 0; z-index: 170; background: rgba(0,0,0,.2);
    display: none;
}
.style-panel-overlay.open { display: block; }

/* ── Login Prompt Overlay ── */
.login-prompt-overlay {
    position: fixed; inset: 0; z-index: 500; background: rgba(0,0,0,.4);
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.login-prompt-card {
    background: var(--bg-card); border-radius: var(--radius-lg); padding: 40px;
    width: 360px; text-align: center; box-shadow: var(--shadow-lg);
}
.login-prompt-card .brand-logo-lg { font-size: 36px; margin-bottom: 16px; }
.login-prompt-card h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.login-prompt-card p { font-size: 14px; color: var(--fg-muted); margin-bottom: 20px; }
.login-prompt-skip {
    display: block; margin-top: 12px; background: none; border: none;
    font-size: 13px; color: var(--fg-muted); cursor: pointer; font-family: inherit;
    padding: 4px 8px;
}
.login-prompt-skip:hover { color: var(--fg); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.25); }
.editor-pane::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); }
.editor-pane::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }
