.font-inter {
    font-family: 'Inter', sans-serif;
}

.code-font {
    font-family: 'JetBrains Mono', monospace;
}

/* --- SCROLLBARS (Cross-browser) --- */
* {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.dark * {
    scrollbar-color: #334155 transparent;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.dark ::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* --- LOADER --- */
.loader {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(16, 185, 129, 0.2);
    border-top-color: #10b981;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- ANIMATIONS --- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

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

.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

.animate-shake {
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-3px);
    }

    75% {
        transform: translateX(3px);
    }
}

/* Slide in from right */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

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

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

/* Slide in from left */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

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

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

/* Scale in */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-scale-in {
    animation: scaleIn 0.3s ease-out forwards;
}

/* Bounce */
@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.animate-bounce {
    animation: bounce 0.5s ease-in-out;
}

/* Pulse glow */
@keyframes pulseGlow {

    0%,
    100% {
        box-shadow: 0 0 5px rgba(16, 185, 129, 0.3);
    }

    50% {
        box-shadow: 0 0 15px rgba(16, 185, 129, 0.6);
    }
}

.animate-pulse-glow {
    animation: pulseGlow 2s ease-in-out infinite;
}

/* Rotate */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

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

.animate-rotate {
    animation: rotate 1s linear infinite;
}

/* Fade in up */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.animate-fade-in-up {
    animation: fadeInUp 0.4s ease-out forwards;
}

/* Success checkmark */
@keyframes checkmark {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.animate-checkmark {
    animation: checkmark 0.4s ease-out forwards;
}

/* Button Glow */
@keyframes glow-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
    }
}

.run-btn-glowing {
    animation: glow-pulse 1.5s infinite;
}

/* Convert Panel Animation */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
        max-height: 0;
    }

    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 200px;
    }
}

@keyframes slideUp {
    from {
        opacity: 1;
        transform: translateY(0);
        max-height: 200px;
    }

    to {
        opacity: 0;
        transform: translateY(-20px);
        max-height: 0;
    }
}

.convert-panel-show {
    animation: slideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    display: block !important;
}

.convert-panel-hide {
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.6, 1) forwards;
}

/* Sidebar */
@keyframes slideInSoft {
    from {
        opacity: 0;
        transform: translateX(-30px) scale(0.98);
    }

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

.sidebar-animate-open {
    animation: slideInSoft 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* --- UI COMPONENTS --- */
.mode-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: all 0.2s;
    position: relative;
    flex-shrink: 0;
}

.dark .mode-btn {
    color: #94a3b8;
}

.mode-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.dark .mode-btn:hover {
    background: #1e293b;
    color: #fff;
}

.active-mode {
    background: #10b981 !important;
    color: white !important;
    box-shadow: 0 4px 10px -2px rgba(16, 185, 129, 0.4);
    transform: scale(1.1);
}

.action-icon-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #94a3b8;
    transition: all 0.2s;
}

.action-icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #10b981;
}

.sidebar-tab {
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    color: #475569;
}

.dark .sidebar-tab {
    color: #94a3b8;
}

.sidebar-tab:hover {
    background-color: #f1f5f9;
}

.dark .sidebar-tab:hover {
    background-color: #1e293b;
}

.active-sidebar-tab {
    background-color: rgba(16, 185, 129, 0.1);
    color: #059669;
    border-color: #bae6fd;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

.dark .active-sidebar-tab {
    background-color: rgba(52, 211, 153, 0.2);
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.3);
}

/* Prism Overrides */
pre[class*="language-"] {
    margin: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
}

/* Tour */
.tour-highlight {
    position: relative !important;
    z-index: 999 !important;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.5), 0 10px 25px -5px rgba(0, 0, 0, 0.4) !important;
    border-radius: 12px;
    pointer-events: auto !important;
}

.tour-highlight.code-font {
    background-color: white;
}

.dark .tour-highlight.code-font {
    background-color: #0f172a;
}

/* --- LINE NUMBERS EDITOR --- */
.editor-wrapper {
    position: absolute;
    inset: 0;
    display: flex;
    overflow: hidden;
}

.line-numbers {
    width: 45px;
    flex-shrink: 0;
    text-align: right;
    padding: 20px 8px 20px 0;
    color: #94a3b8;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
    user-select: none;
    overflow: hidden;
}

.dark .line-numbers {
    background: #0f172a;
    border-color: #1e293b;
    color: #475569;
}

#input-code {
    flex: 1;
    border: none;
    resize: none;
    padding: 20px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
    background: transparent;
    color: inherit;
    white-space: pre;
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

/* --- 3D EFFECTS --- */
.perspective-1000 {
    perspective: 1000px;
}

.hero-grid-3d {
    transform: rotateY(-12deg) rotateX(6deg);
    transform-style: preserve-3d;
    transition: transform 0.7s ease-out;
    will-change: transform;
}

.hero-grid-3d:hover {
    transform: rotateY(0) rotateX(0);
}

/* --- TYPING EFFECT --- */
.typing-effect {
    overflow: hidden;
    border-right: .15em solid #10b981;
    white-space: nowrap;
    margin: 0 auto;
    letter-spacing: .15em;
    animation:
        typing 3.5s steps(40, end),
        blink-caret .75s step-end infinite;
}

@keyframes typing {
    from {
        width: 0
    }

    to {
        width: 100%
    }
}

@keyframes blink-caret {

    from,
    to {
        border-color: transparent
    }

    50% {
        border-color: #10b981;
    }
}

#input-code:focus {
    outline: none;
}

/* --- TYPEWRITER CURSOR --- */
.typing-cursor::after {
    content: '|';
    animation: blink 1s step-start infinite;
    color: #10b981;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

/* --- ACCESSIBILITY --- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid #10b981;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Skip link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #10b981;
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-link:focus {
    top: 0;
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* --- MOBILE OPTIMIZATIONS --- */
@media (max-width: 768px) {

    /* Ensure minimum touch target size (44x44px) */
    button,
    .mode-btn,
    .toolbar-btn-icon,
    a[role="button"] {
        min-width: 44px;
        min-height: 44px;
    }

    /* Optimize spacing for mobile */
    .p-4 {
        padding: 0.75rem;
    }

    .p-5 {
        padding: 1rem;
    }

    .p-6 {
        padding: 1.25rem;
    }

    /* Smaller text on mobile */
    .text-sm {
        font-size: 0.875rem;
    }

    .text-xs {
        font-size: 0.75rem;
    }

    /* Optimize header for mobile */
    header {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    /* Hide resize handle on mobile */
    #resize-handle {
        display: none !important;
    }

    /* Stack sections vertically on mobile */
    .flex-row {
        flex-direction: column !important;
    }

    /* Full width sections on mobile */
    #input-section,
    #output-section {
        width: 100% !important;
        flex: 1 1 100% !important;
        min-height: 50vh !important;
    }

    /* Optimize dialogs for mobile */
    .fixed.inset-0>div {
        margin: 1rem !important;
        max-width: calc(100% - 2rem) !important;
    }

    /* Better scrollbar on mobile */
    .custom-scrollbar {
        scrollbar-width: thin;
    }

    /* Optimize code blocks */
    pre,
    code {
        font-size: 0.75rem !important;
        line-height: 1.5 !important;
    }

    /* Better spacing in output */
    #output-container {
        padding: 1rem !important;
    }

    /* Optimize buttons */
    .mode-btn {
        width: 44px;
        height: 44px;
    }

    /* Toast positioning for mobile */
    #toast {
        top: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: calc(100% - 2rem);
    }

    /* Mobile view toggle styles */
    #mobile-view-toggle {
        backdrop-filter: blur(10px);
        background: rgba(255, 255, 255, 0.95) !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    }

    .dark #mobile-view-toggle {
        background: rgba(15, 23, 42, 0.95) !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }

    .mobile-view-tab {
        color: #64748b;
        background: transparent;
        border: none;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
        min-width: 80px;
        transition: all 0.2s;
        white-space: nowrap;
    }

    .mobile-view-tab.active {
        background: #10b981;
        color: white;
        box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
    }

    .dark .mobile-view-tab {
        color: #94a3b8;
    }

    .dark .mobile-view-tab.active {
        background: #10b981;
        color: white;
    }

    .mobile-view-tab:active {
        transform: scale(0.95);
    }

    /* Hide sections on mobile by default (except input) */
    .mobile-section.hidden {
        display: none !important;
    }

    /* Show sections on desktop */
    @media (min-width: 768px) {
        .mobile-section {
            display: flex !important;
        }

        #mobile-view-toggle {
            display: none !important;
        }
    }

    /* Better spacing for mobile sections */
    #input-section.mobile-section,
    #output-section.mobile-section {
        min-height: calc(100vh - 56px - 80px) !important;
        /* header + toggle */
        max-height: calc(100vh - 56px - 80px) !important;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {

    /* Larger touch targets */
    button,
    .mode-btn,
    .toolbar-btn-icon {
        min-width: 48px;
        min-height: 48px;
    }

    /* Remove hover effects on touch devices */
    *:hover {
        transform: none !important;
    }

    /* Better tap feedback */
    button:active,
    .mode-btn:active,
    .toolbar-btn-icon:active {
        opacity: 0.7;
        transform: scale(0.95);
    }

    /* Prevent text selection on buttons */
    button,
    .mode-btn {
        -webkit-tap-highlight-color: rgba(16, 185, 129, 0.2);
        -webkit-touch-callout: none;
        user-select: none;
    }
}

/* Small screens (phones) */
@media (max-width: 480px) {

    /* Even more compact spacing */
    .p-3 {
        padding: 0.5rem;
    }

    .p-4 {
        padding: 0.75rem;
    }

    /* Smaller header */
    header {
        height: 56px !important;
        padding: 0.5rem !important;
    }

    /* Hide less important elements */
    #active-mode-display span {
        display: none;
    }

    /* Compact mode buttons */
    .mode-btn {
        width: 40px;
        height: 40px;
        font-size: 0.875rem;
    }

    /* Smaller font sizes */
    .text-base {
        font-size: 0.875rem;
    }

    .text-lg {
        font-size: 1rem;
    }

    /* Optimize sidebar */
    #sidebar {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Full screen dialogs on very small screens */
    .fixed.inset-0>div {
        margin: 0.5rem !important;
        border-radius: 0.75rem !important;
    }

    /* Better input area on mobile */
    #input-code {
        font-size: 13px !important;
        padding: 16px !important;
    }

    .line-numbers {
        width: 40px !important;
        padding: 16px 4px 16px 0 !important;
        font-size: 13px !important;
    }
}

/* Landscape mobile optimization */
@media (max-width: 768px) and (orientation: landscape) {
    header {
        height: 48px !important;
    }

    #input-section,
    #output-section {
        min-height: calc(100vh - 48px) !important;
    }
}

/* Prevent horizontal scroll on mobile */
@media (max-width: 768px) {

    body,
    html {
        overflow-x: hidden;
        max-width: 100vw;
    }

    * {
        max-width: 100%;
    }

    /* Fix for code blocks */
    pre {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Better text selection */
    * {
        -webkit-tap-highlight-color: rgba(16, 185, 129, 0.1);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .mode-btn {
        border: 2px solid currentColor;
    }

    .active-mode {
        border-width: 3px;
    }
}

/* Hide scrollbar but keep functionality */
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

/* --- TOOLBAR BUTTONS (Icon-only, like mode buttons) --- */
.toolbar-btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: all 0.2s ease;
    position: relative;
    flex-shrink: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
}

.dark .toolbar-btn-icon {
    color: #94a3b8;
}

.toolbar-btn-icon:hover {
    background: #e2e8f0;
    color: #0f172a;
    transform: scale(1.05);
}

.dark .toolbar-btn-icon:hover {
    background: #1e293b;
    color: #fff;
}

.toolbar-btn-icon:active {
    transform: scale(0.95);
}

.toolbar-btn-icon i {
    transition: transform 0.2s ease;
}

.toolbar-btn-icon:hover i {
    transform: scale(1.1);
}

/* Danger button (clear) */
.toolbar-btn-icon.toolbar-btn-danger {
    color: #dc2626;
}

.dark .toolbar-btn-icon.toolbar-btn-danger {
    color: #f87171;
}

.toolbar-btn-icon.toolbar-btn-danger:hover {
    background: #fee2e2;
    color: #b91c1c;
}

.dark .toolbar-btn-icon.toolbar-btn-danger:hover {
    background: #7f1d1d;
    color: #fca5a5;
}

/* Legacy toolbar-btn for backward compatibility */
.toolbar-btn {
    min-width: 40px;
    height: 36px;
    padding: 0 14px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: all 0.2s ease;
    position: relative;
    flex-shrink: 0;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    font-size: 14px;
    gap: 6px;
}

.dark .toolbar-btn {
    color: #94a3b8;
    background: #1e293b;
    border-color: #334155;
}

.toolbar-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
    border-color: #cbd5e1;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.dark .toolbar-btn:hover {
    background: #334155;
    color: #fff;
    border-color: #475569;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.toolbar-btn:active {
    transform: scale(0.95) translateY(0);
}

.toolbar-btn i {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    width: 18px;
    height: 18px;
    transition: transform 0.2s ease;
}

.toolbar-btn-text {
    flex-shrink: 0;
    user-select: none;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.toolbar-btn:hover i {
    transform: scale(1.15);
}

/* --- FILE TABS --- */
.file-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    max-width: 200px;
}

.dark .file-tab {
    color: #94a3b8;
}

.file-tab:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.dark .file-tab:hover {
    background: #1e293b;
    color: #fff;
}

.file-tab.active {
    background: #10b981;
    color: white;
    border-color: #10b981;
}

.file-tab .close-tab {
    margin-left: 6px;
    padding: 2px;
    border-radius: 3px;
    opacity: 0.6;
    transition: all 0.2s;
}

.file-tab .close-tab:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
}

/* --- DIALOG ANIMATIONS --- */
@keyframes dialogFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }

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

.dialog-open {
    animation: dialogFadeIn 0.3s ease-out forwards;
}

/* --- FILE ANIMATIONS --- */
@keyframes fileSlideIn {
    from {
        opacity: 0;
        transform: translateX(-20px) scale(0.9);
    }

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

.file-tab-new {
    animation: fileSlideIn 0.3s ease-out;
}

@keyframes fileSlideOut {
    0% {
        opacity: 1;
        transform: translateX(0);
        max-width: 200px;
        padding-left: 12px;
        padding-right: 12px;
        margin-right: 4px;
    }

    50% {
        opacity: 0.5;
        transform: translateX(10px);
    }

    100% {
        opacity: 0;
        transform: translateX(30px);
        max-width: 0;
        padding-left: 0;
        padding-right: 0;
        margin-right: 0;
    }
}

.file-tab-closing {
    animation: fileSlideOut 0.2s ease-in forwards;
    overflow: hidden;
    pointer-events: none;
}

/* Editor transition */
#input-code {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Toolbar button animations */
.toolbar-btn {
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.toolbar-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

.toolbar-btn:active::before {
    width: 200%;
    height: 200%;
}

/* --- VERSION HISTORY ITEM --- */
.version-item {
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.2s;
}

.dark .version-item {
    background: #1e293b;
    border-color: #334155;
}

.version-item:hover {
    border-color: #10b981;
    background: #f0fdf4;
}

.dark .version-item:hover {
    background: #064e3b;
    border-color: #10b981;
}

.version-item.active {
    border-color: #10b981;
    background: #d1fae5;
}

.dark .version-item.active {
    background: #065f46;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.history-title {
    flex-grow: 1;
    padding-right: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-badge {
    background: #10b981;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    margin-left: 8px;
    flex-shrink: 0;
}