/* ============================================
   云端工作台 - 响应式布局（手机 / 电脑）
   ============================================ */

.workbench-page {
    padding-bottom: 0;
}

.workbench-nav .nav-link-active {
    color: var(--accent);
}
.workbench-nav .nav-link-active::after {
    width: 100%;
}

/* ----- 主布局：桌面端侧边栏 + 内容 ----- */
.workbench-main {
    display: flex;
    min-height: calc(100vh - 64px);
    padding-top: 64px;
    position: relative;
}

/* ----- 侧边栏（桌面端常显，移动端抽屉） ----- */
.workbench-sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
    z-index: 50;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
}

.sidebar-close {
    display: none;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-close:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.sidebar-section {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
}

.sidebar-section-title {
    display: block;
    padding: 0 16px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-dim);
    font-size: 0.95rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-item:hover {
    color: var(--text);
    background: rgba(255, 107, 53, 0.06);
}

.sidebar-item.active {
    color: var(--accent);
    background: rgba(255, 107, 53, 0.1);
    border-left-color: var(--accent);
}

.sidebar-icon {
    font-size: 1.2rem;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.sidebar-tip {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.5;
}

.sidebar-download {
    display: block;
    text-align: center;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-radius: 8px;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
}

.sidebar-download:hover {
    opacity: 0.95;
    transform: translateY(-1px);
}

/* ----- 菜单按钮（仅移动端显示） ----- */
.workbench-menu-btn {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 110;
    width: 44px;
    height: 44px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
}

.workbench-menu-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
    transition: transform 0.3s;
}

.workbench-menu-btn.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.workbench-menu-btn.active span:nth-child(2) {
    opacity: 0;
}

.workbench-menu-btn.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ----- 内容区 ----- */
.workbench-content {
    flex: 1;
    min-width: 0;
    padding: 24px;
    padding-bottom: 100px; /* 为移动端底部导航留空 */
    overflow-x: hidden;
}

.workbench-header {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.workbench-header h1 {
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    font-weight: 700;
    margin-bottom: 8px;
}

.workbench-header p {
    font-size: 1rem;
    color: var(--text-dim);
    margin-bottom: 12px;
    max-width: 640px;
}

.workbench-login-tip {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    padding: 12px 16px;
    background: rgba(255, 107, 53, 0.08);
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    max-width: 640px;
}

.workbench-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.wb-btn {
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.wb-btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: white;
}

.wb-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--glow);
}

.workbench-status {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.workbench-status.logged-in {
    color: var(--green);
}

/* ----- 功能卡片网格 ----- */
.workbench-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 48px;
}

.wb-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    transition: all 0.3s;
    scroll-margin-top: 90px;
}

.wb-card:hover {
    border-color: rgba(255, 107, 53, 0.3);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    transform: translateY(-4px);
}

.wb-card-icon {
    font-size: 2.5rem;
    margin-bottom: 16px;
}

.wb-card h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.wb-card p {
    font-size: 0.9rem;
    color: var(--text-dim);
    line-height: 1.6;
    margin-bottom: 16px;
}

.wb-card-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: rgba(255, 107, 53, 0.15);
    border: 1px solid rgba(255, 107, 53, 0.4);
    border-radius: 10px;
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
}

.wb-card-btn:hover {
    background: rgba(255, 107, 53, 0.25);
    border-color: var(--accent);
}

/* ----- 使用说明 ----- */
.workbench-info {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
}

.workbench-info h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.workbench-info ul {
    padding-left: 20px;
    color: var(--text-dim);
    line-height: 1.8;
}

.workbench-info li {
    margin-bottom: 8px;
}

.workbench-info a {
    color: var(--accent);
}

.workbench-info a:hover {
    text-decoration: underline;
}

/* ----- 移动端底部导航 ----- */
.workbench-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(17, 17, 17, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    z-index: 100;
    padding: 0 8px;
    align-items: center;
    justify-content: space-around;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 12px;
    color: var(--text-dim);
    font-size: 0.75rem;
    border-radius: 10px;
    transition: all 0.2s;
    min-width: 56px;
}

.bottom-nav-item:hover,
.bottom-nav-item.active {
    color: var(--accent);
}

.bottom-nav-icon {
    font-size: 1.25rem;
}

/* ============================================
   响应式：平板及以下
   ============================================ */
@media (max-width: 1024px) {
    .workbench-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
    }

    .workbench-sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close {
        display: flex;
    }

    .workbench-menu-btn {
        display: flex;
    }

    .workbench-content {
        padding-left: 24px;
        padding-top: 24px;
    }
}

/* ============================================
   响应式：手机（紧凑双列 + 短描述）
   ============================================ */
@media (max-width: 768px) {
    .workbench-main {
        padding-top: 64px;
    }

    .workbench-nav .nav-links {
        display: none;
    }

    .workbench-content {
        padding: 12px;
        padding-bottom: 88px;
    }

    .workbench-header {
        margin-bottom: 16px;
        padding-bottom: 14px;
    }

    .workbench-header h1 {
        font-size: 1.35rem;
        margin-bottom: 6px;
    }

    .workbench-header p {
        font-size: 0.85rem;
        margin-bottom: 8px;
    }

    .workbench-login-tip {
        font-size: 0.8rem;
        margin-bottom: 12px;
        padding: 10px 12px;
    }

    /* 双列紧凑卡片，一屏可见更多功能 */
    .workbench-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 28px;
    }

    .wb-card {
        padding: 12px 14px;
        border-radius: 12px;
    }

    .wb-card:hover {
        transform: translateY(-2px);
    }

    .wb-card-icon {
        font-size: 1.5rem;
        margin-bottom: 8px;
    }

    .wb-card h2 {
        font-size: 0.9rem;
        font-weight: 600;
        margin-bottom: 6px;
        line-height: 1.3;
    }

    .wb-card p {
        font-size: 0.75rem;
        line-height: 1.45;
        margin-bottom: 10px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .wb-card-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
        width: 100%;
        justify-content: center;
    }

    .workbench-bottom-nav {
        display: flex;
    }

    .workbench-info {
        padding: 16px;
    }

    .workbench-info h2 {
        font-size: 1rem;
        margin-bottom: 12px;
    }

    .workbench-info li {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .workbench-content {
        padding: 10px;
    }

    .workbench-cards {
        gap: 8px;
        margin-bottom: 24px;
    }

    .wb-card {
        padding: 10px 12px;
    }

    .wb-card-icon {
        font-size: 1.35rem;
        margin-bottom: 6px;
    }

    .wb-card h2 {
        font-size: 0.85rem;
    }

    .wb-card p {
        font-size: 0.7rem;
        margin-bottom: 8px;
    }

    .wb-card-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    .workbench-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .workbench-actions .wb-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   弹窗
   ============================================ */
.wb-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.wb-modal[data-open="true"] {
    opacity: 1;
    visibility: visible;
}

.wb-modal[hidden] {
    display: none !important;
}

.wb-modal:not([hidden])[data-open="true"] {
    display: flex;
}

.wb-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    cursor: pointer;
}

.wb-modal-box {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
}

.wb-modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.wb-modal-body {
    font-size: 0.95rem;
    color: var(--text-dim);
    line-height: 1.7;
    margin-bottom: 24px;
}

.wb-modal-body a {
    color: var(--accent);
}

.wb-modal-body a:hover {
    text-decoration: underline;
}

.wb-modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: flex-end;
}

.wb-modal-actions .wb-btn {
    margin: 0;
}

.wb-modal-actions .wb-btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
    color: var(--text);
}

.wb-modal-actions .wb-btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* 登录弹窗表单 */
.wb-login-box {
    max-width: 380px;
}

.wb-login-desc {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-bottom: 20px;
    line-height: 1.5;
}

.wb-login-form {
    margin-bottom: 16px;
}

.wb-form-group {
    margin-bottom: 16px;
}

.wb-form-group label:not(.wb-checkbox-label) {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.wb-form-group .wb-form-row {
    margin-bottom: 8px;
}

.wb-form-group input[type="text"],
.wb-form-group input[type="password"] {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.wb-form-group input[type="text"]::placeholder,
.wb-form-group input[type="password"]::placeholder {
    color: var(--text-muted);
}

.wb-form-group input[type="text"]:focus,
.wb-form-group input[type="password"]:focus {
    border-color: var(--accent);
}

.wb-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-dim);
    cursor: pointer;
}

.wb-checkbox-label input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.wb-login-msg {
    font-size: 0.9rem;
    margin-bottom: 12px;
    min-height: 1.4em;
}

.wb-login-msg.error {
    color: var(--error, #ff6b7a);
}

.wb-login-msg.success {
    color: var(--green);
}

.wb-login-form .wb-modal-actions {
    margin-top: 8px;
    margin-bottom: 0;
}

.wb-login-tip {
    font-size: 0.85rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin: 0;
}

.wb-login-tip a {
    color: var(--accent);
}

.wb-login-tip a:hover {
    text-decoration: underline;
}

.wb-login-submit-loading {
    opacity: 0.8;
    pointer-events: none;
}

/* 功能页通用 */
.wb-feature-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.wb-feature-desc {
    color: var(--text-dim);
    margin-bottom: 24px;
}
.wb-form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}
.wb-form-select,
.wb-form-input {
    width: 100%;
    max-width: 320px;
    padding: 12px 14px;
    font-size: 1rem;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.wb-form-textarea {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    resize: vertical;
    min-height: 120px;
}
.wb-form-msg {
    font-size: 0.9rem;
    margin: 12px 0;
    min-height: 1.4em;
}
.wb-form-msg.error {
    color: var(--error, #ff6b7a);
}
.wb-result-body {
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-dim);
}

/* ============================================
   AI 聊天 - 对话流布局
   ============================================ */
.wb-chat-page .workbench-nav {
    position: relative;
    z-index: 60;
}

.wb-chat-main {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-height: 100vh;
    padding-top: 64px;
    padding-bottom: 0;
    overflow: hidden;
    box-sizing: border-box;
}

.wb-chat-header {
    flex-shrink: 0;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(17, 17, 17, 0.6);
}

.wb-chat-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 4px;
}

.wb-chat-desc {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin: 0 0 12px;
}

.wb-chat-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wb-chat-model-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.wb-chat-model-select {
    max-width: 180px;
    padding: 8px 12px;
    font-size: 0.9rem;
}

.wb-chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 20px 24px;
    min-height: 0;
}

.wb-chat-welcome {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    padding: 32px 16px;
}

.wb-chat-welcome p {
    margin: 0;
}

.wb-chat-bubble-wrap {
    margin-bottom: 16px;
    display: flex;
}

.wb-chat-bubble-wrap.wb-chat-user {
    justify-content: flex-end;
}

.wb-chat-bubble-wrap.wb-chat-assistant {
    justify-content: flex-start;
}

.wb-chat-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 14px;
    line-height: 1.55;
    font-size: 0.95rem;
    word-break: break-word;
}

.wb-chat-user .wb-chat-bubble {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    border-bottom-right-radius: 4px;
}

.wb-chat-assistant .wb-chat-bubble {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.wb-chat-bubble-error {
    border-color: rgba(255, 107, 122, 0.5);
    background: rgba(255, 107, 122, 0.08);
    color: var(--error, #ff6b7a);
}

.wb-chat-bubble-text {
    white-space: pre-wrap;
}

.wb-chat-thinking {
    color: var(--text-muted);
    font-style: italic;
}

.wb-chat-input-bar {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 12px 20px 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    position: relative;
    z-index: 10;
}

.wb-chat-textarea {
    flex: 1;
    min-height: 44px;
    max-height: 160px;
    padding: 12px 16px;
    font-size: 1rem;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    line-height: 1.5;
}

.wb-chat-textarea:focus {
    border-color: var(--accent);
}

.wb-chat-textarea::placeholder {
    color: var(--text-muted);
}

.wb-chat-send-btn {
    flex-shrink: 0;
    padding: 12px 20px;
    min-height: 44px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.wb-chat-send-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--glow);
}

.wb-chat-send-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .wb-chat-header {
        padding: 12px 16px;
    }
    .wb-chat-messages {
        padding: 12px 16px 16px;
    }
    .wb-chat-input-bar {
        padding: 10px 16px 16px;
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
    .wb-chat-bubble {
        max-width: 92%;
    }
}
