/* ==========================================================
   全局 :root 主题变量 - GitHub Primer 浅色风格
   适用于 Typecho 后台所有页面（被 admin/header.php 全局引入）
   ========================================================== */
:root {
    --bg: #f6f8fa;
    --card: #ffffff;
    --border: #d0d7de;
    --border-light: #d8dee4;
    --text: #1f2328;
    --text-2: #59636e;
    --text-3: #8c959f;
    --primary: #0969da;
    --primary-hover: #0860c7;
    --primary-soft: #ddf4ff;
    --primary-border: #54aeff;
    --success: #1a7f37;
    --success-soft: #dafbe1;
    --warning: #9a6700;
    --warning-soft: #fff8c5;
    --danger: #d1242f;
    --danger-soft: #ffebe9;
    --info: #9a68c4;
    --info-soft: #fbefff;
}

/* ==========================================================
   顶部导航栏 + 页面 H2 标题按钮 - GitHub 浅色风格
   (覆盖 style.css 默认深色工具栏与 .primary 蓝色按钮)
   ========================================================== */

/* ===== 顶部导航栏 ===== */
.typecho-head-nav {
    background: var(--card) !important;
    border-bottom: 1px solid var(--border) !important;
    padding: 0 16px !important;
    height: 48px;
    box-shadow: none !important;
    position: relative;
    z-index: 20;
}
.typecho-head-nav a,
.typecho-head-nav button.menu-bar {
    color: var(--text-2) !important;
    height: 48px !important;
    line-height: 48px !important;
    padding: 0 16px !important;
    transition: color 0.1s, background 0.1s;
    font-size: 13.5px;
    border: none !important;
    background: transparent !important;
}
.typecho-head-nav a:hover,
.typecho-head-nav a:focus,
.typecho-head-nav button.menu-bar:hover,
.typecho-head-nav button.menu-bar:focus {
    color: var(--text) !important;
    background: var(--bg) !important;
    text-decoration: none !important;
}
.typecho-head-nav button.menu-bar { display: none; }

.typecho-head-nav #typecho-nav-list {
    float: left;
    display: flex;
    align-items: stretch;
    height: 48px;
}
.typecho-head-nav #typecho-nav-list > ul {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative;
    float: none !important;
    display: flex;
    align-items: stretch;
    border: none !important;
}
.typecho-head-nav #typecho-nav-list > ul:first-child { border-left: none !important; }
.typecho-head-nav #typecho-nav-list > ul .parent a {
    display: inline-flex !important;
    align-items: center;
    border-right: none !important;
    background: transparent !important;
    color: var(--text-2) !important;
    font-weight: 500;
    position: relative;
}
.typecho-head-nav #typecho-nav-list > ul .parent a::after {
    content: "";
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 0;
    height: 2px;
    background: transparent;
    transition: background 0.12s;
}
.typecho-head-nav #typecho-nav-list > ul .parent a:hover,
.typecho-head-nav #typecho-nav-list > ul .parent a:focus {
    color: var(--text) !important;
    background: var(--bg) !important;
}
.typecho-head-nav #typecho-nav-list > ul .child {
    position: absolute !important;
    list-style: none !important;
    top: 48px !important;
    display: none;
    margin: 0 !important;
    padding: 6px !important;
    min-width: 180px;
    max-width: 260px;
    background: var(--card) !important;
    border: 1px solid var(--border) !important;
    border-radius: 6px !important;
    box-shadow: none !important;
    z-index: 250;
}
.typecho-head-nav #typecho-nav-list > ul .child li.return { display: none; }
.typecho-head-nav #typecho-nav-list > ul .child li a {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block !important;
    padding: 6px 12px !important;
    border-radius: 6px;
    color: var(--text-2) !important;
    height: auto !important;
    line-height: 1.5 !important;
    background: transparent !important;
    border: none !important;
    font-size: 13px;
}
.typecho-head-nav #typecho-nav-list > ul .child li a:hover,
.typecho-head-nav #typecho-nav-list > ul .child li a:focus {
    background: var(--bg) !important;
    color: var(--text) !important;
}
.typecho-head-nav #typecho-nav-list > ul .child li.focus a {
    color: var(--primary) !important;
    font-weight: 600;
    background: var(--primary-soft) !important;
}
.typecho-head-nav #typecho-nav-list > ul .parent a:hover,
.typecho-head-nav #typecho-nav-list > ul.focus .parent a,
.typecho-head-nav #typecho-nav-list > ul.root:hover .parent a {
    background: var(--bg) !important;
}
.typecho-head-nav #typecho-nav-list > ul.focus .parent a {
    font-weight: 600;
    color: var(--text) !important;
}
.typecho-head-nav #typecho-nav-list > ul.focus .parent a::after {
    background: var(--primary) !important;
}
.typecho-head-nav #typecho-nav-list > ul.root:hover .child,
.typecho-head-nav #typecho-nav-list > ul.root.expanded .child {
    display: block;
    animation: nav-fade-in 0.12s ease-out;
}
@keyframes nav-fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.typecho-head-nav .operate {
    float: right;
    display: flex;
    align-items: stretch;
    height: 48px;
    border: none !important;
}
.typecho-head-nav .operate a {
    display: inline-flex !important;
    align-items: center;
    margin-left: 0 !important;
    border: none !important;
    color: var(--text-2) !important;
    padding: 0 14px !important;
    font-size: 13px;
    background: transparent !important;
}
.typecho-head-nav .operate a:hover {
    background: var(--bg) !important;
    color: var(--text) !important;
}

/* ===== 页面顶部标题 H2 (含"撰写/新增"按钮) ===== */
.typecho-page-title {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    margin: 20px 0 18px !important;
    padding: 0 4px;
}
.typecho-page-title h2 {
    margin: 0 !important;
    font-size: 22px !important;
    font-weight: 700 !important;
    color: var(--text) !important;
    letter-spacing: -0.01em;
    line-height: 1.2;
    display: flex !important;
    align-items: center !important;
    flex-wrap: wrap;
    gap: 12px;
}
/* "撰写/新增" 主操作按钮 - GitHub 实心蓝 (撰写新文章、创建新页面、新增分类 等) */
.typecho-page-title h2 a {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    margin: 0 !important;
    padding: 5px 12px !important;
    background: var(--primary) !important;
    color: #fff !important;
    font-size: 12.5px !important;
    font-weight: 500 !important;
    border-radius: 6px !important;
    border: 1px solid var(--primary) !important;
    box-shadow: none !important;
    transition: background 0.12s, border-color 0.12s;
    text-decoration: none !important;
    line-height: 1.2;
}
.typecho-page-title h2 a::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'><path fill='%23ffffff' d='M256 80c0-17.7-14.3-32-32-32s-32 14.3-32 32V224H48c-17.7 0-32 14.3-32 32s14.3 32 32 32H192V432c0 17.7 14.3 32 32 32s32-14.3 32-32V288H400c17.7 0 32-14.3 32-32s-14.3-32-32-32H256V80z'/></svg>");
    background-size: contain;
    background-repeat: no-repeat;
}
.typecho-page-title h2 a:hover {
    background: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
    box-shadow: none !important;
    text-decoration: none !important;
}
.typecho-page-title h2 a:active {
    transform: translateY(1px);
    box-shadow: none !important;
}

/* ===== Typecho 原生 .primary 按钮(提交按钮等) - GitHub 实心蓝 ===== */
.primary,
button.primary,
a.primary,
.btn.primary,
.typecho-post-area .submit .right button,
.typecho-option-submit button[type="submit"] {
    background-color: var(--primary) !important;
    color: #fff !important;
    border: 1px solid var(--primary) !important;
    border-radius: 6px !important;
    box-shadow: none !important;
    transition: background 0.12s, border-color 0.12s;
}
.primary:hover,
button.primary:hover,
a.primary:hover,
.btn.primary:hover,
.typecho-post-area .submit .right button:hover,
.typecho-option-submit button[type="submit"]:hover {
    background-color: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
    box-shadow: none !important;
}
.primary:active,
button.primary:active,
a.primary:active,
.btn.primary:active,
.typecho-post-area .submit .right button:active,
.typecho-option-submit button[type="submit"]:active {
    background-color: var(--primary-hover) !important;
    box-shadow: none !important;
}

/* ===== Typecho 原生 .btn 通用按钮 - GitHub 风格 6px 圆角 ===== */
.btn,
#ui-datepicker-div .ui-datepicker-current,
#ui-datepicker-div .ui-datepicker-close {
    border: 1px solid var(--border) !important;
    background-color: var(--card) !important;
    cursor: pointer;
    border-radius: 6px !important;
    display: inline-block;
    padding: 0 12px;
    height: 32px;
    color: var(--text) !important;
    vertical-align: middle;
    zoom: 1;
    transition: background 0.12s, border-color 0.12s;
    box-shadow: none !important;
}
.btn:hover,
#ui-datepicker-div .ui-datepicker-current:hover,
#ui-datepicker-div .ui-datepicker-close:hover {
    background-color: var(--bg) !important;
    border-color: var(--border) !important;
    transition-duration: .12s;
}
.btn:active,
#ui-datepicker-div .ui-datepicker-current:active,
#ui-datepicker-div .ui-datepicker-close:active,
.btn.active,
#ui-datepicker-div .active.ui-datepicker-current,
#ui-datepicker-div .active.ui-datepicker-close {
    background-color: var(--border-light) !important;
    border-color: var(--border) !important;
}
.btn:disabled,
#ui-datepicker-div .ui-datepicker-current:disabled,
#ui-datepicker-div .ui-datepicker-close:disabled {
    background-color: var(--bg) !important;
    border-color: var(--border) !important;
    color: var(--text-3) !important;
    cursor: default;
}

/* ===== 主体背景轻微 GitHub 化 ===== */
body {
    background: var(--bg);
}

/* ===== 移动端适配 ===== */
/* 平板: 768px 及以下 */
@media (max-width: 768px) {
    /* Hero: 改为"卡片式"垂直布局 - 标题在上、按钮在下 */
    .typecho-page-title {
        margin: 12px 0 14px !important;
        padding: 14px 16px !important;
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: 6px;
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        gap: 10px;
        box-shadow: none !important;
    }
    .typecho-page-title h2 {
        font-size: 19px !important;
        gap: 10px !important;
        width: 100%;
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        line-height: 1.3;
    }
    .typecho-page-title h2 a {
        align-self: flex-start;
        padding: 6px 14px !important;
        font-size: 12.5px !important;
        height: auto;
        line-height: 1.3;
    }
    .typecho-page-title h2 a::before {
        width: 9px;
        height: 9px;
    }
    .typecho-head-nav {
        padding: 0 !important;
    }
    .typecho-head-nav > ul > li a {
        padding: 0 10px !important;
        font-size: 12px !important;
    }
    .typecho-head-nav .operate {
        padding-right: 8px !important;
        gap: 6px !important;
    }
    .typecho-head-nav .operate a {
        font-size: 12px !important;
    }
}

/* 手机: 575px 及以下 */
@media (max-width: 575px) {
    .typecho-page-title {
        margin: 8px 0 12px !important;
        padding: 12px 14px !important;
        border-radius: 6px;
    }
    .typecho-page-title h2 {
        font-size: 17px !important;
        gap: 10px !important;
        line-height: 1.3;
    }
    .typecho-page-title h2 a {
        padding: 5px 12px !important;
        font-size: 12px !important;
    }
    .typecho-page-title h2 a::before {
        width: 8px;
        height: 8px;
    }
    /* 底部固定导航 + 汉堡按钮 */
    .typecho-head-nav { padding: 0 !important; position: fixed; bottom: 0; width: 100%; z-index: 100; box-shadow: 0 -1px 0 var(--border) !important; }
    .typecho-head-nav #typecho-nav-list { display: none; }
    .typecho-head-nav button.menu-bar {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        border: none !important;
        background: transparent !important;
        border-right: 1px solid var(--border) !important;
        width: 48px;
        height: 48px;
        color: var(--text-2) !important;
        font-size: 16px !important;
    }
    .typecho-head-nav button.menu-bar.focus { color: var(--text) !important; }
    .typecho-head-nav button.menu-bar.focus + #typecho-nav-list { display: block; float: none; position: absolute; bottom: 48px; width: 100%; }
    .typecho-head-nav button.menu-bar.focus + #typecho-nav-list > ul { float: none; border-bottom: 1px solid var(--border); position: static; }
    .typecho-head-nav button.menu-bar.focus + #typecho-nav-list > ul:first-child { border-left: none; }
    /* 底部留出导航高度，避免内容被遮挡 */
    body { padding-bottom: 56px; }
    /* 顶部用户区 (右上角) 在手机上也变紧凑 */
    .typecho-head-nav .operate {
        padding-right: 6px !important;
        gap: 4px !important;
    }
    .typecho-head-nav .operate a {
        font-size: 11px !important;
    }
}

/* 小屏手机: 380px 及以下 */
@media (max-width: 380px) {
    .typecho-page-title {
        padding: 10px 12px !important;
        margin: 6px 0 10px !important;
    }
    .typecho-page-title h2 {
        font-size: 15.5px !important;
        gap: 8px !important;
    }
    .typecho-page-title h2 a {
        padding: 4px 10px !important;
        font-size: 11px !important;
    }
}
