/* ============================================================
   ZHI Studio · DeepSeek AI Tutor + Sticky Activity Bar
   ============================================================ */

/* ===== Sticky activity navigation bar (so you never scroll to advance) ===== */
.exercise-shell {
    position: relative;
    padding-bottom: 96px;
}

.activity-sticky-bar {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 24px;
    padding: 12px 16px;
    background: linear-gradient(180deg, rgba(10, 10, 15, 0) 0%, rgba(10, 10, 15, 0.85) 35%, rgba(10, 10, 15, 0.96) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.activity-sticky-bar .sticky-spacer { flex: 1; }

.activity-sticky-bar .btn {
    min-width: 132px;
    justify-content: center;
}

.activity-sticky-bar .btn-icon {
    min-width: auto;
    width: 44px;
    padding: 8px 0;
}

.activity-sticky-bar .sticky-progress {
    color: rgba(255, 255, 255, 0.55);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    padding: 0 8px;
}
@media (max-width: 844px) {
    .activity-sticky-bar { 
        gap: 6px; 
        padding: 10px; 
        position: sticky;
        bottom: calc(64px + env(safe-area-inset-bottom, 0px));
        margin-bottom: 0;
        z-index: 250;
    }
    .activity-sticky-bar .btn { min-width: 0; flex: 1; padding: 10px 10px; font-size: 13px; min-height: 44px; }
    .activity-sticky-bar .btn-icon { flex: 0 0 44px; min-height: 44px; }
}

/* ===== AI Tutor slide-in panel ===== */
#ai-tutor-panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(420px, 90vw);
    z-index: 400;
    display: flex;
    flex-direction: column;
    background: rgba(14, 14, 20, 0.97);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 18px 0 60px rgba(0, 0, 0, 0.55);
    transform: translateX(-105%);
    transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: rgba(255, 255, 255, 0.88);
}

#ai-tutor-panel.open { transform: translateX(0); }

#ai-tutor-panel .ai-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

#ai-tutor-panel .ai-seal {
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 10px;
    background: linear-gradient(135deg, #4f7cff, #7c4dff);
    font-weight: 800; font-size: 16px;
    box-shadow: 0 0 18px rgba(79, 124, 255, 0.45);
}

#ai-tutor-panel .ai-title { display: flex; flex-direction: column; line-height: 1.2; }
#ai-tutor-panel .ai-title strong { font-size: 14px; letter-spacing: 0.04em; }
#ai-tutor-panel .ai-title small { font-size: 11px; color: rgba(255, 255, 255, 0.5); }

#ai-tutor-panel .ai-head .ai-actions { margin-left: auto; display: flex; gap: 6px; }

#ai-tutor-panel .ai-icon-btn {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    font-size: 16px;
}
#ai-tutor-panel .ai-icon-btn:hover { background: rgba(255, 255, 255, 0.12); transform: translateY(-1px); }}

#ai-tutor-panel .ai-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

#ai-tutor-panel .ai-msg {
    padding: 12px 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

#ai-tutor-panel .ai-msg.ai-user {
    background: rgba(79, 124, 255, 0.14);
    border-color: rgba(79, 124, 255, 0.3);
    align-self: flex-end;
    max-width: 90%;
}

#ai-tutor-panel .ai-context {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.55);
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed rgba(255, 255, 255, 0.1);
}
#ai-tutor-panel .ai-context b { color: rgba(255, 255, 255, 0.8); }

#ai-tutor-panel .ai-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
    padding: 6px 0;
}
#ai-tutor-panel .ai-loading .ai-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: #6f93ff;
    animation: ai-tutor-bounce 1s infinite ease-in-out;
}
#ai-tutor-panel .ai-loading .ai-dot:nth-child(2) { animation-delay: 0.18s; }
#ai-tutor-panel .ai-loading .ai-dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes ai-tutor-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

#ai-tutor-panel .ai-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 12px 14px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#ai-tutor-panel .ai-input {
    flex: 1;
    resize: none;
    max-height: 120px;
    min-height: 42px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    transition: border-color 0.15s;
}
#ai-tutor-panel .ai-input:focus { outline: none; border-color: rgba(79, 124, 255, 0.55); }

#ai-tutor-panel .ai-send {
    height: 42px;
    width: 42px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, #4f7cff, #7c4dff);
    color: #fff;
    font-size: 16px;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 14px rgba(79, 124, 255, 0.4);
}
#ai-tutor-panel .ai-send:hover { transform: translateY(-1px); }
#ai-tutor-panel .ai-send:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

#ai-tutor-panel .ai-empty {
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
    margin: auto 0;
    line-height: 1.7;
}

/* The hidden handle that lets you re-open a hidden panel */
#ai-tutor-handle {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 89;
    display: none;
    width: 26px;
    padding: 12px 4px;
    border-radius: 0 12px 12px 0;
    background: linear-gradient(180deg, #4f7cff, #7c4dff);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.18em;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    cursor: pointer;
    box-shadow: 4px 0 18px rgba(79, 124, 255, 0.4);
    border: none;
}
#ai-tutor-handle.show { display: flex; align-items: center; justify-content: center; }

/* ===== DeepSeek config modal ===== */
.ai-config-card { max-width: 520px; text-align: left; }
.ai-config-card h2 { margin: 0 0 6px; color: #fff; font-size: 20px; }
.ai-config-card .ai-config-sub { color: rgba(255,255,255,0.75); font-size: 14px; margin: 0 0 16px; line-height: 1.5; }

.ai-config-card .ai-privacy {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.25);
    font-size: 12.5px;
    color: rgba(185, 246, 220, 0.85);
    line-height: 1.5;
    margin: 0 0 18px;
}
.ai-config-card .ai-privacy .ai-privacy-icon { font-size: 18px; }

.ai-config-card .ai-field { margin-bottom: 12px; }
.ai-config-card .ai-field label {
    display: block;
    font-size: 12px;
    color: rgba(255,255,255,0.85);
    margin: 0 0 6px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 600;
}

.ai-config-card .ai-field input,
.ai-config-card .ai-field select {
    width: 100%;
    padding: 12px;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23fff' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.ai-config-card .ai-field select option {
    background: #1a1a25;
    color: #fff;
}

.ai-config-card .ai-field input:focus,
.ai-config-card .ai-field select:focus {
    outline: none;
    border-color: rgba(79, 124, 255, 0.8);
    box-shadow: 0 0 0 2px rgba(79, 124, 255, 0.2);
}

.ai-config-card .ai-field .ai-hint { font-size: 11px; color: rgba(255,255,255,0.5); margin-top: 4px; }

.ai-config-card .ai-model-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.ai-config-card .ai-model-chip {
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.18);
    color: rgba(255,255,255,0.85);
    transition: all 0.15s;
    font-family: inherit;
}

.ai-config-card .ai-model-chip:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.ai-config-card .ai-model-chip.active {
    background: rgba(79,124,255,0.25);
    border-color: rgba(79,124,255,0.6);
    color: #fff;
    box-shadow: 0 0 8px rgba(79,124,255,0.3);
}

.ai-config-card .ai-privacy {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.25);
    font-size: 12.5px;
    color: rgba(185, 246, 220, 0.9);
    line-height: 1.5;
    margin: 0 0 16px;
}

.ai-config-card .ai-privacy b { color: #fff; }

.ai-config-card .ai-config-actions {
    display: flex; gap: 12px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap;
}
.ai-config-card .ai-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.ai-config-card .ai-row .ai-field {
    flex: 1;
    margin-bottom: 0;
}

@media (max-width: 600px) {
    .ai-config-card .ai-row {
        flex-direction: column;
        gap: 0;
        margin-bottom: 0;
    }

    .ai-config-card .ai-row .ai-field {
        margin-bottom: 12px;
    }
}
