/* ===== Base & Reset ===== */
:root {
    --primary: #1a1a2e;
    --primary-light: #16213e;
    --accent: #e94560;
    --accent-hover: #d63851;
    --bg: #f5f5f7;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-elevated: #f1f3f5;
    --text: #2d2d2d;
    --text-light: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --border-focus: #e94560;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.2s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

#app { display: flex; flex-direction: column; min-height: 100vh; }

/* ===== Header ===== */
.header {
    background: var(--primary);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 6px;
    font-weight: 700;
    font-size: 18px;
}

.logo-text {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.nav { display: flex; gap: 8px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border-radius: 6px;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
    text-decoration: none;
}

.nav-link:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-link.active { background: rgba(233,69,96,0.2); color: var(--accent); }

/* ===== Main ===== */
.main { flex: 1; max-width: 1200px; margin: 0 auto; padding: 24px; width: 100%; }

.page { display: none; }
.page.active { display: block; }

/* ===== Home Layout ===== */
.home-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 24px;
    align-items: start;
}

@media (max-width: 768px) {
    .home-layout { grid-template-columns: 1fr; }
    .sidebar { order: -1; }
}

/* ===== Filter Bar ===== */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.search-box {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    transition: var(--transition);
}

.search-box:focus-within { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(233,69,96,0.1); }

.search-box svg { color: var(--text-muted); margin-right: 8px; }

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    background: transparent;
    color: var(--text);
}

.search-box input::placeholder { color: var(--text-muted); }

.sort-select select {
    appearance: none;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 32px 9px 12px;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    outline: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

/* ===== Article Card ===== */
.article-list { display: flex; flex-direction: column; gap: 16px; }

.article-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--border);
    position: relative;
}

.article-card:hover {
    box-shadow: var(--shadow-md);
    border-color: transparent;
    transform: translateY(-2px);
}

.article-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.article-card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
    flex: 1;
}

.article-card-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.article-card-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.article-card-excerpt {
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-card-tags {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.tag {
    display: inline-block;
    padding: 3px 10px;
    font-size: 12px;
    background: rgba(233,69,96,0.08);
    color: var(--accent);
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
}

.tag:hover { background: rgba(233,69,96,0.15); }

/* ===== Pagination ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
    padding-bottom: 24px;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn.disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Sidebar ===== */
.sidebar-card {
    background: var(--bg-sidebar);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    border: 1px solid var(--border);
    margin-bottom: 16px;
}

.sidebar-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.sidebar-desc {
    font-size: 13px;
    color: var(--text-light);
    line-height: 1.7;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-item {
    text-align: center;
    padding: 8px;
}

.stat-num {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    display: block;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
}

.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }

/* ===== Article Detail ===== */
.detail-container {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

/* Detail page: full-width background with breathing room */
#page-detail {
    padding: 24px 16px;
    min-height: calc(100vh - 120px);
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-light);
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 20px;
    transition: var(--transition);
}

.back-btn:hover { border-color: var(--accent); color: var(--accent); }

.article-detail {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 36px 40px;
    border: 1px solid var(--border);
}

.article-detail-title {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.35;
    margin-bottom: 16px;
    color: var(--text);
}

.article-detail-meta {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.article-detail-content {
    font-size: 16px;
    line-height: 1.85;
    color: var(--text);
    max-width: 720px;
}

.article-detail-content h1 { font-size: 24px; font-weight: 700; margin: 24px 0 12px; }
.article-detail-content h2 { font-size: 20px; font-weight: 600; margin: 20px 0 10px; }
.article-detail-content h3 { font-size: 18px; font-weight: 600; margin: 16px 0 8px; }
.article-detail-content p { margin: 12px 0; }
.article-detail-content ul, .article-detail-content ol { margin: 12px 0; padding-left: 24px; }
.article-detail-content li { margin: 4px 0; }
.article-detail-content code {
    background: #f1f3f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
    font-family: "Fira Code", "Consolas", monospace;
}
.article-detail-content pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 16px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 16px 0;
}
.article-detail-content pre code { background: none; padding: 0; color: inherit; }
.article-detail-content blockquote {
    border-left: 4px solid var(--accent);
    padding: 12px 16px;
    margin: 16px 0;
    background: rgba(233,69,96,0.04);
    color: var(--text-light);
}
.article-detail-content img { max-width: 100%; border-radius: var(--radius); margin: 12px 0; }
.article-detail-content a { color: var(--accent); text-decoration: underline; }
.article-detail-content table { border-collapse: collapse; width: 100%; margin: 16px 0; }
.article-detail-content th, .article-detail-content td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
}
.article-detail-content th { background: #f9fafb; font-weight: 600; }

.article-detail-tags {
    display: flex;
    gap: 6px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ===== Share Bar ===== */
.share-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px dashed var(--border);
    flex-wrap: wrap;
}

.share-bar-label {
    font-size: 14px;
    color: var(--text-muted);
}

.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.share-btn:hover {
    background: var(--accent-hover, #d63a52);
    transform: translateY(-1px);
}

/* ===== Share Sheet (custom fallback) ===== */
.share-sheet-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
    z-index: 9998;
}

.share-sheet-mask.show {
    opacity: 1;
    visibility: visible;
}

.share-sheet {
    background: #fff;
    width: 100%;
    max-width: 460px;
    border-radius: 16px 16px 0 0;
    padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.25s ease;
}

.share-sheet-mask.show .share-sheet {
    transform: translateY(0);
}

.share-sheet-title {
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 20px;
}

.share-sheet-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: space-around;
}

.share-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 72px;
    cursor: pointer;
    font-size: 13px;
    color: #4b5563;
}

.share-item:hover { opacity: 0.8; }

.share-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
}

.share-sheet-cancel {
    width: 100%;
    margin-top: 22px;
    padding: 12px;
    background: #f3f4f6;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    color: #374151;
    cursor: pointer;
}

.share-sheet-cancel:hover { background: #e5e7eb; }

/* WeChat QR modal (centered) */
.share-sheet-mask .wechat-qr {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    max-width: 320px;
    text-align: center;
}

.wechat-qr img {
    width: 220px;
    height: 220px;
    border-radius: 8px;
    margin: 8px 0 12px;
}

@media (min-width: 600px) {
    .share-sheet-mask { align-items: center; }
    .share-sheet { border-radius: 16px; }
}

/* ===== Back Button ===== */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-light);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 20px;
}

.back-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(233,69,96,0.04);
}

/* ===== Publish Page ===== */
.publish-container { max-width: 800px; }

.publish-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.publish-note {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 24px;
    padding: 8px 14px;
    background: rgba(233,69,96,0.05);
    border-left: 3px solid var(--accent);
    border-radius: 4px;
}

.publish-form { display: flex; flex-direction: column; gap: 20px; }

.form-group { display: flex; flex-direction: column; gap: 8px; }

.form-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.markdown-hint { font-size: 12px; color: var(--text-muted); font-weight: 400; }

.form-input {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    outline: none;
    transition: var(--transition);
    background: var(--bg-card);
}

.form-input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(233,69,96,0.1); }

.form-group-editor { position: relative; }

/* ===== Markdown Toolbar ===== */
.md-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 8px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
}

.md-btn {
    min-width: 32px;
    height: 30px;
    padding: 0 8px;
    font-size: 13px;
    color: var(--text-light);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
}

.md-btn:hover {
    background: rgba(233,69,96,0.1);
    color: var(--accent);
    border-color: rgba(233,69,96,0.25);
}

.md-btn:active { transform: scale(0.94); }

.md-btn-right { margin-left: auto; }

.md-sep {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
}

/* ===== Editor Layout (side-by-side) ===== */
.editor-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden;
    background: var(--bg-card);
}

.form-editor {
    padding: 16px;
    border: none;
    border-right: 1px solid var(--border);
    border-radius: 0;
    font-size: 14px;
    line-height: 1.7;
    outline: none;
    resize: none;
    min-height: 420px;
    height: 420px;
    transition: var(--transition);
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    background: var(--bg-card);
    color: var(--text);
}

.form-editor:focus { box-shadow: none; }

.editor-preview {
    padding: 16px 20px;
    min-height: 420px;
    height: 420px;
    overflow-y: auto;
    background: var(--bg-card);
    line-height: 1.8;
    border-left: 1px solid var(--border);
}

.editor-preview .preview-empty {
    color: var(--text-muted);
    font-style: italic;
}

.editor-preview h1, .editor-preview h2, .editor-preview h3,
.editor-preview h4, .editor-preview h5, .editor-preview h6 { margin: 16px 0 10px; line-height: 1.3; }
.editor-preview h1 { font-size: 1.8em; border-bottom: 2px solid var(--border); padding-bottom: 8px; }
.editor-preview h2 { font-size: 1.5em; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.editor-preview h3 { font-size: 1.25em; }
.editor-preview p { margin: 10px 0; }
.editor-preview a { color: var(--accent); text-decoration: underline; }
.editor-preview ul, .editor-preview ol { padding-left: 24px; margin: 10px 0; }
.editor-preview li { margin: 4px 0; }
.editor-preview code { background: #f1f3f5; padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }
.editor-preview pre { background: #1e1e2e; color: #cdd6f4; padding: 16px; border-radius: var(--radius); overflow-x: auto; margin: 12px 0; }
.editor-preview pre code { background: none; padding: 0; color: inherit; }
.editor-preview blockquote { border-left: 4px solid var(--accent); padding: 8px 14px; margin: 12px 0; background: rgba(233,69,96,0.04); color: var(--text-light); }
.editor-preview img { max-width: 100%; border-radius: var(--radius); margin: 8px 0; }
.editor-preview table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.editor-preview th, .editor-preview td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.editor-preview th { background: var(--bg-elevated); }
.editor-preview hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.editor-stat { font-variant-numeric: tabular-nums; }

/* ===== Fullscreen mode (whole publish form) ===== */
/* Fullscreen top bar: hidden in normal mode, shown when fullscreen */
.fs-bar { display: none; }

.publish-container.editor-fullscreen {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    max-width: none;
    z-index: 10000;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    padding: 16px 32px 20px;
    margin: 0;
    overflow: hidden;
}

.publish-container.editor-fullscreen .fs-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.fs-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-light);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 14px;
    cursor: pointer;
    transition: var(--transition);
}

.fs-back:hover { color: var(--accent); border-color: var(--accent); }

.fs-title { font-size: 16px; font-weight: 700; color: var(--text); }

.fs-actions { margin-left: auto; display: flex; gap: 10px; }

/* In fullscreen, the big title/note are replaced by the compact fs-bar */
.publish-container.editor-fullscreen .publish-title,
.publish-container.editor-fullscreen .publish-note {
    display: none;
}

.publish-container.editor-fullscreen .publish-form {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Keep title/author/tags at natural height; let editor take the rest */
.publish-container.editor-fullscreen .form-group:not(.form-group-editor) {
    flex-shrink: 0;
}

.publish-container.editor-fullscreen .form-group-editor {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Critical fix: give the grid a definite row height so children can fill it */
.publish-container.editor-fullscreen .editor-wrap {
    flex: 1;
    min-height: 0;
    height: auto;
    grid-template-rows: minmax(0, 1fr);
}

.publish-container.editor-fullscreen .form-editor,
.publish-container.editor-fullscreen .editor-preview {
    height: 100%;
    min-height: 0;
}

/* hide the bottom action row in fullscreen (moved into fs-bar) */
.publish-container.editor-fullscreen .form-actions {
    display: none;
}

.no-scroll { overflow: hidden; }

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

.btn {
    padding: 10px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

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

.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-light);
    border: 1px solid var(--border);
}

.btn-secondary:hover { border-color: var(--text-light); color: var(--text); }

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 70px;
    right: 24px;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    color: #fff;
    z-index: 200;
    transform: translateX(calc(100% + 24px));
    transition: transform 0.3s ease;
    max-width: 360px;
}

.toast.show { transform: translateX(0); }
.toast.success { background: #10b981; }
.toast.error { background: #ef4444; }
.toast.info { background: #3b82f6; }

/* ===== Loading ===== */
.loading-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg { margin-bottom: 16px; opacity: 0.4; }
.empty-state p { font-size: 15px; margin-bottom: 8px; }
.empty-state .hint { font-size: 13px; }

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 20px;
    font-size: 13px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* ===== Bottom Tab Bar (mobile only) ===== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 54px;
    background: #fff;
    border-top: 1px solid var(--border);
    z-index: 999;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 60px;
    min-height: 44px;
    padding: 4px 12px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    font-size: 11px;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item svg { display: block; }

.bottom-nav-item.active {
    color: var(--accent);
}

.bottom-nav-item:active {
    opacity: 0.6;
}

/* ===== Mobile Editor Tabs ===== */
.editor-tabs {
    display: none;
}

/* Mobile: editor tabs visible + wrap goes stacked */
@media (max-width: 480px) {
    .editor-tabs {
        display: flex;
        border-bottom: 1px solid var(--border);
        background: var(--bg-elevated);
    }

    .editor-tab {
        flex: 1;
        text-align: center;
        padding: 10px 0;
        font-size: 14px;
        font-weight: 500;
        color: var(--text-muted);
        cursor: pointer;
        transition: var(--transition);
        -webkit-tap-highlight-color: transparent;
        position: relative;
        user-select: none;
    }

    .editor-tab.active {
        color: var(--accent);
    }

    .editor-tab.active::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 20%;
        right: 20%;
        height: 2px;
        background: var(--accent);
        border-radius: 1px;
    }

    .editor-tab:active {
        background: rgba(233,69,96,0.06);
    }

    .editor-wrap {
        grid-template-columns: 1fr;
    }

    .editor-wrap .form-editor {
        border-right: none;
        min-height: 300px;
        height: 350px;
    }

    .editor-wrap .editor-preview {
        display: none;
        border-left: none;
        min-height: 300px;
        height: 350px;
    }

    .editor-wrap.preview-mode .form-editor {
        display: none;
    }

    .editor-wrap.preview-mode .editor-preview {
        display: block;
    }
}

/* ===== Mobile toggle for main bottom padding ===== */

/* ===== Mobile Layout Overrides (< 480px) ===== */
@media (max-width: 480px) {
    /* --- Header: compact --- */
    .header-inner {
        padding: 0 12px;
        height: 48px;
    }
    .logo-text { font-size: 17px; }
    .logo-icon { width: 28px; height: 28px; font-size: 15px; }
    .nav { display: none; }  /* moved to bottom-nav */

    /* --- Main: leave room for bottom bar --- */
    .main { padding: 12px 12px 64px; }

    /* --- Bottom nav: show --- */
    .bottom-nav { display: flex; }

    /* --- Filter bar: compact inline --- */
    .filter-bar {
        flex-direction: row;
        gap: 8px;
        margin-bottom: 12px;
    }
    .search-box { padding: 6px 10px; }
    .search-box input { font-size: 13px; }
    .sort-select select { font-size: 13px; padding: 7px 28px 7px 10px; }

    /* --- Cards: compact --- */
    .article-card { padding: 12px 14px; }
    .article-card-header { gap: 8px; margin-bottom: 6px; }
    .article-card-title { font-size: 15px; }
    .article-card-meta { font-size: 12px; gap: 10px; margin-bottom: 4px; }
    .article-card-excerpt { font-size: 13px; -webkit-line-clamp: 2; }
    .article-card-tags { margin-top: 6px; }
    .tag { font-size: 11px; padding: 2px 8px; }

    /* --- Pagination: bigger touch targets --- */
    .page-btn {
        min-width: 44px;
        height: 44px;
        font-size: 15px;
    }

    /* --- Sidebar: hide on mobile --- */
    .sidebar { display: none; }
    .home-layout { grid-template-columns: 1fr; }

    /* --- Detail page: reading mode --- */
    #page-detail { padding: 12px 8px 64px; }
    .article-detail { padding: 16px; }
    .article-detail-title { font-size: 20px; }
    .article-detail-content { font-size: 16px; line-height: 1.9; max-width: 100%; }
    .article-detail-content pre { font-size: 13px; padding: 12px; }
    .article-detail-meta { gap: 12px; font-size: 13px; flex-wrap: wrap; }
    .detail-container { margin: 0; }
    .back-btn { padding: 10px 14px; margin-bottom: 12px; }
    .share-btn { padding: 10px 18px; }
    .share-bar { margin-top: 20px; padding-top: 14px; }

    /* --- Publish page: mobile --- */
    .publish-container { max-width: 100%; }
    .publish-title { font-size: 18px; }
    .publish-note { font-size: 12px; margin-bottom: 16px; }

    /* --- Form elements: touch friendly --- */
    .form-input { padding: 12px 14px; font-size: 15px; }
    .btn { padding: 12px 20px; font-size: 15px; min-height: 44px; }
    .form-actions { gap: 10px; }

    /* --- Editor tool bar: compact --- */
    .md-toolbar { gap: 2px; padding: 6px 8px; }
    .md-btn { min-width: 30px; height: 32px; font-size: 12px; padding: 0 6px; }

    /* --- Footer: account for bottom bar --- */
    .footer { padding: 12px 16px 64px; font-size: 12px; }

    /* --- Toast: adjust position --- */
    .toast { top: 56px; right: 12px; left: 12px; max-width: none; font-size: 14px; }
}

/* ===== Tablet Layout (480-768px) ===== */
@media (min-width: 481px) and (max-width: 768px) {
    .header-inner { padding: 0 20px; }
    .main { padding: 16px 20px; }
    .bottom-nav { display: none; }
    .article-card { padding: 16px 20px; }
    .article-detail { padding: 24px; }
    .article-detail-title { font-size: 24px; }
    .article-detail-content { max-width: 100%; font-size: 16px; }
    .detail-container { margin: 0; }
    .filter-bar { flex-direction: column; }
    .form-actions { flex-direction: column; }
    .home-layout { grid-template-columns: 1fr; }
    .sidebar { order: -1; }
    .tag { font-size: 12px; padding: 3px 10px; }
}

/* ===== Desktop (> 768px) ===== */
@media (min-width: 769px) {
    .bottom-nav { display: none; }
}

/* ===== Safe Area padding for notched phones ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .bottom-nav { padding-bottom: env(safe-area-inset-bottom); }
    .share-sheet { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}
