/* shared standalone base — auto: tools/generate-standalone-css.mjs */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
.chat-container {
    --bottom-nav-h: calc(52px + env(safe-area-inset-bottom, 0px));
}

.app-bottom-nav {
    flex-shrink: 0;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    min-height: 52px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #fff;
    border-top: none;
    box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.05);
    z-index: 6;
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #9a9a9a;
    font-family: inherit;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item.is-active {
    color: #1a1a1a;
}

.bottom-nav-icon {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bottom-nav-icon--chat {
    position: relative;
    width: 30px;
    height: 30px;
}

.bottom-nav-icon--chat::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 10px;
    background: radial-gradient(circle, rgba(255, 127, 80, 0.16) 0%, transparent 70%);
    pointer-events: none;
}

.bottom-nav-icon img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    background: transparent;
    border-radius: 0;
    opacity: 0.72;
}

.bottom-nav-item.is-active .bottom-nav-icon img {
    opacity: 1;
}

.bottom-nav-icon svg {
    display: block;
}

.bottom-nav-item.is-active .bottom-nav-icon svg {
    stroke: #ff7f50;
}

.bottom-nav-item.is-active .bottom-nav-icon--kb svg {
    fill: rgba(255, 127, 80, 0.15);
    stroke: #ff7f50;
}

.bottom-nav-label {
    font-size: 10px;
    line-height: 1.2;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.bottom-nav-item.is-active .bottom-nav-label {
    font-weight: 600;
    color: #ff7f50;
}

.bottom-nav-item[data-tab="apikey"] .bottom-nav-label {
    font-size: 10px;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.auth-modal-overlay {
    position: fixed;
    inset: 0;
    background: #fff;
    z-index: 1001;
    display: none;
}

.auth-modal-overlay.open {
    display: block;
}

.auth-modal {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    transform: none;
    overflow: hidden;
    background: #fff;
    border: none;
    border-radius: 0;
    box-shadow: none;
    z-index: 1002;
    display: none;
    flex-direction: column;
}

.auth-modal.open {
    display: flex;
}

.auth-modal-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100dvh;
    overflow: hidden;
}

.auth-page-top {
    flex-shrink: 0;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 8px 8px 16px;
}

.auth-back-btn {
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    -webkit-tap-highlight-color: transparent;
}

.auth-back-btn:hover {
    background: #f5f5f5;
}

.auth-back-btn svg {
    display: block;
}

.auth-modal-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 0 28px 28px;
    padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
    -webkit-overflow-scrolling: touch;
}

.auth-pane {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.auth-page-title {
    margin: 8px 0 0;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #1a1a1a;
    line-height: 1.25;
}

.auth-page-subtitle {
    margin: 10px 0 36px;
    font-size: 14px;
    color: #999;
    line-height: 1.45;
}

.auth-field {
    border-bottom: 1px solid #eee;
    margin-bottom: 0;
}

.auth-field input {
    width: 100%;
    padding: 16px 0;
    border: none;
    background: transparent;
    font-size: 16px;
    color: #333;
    outline: none;
    font-family: inherit;
}

.auth-field input::placeholder {
    color: #bbb;
}

.auth-field--code {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auth-field--code input {
    flex: 1;
    min-width: 0;
}

.auth-sms-send-btn {
    flex-shrink: 0;
    padding: 8px 0 8px 8px;
    border: none;
    background: transparent;
    font-size: 15px;
    font-weight: 500;
    color: #3dccc0;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.auth-sms-send-btn:hover:not(:disabled) {
    color: #2eb8a6;
}

.auth-sms-send-btn:disabled {
    color: #bbb;
    cursor: not-allowed;
}

.auth-agree-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 28px 0 24px;
    font-size: 13px;
    line-height: 1.55;
    color: #666;
}

.auth-agree-row input[type="checkbox"] {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 2px;
    border-radius: 50%;
    accent-color: #3dccc0;
    cursor: pointer;
}

.auth-agree-text {
    flex: 1;
    min-width: 0;
}

.auth-legal-link {
    color: #3dccc0;
    text-decoration: none;
}

.auth-legal-link:hover {
    color: #2eb8a6;
    text-decoration: underline;
}

.auth-form-error {
    color: #e53935;
    font-size: 13px;
    margin: -12px 0 12px;
    line-height: 1.45;
    display: none;
}

.auth-form-error:not(:empty) {
    display: block;
}

.auth-login-btn {
    width: 100%;
    padding: 15px 16px;
    border: none;
    border-radius: 999px;
    font-size: 16px;
    font-weight: 600;
    color: #999;
    background: #f0f0f0;
    cursor: not-allowed;
    font-family: inherit;
    transition: background 0.2s, color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.auth-login-btn.is-ready {
    color: #fff;
    background: linear-gradient(135deg, #ff8f6b 0%, #ff7f50 100%);
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(255, 127, 80, 0.35);
}

.auth-login-btn.is-ready:active {
    transform: scale(0.99);
}

.auth-login-btn:disabled:not(.is-ready) {
    opacity: 1;
}

.auth-oauth-wrap {
    margin-top: auto;
    padding-top: 48px;
}

.auth-oauth-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
    color: #ccc;
    font-size: 13px;
}

.auth-oauth-divider::before,
.auth-oauth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #eee;
}

.auth-oauth-divider span {
    flex-shrink: 0;
    color: #bbb;
}

.auth-oauth-icons {
    display: flex;
    justify-content: center;
    padding-bottom: 12px;
}

.auth-wechat-btn {
    width: 48px;
    height: 48px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.auth-wechat-btn:hover {
    opacity: 0.88;
}

.auth-wechat-btn svg {
    display: block;
}

@media (min-width: 641px) {
    .auth-modal {
        left: 50%;
        top: 50%;
        right: auto;
        bottom: auto;
        width: min(420px, 100%);
        height: auto;
        max-height: min(720px, 92vh);
        transform: translate(-50%, -50%);
        border-radius: 16px;
        box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12);
    }

    .auth-modal-inner {
        max-height: min(720px, 92vh);
        border-radius: 16px;
        overflow: hidden;
    }

    .auth-modal-overlay.open {
        background: rgba(0, 0, 0, 0.35);
    }
}



body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    background: #ffffff;
    overflow-x: hidden;
    overflow-y: auto;
}

[hidden] {
    display: none !important;
}

/* 独立页外壳：API-KEY 设置 / 会员中心 / 知识库 */
.settings-standalone-app,
.me-standalone-app,
.kb-standalone-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.04);
    --bottom-nav-h: calc(52px + env(safe-area-inset-bottom, 0px));
}

.settings-standalone-app,
.me-standalone-app {
    background: #ffffff;
}

.settings-standalone-app .app-bottom-nav,
.me-standalone-app .app-bottom-nav,
.kb-standalone-app .app-bottom-nav {
    flex-shrink: 0;
}

.kb-standalone-app .kb-page {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    background: #fff;
}

a.bottom-nav-item,
button.bottom-nav-item,
span.bottom-nav-item {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-family: inherit;
    padding: 6px 4px 4px;
    box-sizing: border-box;
}

span.bottom-nav-item {
    cursor: default;
}

.bottom-nav-item[data-tab="apikey"] .bottom-nav-label {
    font-size: 10px;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.app-toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--bottom-nav-h, 52px) + 16px);
    transform: translateX(-50%) translateY(12px);
    max-width: min(90vw, 360px);
    padding: 10px 16px;
    border-radius: 10px;
    background: rgba(26, 26, 26, 0.88);
    color: #fff;
    font-size: 14px;
    line-height: 1.4;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1100;
}

.app-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}


/* settings.html */
.settings-page-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 14px 20px;
    border-bottom: 1px solid #f0f0f0;
    background: #fff;
}

.settings-page-header h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    letter-spacing: -0.02em;
}

.settings-page-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #333;
    cursor: pointer;
}

.settings-page-back:hover {
    background: #f5f5f5;
}

.settings-page-account {
    font-size: 12px;
    color: #888;
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-page-main {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 16px calc(20px + var(--bottom-nav-h));
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
    background: #ffffff;
}

.settings-standalone-app .settings-body {
    padding: 0;
    overflow: visible;
}

.settings-standalone-app .settings-api-manual-toggle,
.settings-standalone-app .settings-tokens-section,
.settings-standalone-app .settings-token-pack,
.settings-standalone-app .settings-alipay-btn,
.settings-standalone-app .save-settings {
    position: relative;
    z-index: 1;
    pointer-events: auto;
    touch-action: manipulation;
}

.settings-standalone-app .settings-header {
    display: none;
}

.settings-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.settings-api-manual-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 4px;
    border: 1px dashed #c5cdd8;
    border-radius: 12px;
    background: #f8fafc;
    color: #4f46e5;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.settings-api-manual-toggle:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #4338ca;
}

.settings-api-manual-toggle-text {
    flex: 1;
    min-width: 0;
    line-height: 1.45;
}

.settings-api-manual-toggle-icon {
    flex-shrink: 0;
    font-size: 12px;
    color: #64748b;
    transition: transform 0.2s ease;
}

.settings-api-manual-toggle.is-open .settings-api-manual-toggle-icon {
    transform: rotate(-180deg);
}

.settings-api-manual-wrap {
    display: none;
    padding-top: 12px;
}

.settings-api-manual-wrap.is-open {
    display: block;
}

.settings-api-manual-note {
    font-size: 13px;
    line-height: 1.55;
    color: #475569;
    margin: 0 0 18px;
    padding: 12px 14px;
    border-radius: 10px;
    background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 100%);
    border: 1px solid #e0e7ff;
}

.settings-api-manual-wrap .settings-group {
    margin-bottom: 20px;
}

.settings-api-manual-wrap .save-settings {
    margin-top: 4px;
}

.settings-group {
    margin-bottom: 24px;
}

.settings-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
}

.settings-group input, .settings-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-size: 14px;
}

.settings-group textarea {
    resize: vertical;
    font-family: monospace;
}

.settings-input-split {
    display: flex;
    align-items: stretch;
    width: 100%;
    border: 1px solid #dcdfe6;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    box-sizing: border-box;
}

.settings-input-split:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.settings-group .settings-input-split input {
    width: auto;
    flex: 1;
    min-width: 0;
    margin: 0;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 12px 14px;
    font-size: 14px;
    box-sizing: border-box;
}

.settings-group .settings-input-split #apiKey {
    flex: 1.2;
}

.settings-group .settings-input-split #model {
    flex: 0.85;
    min-width: 108px;
    border-left: 1px solid #dcdfe6 !important;
    background: #f1f5f9;
    color: #64748b;
    cursor: default;
}

.settings-group .settings-input-split #model:focus {
    outline: none;
}

.settings-split-grid-label {
    display: grid;
    grid-template-columns: 1.2fr 0.85fr;
    gap: 0;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 8px;
}

.settings-split-grid-label span:last-child {
    padding-left: 14px;
}

.save-settings {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 24px;
    font-size: 16px;
    cursor: pointer;
    margin-top: 16px;
}

.settings-section-divider {
    margin: 22px 0 0;
    padding-top: 22px;
    border-top: 1px solid #e8ecf0;
}

.settings-tokens-title {
    font-size: 16px;
    font-weight: 600;
    color: #1a2a3a;
    margin: 0 0 6px;
}

.settings-tokens-hint {
    font-size: 12px;
    color: #64748b;
    margin: 0 0 14px;
    line-height: 1.45;
}

.settings-token-packs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.settings-token-pack {
    padding: 10px 6px;
    border: 1px solid #dcdfe6;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    text-align: center;
    line-height: 1.4;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.settings-token-pack:hover {
    border-color: #c5cdd8;
}

.settings-token-pack.selected {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.18);
    background: #f8f9ff;
}

.settings-token-pack-sub {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    font-weight: 400;
    color: #64748b;
}

.settings-token-pack-yuan {
    display: block;
    font-weight: 500;
    color: #334155;
}

.settings-alipay-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    background: linear-gradient(135deg, #1677ff 0%, #0958d9 100%);
    color: #fff;
}

.settings-alipay-btn:hover {
    filter: brightness(1.03);
}

.settings-alipay-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    filter: none;
}


/* 暖橙品牌色覆盖 */
.settings-standalone-app .settings-api-manual-toggle {
    color: #e85d2c;
    border: 1px solid rgba(255, 127, 80, 0.35);
    background: #fff8f5;
}

.settings-standalone-app .settings-api-manual-toggle:hover {
    border-color: rgba(255, 127, 80, 0.5);
    color: #d35400;
    background: #fff5f0;
}

.settings-standalone-app .settings-api-manual-note {
    background: linear-gradient(135deg, #fff5f0 0%, #fafafa 100%);
    border-color: rgba(255, 127, 80, 0.2);
}

.settings-standalone-app .settings-input-split:focus-within {
    border-color: #ff7f50;
    box-shadow: 0 0 0 2px rgba(255, 127, 80, 0.2);
}

.settings-standalone-app .save-settings {
    background: linear-gradient(135deg, #ff8f5a 0%, #ff6b35 100%);
    color: #fff;
}

.settings-standalone-app .settings-token-pack.selected {
    border-color: #ff7f50;
    box-shadow: 0 0 0 2px rgba(255, 127, 80, 0.18);
    background: #fff8f5;
}

.settings-standalone-app .settings-tokens-section {
    margin-top: 0;
    padding: 18px 16px 20px;
    background: #fff;
    border-radius: 16px;
    border: 1px solid #ebebeb;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
}

.settings-standalone-app .settings-alipay-btn {
    background: linear-gradient(135deg, #ff8f5a 0%, #ff6b35 100%);
    border-radius: 24px;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(255, 107, 53, 0.28);
}

.settings-standalone-app .settings-alipay-btn:hover {
    filter: brightness(1.04);
}

.settings-standalone-app .settings-token-pack {
    border-radius: 12px;
    border-color: #ebebeb;
    background: #fff;
}

.settings-standalone-app .settings-token-pack:hover {
    border-color: rgba(255, 127, 80, 0.45);
}

.settings-standalone-app .settings-tokens-title {
    font-size: 17px;
    font-weight: 700;
    color: #1a1a1a;
}

.settings-standalone-app .settings-tokens-hint {
    color: #8a8a8a;
}

.settings-standalone-app .settings-page-header {
    border-bottom: none;
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.05);
}

.settings-standalone-app .settings-section-divider {
    height: 0;
    margin: 16px 0;
    border: none;
    padding: 0;
}

.settings-page-logout {
    width: 100%;
    margin-top: 24px;
    padding: 12px;
    border: 1px solid #fecaca;
    border-radius: 12px;
    background: #fff;
    color: #dc2626;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}

.settings-page-logout:hover {
    background: #fef2f2;
}

.settings-page-header h1 {
    flex: 1;
    min-width: 0;
}

.settings-page-account {
    margin-left: auto;
}

.settings-field-hint {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: #999;
}

.settings-tokens-balance-line {
    color: #475569;
    font-weight: 500;
}

@media (min-width: 641px) {
    .settings-page-main {
        max-width: 640px;
    }

    .settings-standalone-app .settings-token-packs {
        grid-template-columns: repeat(3, 1fr);
    }
}
