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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: #f8f9fa;
    color: #1a1a2e;
    min-height: 100vh;
}

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.header {
    padding: 0.9rem 2rem;
    border-bottom: 1px solid #e2e5ea;
    background: #fff;
    display: flex;
    align-items: baseline;
    gap: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #1a1a2e;
}

.header h1 span {
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: #9ca3af;
    font-size: 0.82rem;
    font-weight: 400;
}

.main {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 49px);
}

.panel {
    flex: 1;
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.left-panel {
    border-right: 1px solid #e2e5ea;
    max-width: 50%;
    background: #fff;
}

.right-panel {
    background: #f8f9fa;
}

h2 {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #9ca3af;
}

h3 {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #b0b8c4;
}

.editor {
    width: 100%;
    flex: 1;
    min-height: 160px;
    padding: 0.875rem 1rem;
    background: #fff;
    border: 1.5px solid #e2e5ea;
    border-radius: 8px;
    color: #1a1a2e;
    font-family: 'JetBrains Mono', 'Fira Code', 'Menlo', monospace;
    font-size: 0.875rem;
    line-height: 1.65;
    resize: vertical;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.editor:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.examples { display: flex; flex-direction: column; gap: 0.4rem; }

.example-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.example-btn {
    padding: 0.25rem 0.65rem;
    font-size: 0.75rem;
    background: #f1f3f6;
    border: 1px solid #e2e5ea;
    border-radius: 5px;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.12s;
    font-family: inherit;
}

.example-btn:hover {
    background: #e8edf5;
    color: #1a1a2e;
    border-color: #3b82f6aa;
}

.output-wrap {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.katex-output {
    padding: 1.75rem 2rem;
    background: #fff;
    border: 1.5px solid #e2e5ea;
    border-radius: 8px;
    min-height: 80px;
    font-size: 1.15rem;
    line-height: 2.2;
    overflow-x: auto;
    color: #1a1a2e;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.raw-details summary {
    font-size: 0.72rem;
    color: #9ca3af;
    cursor: pointer;
    user-select: none;
    padding: 0.25rem 0;
    list-style: none;
}

.raw-details summary::before {
    content: '▸  LaTeX source';
}

.raw-details[open] summary::before {
    content: '▾  LaTeX source';
}

.raw-details summary * { display: none; }

.raw-latex {
    margin-top: 0.5rem;
    padding: 0.875rem 1rem;
    background: #fff;
    border: 1.5px solid #e2e5ea;
    border-radius: 8px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.78rem;
    color: #6b7280;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.6;
}

.error {
    padding: 0.875rem 1rem;
    background: #fef2f2;
    border: 1.5px solid #fecaca;
    border-radius: 8px;
    color: #dc2626;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
}

@media (max-width: 768px) {
    .main { flex-direction: column; height: auto; }
    .left-panel { max-width: 100%; border-right: none; border-bottom: 1px solid #e2e5ea; }
}
