:root {
    --bg-color: #1e1e1e;
    --editor-bg: #111;
    --key-bg: #333;
    --key-active: #555;
    --key-shift-active: #005a9e;
    --key-ctrl-active: #007acc;
    --text-color: #d4d4d4;
    --dim-color: #666;
    --accent-color: #007acc;
    --border-color: #111;
}

* { box-sizing: border-box; touch-action: none; }
/* 只对特定元素禁用选择，保留其他元素可选择 */
.key, .tool-btn, .line-number, .line-view, .line-wrapper, .row, .modal-header, .output-header { user-select: none; -webkit-user-select: none; }
body { margin: 0; padding: 0; background-color: var(--bg-color); height: 100vh; width: 100vw; display: flex; flex-direction: column; overflow: hidden; font-family: Consolas, "Courier New", monospace; }

/* VS Code 风格顶部菜单栏 */
#top-menu-bar {
    height: 36px;
    min-height: 36px;
    background-color: #333333;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #444444;
    z-index: 50;
    padding: 0 8px;
}

#menu-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

#logo {
    height: 20px;
    margin-right: 12px;
}

.menu-item {
    color: #cccccc;
    font-size: 14px;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 2px;
    user-select: none;
}

.menu-item:hover {
    background-color: #444444;
}

#menu-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

#menu-bar-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: white;
    font-size: 14px;
    margin: 0 10px;
}

.current-file {
    color: white;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.tool-btn {
    background-color: #000;
    color: white;
    border: none;
    border-radius: 4px;
    width: 32px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    padding: 0;
}

.tool-btn img {
    width: 16px;
    height: 16px;
    max-width: 100%;
    max-height: 100%;
}

#run-btn {
    background: none;
    border: none;
    padding: 0;
    width: auto;
    height: auto;
}

#run-btn img {
    width: 20px;
    height: 20px;
}

#luogu-btn {
    background: none;
    border: none;
    padding: 0;
    width: auto;
    height: auto;
}

#luogu-btn img {
    width: 20px;
    height: 20px;
}

/* 下拉菜单样式 */
.dropdown-menu {
    position: absolute;
    top: 36px;
    left: 0;
    background-color: #333333;
    border: 1px solid #444444;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    min-width: 180px;
    z-index: 100;
}

.dropdown-item {
    padding: 6px 12px;
    color: #cccccc;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
}

.dropdown-item:hover {
    background-color: #444444;
}

.dropdown-divider {
    height: 1px;
    background-color: #444444;
    margin: 4px 0;
}

/* 左侧边栏 */
#left-sidebar {
    position: fixed;
    top: 36px;
    left: 0;
    width: 40px;
    height: calc(100vh - 36px);
    background-color: #252526;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 12px;
    z-index: 40;
    border-right: 1px solid #333333;
}

.sidebar-button {
    width: 32px;
    height: 32px;
    background-color: #333333;
    color: #cccccc;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    margin-bottom: 8px;
    user-select: none;
}

.sidebar-button:hover {
    background-color: #444444;
}

/* 虚拟文件系统面板 */
.vfs-panel {
    position: fixed;
    top: 36px;
    left: 40px;
    width: 250px;
    height: calc(100vh - 36px);
    background-color: #252526;
    border-right: 1px solid #333333;
    z-index: 30;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.vfs-header {
    height: 36px;
    background-color: #333333;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-bottom: 1px solid #444444;
    font-size: 14px;
    color: #cccccc;
}

.vfs-close-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: #cccccc;
    font-size: 16px;
    cursor: pointer;
    width: 20px;
    height: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.vfs-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.vfs-root {
    margin-bottom: 8px;
}

.vfs-folder, .vfs-file {
    padding: 4px 8px;
    margin: 2px 0;
    border-radius: 2px;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 特别针对根目录文件夹设置白色文字 */
.vfs-folder[data-path="/"] {
    color: white;
}

.vfs-folder:hover, .vfs-file:hover {
    background-color: #444444;
}

.vfs-folder::before {
    content: "📁";
    font-size: 14px;
}

.vfs-file::before {
    content: "📄";
    font-size: 14px;
}

/* 3行预览区 (Flex列布局，内部包含行号+文本) */
#lines-container {
    height: 80px;
    min-height: 80px;
    background-color: #000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    padding: 5px 0;
    border-bottom: 2px solid #444;
    margin-left: 40px; /* 为侧边栏留出空间 */
}

.line-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    height: 22px;
}
.line-wrapper.current {
    height: 26px;
    background-color: #1a1a1a;
}

/* 键盘模式下的行号 */
.line-number {
    width: 40px; min-width: 40px;
    text-align: right; padding-right: 10px;
    color: #555; font-size: 12px; font-family: Consolas, monospace;
    user-select: none; border-right: 1px solid #333; margin-right: 8px;
    background-color: #1e1e1e; height: 100%; line-height: 22px;
}
.line-wrapper.current .line-number {
    color: #d4d4d4; font-weight: bold; font-size: 14px; line-height: 26px;
}

.line-view {
    flex: 1; white-space: pre; overflow: hidden; font-size: 14px; color: var(--dim-color); line-height: 22px; tab-size: 4;
}
.line-view.current {
    color: #d4d4d4; font-size: 16px; line-height: 26px; font-weight: bold; overflow-x: auto; scrollbar-width: none;
}
.line-view.current::-webkit-scrollbar { display: none; }

.cursor { display: inline-block; width: 2px; height: 18px; background-color: #0f0; animation: blink 1s step-end infinite; vertical-align: text-bottom; margin-bottom: 3px; }
@keyframes blink { 50% { opacity: 0; } }

/* 编辑器区域 */
#editor-area {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
    margin-left: 40px; /* 为侧边栏留出空间 */
}

#editor-container {
    flex: 1;
    height: 100%;
}

/* 模态框 */
#input-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.7); z-index: 300; justify-content: center; align-items: center; backdrop-filter: blur(2px); }
.modal-content { background-color: #252526; width: 85%; max-width: 400px; border: 1px solid #444; border-radius: 6px; padding: 15px; display: flex; flex-direction: column; box-shadow: 0 10px 25px rgba(0,0,0,0.5); }
.modal-header { color: #ccc; font-weight: bold; margin-bottom: 10px; font-size: 14px; }
#modal-textarea { background-color: #1e1e1e; color: #d4d4d4; border: 1px solid #3c3c3c; border-radius: 4px; padding: 8px; font-family: Consolas, monospace; font-size: 14px; height: 150px; resize: none; outline: none; user-select: text; -webkit-user-select: text; }
.modal-footer { display: flex; justify-content: flex-end; margin-top: 15px; gap: 10px; }
.modal-btn { padding: 8px 16px; border: none; border-radius: 3px; font-size: 14px; cursor: pointer; color: #fff; }
#modal-cancel { background-color: #3e3e42; }
#modal-run { background-color: #0e639c; }

/* 输出面板 */
#output-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 30%;
    min-height: 150px;
    background-color: #0d0d0d;
    border-top: 2px solid #007acc;
    z-index: 200;
    display: none;
    flex-direction: column;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.5);
    transition: height 0.1s ease; /* 平滑过渡效果 */
}
#output-header {
    height: 35px;
    background-color: #1e1e1e;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    border-bottom: 1px solid #333;
    color: #eee;
    font-size: 14px;
    cursor: ns-resize;
    user-select: none;
}

/* 关闭按钮使用默认光标 */
#close-output {
    cursor: default;
}
#output-content {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    font-family: Consolas, monospace;
    font-size: 13px;
    white-space: pre-wrap;
    color: #ccc;
    user-select: text;
    -webkit-user-select: text;
    cursor: text; /* 显示文本光标 */
}
/* 输出面板调整大小手柄 */
#output-resizer {
    height: 6px;
    background: #007acc;
    cursor: ns-resize;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    border-bottom: 1px solid #333;
    z-index: 10;
}
.out-section { margin-bottom: 10px; }
.out-title { color: #569cd6; font-weight: bold; margin-bottom: 4px; display: block; }
.out-err { color: #f48771; } .out-warn { color: #cca700; } .out-res { color: #fff; } .out-stat { color: #6a9955; font-size: 12px; font-style: italic; border-top: 1px solid #333; margin-top: 5px; padding-top: 5px;}

/* 高亮 */
.hl-kw { color: #569cd6; font-weight: bold; } .hl-str { color: #ce9178; } .hl-com { color: #6a9955; } .hl-dir { color: #c586c0; } .hl-num { color: #b5cea8; }

/* 键盘 */
#keyboard-container {
    position: fixed;
    bottom: 0;
    left: 40px; /* 从侧边栏右边开始 */
    right: 0;
    height: 200px;
    display: flex;
    flex-direction: column;
    padding: 2px;
    justify-content: space-between;
    background-color: var(--bg-color);
    border-top: 1px solid #333;
    z-index: 100;
    margin-left: 0; /* 重置可能的左边距 */
}
.row { display: flex; width: 100%; height: 20%; margin-bottom: 2px; }
.key { background-color: #333; color: #eee; border: 1px solid #111; border-radius: 4px; margin: 0 1px; display: flex; justify-content: center; align-items: center; font-size: 14px; font-weight: bold; flex-grow: 1; position: relative; box-shadow: 0 2px 0 #000; }
.key:active, .key.active { background-color: #555; transform: translateY(2px); box-shadow: none; }
.key.shift-hold { background-color: #005a9e; border-color: #007acc; }
.key.ctrl-hold { background-color: #006000; border-color: #0f0; }
.key-content { display: flex; flex-direction: column; alignItems: center; line-height: 1; pointer-events: none; }
.sup { font-size: 9px; color: #888; margin-bottom: 2px; } .main { font-size: 14px; }
.shifted .sup { color: #fff; font-size: 14px; } .shifted .main { color: #666; font-size: 9px; } .alpha-key .sup { display: none; }
.w-1 { flex: 1; } .w-1-5 { flex: 1.5; } .w-2 { flex: 2; } .w-2-25 { flex: 2.25; } .w-space { flex: 6; }
.spacer { flex: 1; visibility: hidden; } .spacer-1-5 { flex: 1.5; visibility: hidden; } .spacer-sm { flex: 0.2; visibility: hidden; }
.mod { background-color: #2a2a2a; font-size: 11px; } .nav-key { background-color: #252526; } .hide-keyboard { display: none !important; }
/* 图标按钮样式 */
.icon-btn {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
}

/* 侧边栏按钮样式 */
.sidebar-button {
    width: 32px;
    height: 32px;
    background-color: #333333;
    color: #cccccc;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    margin-bottom: 8px;
    user-select: none;
}

.sidebar-button img {
    width: 20px;
    height: 20px;
    pointer-events: none; /* 防止图片影响点击事件 */
    transition: transform 0.2s ease; /* 添加过渡效果 */
}

.sidebar-button.vfs-open img {
    transform: rotate(180deg); /* 当面板打开时旋转图标 */
}

.sidebar-button.plugin-center-open img {
    transform: rotate(180deg); /* 当插件中心面板打开时旋转图标 */
}

.sidebar-button.cph-open img {
    transform: rotate(180deg); /* 当CPH面板打开时旋转图标 */
}

/* 插件中心样式 */
.plugin-item {
    margin-bottom: 15px;
    padding: 10px;
    border: 1px solid #444;
    border-radius: 4px;
    background-color: #2d2d30;
}

.plugin-header {
    font-weight: bold;
    color: #ffffff;
    margin-bottom: 8px;
    font-size: 14px;
}

.plugin-settings {
    padding-left: 10px;
}

.plugin-actions {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.plugin-btn {
    padding: 6px 12px;
    background-color: #0e639c;
    color: white;
    border: none;
    border-radius: 3px;
    font-size: 13px;
    cursor: pointer;
    text-align: center;
}

.plugin-btn:hover {
    background-color: #1177bb;
}

.setting-item {
    margin: 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-item label {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #cccccc;
    font-size: 13px;
}

.setting-item input[type="number"] {
    width: 80px;
    padding: 3px 6px;
    background-color: #1e1e1e;
    color: #d4d4d4;
    border: 1px solid #3c3c3c;
    border-radius: 3px;
    font-size: 12px;
}

@media screen and (orientation: portrait) { .key { font-size: 11px; } .sup { font-size: 8px; } .main { font-size: 11px; } }

/* 关于弹窗样式 */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.about-modal, .preferences-modal {
    width: 80%;
    max-width: 600px;
    background-color: #252526;
    border: 1px solid #444;
    border-radius: 6px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #444;
    background-color: #333;
}

.modal-header h2 {
    margin: 0;
    color: #ccc;
    font-size: 18px;
}

.close-btn {
    font-size: 24px;
    color: #ccc;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close-btn:hover {
    background-color: #444;
}

.modal-body {
    padding: 20px;
    color: #ccc;
    line-height: 1.6;
}

.modal-body p {
    margin: 10px 0;
}

.modal-body a {
    color: #4daafc;
    text-decoration: none;
}

.modal-body a:hover {
    text-decoration: underline;
}

/* 首选项弹窗特殊样式 */
.preferences-modal .modal-body {
    max-height: 400px;
    overflow-y: auto;
}

.preferences-modal .setting-item {
    margin-bottom: 15px;
}

.preferences-modal .setting-item label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #ddd;
}

.preferences-modal textarea#default-code-editor {
    width: 100%;
    height: 200px;
    background-color: #1e1e1e;
    color: #d4d4d4;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    padding: 8px;
    font-family: Consolas, monospace;
    font-size: 14px;
    resize: vertical;
    box-sizing: border-box;
}

/* 首选项弹窗按钮样式 */
.preferences-modal .modal-footer .modal-btn {
    color: #ffffff; /* 白色文字 */
}

.preferences-modal .modal-footer #reset-default-code {
    background-color: #3e3e42; /* 灰色背景 */
}

.preferences-modal .modal-footer #cancel-preferences {
    background-color: #3e3e42; /* 灰色背景 */
}

.preferences-modal .modal-footer #save-preferences {
    background-color: #0e639c; /* 蓝色背景 */
}

/* 移动端代码补全样式 */
#mobile-autocomplete-container {
    display: flex;
    background-color: #1e1e1e;
    color: #d4d4d4;
    height: 40px;
    align-items: center;
    padding: 0 10px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    border-top: 1px solid #333;
    z-index: 99;
    position: fixed;
    bottom: 200px;  /* 键盘高度是200px，所以补全框在键盘上方 */
    left: 40px;     /* 从侧边栏右边开始 */
    right: 0;
}

/* 当键盘被隐藏时，补全框也应该隐藏 */
#keyboard-container.hide-keyboard ~ #mobile-autocomplete-container {
    display: none !important;
}

.mobile-autocomplete-item {
    color: #d4d4d4;
    margin: 0 8px;
    cursor: pointer;
    user-select: none;
}

.mobile-autocomplete-item:hover {
    text-decoration: underline;
}

/* 移动端滚动按钮样式 */
.up-btn-mobile, .down-btn-mobile {
    position: fixed;
    width: 40px;
    height: 40px;
    background-color: rgba(14, 99, 156, 0.8);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    z-index: 102;
    font-size: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    user-select: none;
}

.up-btn-mobile {
    top: 60px;
    right: 20px;
}

.down-btn-mobile {
    bottom: 80px;
    right: 20px;
}

/* CPH插件样式 */
.cph-controls {
    padding: 10px;
    border-bottom: 1px solid #444;
}

.cph-problem-set {
    margin-bottom: 10px;
    border: 1px solid #444;
    border-radius: 4px;
    background-color: #2d2d30;
}

.cph-problem-set-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    background-color: #3c3c40;
    border-bottom: 1px solid #444;
    border-radius: 4px 4px 0 0;
}

.cph-problem-set-name {
    font-weight: bold;
    color: #ffffff;
}

.cph-problem-set-actions {
    display: flex;
    gap: 5px;
}

.cph-test-cases-container {
    padding: 8px;
}

.cph-test-case {
    margin-bottom: 10px;
    border: 1px solid #444;
    border-radius: 4px;
    background-color: #252526;
}

.cph-test-case-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    background-color: #333335;
    border-bottom: 1px solid #444;
}

.cph-test-case-name {
    font-weight: bold;
    color: #cccccc;
}

.cph-test-case-actions {
    display: flex;
    gap: 5px;
}

.cph-test-case-content {
    padding: 8px;
}

.cph-test-case-input, .cph-test-case-output {
    margin-bottom: 8px;
}

.cph-test-case-input label, .cph-test-case-output label {
    display: block;
    margin-bottom: 4px;
    color: #aaaaaa;
    font-size: 13px;
}

.cph-test-case-textarea, .cph-test-case-textarea-main {
    width: 100%;
    height: 60px;
    background-color: #1e1e1e;
    color: #d4d4d4;
    border: 1px solid #3c3c3c;
    border-radius: 3px;
    padding: 6px;
    font-family: Consolas, monospace;
    font-size: 12px;
    resize: vertical;
    box-sizing: border-box;
}

.cph-test-case-actions-bottom {
    padding: 8px;
    border-top: 1px solid #444;
    text-align: center;
}

.btn-small {
    padding: 4px 8px;
    background-color: #0e639c;
    color: white;
    border: none;
    border-radius: 3px;
    font-size: 12px;
    cursor: pointer;
}

.btn-small:hover {
    background-color: #1177bb;
}

.cph-empty-state, .cph-empty-test-cases {
    padding: 10px;
    color: #888888;
    font-style: italic;
    text-align: center;
}

.sidebar-button.active {
    background-color: #007acc;
}

.plugin-description {
    color: #aaaaaa;
    font-size: 13px;
    margin-bottom: 8px;
}

/* CPH管理所有题目样式 */
.cph-all-files-container {
    margin-top: 10px;
    padding: 10px;
    border-top: 1px solid #444;
}

.cph-all-files-container h3 {
    margin: 0 0 10px 0;
    color: #ffffff;
    font-size: 14px;
}

.cph-all-files-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.cph-file-item {
    margin-bottom: 8px;
    padding: 8px;
    border: 1px solid #444;
    border-radius: 4px;
    background-color: #252526;
}

.cph-file-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.cph-file-name {
    font-weight: bold;
    color: #cccccc;
}

.cph-file-actions {
    display: flex;
    gap: 5px;
}

.cph-file-info {
    font-size: 12px;
    color: #888888;
    padding-left: 20px;
}