.material-symbols-outlined {
    font-size: 1.5rem;
    vertical-align: middle;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.material-symbols-outlined.hidden {
    display: none;
}

.no-underline {
    text-decoration: none !important;
}

/* Custom Scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(156, 163, 175, 0.4) transparent;
    scroll-behavior: smooth;
}

.dark * {
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

body {
    font-family: 'Inter', sans-serif;
    scroll-behavior: smooth;
    overscroll-behavior-y: contain;
    /* Disable pull-to-refresh */
}

@media (display-mode: standalone) {
    body {
        overscroll-behavior-y: contain;
    }
}

.dark select {
    background-color: transparent;
}

textarea:focus,
input:focus {
    outline: none;
}

button {
    cursor: pointer;
}

/* Dark mode input colors for studio toolbar */
.dark input[type="number"],
.dark input[type="text"],
.dark input[type="date"],
.dark textarea,
.dark select {
    background-color: #252525 !important;
}

.dark input[type="number"]:focus,
.dark input[type="text"]:focus,
.dark input[type="date"]:focus,
.dark textarea:focus,
.dark select:focus {
    background-color: #282a2c !important;
}

#chat-input {
    overflow-wrap: break-word;
    word-break: break-word;
    word-wrap: break-word;
    max-height: 155px;
}

.chat-container {
    min-height: 0;
}

/* Ensure Tools text is never shown on mobile */
@media (max-width: 999px) {
    #tools-menu-text {
        display: none !important;
    }
}

.sidebar-container {
    height: 100dvh;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Collapsible Sections */
.collapsible-header .chevron {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.collapsible-section.collapsed .chevron {
    transform: rotate(-90deg);
}

.collapsible-content {
    max-height: 2000px;
    /* High enough to show all content */
    opacity: 1;
    overflow: visible;
    transition: max-height 0.3s ease-in-out, opacity 0.2s ease-in-out, padding 0.3s ease-in-out;
}

.collapsible-section.collapsed .collapsible-content {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    pointer-events: none;
    overflow: hidden;
}

.collapsible-header:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.dark .collapsible-header:hover {
    background-color: rgba(255, 255, 255, 0.05);
}


.chat-bubble:hover+.message-controls,
.message-controls:hover {
    opacity: 1 !important;
}

.flex-col:hover .message-controls {
    opacity: 1 !important;
}

body.generating .copy-btn,
body.generating .regenerate-msg-btn,
body.generating .copy-msg-btn,
body.generating .edit-msg-btn {
    display: none !important;
}

/* Large Model Selector Dropdown (Reference Image Style) */
.large-model-selector .custom-select-wrapper {
    margin-top: 8px;
}

.large-model-selector .custom-select-trigger {
    height: 48px;
    border-radius: 24px;
    padding: 0 16px;
    background-color: #f0f4f9;
    border: 1px solid transparent;
    box-shadow: none;
}

.dark .large-model-selector .custom-select-trigger {
    background-color: #1e1f20;
}

.large-model-selector .custom-select-trigger:hover {
    background-color: #e9eef6;
}

.dark .large-model-selector .custom-select-trigger:hover {
    background-color: #282a2c;
}

.large-model-selector .current-value {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 500;
}

.large-model-selector .current-value::before {
    content: "";
    display: inline-block;
    width: 24px;
    height: 24px;
    background-image: url("img/icon_plain.svg");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.large-model-selector .tune-icon {
    display: flex;
    align-items: center;
    color: #5f6368;
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid #dadce0;
}

.dark .large-model-selector .tune-icon {
    color: #9aa0a6;
    border-left-color: #3c4043;
}

/* Sidebar Sections */
#model-options-area {
    scrollbar-width: thin;
}

#user-preferences-area {
    background-color: transparent;
}

.settings-label {
    display: block;
    margin-bottom: 2px;
    color: #444746;
    font-size: 12px;
}

/* Custom Audio Player */
.custom-audio-player {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 400px;
    background: #f0f4f9;
    border-radius: 20px;
    padding: 12px;
    gap: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    user-select: none;
}

.dark .custom-audio-player {
    background: #1e1f20;
    border-color: rgba(255, 255, 255, 0.1);
}

.audio-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.audio-icon-wrapper {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #004a77;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dark .audio-icon-wrapper {
    background: #a8c7fa;
    color: #062e6f;
}

.audio-controls-main {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.play-pause-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #004a77;
    color: white !important;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: none;
    flex-shrink: 0;
}

.play-pause-btn:hover {
    transform: scale(1.05);
    background: #003a5c;
}

.dark .play-pause-btn {
    background: #a8c7fa;
    color: #062e6f !important;
}

.dark .play-pause-btn:hover {
    background: #d3e3fd;
}

.progress-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.progress-bar-wrapper {
    position: relative;
    height: 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    cursor: pointer;
    overflow: visible;
}

.dark .progress-bar-wrapper {
    background: rgba(255, 255, 255, 0.1);
}

.progress-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: #004a77;
    border-radius: 3px;
    width: 0%;
    pointer-events: none;
}

.dark .progress-bar-fill {
    background: #a8c7fa;
}

.progress-thumb {
    position: absolute;
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    background: #004a77;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s;
    pointer-events: none;
}

.progress-bar-wrapper:hover .progress-thumb {
    transform: translate(-50%, -50%) scale(1.2);
}

.dark .progress-thumb {
    background: #a8c7fa;
}

.audio-time {
    font-size: 11px;
    color: #5f6368;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    font-family: monospace;
}

.dark .audio-time {
    color: #9aa0a6;
}

.audio-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.audio-action-btn {
    padding: 6px;
    border-radius: 50%;
    color: #5f6368 !important;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-action-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.dark .audio-action-btn {
    color: #c4c7c5 !important;
}

.dark .audio-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.custom-audio-player .material-symbols-outlined {
    font-size: 24px;
}

.play-pause-btn .material-symbols-outlined {
    font-size: 32px;
}

.dark .settings-label {
    color: #c4c7c5;
}

/* Storage Progress Bar Styles */
.storage-bar-progress {
    transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.4s ease-in-out, box-shadow 0.4s ease-in-out;
}

.storage-bar-progress.safe {
    background: linear-gradient(90deg, #3b82f6, #2563eb);
    box-shadow: 0 0 8px rgba(37, 99, 235, 0.3);
}

.storage-bar-progress.danger {
    background: linear-gradient(90deg, #ef4444, #dc2626);
    box-shadow: 0 0 10px rgba(220, 38, 38, 0.4);
}

.custom-select-wrapper select {
    display: none !important;
}

.map-citation {
    display: inline-flex;
    transition: transform 0.2s ease;
}

.map-citation:hover {
    transform: scale(1.2);
}

/* Citations Styling */
.citations-container {
    vertical-align: super;
    font-size: 0.7em;
    font-weight: 500;
    margin-left: 1px;
    display: inline-flex;
    gap: 1px;
    user-select: none;
}

.citation-link {
    color: #3b82f6;
    text-decoration: none;
    padding: 0 1px;
    border-radius: 2px;
    transition: background-color 0.2s;
    line-height: 1;
}

.citation-link:hover {
    background-color: rgba(59, 130, 246, 0.1);
    text-decoration: underline;
}

.dark .citation-link {
    color: #60a5fa;
}

.dark .citation-link:hover {
    background-color: rgba(96, 165, 250, 0.2);
}

.markdown-body sup.citations-container {
    top: -0.4em;
    position: relative;
}

.chat-bubble {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

/* Quiz Details/Summary Styles */
details summary::-webkit-details-marker {
    display: none;
}

details summary {
    list-style: none;
}

.streaming-glow::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.4), #3b82f6, rgba(59, 130, 246, 0.4), transparent);
    background-size: 200% 100%;
    animation: streaming-loading 1.5s infinite cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0 0 1rem 1rem;
}

.streaming-glow .word-fade-in-inline {
    animation: word-fade-in 0.2s ease-out forwards;
}

@keyframes word-fade-in {
    from {
        opacity: 0;
        transform: translateY(2px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes streaming-loading {
    from {
        background-position: 200% 0;
    }

    to {
        background-position: -200% 0;
    }
}

.markdown-body {
    background-color: transparent !important;
    color: inherit !important;
    font-size: inherit;
    line-height: 1.6 !important;
    transition: opacity 0.2s ease-in-out;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.markdown-body p {
    margin-top: 0.75rem !important;
    margin-bottom: 0.75rem !important;
}

.markdown-body p:first-child {
    margin-top: 0 !important;
}

.markdown-body p:last-child {
    margin-bottom: 0 !important;
}

/* Fix missing list styles due to Tailwind reset */
.markdown-body ul {
    list-style-type: disc !important;
    padding-left: 1.5rem !important;
    margin-top: 0.5rem !important;
    margin-bottom: 0.5rem !important;
}

.markdown-body ol {
    list-style-type: decimal !important;
    padding-left: 1.5rem !important;
    margin-top: 0.5rem !important;
    margin-bottom: 0.5rem !important;
}

.markdown-body li {
    margin-top: 0.25rem;
}

.markdown-body pre {
    background: #f0f4f9 !important;
    padding: 1rem;
    border-radius: 1rem;
    overflow-x: auto;
}

.markdown-body .code-block-container pre {
    background: transparent !important;
    padding: 1rem !important;
    border-radius: 0 !important;
    margin: 0 !important;
}

.markdown-body .code-block-container {
    background: white !important;
}

.dark .markdown-body .code-block-container {
    background: #0d0d0d !important;
}

.dark .markdown-body pre {
    background: #000000 !important;
}

.code-block-container {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dark .code-block-container {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.copy-code-btn:active,
.run-html-btn:active {
    transform: scale(0.95);
}

.html-preview-area iframe {
    background: white;
}

.markdown-body code {
    font-family: 'Fira Code', monospace;
    background-color: transparent !important;
}

.dark .markdown-body code {
    background-color: transparent !important;
}

.dark,
.dark-mode {
    background-color: #131314;
    color: #e3e3e3;
}

/* Quiz specific styles */
#options-container button {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#options-container button:not(:disabled):active {
    transform: scale(0.98);
}

#options-container button:disabled {
    cursor: default;
}

#quiz-overlay {
    animation: slideInUp 0.3s ease-out;
}

@keyframes slideInUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

/* Flashcard styles */
.perspective-1000 {
    perspective: 1000px;
}

/* Quiz UI Enhancements */
.quiz-opt-btn {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: #F1F4F8;
}

.dark .quiz-opt-btn {
    background-color: #1E1F20;
}

.quiz-opt-btn:not(:disabled):hover {
    background-color: #E0E3E7;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dark .quiz-opt-btn:not(:disabled):hover {
    background-color: #2E2F2F;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.quiz-opt-btn:not(:disabled):active {
    transform: translateY(0);
}

.dark .quiz-opt-btn:not(:disabled):hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

details summary::-webkit-details-marker {
    display: none;
}

details summary {
    list-style: none;
}

.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Specific feedback colors from the screenshot */
.dark .quiz-opt-correct {
    border-color: #2e7d32;
    background-color: #1b2e1b;
}

.dark .quiz-opt-incorrect {
    border-color: #d32f2f;
    background-color: #2e1b1b;
}


@keyframes slideInRight {
    from {
        transform: translateX(100%) rotate(15deg);
        opacity: 0;
    }

    to {
        transform: translateX(0) rotate(0deg);
        opacity: 1;
    }
}

@keyframes slideOutLeft {
    from {
        transform: translateX(0) rotate(0deg);
        opacity: 1;
    }

    to {
        transform: translateX(-100%) rotate(-15deg);
        opacity: 0;
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%) rotate(-15deg);
        opacity: 0;
    }

    to {
        transform: translateX(0) rotate(0deg);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0) rotate(0deg);
        opacity: 1;
    }

    to {
        transform: translateX(100%) rotate(15deg);
        opacity: 0;
    }
}

.animate-slide-in-right {
    animation: slideInRight 0.1s ease-out forwards;
}

.animate-slide-out-left {
    animation: slideOutLeft 0.1s ease-out forwards;
}

.animate-slide-in-left {
    animation: slideInLeft 0.1s ease-out forwards;
}

.animate-slide-out-right {
    animation: slideOutRight 0.1s ease-out forwards;
}

.transform-style-3d {
    transform-style: preserve-3d;
}

.backface-hidden {
    backface-visibility: hidden;
}

.rotate-y-180 {
    transform: rotateY(180deg);
}

.text-gray-400,
.text-gray-500,
.text-gray-600,
.model-badge,
.time-badge,
.token-badge,
.message-controls {
    color: #444746 !important;
}

.dark .text-gray-300,
.dark .text-gray-400,
.dark .text-gray-500,
.dark .text-gray-600,
.dark-mode .text-gray-300,
.dark-mode .text-gray-400,
.dark-mode .text-gray-500,
.dark-mode .text-gray-600,
.dark .model-badge,
.dark .time-badge,
.dark .token-badge,
.dark .message-controls {
    color: #c4c7c5 !important;
}

.dark .hover\:text-gray-700:hover,
.dark-mode .hover\:text-gray-700:hover {
    color: #e2e8f0;
}

.dark .text-blue-600,
.dark-mode .text-blue-600 {
    color: #60a5fa;
}

.dark .bg-blue-100,
.dark-mode .bg-blue-100 {
    background-color: #1e3a8a;
}

.dark #chat-input,
.dark-mode #chat-input {
    background-color: transparent !important;
}

.dark .dark\:border-gray-600,
.dark-mode .dark\:border-gray-600 {
    border-color: #4b5563;
}

.dark .hover\:text-blue-600:hover,
.dark-mode .hover\:text-blue-600:hover {
    color: #93c5fd;
}


.thinking-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-spin {
    animation: spin 1s cubic-bezier(0.5, 0, 0.5, 1) infinite !important;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .5;
    }
}

hr {
    height: inherit;
}

#sidebar.is-collapsed {
    width: 68px !important;
}

.sidebar-text,
#history-header,
#history-list {
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

#history-list>div {
    -webkit-touch-callout: none;
}

#sidebar.is-collapsed .sidebar-text,
#sidebar.is-collapsed #history-header,
#sidebar.is-collapsed #history-list {
    opacity: 0;
    pointer-events: none;
}

.sidebar-btn {
    transition-property: padding, background-color, width, transform;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 300ms;
}

.sidebar-btn .material-symbols-outlined {
    transition: margin 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar.is-collapsed .sidebar-btn {
    padding-right: 0 !important;
}

#sidebar.is-collapsed .sidebar-btn .material-symbols-outlined {
    margin-right: 0 !important;
}

.container {
    max-width: unset !important;
}

.line-clamp-5 {
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@keyframes spin-once {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes fadeInFromTop {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-spin-once {
    animation: spin-once 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-fade-in-from-top {
    animation: fadeInFromTop 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Global App Loader */
#app-loader-overlay {
    opacity: 1;
    pointer-events: all;
}

.app-loader {
    position: relative;
}

.app-loader .star-container {
    position: absolute;
    top: 25%;
    left: 25%;
    width: 50%;
    height: 50%;
}

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

.app-loader .spinner-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.app-loader .arc {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    transform-origin: 50px 50px;
    animation-duration: 6s;
    animation-iteration-count: infinite;
    animation-timing-function: ease-in-out;
    opacity: 0;
}

.app-loader .arc-blue {
    stroke: #4285F4;
    animation-name: anim-fast-blue;
}

.app-loader .arc-orange {
    stroke: url(#grad-orange);
    animation-name: anim-slow-orange;
}

.app-loader .arc-green {
    stroke: url(#grad-green);
    animation-name: anim-slow-green;
}

@keyframes anim-fast-blue {
    0% {
        opacity: 1;
        stroke-dasharray: 1, 251;
        stroke-dashoffset: 0;
        transform: rotate(-90deg);
    }

    10% {
        opacity: 1;
        stroke-dasharray: 80, 251;
        stroke-dashoffset: -20;
        transform: rotate(90deg);
    }

    20% {
        opacity: 1;
        stroke-dasharray: 1, 251;
        stroke-dashoffset: -250;
        transform: rotate(270deg);
    }

    20.01% {
        opacity: 0;
    }

    49.99% {
        opacity: 0;
        transform: rotate(-90deg);
        stroke-dashoffset: 0;
        stroke-dasharray: 1, 251;
    }

    50% {
        opacity: 1;
        stroke-dasharray: 1, 251;
        stroke-dashoffset: 0;
        transform: rotate(-90deg);
    }

    60% {
        opacity: 1;
        stroke-dasharray: 80, 251;
        stroke-dashoffset: -20;
        transform: rotate(90deg);
    }

    70% {
        opacity: 1;
        stroke-dasharray: 1, 251;
        stroke-dashoffset: -250;
        transform: rotate(270deg);
    }

    70.01% {
        opacity: 0;
    }

    100% {
        opacity: 0;
    }
}

@keyframes anim-slow-orange {

    0%,
    19.99% {
        opacity: 0;
    }

    20% {
        opacity: 1;
        stroke-dasharray: 1, 251;
        stroke-dashoffset: 0;
        transform: rotate(-90deg);
    }

    35% {
        opacity: 1;
        stroke-dasharray: 180, 251;
        stroke-dashoffset: -20;
        transform: rotate(45deg);
    }

    50% {
        opacity: 1;
        stroke-dasharray: 1, 251;
        stroke-dashoffset: -250;
        transform: rotate(270deg);
    }

    50.01%,
    100% {
        opacity: 0;
    }
}

@keyframes anim-slow-green {

    0%,
    69.99% {
        opacity: 0;
    }

    70% {
        opacity: 1;
        stroke-dasharray: 1, 251;
        stroke-dashoffset: 0;
        transform: rotate(-90deg);
    }

    85% {
        opacity: 1;
        stroke-dasharray: 180, 251;
        stroke-dashoffset: -20;
        transform: rotate(45deg);
    }

    100% {
        opacity: 1;
        stroke-dasharray: 1, 251;
        stroke-dashoffset: -250;
        transform: rotate(270deg);
    }
}

.katex-display {
    margin: 0.5rem;
}

@media (max-width: 1000px) {
    .user-message .chat-bubble {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
}