/* 全局字体优化 */
body {
    margin: 0;
    background-color: #f6f8fa; /* 柔和的浅灰背景 */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    color: #24292e;
}

/* 导航栏美化 */
#navbar {
    top: 0;
    left: 0;
    width: 100%;
    height: 50px;
    margin: 0;
    padding: 0 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    background-color: #24292e; /* 深色 GitHub 风格 */
    z-index: 10;
    position: absolute;
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

#navcontent {
    width: 100%;
    display: flex;
    align-items: center;
}

/* 标题样式 */
#title {
    cursor: pointer;
    color: #ffffff !important;
    text-align: left;
    font-size: 18px;
    margin: 0 15px 0 5px;
    font-weight: 600;
    line-height: 50px;
    font-family: inherit;
    display: inline-block;
}

/* 按钮美化 */
.navbutton {
    color: #d1d5da;
    cursor: pointer;
    text-align: center;
    font-size: 20px; /* 图标大小 */
    margin: 0 2px;
    padding: 6px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.navbutton:hover {
    background-color: #444d56;
    color: #fff;
}

.navbutton.selected {
    background-color: #0366d6;
    color: white;
}

/* 隐藏元素 */
.hidden {
    display: none !important;
}

/* 左侧：输入区 */
#in {
    position: fixed;
    top: 50px; /* 避开导航栏 */
    left: 0;
    bottom: 0;
    width: 50%;
    height: auto;
    overflow: auto;
    font-size: 14px;
    box-shadow: none;
    border-right: 1px solid #e1e4e8;
    background-color: #fff;
    z-index: 1;
}

/* CodeMirror 编辑器核心样式 */
.CodeMirror {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: auto; /* 让它自适应填充 #in */
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    background: transparent;
}

.CodeMirror pre {
    line-height: 1.6;
}

.CodeMirror-scroll {
    padding: 30px;
    box-sizing: border-box;
}

/* 右侧：预览区 */
#out {
    position: fixed;
    top: 50px;
    right: 0;
    left: 50%;
    bottom: 0;
    overflow: auto;
    padding: 30px 40px;
    background-color: #fff;
    color: #24292e;
}

/* 菜单弹窗 */
#menu {
    display: none;
    position: fixed;
    background-color: #ffffff;
    border-radius: 8px;
    top: 50%;
    left: 50%;
    width: 300px;
    padding: 20px;
    transform: translate(-50%, -50%);
    margin: 0;
    z-index: 99;
    text-align: center;
    color: #333;
    box-shadow: 0 15px 30px rgba(0,0,0,0.2);
    border: 1px solid #eee;
}

#menu > span {
    display: block;
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 20px;
}

#menu > div {
    display: inline-block;
    width: 100px;
    text-align: center;
    vertical-align: top;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

#menu > div:hover {
    opacity: 1;
}

#menu svg {
    width: 64px;
    height: 64px;
    margin: 0 auto;
    display: block;
}

#menu path {
    fill: #333;
}

#close-menu {
    position: absolute;
    top: 10px;
    right: 15px;
    color: #999;
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
}

#close-menu:hover {
    color: #d73a49;
}

/* 辅助样式 */
.left { float: left; }
.right { float: right; }
.emoji { width: 1.2em; height: 1.2em; vertical-align: middle; }

/* 响应式设计：手机端 */
@media screen and (max-width: 1024px) {
     #in, #out {
        margin: 0;
        left: 0;
        width: 100%;
        position: relative;
        height: 50vh;
        border-right: none;
        border-bottom: 1px solid #ddd;
     }
     #in { top: 50px; z-index: 100; }
     #out { top: 0; }
     a#logo { display: none; }
     .navbutton { margin-left: 5px !important; }
     
     /* 手机端阅读模式时的样式 */
     .focused {
         display: block;
         width: 100%;
         margin-left: 0%;
         padding-left: 0%;
         left: 0;
         height: calc(100vh - 50px); /* 全屏高度减去导航栏 */
      }
 }

/* 阅读模式 */
.view #in { display: none; }
.view #out { left: 0; padding-left: 10px; }

.focused {
    display: block;
    width: 50%;
    margin-left: -25%;
    padding-left: 0%;
    left: 0;
    border-left: 0 !important;
}

/* 夜间模式逻辑 (保留原有的 invert 逻辑以兼容 JS) */
body.nightmode {
    background-color: #222;
}

/* 反转内容区颜色 */
.nightmode #in {
    filter: invert(100%) hue-rotate(180deg);
}

.nightmode #out {
    filter: invert(100%) hue-rotate(180deg);
    background-color: #fff; /* 反转后变黑 */
}

/* 防止图片被反转（需要双重反转回来） */
.nightmode #out img:not(.emoji) {
    filter: invert(100%) hue-rotate(180deg);
}

/* 导航栏保持深色，不反转 */
.nightmode #navbar {
    filter: none;
}

/* 拼写错误高亮修复 */
.no-spellcheck .cm-spell-error { background: none !important; }
span.cm-error { background: #ac414222 !important; }

/* 打印样式 */
@media print {
    #in, #navbar { display: none !important; }
    #out {
        left: 0 !important;
        top: 0 !important;
        position: static !important;
        border-width: 0px !important;
        filter: none !important;
        overflow: visible;
    }
}

/* 滚动条美化 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }
