:root {
    /* Query Gold Palette */
    --primary: #EAB308;
    --primary-glow: rgba(234, 179, 8, 0.4);
    --secondary: #FACC15;
    --accent: #3B82F6;
    --accent-glow: rgba(59, 130, 246, 0.4);

    --bg-dark: #0F0D08;
    --bg-panel: #1A1710;
    --bg-input: #262217;

    --text-main: #FFFFFF;
    --text-muted: #A3A199;
    --text-dark: #12100A;
    --border: #3D3624;

    --success: #22C55E;
    --warning: #F97316;
    --danger: #EF4444;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.code-font {
    font-family: var(--font-mono);
}

.mt-2 {
    margin-top: 1rem;
}

.mt-4 {
    margin-top: 2rem;
}

/* Base Components */
.layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(26, 23, 16, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
}

.brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.5px;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.dialect-select {
    background: var(--bg-input);
    color: var(--secondary);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.dialect-select:focus {
    outline: none;
    border-color: var(--primary);
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    outline: none;
}

.btn-xl {
    padding: 1rem 1.5rem;
    font-size: 1.05rem;
}

.sm-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.full-width {
    width: 100%;
}

.primary-btn {
    background: var(--primary);
    color: var(--text-dark);
    box-shadow: 0 4px 14px var(--primary-glow);
}

.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--primary-glow);
    background: var(--secondary);
}

.secondary-btn {
    background: rgba(234, 179, 8, 0.15);
    color: var(--secondary);
    border: 1px solid rgba(234, 179, 8, 0.3);
}

.secondary-btn:hover {
    background: rgba(234, 179, 8, 0.25);
    color: white;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    color: var(--primary);
    background: rgba(234, 179, 8, 0.1);
}

/* Workspace */
.workspace {
    flex-grow: 1;
    display: flex;
    overflow: hidden;
    background: radial-gradient(circle at top left, rgba(234, 179, 8, 0.03), transparent 60%);
}

.panel {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.input-panel {
    border-right: 1px solid var(--border);
    max-width: 500px;
    background: rgba(26, 23, 16, 0.4);
}

.input-panel::-webkit-scrollbar {
    width: 6px;
}

.input-panel::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.output-panel {
    flex-grow: 1;
    background: var(--bg-dark);
    position: relative;
}

.output-panel::-webkit-scrollbar {
    width: 8px;
}

.output-panel::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.panel-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
}

.badge {
    background: rgba(234, 179, 8, 0.2);
    color: var(--primary);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge.secondary {
    background: rgba(59, 130, 246, 0.2);
    color: var(--accent);
}

/* Input Area */
.editor-container {
    display: flex;
    flex-direction: column;
}

.modern-textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    line-height: 1.6;
    resize: vertical;
    min-height: 300px;
    transition: var(--transition);
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}

.explain-container .modern-textarea {
    min-height: 150px;
    color: var(--text-muted);
}

.modern-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: inset 0 0 0 1px var(--primary);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

.empty-state svg {
    color: var(--border);
    margin-bottom: 1.5rem;
    width: 64px;
    height: 64px;
}

.empty-state h3 {
    font-size: 1.25rem;
    color: white;
    margin-bottom: 0.5rem;
}

.empty-state p {
    max-width: 400px;
    line-height: 1.5;
}

.hidden {
    display: none !important;
}

/* Analysis Results */
.analysis-results {
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.4s ease forwards;
}

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

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

/* Score Card */
.score-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.score-circle {
    width: 100px;
    height: 100px;
}

.circular-chart {
    display: block;
    margin: 0 auto;
    max-width: 80%;
    max-height: 250px;
}

.circle-bg {
    fill: none;
    stroke: var(--bg-input);
    stroke-width: 3.8;
}

.circle {
    fill: none;
    stroke-width: 3.8;
    stroke-linecap: round;
    transition: stroke-dasharray 1s ease-out;
}

.percentage {
    fill: white;
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 700;
    text-anchor: middle;
}

.score-details h2 {
    font-size: 1.5rem;
    color: white;
    margin-bottom: 0.5rem;
}

.score-details p {
    color: var(--text-muted);
    line-height: 1.5;
}

/* Colors based on JS logic injected to path stroke */
.score-excellent {
    stroke: var(--success);
}

.score-good {
    stroke: var(--primary);
}

.score-poor {
    stroke: var(--danger);
}

/* Issues Grid */
.issues-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.issue-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
}

.issue-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

.issue-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: white;
}

.issue-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 1.2rem;
}

.index-icon {
    background: rgba(59, 130, 246, 0.2);
}

.n1-icon {
    background: rgba(239, 68, 68, 0.2);
}

.join-icon {
    background: rgba(234, 179, 8, 0.2);
}

.issue-list {
    list-style: none;
}

.issue-list li {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.issue-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.issue-list li code {
    color: var(--secondary);
    background: var(--bg-input);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-weight: bold;
}

.issue-ok {
    color: var(--success) !important;
    font-weight: 500;
}

/* Rewrite Section */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h3 {
    font-size: 1.1rem;
    color: white;
}

.code-block {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    overflow-x: auto;
}

.code-block pre {
    color: var(--primary);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Visual Plan Tree */
.plan-section {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 2rem;
}

.tree-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.tree-node {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-main);
    position: relative;
}

.tree-node.indent-1 {
    margin-left: 2rem;
}

.tree-node.indent-2 {
    margin-left: 4rem;
}

.tree-node.indent-3 {
    margin-left: 6rem;
}

.node-op {
    font-weight: 700;
    color: var(--accent);
}

.node-alert {
    color: var(--danger);
    margin-left: auto;
    font-weight: bold;
}

.plan-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--primary);
    color: var(--text-dark);
    padding: 1rem 1.5rem;
    border-radius: 30px;
    font-weight: 600;
    box-shadow: 0 10px 25px var(--primary-glow);
    transition: var(--transition);
    z-index: 1000;
}

.toast.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}