body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background-color: #1a1a1a;
    color: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 40px;
    background-color: transparent;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: #ffffff;
}

.wechat-group, .lang-switch {
    padding: 8px 15px;
    border-radius: 4px;
    background-color: #333;
    color: #ffffff;
    font-size: 14px;
    cursor: pointer;
    border: none;
}

.wechat-group:hover, .lang-switch:hover {
    background-color: #444;
}

.wechat-group {
    position: relative;
    padding: 8px 15px;
    border-radius: 4px;
    background-color: #333;
    color: #ffffff;
    font-size: 14px;
    cursor: pointer;
    z-index: 1002;
}

.qr-code {
    display: none;
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    background-color: #fff;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 1003;
}

/* 使用纯 CSS 实现悬浮显示 */
.wechat-group:hover .qr-code {
    display: block !important;
}

.qr-code img {
    display: block;
    width: 200px;
    height: 200px;
    border-radius: 4px;
    pointer-events: none;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 20px 30px;
    min-height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
}

#chart-area {
    flex: 1;
    width: 95%;
    margin: 0 auto 15px;
    aspect-ratio: 16 / 9;
    min-height: auto;
    max-height: calc(100vh - 200px);
    background-color: #252525;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.loading-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(37, 37, 37, 0.95);
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 20px;
    z-index: 100;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #ffffff;
    border-top: 5px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    color: #ffffff;
    font-size: 18px;
}

.input-area {
    width: 95%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-row {
    display: flex;
    gap: 10px;
    width: 100%;
}

/* 输入框包装器 */
.input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
}

/* 恢复输入框样式 */
#prompt-input {
    width: 100%;
    height: 50px;
    padding: 0 20px;
    font-size: 16px;
    background-color: #252525;
    border: 1px solid #333;
    border-radius: 8px;
    color: #fff;
}

#generate-btn {
    width: 120px;
    height: 50px;
    padding: 0 20px;
    background: #4a9eff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: background-color 0.2s;
}

#prompt-input:focus {
    outline: none;
    border-color: #4a9eff;
}

#generate-btn:hover {
    background: #3a8eef;
}

#generate-btn:disabled {
    background: #333;
    cursor: not-allowed;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.chart-toolbar {
    position: absolute;
    bottom: 15px;
    right: 15px;
    display: flex;
    gap: 10px;
    z-index: 10;
}

.tool-button {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.tool-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.tool-button svg {
    width: 20px;
    height: 20px;
}

.download-menu {
    display: none;
    position: absolute;
    bottom: 100%;
    right: 0;
    background-color: #252525;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 8px 0;
    margin-bottom: 8px;
    min-width: 120px;
}

.download-menu.active {
    display: block;
}

.download-menu-item {
    padding: 8px 16px;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.2s;
}

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

.default-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px;
    box-sizing: border-box;
}

.chart-content {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
    overflow: hidden;
    position: relative !important;
    touch-action: none; /* 防止触摸设备的默认行为 */
}

.chart-content.active {
    display: flex;
}

.chart-content svg {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    transition: transform 0.1s ease;
    transform-origin: center center;
}

/* 下载按钮默认隐藏 */
#download-btn {
    display: none;
}

/* 移动端适配 */
@media screen and (max-width: 768px) {
    .header {
        padding: 5px 15px;
    }

    .container {
        padding: 5px 10px 10px;
        min-height: unset;
        height: calc(100vh - 50px);
        justify-content: space-between;
    }

    #chart-area {
        width: 100%;
        aspect-ratio: 4/3;
        margin: 0 0 10px;
        padding: 10px;
        min-height: unset;
        max-height: calc(100vh - 160px);
        flex: 0 1 auto;
    }

    .input-area {
        width: 100%;
        padding: 0 5px;
        margin-bottom: 10px;
    }

    .input-row {
        gap: 8px;
    }

    #prompt-input {
        height: 40px;
        font-size: 14px;
        padding: 0 12px;
    }

    #generate-btn {
        height: 40px;
        font-size: 14px;
        padding: 0 15px;
        min-width: 80px;
    }

    .import-link {
        font-size: 12px;
        margin-top: 2px;
    }

    .tool-button {
        width: 32px;
        height: 32px;
    }

    .qr-code {
        width: 160px;
        height: 160px;
    }

    .qr-code img {
        width: 160px;
        height: 160px;
    }

    /* 超小屏幕特别优化 */
    @media screen and (max-height: 600px) {
        #chart-area {
            aspect-ratio: 16/9;
            max-height: calc(100vh - 140px);
        }

        .input-area {
            margin-bottom: 5px;
        }
    }
}

/* 超小屏幕适配 */
@media screen and (max-width: 360px) {
    .header {
        padding: 5px 15px;
    }

    .logo {
        font-size: 18px;
    }

    #chart-area {
        aspect-ratio: 1/1; /* 更小屏幕使用正方形 */
    }

    .qr-code {
        width: 140px;
        height: 140px;
    }

    .qr-code img {
        width: 140px;
        height: 140px;
    }
}

/* 横屏模式优化 */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .container {
        height: calc(100vh - 40px);
    }

    #chart-area {
        aspect-ratio: 16/9;
        max-height: calc(100vh - 120px);
    }

    .input-row {
        flex-direction: row;
    }

    #generate-btn {
        width: 100px;
    }
}

/* 编辑弹窗样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
}

.modal-content {
    position: relative;
    background-color: #252525;
    margin: 50px auto;
    padding: 20px;
    width: 80%;
    max-width: 800px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    margin: 0;
    color: #fff;
}

.close-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
}

#code-editor {
    width: 100%;
    height: 300px;
    background-color: #1a1a1a;
    color: #fff;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 10px;
    font-family: monospace;
    margin-bottom: 20px;
    resize: vertical;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-footer button {
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

#save-btn {
    background-color: #ffffff;
    color: #1a1a1a;
}

#cancel-btn {
    background-color: transparent;
    border: 1px solid #ffffff;
    color: #ffffff;
}

/* 修改导入代码链接样式 */
.import-link {
    display: block;
    text-align: center;
    color: #999;
    text-decoration: underline;
    font-size: 14px;
    margin-top: 4px;
    cursor: pointer;
    width: 120px;
    margin-left: auto;
}

/* 语言切换按钮样式 */
.right-section {
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
    z-index: 1002;
}

/* 加粗所有 SVG 线条 */
.chart-content svg path,
.chart-content svg line,
.chart-content svg rect {
    stroke: #ffffff !important;
    stroke-width: 2px !important;
}

/* 只保留 flowchart 的编辑样式 */
.edit-mode .node text,
.edit-mode text,
.edit-mode tspan {
    cursor: text !important;
    pointer-events: all !important;
}

.edit-mode .node:hover,
.edit-mode text:hover,
.edit-mode tspan:hover {
    filter: brightness(1.2);
}

/* 移除其他图表类型的编辑相关样式 */
.mindmap-node text,
.mindmap-node tspan,
.timeline text,
.timeline tspan,
.floating-edit-box {
    cursor: default !important;
    pointer-events: none !important;
}

/* 编辑状态下的文本元素 */
[contenteditable="true"] {
    -webkit-user-modify: read-write-plaintext-only;
    -moz-user-modify: read-write-plaintext-only;
    -ms-user-modify: read-write-plaintext-only;
    user-modify: read-write-plaintext-only;
    outline: none;
    background: rgba(74, 158, 255, 0.1);
    padding: 2px 4px;
    border-radius: 2px;
    min-width: 1em;
    position: relative !important;
    transform: none !important;
    transform-origin: unset !important;
    z-index: 1000;
}

/* 保持编辑状态下的位置 */
.editing text,
.editing tspan,
.editing p {
    position: relative !important;
    transform: none !important;
    transform-origin: unset !important;
}

.direct-edit-input {
    background: #333;
    color: #fff;
    border: 1px solid #4a9eff;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 14px;
    z-index: 1000;
    position: absolute;
    min-width: 100px;
    box-sizing: border-box;
    font-family: inherit;
    line-height: 1.2;
    resize: none;
    white-space: nowrap;
    overflow: hidden;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.direct-edit-input:focus {
    outline: none;
    border-color: #4a9eff;
    background: #444;
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.2);
}

.tool-button.active {
    background-color: #4a9eff !important;
    border-color: #4a9eff !important;
}

.toast-message {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    z-index: 1000;
    animation: fadeInOut 3s ease-in-out;
}

@keyframes fadeInOut {
    0% { opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { opacity: 0; }
}

/* 修改图表类型选择器样式 */
.chart-type-selector {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

.type-select-btn {
    height: 36px;
    padding: 0 12px;
    background: transparent;
    border: none;
    color: #999;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    transition: all 0.2s;
}

.type-select-btn:hover {
    color: #4a9eff;
}

.arrow-icon {
    width: 14px;
    height: 14px;
    transition: transform 0.2s;
}

.type-select-btn.active .arrow-icon {
    transform: rotate(180deg);
}

/* 下拉菜单样式 */
.type-dropdown {
    display: none;
    position: absolute;
    bottom: calc(100% + 5px);
    right: 0;
    background: #252525;
    border: 1px solid #333;
    border-radius: 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.2);
    min-width: 120px;
}

.type-dropdown.active {
    display: block;
}

.type-item {
    padding: 10px 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.type-item:hover {
    background: #333;
}

.type-item.active {
    background: #4a9eff;
    color: #fff;
}

/* 移动端适配 */
@media screen and (max-width: 768px) {
    .type-select-btn {
        height: 40px;
        min-width: 100px;
        padding: 0 10px;
    }
    
    .type-dropdown {
        max-height: 250px;
    }
    
    .type-item {
        padding: 8px 12px;
    }
}

/* 确保编辑时文本位置稳定 */
.edit-mode text,
.edit-mode tspan {
    dominant-baseline: central !important;
    text-anchor: middle !important;
}

/* mindmap 节点样式 */
.mindmap-node text,
.mindmap-node tspan {
    dominant-baseline: central !important;
    text-anchor: middle !important;
}

/* mindmap 节点内的文本容器定位 */
.mindmap-node foreignObject {
    overflow: visible;
}

.mindmap-node foreignObject div {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    text-align: center;
}

/* 浮动编辑框样式 */
.floating-edit-box {
    position: absolute;
    background: rgba(74, 158, 255, 0.1);
    border: 1px solid rgba(74, 158, 255, 0.3);
    border-radius: 4px;
    padding: 2px 4px;
    color: #fff;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    cursor: text;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-sizing: border-box;
    min-width: 1em;
    pointer-events: all;
    user-select: text;
    -webkit-user-modify: read-write-plaintext-only;
}

.floating-edit-box:focus {
    outline: none;
    background: rgba(74, 158, 255, 0.2);
    border-color: rgba(74, 158, 255, 0.5);
}

/* 确保 SVG 容器是相对定位 */
.chart-content {
    position: relative !important;
}

.style-switcher {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #ffffff;
    cursor: pointer;
    font-size: 14px;
    z-index: 1000;
    transition: all 0.2s;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.8;
}

.style-switcher:hover {
    opacity: 1;
    transform: scale(1.05);
}

.style-switcher:active {
    transform: scale(0.95);
}

.style-switcher .switch-icon {
    width: 14px;
    height: 14px;
    transition: transform 0.3s ease;
}

.style-switcher .switch-icon.rotating {
    animation: rotate360 1s linear infinite;
}

@keyframes rotate360 {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
} 