:root {
    /* Palette: Slate-like colors */
    --bg-body: #0f172a;
    --bg-body: #020617;
    --bg-header: rgba(15, 23, 42, 0.5);
    --bg-card: rgba(30, 41, 59, 0.6);
    --bg-card-solid: #1e293b;
    --bg-input: #334155;
    --bg-output: #020617;
    --bg-output: #0f172a;
    /* Very dark slate */

    /* Text Colors */
    --text-main: #f8fafc;
    --text-muted: #a8b2c2;
    --text-dim: #808d9f;

    /* Accents */
    --primary: #0284c7;
    /* Sky 600 */
    --primary-hover: #0ea5e9;
    /* Sky 500 */
    --border-color: #1e293b;
    --border-hover: #38bdf8;

    /* Danger */
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);

    /* Success */
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.2);

    /* Spacing & Sizing */
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-full: 9999px;
    --header-height: 4rem;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}



body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-input);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* Icons */
svg.icon {
    width: 1.25rem;
    height: 1.25rem;
    display: block;
}

svg.icon-lg {
    width: 3rem;
    height: 3rem;
}

svg.icon-sm {
    width: 0.875rem;
    height: 0.875rem;
}

/* Utility Helpers */
.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 0.5rem;
}

.text-center {
    text-align: center;
}

/* -----------------------------------------------------------------------------
           2. Layout Components
           ----------------------------------------------------------------------------- */

/* Header */
header {
    height: var(--header-height);
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-header);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 10;
    flex-shrink: 0;
}

.header-inner {
    max-width: 80rem;
    margin: 0 auto;
    padding: 0 0.5rem;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-box {
    background-color: var(--primary);
    padding: 6px;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;

    svg{
        filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.8));
    }
}

.app-title {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(to right, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    color: transparent;
}

/* Main Container */
main {
    flex: 1;
    width: 100%;
    max-width: 80rem;
    margin: 0 auto;
    padding: 0.5rem;
    overflow: hidden;
}

.grid-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 0.5rem;
    height: 100%;
}

@media (max-width: 640px) {
    body {
        overflow: auto;
    }

    main {
        height: auto;
        overflow: visible;
    }

    .grid-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .sidebar {
        height: auto;
        padding-right: 0;
        padding-bottom: 1em;
    }

    .output-panel-container {
        height: 60vh;
    }
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    padding-right: 4px;
}

.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.55rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(4px);
}

.card-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-main);
    margin-bottom: 1rem;
}

/* Toggle Switch */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.toggle-label {
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.2s;
}

.toggle-row:hover .toggle-label {
    color: #7dd3fc;
}

.toggle-switch {
    position: relative;
    width: 2.75rem;
    height: 1.5rem;
    background-color: var(--bg-input);
    border-radius: var(--radius-full);
    transition: background-color 0.2s;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 1.25rem;
    height: 1.25rem;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

input[type="checkbox"]:checked+.toggle-switch {
    background-color: var(--primary);
}

input[type="checkbox"]:checked+.toggle-switch::after {
    transform: translateX(1.25rem);
}

/* Style Buttons Grid */
.style-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn-style {
    padding: 0.35rem;
    font-size: 0.75rem;
    border: 1px solid var(--bg-input);
    background-color: var(--bg-card-solid);
    color: var(--text-muted);
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-style:hover {
    border-color: var(--text-dim);
}

.btn-style.active {
    background-color: rgba(2, 132, 199, 0.2);
    border-color: var(--primary);
    color: #38bdf8;
    font-weight: 500;
}

/* Collapsible Section */
.collapsible {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    max-height: 0;
    opacity: 0.5;
}

.collapsible.open {
    max-height: 12rem;
    opacity: 1;
}

.file-list-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

.file-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.btn-text-danger {
    background: none;
    border: none;
    color: #f87171;
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid black;
}

.btn-text-danger:hover {
    background-color: var(--danger-bg);
    border: 1px solid var(--danger);
}

.file-list-container {
    flex: 1;
    overflow-y: auto;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-height: 100px;
}

/* Empty State */
.empty-state {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--bg-input);
    border-radius: var(--radius-lg);
    background-color: rgba(30, 41, 59, 0.3);
    color: var(--text-muted);
    padding: 2rem;
    text-align: center;
}

/* File Item */
.file-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background-color: var(--bg-card-solid);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: grab;
    transition: all 0.2s;
    user-select: none;
}

.file-item:active {
    cursor: grabbing;
}

.file-item:hover {
    border-color: rgba(56, 189, 248, 0.5);
    background-color: #263345;
}

.file-item.dragging {
    opacity: 0.4;
}

.file-index {
    width: 2rem;
    height: 2rem;
    background-color: var(--bg-input);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-main);
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 0.75rem;
    color: var(--text-dim);
    font-family: monospace;
}

.btn-remove {
    background: none;
    border: none;
    color: var(--text-dim);
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
}

.file-item:hover .btn-remove {
    opacity: 1;
}

.btn-remove:hover {
    color: var(--danger);
    background-color: var(--danger-bg);
}

/* Action Buttons Area */
.actions-area {
    padding-top: 0.5rem;
    border-top: 1px solid rgba(51, 65, 85, 0.5);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.btn-primary,
.btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid var(--border-color); /* Added border */
    width: 100%;
}

.btn-secondary {
    background-color: var(--bg-input);
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: #475569;
    border-color: var(--primary-hover); /* Added border hover */
}

.btn-secondary:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover); /* Added border hover */
}

.btn-primary:active {
    transform: scale(0.98);
}

.output-panel-container {
    flex: 1;
    background-color: var(--bg-output);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.3);
    height: 100%;
}

.output-toolbar {
    background-color: rgba(15, 23, 42, 0.5);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.window-controls {
    display: flex;
    gap: 0.375rem;
}

.dot {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
}

.dot-red {
    background-color: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.5);
}

.dot-yellow {
    background-color: rgba(234, 179, 8, 0.2);
    border: 1px solid rgba(234, 179, 8, 0.5);
}

.dot-green {
    background-color: rgba(34, 197, 94, 0.2);
    border: 1px solid rgba(34, 197, 94, 0.5);
}

.line-counter {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 1rem;
}

.btn-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    background-color: var(--bg-card);
    color: var(--text-main);
    transition: all 0.2s;
}

.btn-toolbar:hover {
    background-color: var(--bg-input);
}

.btn-toolbar.success {
    background-color: var(--success-bg);
    border-color: rgba(34, 197, 94, 0.3);
    color: #4ade80;
}

.btn-toolbar.primary {
    background-color: var(--primary);
    color: white;
}

.btn-toolbar.primary:hover {
    background-color: var(--primary-hover);
}

.output-content {
    flex: 1;
    overflow: auto;
    font-family: monospace;
    font-size: 0.875rem;
    color: #e2e8f0;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Highlight flash animation */
@keyframes highlightFlash {
    0% {
        background-color: rgba(14, 165, 233, 0.2);
    }

    100% {
        background-color: transparent;
    }
}

.flash-highlight {
    animation: highlightFlash 1s ease-out;
}

.drag-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    background-color: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.drag-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.bounce-box {
    background-color: var(--bg-card-solid);
    padding: 1.5rem;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
    animation: bounce 1s infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(-10%);
    }

    50% {
        transform: translateY(10%);
    }
}

.drag-title {
    font-size: 2.25rem;
    font-weight: 700;
    color: white;
    margin-bottom: 1rem;
}

.drag-subtitle {
    font-size: 1.125rem;
    color: var(--text-muted);
}

.drag-placeholder-bar {
    height: 4px;
    background-color: var(--primary);
    border-radius: 99px;
    margin: 4px 0;
    pointer-events: none;
}

.output-content span {
    border-bottom: 1px solid var(--border-color);
    padding-right: 1em;
    padding-left: 1em;
}

.output-content span:nth-child(odd) {
    background-color: rgba(2, 132, 199, 0.02);
}

.output-content span:nth-child(even) {
    background-color: rgba(15, 23, 42, 0.1);
}

.output-content span:last-child {
    padding-bottom: 1em;
}

.output-content span:first-child {
    padding-top: 1em;
}