* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 40px;
}

header {
    text-align: center;
    margin-bottom: 40px;
}

header h1 {
    color: #667eea;
    font-size: 3em;
    margin-bottom: 10px;
}

header p {
    color: #666;
    font-size: 1.2em;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid #eee;
}

.tab-btn {
    padding: 15px 30px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    color: #666;
    transition: all 0.3s;
}

.tab-btn:hover {
    color: #667eea;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.input-section h2 {
    color: #333;
    margin-bottom: 20px;
}

textarea {
    width: 100%;
    min-height: 100px;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 1em;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 15px;
    transition: border-color 0.3s;
}

textarea:focus {
    outline: none;
    border-color: #667eea;
}

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 1em;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-weight: 600;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

button:active {
    transform: translateY(0);
}

.output-section {
    margin-top: 30px;
}

.output-section h3 {
    color: #333;
    margin-bottom: 15px;
}

.visualization {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    min-height: 100px;
}

.word-tag {
    display: inline-block;
    margin: 5px;
    padding: 8px 15px;
    border-radius: 20px;
    background: #e3f2fd;
    border: 2px solid #2196f3;
}

.word-tag .word {
    font-weight: bold;
    color: #1976d2;
}

.word-tag .tag {
    font-size: 0.8em;
    color: #666;
    margin-left: 5px;
}

.structure-group {
    margin: 15px 0;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.structure-group h4 {
    color: #667eea;
    margin-bottom: 10px;
}

.structure-item {
    display: inline-block;
    margin: 5px;
    padding: 6px 12px;
    background: #f0f0f0;
    border-radius: 15px;
    color: #333;
}

.compare-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.compare-inputs label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
}

.similarity-score {
    margin: 15px 0;
    padding: 15px;
    background: white;
    border-radius: 8px;
}

.similarity-score h4 {
    color: #333;
    margin-bottom: 10px;
}

.score-bar {
    height: 30px;
    background: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
    position: relative;
}

.score-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    transition: width 1s ease;
}

.word-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.word-badge {
    padding: 5px 12px;
    border-radius: 12px;
    font-size: 0.9em;
}

.common-word {
    background: #c8e6c9;
    color: #2e7d32;
}

.unique-word-1 {
    background: #ffccbc;
    color: #d84315;
}

.unique-word-2 {
    background: #b3e5fc;
    color: #01579b;
}

/* ========== FUNCTION WORD EXPLORER STYLES ========== */

.explorer-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    margin-top: 20px;
}

.word-library {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    height: fit-content;
    position: sticky;
    top: 20px;
    max-height: 80vh;
    overflow-y: auto;
}

.word-library h3 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.library-hint {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 20px;
    font-style: italic;
}

.word-category {
    margin-bottom: 20px;
}

.word-category h4 {
    color: #333;
    font-size: 0.9em;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.word-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.word-chip {
    display: inline-block;
    padding: 6px 12px;
    background: white;
    border: 2px solid #667eea;
    border-radius: 20px;
    color: #667eea;
    font-weight: 600;
    cursor: grab;
    transition: all 0.2s;
    user-select: none;
}

.word-chip:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.word-chip:active {
    cursor: grabbing;
}

.explorer-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sentence-workspace {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
}

.sentence-display {
    margin-bottom: 15px;
}

.sentence-display h3 {
    color: #333;
    font-size: 1em;
    margin-bottom: 10px;
}

.sentence-text {
    padding: 15px;
    background: white;
    border-radius: 10px;
    font-size: 1.1em;
    line-height: 1.6;
    color: #333;
}

.sentence-tokens {
    padding: 15px;
    background: white;
    border-radius: 10px;
    font-size: 1.1em;
    line-height: 1.6;
    min-height: 50px;
}

.sentence-token {
    display: inline-block;
    padding: 4px 8px;
    margin: 2px;
    background: #e3f2fd;
    border: 2px solid #2196f3;
    border-radius: 6px;
    color: #1565c0;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.sentence-token:hover {
    background: #bbdefb;
    transform: scale(1.05);
}

.sentence-token.drag-over {
    background: #ffd54f;
    border-color: #ffa000;
    transform: scale(1.1);
    box-shadow: 0 0 0 3px rgba(255, 213, 79, 0.3);
}

.history-section {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin-top: 10px;
}

.history-section h4 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1em;
}

.change-log {
    max-height: 150px;
    overflow-y: auto;
}

.history-list {
    list-style: none;
    padding: 0;
}

.history-list li {
    padding: 8px;
    margin-bottom: 5px;
    background: white;
    border-radius: 6px;
    font-size: 0.9em;
}

.history-index {
    color: #999;
    margin-right: 8px;
}

.old-word {
    padding: 2px 8px;
    background: #ffcdd2;
    color: #c62828;
    border-radius: 4px;
    font-weight: 600;
}

.new-word {
    padding: 2px 8px;
    background: #c8e6c9;
    color: #2e7d32;
    border-radius: 4px;
    font-weight: 600;
}

.history-position {
    color: #666;
    font-size: 0.85em;
    margin-left: 8px;
}

.swap-analysis {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
}

.change-summary {
    font-size: 1.1em;
    padding: 15px;
    background: white;
    border-left: 4px solid #667eea;
    border-radius: 6px;
    margin-bottom: 15px;
}

.word-info {
    padding: 10px;
    background: #e3f2fd;
    border-radius: 6px;
    margin-bottom: 10px;
}

.explanation {
    padding: 15px;
    background: #fff9c4;
    border-radius: 6px;
    margin-bottom: 10px;
    line-height: 1.6;
}

.structural-changes {
    padding: 15px;
    background: #f3e5f5;
    border-radius: 6px;
    margin-bottom: 10px;
}

.structural-changes ul {
    margin-top: 10px;
    margin-left: 20px;
}

.structural-changes li {
    margin-bottom: 5px;
    color: #4a148c;
}

.semantic-impact {
    padding: 15px;
    background: #e8f5e9;
    border-radius: 6px;
    line-height: 1.6;
    color: #1b5e20;
}

.explorer-explanation {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .container {
        padding: 20px;
    }
    
    .compare-inputs {
        grid-template-columns: 1fr;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .tabs {
        flex-direction: column;
    }
    
    .explorer-layout {
        grid-template-columns: 1fr;
    }
    
    .word-library {
        position: static;
        max-height: none;
    }
}

/* ========== DEPENDENCY VISUALIZER STYLES ========== */

.visualizer-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    margin-top: 20px;
}

.visualizer-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.word-chip-viz {
    display: inline-block;
    padding: 5px 10px;
    background: white;
    border: 2px solid #764ba2;
    border-radius: 15px;
    color: #764ba2;
    font-weight: 600;
    font-size: 0.85em;
    cursor: grab;
    transition: all 0.2s;
    user-select: none;
}

.word-chip-viz:hover {
    background: #764ba2;
    color: white;
    transform: scale(1.05);
}

.word-chip-viz:active {
    cursor: grabbing;
}

.controls-panel {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 15px;
}

.controls-panel h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1em;
}

.control-btn {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.reset-btn {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

.heatmap-btn {
    background: linear-gradient(135deg, #ff9800, #f57c00);
    color: white;
}

.heatmap-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
}

.impact-legend {
    margin-top: 15px;
}

.impact-legend h4 {
    font-size: 0.9em;
    color: #333;
    margin-bottom: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    font-size: 0.85em;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    margin-right: 8px;
}

.legend-color.high {
    background: #ff5722;
}

.legend-color.medium {
    background: #ff9800;
}

.legend-color.low {
    background: #ffc107;
}

.visualizer-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sentence-display-viz {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 15px;
}

.sentence-display-viz h3 {
    color: #333;
    font-size: 1em;
    margin-bottom: 10px;
}

.viz-tokens {
    padding: 15px;
    background: white;
    border-radius: 10px;
    min-height: 50px;
    line-height: 2;
}

.viz-token {
    display: inline-block;
    padding: 6px 12px;
    margin: 3px;
    background: #e3f2fd;
    border: 2px solid #2196f3;
    border-radius: 8px;
    color: #1565c0;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.viz-token:hover {
    background: #bbdefb;
    transform: scale(1.05);
}

.viz-token.drag-over {
    background: #ffd54f;
    border-color: #ffa000;
    transform: scale(1.1);
    box-shadow: 0 0 0 3px rgba(255, 213, 79, 0.3);
}

.tree-canvas {
    background: #fafafa;
    border-radius: 15px;
    padding: 20px;
    min-height: 450px;
    position: relative;
    overflow: hidden;
}

.dependency-link {
    stroke-dasharray: 5, 5;
    animation: dash 20s linear infinite;
}

@keyframes dash {
    to {
        stroke-dashoffset: -1000;
    }
}

.node-label {
    font-weight: 600;
    font-size: 14px;
    fill: #333;
}

.link-label {
    font-size: 11px;
    fill: #666;
    font-weight: 600;
    background: white;
}

.pos-label {
    font-size: 10px;
    fill: #999;
}

.analysis-panel {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
}

.analysis-panel h3 {
    color: #333;
    margin-bottom: 15px;
}

.viz-output {
    min-height: 100px;
}

.impact-display {
    background: white;
    padding: 15px;
    border-radius: 10px;
}

.swap-info {
    font-size: 1.1em;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.impact-level {
    margin-bottom: 15px;
}

.impact-badge {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    color: white;
    font-weight: 700;
    font-size: 0.9em;
}

.tree-info {
    background: #f0f4f8;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.95em;
    line-height: 1.8;
}

@media (max-width: 768px) {
    .visualizer-layout {
        grid-template-columns: 1fr;
    }
    
    .visualizer-sidebar {
        order: 2;
    }
    
    .visualizer-main {
        order: 1;
    }
}
