:root {
    --primary: #6366F1;
    --secondary: #94A3B8;
    --accent: #22D3EE;
    --bg-main: #0F172A;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-card-hover: rgba(30, 41, 59, 0.9);
    --text-main: #F8FAFC;
    --text-muted: #CBD5E1;
    --radius: 12px;
    --transition: 250ms ease;

    --diff-add-bg: rgba(34, 197, 94, 0.15);
    --diff-add-text: #4ADE80;
    --diff-remove-bg: rgba(239, 68, 68, 0.15);
    --diff-remove-text: #F87171;
    --diff-conflict-bg: rgba(234, 179, 8, 0.1);
    --diff-marker-bg: rgba(99, 102, 241, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
    background-image:
        radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.08), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(34, 211, 238, 0.08), transparent 25%);
}

header {
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--primary);
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(to right, var(--text-main), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    -webkit-text-fill-color: transparent;
}

.header-stats {
    display: flex;
    gap: 1.5rem;
}

.stat-pill {
    background: var(--bg-card);
    padding: 0.5rem 1rem;
    border-radius: 99px;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-pill svg {
    width: 16px;
    height: 16px;
    color: var(--accent);
}

main {
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
}

@media (max-width: 900px) {
    main {
        grid-template-columns: 1fr;
    }
}

.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.glass-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.scenario-title {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.scenario-desc {
    color: var(--secondary);
    font-size: 0.9rem;
}

.difficulty-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.diff-easy {
    background: rgba(34, 197, 94, 0.2);
    color: #4ADE80;
}

.diff-medium {
    background: rgba(234, 179, 8, 0.2);
    color: #FACC15;
}

.diff-hard {
    background: rgba(239, 68, 68, 0.2);
    color: #F87171;
}

.editor-container {
    display: flex;
    flex-direction: column;
}

.editor-toolbar {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.btn {
    background: transparent;
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: #4F46E5;
    border-color: #4F46E5;
}

.btn-secondary {
    color: var(--accent);
    border-color: rgba(34, 211, 238, 0.3);
}

.btn-secondary:hover {
    background: rgba(34, 211, 238, 0.1);
    border-color: var(--accent);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.code-editor {
    background: #1E1E1E;
    /* Standard VS Code dark theme bg */
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    padding: 1rem 0;
    overflow-x: auto;
    min-height: 300px;
}

.code-line {
    display: flex;
    padding: 0 1rem;
}

.line-num {
    color: #6E7681;
    width: 40px;
    text-align: right;
    padding-right: 1rem;
    user-select: none;
    border-right: 1px solid #30363D;
    margin-right: 1rem;
}

.line-content {
    flex: 1;
    white-space: pre;
}

/* Diff Styling */
.diff-marker {
    color: var(--secondary);
    font-weight: bold;
    background-color: var(--diff-marker-bg);
    padding: 0.25rem 1rem;
    border-left: 2px solid var(--primary);
    margin: 0.25rem 0;
}

.diff-ours {
    background-color: var(--diff-add-bg);
}

.diff-ours .line-content {
    color: var(--diff-add-text);
}

.diff-ours::before {
    content: "+";
    color: var(--diff-add-text);
    position: absolute;
    left: 3rem;
}

.diff-theirs {
    background-color: var(--diff-add-bg);
    /* Using add color because standard conflicts treat both as "these are the two versions" visually depending on tool, but typically they are highlighted */
}

.diff-theirs .line-content {
    color: var(--accent);
    /* distinct color for 'theirs' */
}

.diff-theirs::before {
    content: "+";
    color: var(--accent);
    position: absolute;
    left: 3rem;
}

.diff-base {
    background-color: transparent;
}


/* Resolution Controls styling inside toolbar */
.resolution-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

/* Editable mode */
.editable-code {
    width: 100%;
    background: transparent;
    color: var(--text-main);
    border: none;
    font-family: inherit;
    font-size: inherit;
    resize: vertical;
    min-height: 200px;
    padding: 0.5rem;
    outline: none;
}

.editable-code:focus {
    background: rgba(255, 255, 255, 0.02);
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-panel {
    padding: 1.5rem;
}

.sidebar-panel h3 {
    font-size: 1rem;
    color: var(--accent);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hint-content {
    color: var(--secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 8px;
    border-left: 3px solid var(--accent);
    display: none;
}

.hint-content.visible {
    display: block;
    animation: fadeIn 0.3s ease;
}

.term-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.term-item dt {
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.9rem;
}

.term-item dd {
    color: var(--secondary);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Feedback Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
}

.modal-icon.success {
    color: #4ADE80;
}

.modal-icon.error {
    color: #F87171;
}

.modal-title {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.modal-body {
    color: var(--secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
}

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

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

/* Utility to render real raw code with syntax colors if needed */
.kw {
    color: #569CD6;
}

.str {
    color: #CE9178;
}

.func {
    color: #DCDCAA;
}

.cmt {
    color: #6A9955;
}

.var {
    color: #9CDCFE;
}