:root {
    --bg-main: #f8fafc;
    --border-light: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --brand: #0f172a;
    
    /* Note Colors */
    --color-fact-bg: #eff6ff; /* blue */
    --color-fact-border: #bfdbfe;
    --color-finding-bg: #fdf2f8; /* pink/red */
    --color-finding-border: #fbcfe8;
    --color-definition-bg: #f0fdf4; /* green */
    --color-definition-border: #bbf7d0;
    --color-statistic-bg: #fefce8; /* yellow */
    --color-statistic-border: #fef08a;
    --color-concept-bg: #faf5ff; /* purple */
    --color-concept-border: #e9d5ff;
    --color-quote-bg: #f8fafc; /* gray */
    --color-quote-border: #cbd5e1;
    --color-action-bg: #fff1f2; /* red */
    --color-action-border: #fecdd3;
    
    /* Default fallback card color */
    --color-default-bg: #ffffff;
    --color-default-border: #e2e8f0;
}

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

body {
    font-family: 'DM Sans', -apple-system, blinkmacsystemfont, 'Segoe UI', roboto, oxygen, ubuntu, cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Typography elements */
h1, h2, h3, h4, .headline {
    font-family: 'DM Serif Display', Georgia, serif;
}

/* NAVBAR */
.navbar {
    height: 60px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
}
.nav-left {
    display: flex;
    align-items: center;
    gap: 24px;
}
.logo {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--brand);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.nav-links {
    display: flex;
    gap: 16px;
}
.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
    cursor: pointer;
}
.nav-links a:hover {
    color: var(--text-main);
}
.nav-right {
    display: flex;
    gap: 12px;
}
.btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}
.btn-primary {
    background: var(--brand);
    color: #ffffff;
}
.btn-primary:hover:not(:disabled) {
    background: #1e293b;
    transform: translateY(-1px);
}
.btn-secondary {
    background: #ffffff;
    border-color: var(--border-light);
    color: var(--text-main);
}
.btn-secondary:hover:not(:disabled) {
    background: #f1f5f9;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* MAIN LAYOUT */
.split-view {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* LEFT PANE - EDITOR */
.pane-left {
    width: 45%;
    max-width: 650px;
    min-width: 350px;
    background: #ffffff;
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    padding: 24px;
    position: relative;
}
.editor-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid transparent;
    transition: border-color 0.2s;
}
.editor-wrapper:focus-within {
    border-color: var(--border-light);
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}
#textInput {
    width: 100%;
    height: 100%;
    resize: none;
    border: none;
    background: transparent;
    padding: 20px;
    font-family: inherit;
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--text-main);
    outline: none;
}
#textInput::placeholder {
    color: #94a3b8;
}
.editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-light);
}
.controls-area {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.examples-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.example-btn {
    background: transparent;
    border: 1px solid var(--border-light);
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}
.example-btn:hover {
    color: var(--text-main);
    border-color: #cbd5e1;
    background: #f1f5f9;
}

/* RIGHT PANE - NOTES */
.pane-right {
    flex: 1;
    background: var(--bg-main);
    overflow-y: auto;
    padding: 32px;
    position: relative;
}
.notes-empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    text-align: center;
}
.notes-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding-bottom: 40px;
}

/* STATUS OVERLAY (Loading/Error) */
.status-overlay {
    position: absolute;
    inset: 0;
    background: rgba(248, 250, 252, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.status-overlay.active {
    opacity: 1;
    pointer-events: all;
}
.status-content {
    background: white;
    padding: 24px 32px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    max-width: 400px;
    text-align: center;
}
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-light);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

/* NOTE CARD */
.note-card {
    border-radius: 12px;
    padding: 20px;
    border: 1px solid;
    display: flex;
    flex-direction: column;
    gap: 12px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s;
    position: relative;
}
.note-card.visible {
    opacity: 1;
    transform: translateY(0);
}
.note-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.05);
}
.note-headline {
    font-size: 1.25rem;
    line-height: 1.3;
    font-weight: 500;
    color: var(--text-main);
}
.note-subtext {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
    flex-grow: 1;
}
.note-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid rgba(0,0,0,0.05);
}
.note-source {
    font-size: 0.7rem;
    color: #94a3b8;
    font-family: monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}
.note-tag {
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(0,0,0,0.05);
    color: var(--text-muted);
}

/* Card Categories */
.cat-fact { background: var(--color-fact-bg); border-color: var(--color-fact-border); }
.cat-finding { background: var(--color-finding-bg); border-color: var(--color-finding-border); }
.cat-definition { background: var(--color-definition-bg); border-color: var(--color-definition-border); }
.cat-statistic { background: var(--color-statistic-bg); border-color: var(--color-statistic-border); }
.cat-concept { background: var(--color-concept-bg); border-color: var(--color-concept-border); }
.cat-quote { background: var(--color-quote-bg); border-color: var(--color-quote-border); }
.cat-action { background: var(--color-action-bg); border-color: var(--color-action-border); }

/* MODALS */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active {
    display: flex;
}
.modal {
    background: #fff;
    border-radius: 12px;
    width: 400px;
    max-width: 90%;
    padding: 24px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
}
.modal-close {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-muted);
}
.export-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.export-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: #fafafa;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}
.export-btn:hover {
    border-color: #94a3b8;
    background: #fff;
}
.export-btn .title { font-weight: 600; font-size: 0.95rem; margin-bottom: 2px;}
.export-btn .desc { font-size: 0.8rem; color: var(--text-muted); }

/* Responsive */
@media (max-width: 900px) {
    .split-view { flex-direction: column; }
    .pane-left { width: 100%; max-width: none; border-right: none; border-bottom: 1px solid var(--border-light); height: 40vh; }
    .pane-right { height: 60vh; }
}
