:root {
    --primary: #E17055;
    --primary-hover: #D66044;
    --secondary: #FAB1A0;
    --accent: #FFEAA7;

    --bg-dark: #1A0F0A;
    --bg-panel: rgba(45, 26, 17, 0.6);
    --bg-panel-hover: rgba(65, 36, 22, 0.8);
    --glass-border: rgba(255, 255, 255, 0.08);

    --text-main: #FDF4ED;
    --text-muted: #BFA89E;

    --pos-noun: #74B9FF;
    --pos-verb: #55E6C1;
    --pos-adj: #FFEAA7;
    --pos-adv: #A29BFE;

    --ner-person: #FF7675;
    --ner-org: #0984E3;
    --ner-loc: #00B894;
    --ner-time: #FDCB6E;

    --sent-pos: #55E6C1;
    --sent-neg: #FF7675;
    --sent-neu: #BFA89E;

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

    --radius: 12px;
    --radius-sm: 8px;
    --radius-pill: 99px;

    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    overflow: hidden;
}

.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

/* Layout */
.app-layout {
    display: flex;
    width: 100vw;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    height: 100%;
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.brand {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
    border-bottom: 1px solid var(--glass-border);
}

.brand svg {
    width: 24px;
    height: 24px;
}

.brand h1 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

.nav-menu {
    flex: 1;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.875rem 1rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
}

.nav-item svg {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
}

.nav-item.active {
    background: rgba(225, 112, 85, 0.1);
    border-color: rgba(225, 112, 85, 0.3);
    color: var(--primary);
}

.nav-item.active svg {
    opacity: 1;
    color: var(--primary);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

/* Workspace */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1.5rem;
    gap: 1.5rem;
    overflow: hidden;
}

/* Common Section Styles */
.editor-section {
    flex: 0 0 40%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 250px;
}

.results-section {
    flex: 1;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
}

.section-header.border-bottom {
    border-bottom: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
}

.section-header h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Editor */
.header-actions {
    display: flex;
    gap: 0.5rem;
}

.textarea-wrapper {
    flex: 1;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--transition);
}

.textarea-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(225, 112, 85, 0.1);
}

textarea {
    flex: 1;
    width: 100%;
    background: transparent;
    border: none;
    padding: 1.5rem;
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
    resize: none;
}

textarea:focus {
    outline: none;
}

textarea::placeholder {
    color: rgba(191, 168, 158, 0.4);
}

.textarea-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid var(--glass-border);
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Results Area */
.results-container {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    line-height: 2;
    font-size: 1rem;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    opacity: 0.6;
    font-style: italic;
}

/* --- Dynamic Visualization Components --- */

/* Token Tags */
.token-tag {
    display: inline-block;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    margin: 0.2rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    transition: var(--transition);
}

.token-tag:hover {
    background: var(--bg-panel-hover);
    border-color: var(--primary);
}

.token-tag.punct {
    opacity: 0.5;
}

/* Stemming Diff */
.stem-pair {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    margin: 0.25rem 0.5rem;
    padding: 0.25rem 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
}

.stem-pair:hover {
    border-color: var(--secondary);
}

.stem-orig {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: line-through;
    opacity: 0.7;
}

.stem-root {
    font-size: 0.95rem;
    color: var(--primary);
    font-weight: 500;
}

/* Pos/NER Tags */
.annotated-word {
    display: inline-flex;
    align-items: baseline;
    margin: 0.25rem 0.4rem;
    padding: 0 0.3rem 0 0.4rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    border-left: 3px solid transparent;
}

.annotated-word .txt {
    font-weight: 500;
}

.annotated-word .lbl {
    font-size: 0.6rem;
    text-transform: uppercase;
    font-weight: 700;
    margin-left: 0.3rem;
    opacity: 0.8;
    font-family: var(--font-mono);
}

/* Legend */
.legend {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
}

.btn.ghost {
    background: transparent;
    color: var(--text-main);
}

.btn.ghost.outline {
    border-color: var(--glass-border);
}

.btn.ghost:hover {
    background: rgba(255, 255, 255, 0.05);
}

.btn.text-only {
    padding: 0.25rem 0.5rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.btn.text-only:hover {
    color: var(--text-main);
}

.error-text {
    color: var(--primary) !important;
}

/* Sentiment & Freq Modules */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    padding: 1rem;
    border-radius: var(--radius-sm);
}

.stat-card h4 {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.stat-card .val {
    font-size: 1.5rem;
    font-weight: 600;
    font-family: var(--font-mono);
}