﻿.ai-hint-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    margin: 12px 0 16px;
    width: 100%;
    min-width: 0;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.ai-hint-panel:not(.is-floating) {
    max-width: 100%;
    justify-self: stretch;
}

.ai-hint-panel.is-floating {
    position: fixed;
    right: max(16px, calc(var(--app-safe-right) + 16px));
    bottom: max(24px, calc(var(--app-safe-bottom) + 24px));
    z-index: 1180;
    margin: 0;
    width: min(360px, calc(100vw - max(16px, calc(var(--app-safe-right) + 16px)) - max(16px, calc(var(--app-safe-left) + 16px))));
    max-width: calc(100vw - max(16px, calc(var(--app-safe-right) + 16px)) - max(16px, calc(var(--app-safe-left) + 16px)));
    transition: opacity 0.18s ease, transform 0.18s ease, bottom 0.18s ease;
}

.ai-hint-panel.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.ai-hint-fab {
    width: 100%;
    min-width: 0;
    height: 58px;
    padding: 0 12px;
    border: none;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.ai-hint-fab:active {
    transform: scale(0.96);
}

.ai-hint-fab .ai-hint-icon {
    flex: 0 0 auto;
    display: inline-flex;
    width: 24px;
    height: 24px;
}

.ai-hint-fab-label {
    flex: 1 1 auto;
    min-width: 0;
    max-width: min(48vw, 170px);
    overflow: hidden;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.ai-hint-sheet-open .ai-hint-panel {
    opacity: 1;
    pointer-events: auto;
}

.ai-hint-icon {
    background: currentColor;
    -webkit-mask: url("/static/images/icon_ai.svg") center / contain no-repeat;
    mask: url("/static/images/icon_ai.svg") center / contain no-repeat;
}

.ai-hint-fab:disabled {
    opacity: 0.7;
    cursor: wait;
}

.task-skip-btn {
    height: 58px;
    padding: 0 12px;
    border: 1px solid var(--card-border);
    border-radius: 999px;
    background: var(--card-bg);
    color: var(--text);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.18s ease, opacity 0.18s ease, border-color 0.18s ease;
    white-space: nowrap;
}

.task-skip-btn:active {
    transform: scale(0.96);
}

.task-skip-btn:disabled {
    opacity: 0.55;
    cursor: wait;
}

.ai-hint-sheet {
    position: static;
    z-index: auto;
    pointer-events: auto;
    opacity: 1;
    overflow: hidden;
    transform: translateY(0);
}

body.ai-hint-sheet-open {
    overflow: visible;
}

.ai-hint-sheet-backdrop {
    display: none;
    border: 0;
    background: transparent;
    pointer-events: none;
}

.ai-hint-sheet-panel {
    position: static;
    width: 100%;
    max-height: none;
    margin: 6px 0 6px;
    display: flex;
    flex-direction: column;
    padding: 8px 10px 10px;
    border: 1px solid rgba(30, 111, 255, 0.24);
    border-radius: var(--radius-sm);
    background: var(--bg);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
    overflow: hidden;
    pointer-events: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    opacity: 1;
}

.solution-ai-btn + .ai-hint-sheet .ai-hint-sheet-panel {
    margin: 0 0 6px !important;
}

.solution-ai-btn + .ai-hint-sheet {
    margin-top: 0 !important;
    padding-top: 0 !important;
    line-height: normal;
}

.ai-hint-sheet.is-collapsed {
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
}

.ai-hint-sheet.is-closing {
    transition: opacity 0.24s ease, transform 0.24s ease;
}

.ai-hint-sheet.is-collapsed .ai-hint-sheet-backdrop {
    opacity: 0;
    pointer-events: none;
}

.ai-hint-sheet.is-collapsed .ai-hint-sheet-panel {
    transform: translateY(8px);
    opacity: 0;
    box-shadow: none;
    pointer-events: none;
}

.ai-hint-sheet.is-closing .ai-hint-sheet-panel {
    transition: opacity 0.24s ease, transform 0.24s ease, box-shadow 0.24s ease;
}

.ai-hint-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 2px 2px;
    cursor: grab;
    touch-action: pan-y;
}

.ai-hint-sheet-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    color: var(--text);
    font-size: 15px;
    font-weight: 800;
}

.ai-hint-sheet-title .ai-hint-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
}

.ai-hint-report {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    position: relative;
    z-index: 2;
    border: 1px solid rgba(255, 112, 87, 0.45);
    border-radius: 999px;
    background: rgba(255, 112, 87, 0.12);
    color: #ff7057;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.16s ease, background 0.16s ease;
}

.ai-hint-report svg {
    width: 16px;
    height: 16px;
}

.ai-hint-report:active {
    transform: scale(0.94);
    background: rgba(255, 112, 87, 0.18);
}

.ai-hint-sheet-body {
    flex: 0 0 auto;
    overflow: hidden;
}

.ai-hint-box {
    margin-top: 0;
    padding: 8px 10px;
    border: 1px solid rgba(30, 111, 255, 0.28);
    border-radius: var(--radius-sm);
    background: rgba(30, 111, 255, 0.08);
    color: var(--text);
    font-size: 14px;
    line-height: 1.45;
    text-align: left;
    animation: fadeSlideIn 0.25s ease;
    height: 250px;
    max-height: 250px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.ai-hint-box.loading {
    color: var(--text-hint);
}

.ai-hint-message {
    max-width: 92%;
    width: fit-content;
    padding: 7px 9px;
    border-radius: var(--radius-sm);
    margin-bottom: 5px;
    white-space: pre-wrap;
}

.ai-hint-message .katex {
    max-width: 100%;
    white-space: normal;
}

.ai-hint-message .katex-display {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

.ai-hint-message:last-child {
    margin-bottom: 0;
}

.ai-hint-message.assistant {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
}

.ai-hint-message.user {
    margin-left: auto;
    background: rgba(30, 111, 255, 0.18);
    border: 1px solid rgba(30, 111, 255, 0.28);
}

.ai-hint-question-form {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    scroll-margin-bottom: 140px;
}

.ai-hint-question-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 9px 12px;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text);
    font-size: 13px;
    outline: none;
}

.ai-hint-question-input:focus {
    border-color: var(--accent);
}

.ai-hint-question-send {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.ai-hint-question-send svg {
    width: 18px;
    height: 18px;
}

@media (max-width: 640px) {
    .ai-hint-sheet-panel {
        border-radius: var(--radius-sm);
    }

    .ai-hint-box {
        height: 230px;
        max-height: 230px;
    }
}

@media (max-width: 640px) and (max-height: 700px) {
    .ai-hint-box {
        height: 190px;
        max-height: 190px;
    }
}
