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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 2px solid #f0f0f0;
}

header h1 {
    font-size: 2.5em;
    color: #667eea;
    margin-bottom: 10px;
}

.subtitle {
    color: #666;
    font-size: 1.1em;
}

.input-section {
    margin-bottom: 40px;
}

.input-group {
    margin-bottom: 30px;
}

.input-group label h2 {
    font-size: 1.3em;
    color: #333;
    margin-bottom: 5px;
}

.label-hint {
    font-size: 0.9em;
    color: #888;
    font-weight: normal;
}

textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s;
}

textarea:focus {
    outline: none;
    border-color: #667eea;
}

.input-type-selector {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(51, 65, 85, 0.7);
    border-radius: 8px;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.95em;
    color: #555;
}

.radio-label input[type="radio"] {
    margin-right: 8px;
    cursor: pointer;
}

.radio-label:hover {
    color: #667eea;
}

.url-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.url-dropdown {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

.url-dropdown:focus {
    outline: none;
    border-color: #667eea;
}

.url-dropdown:hover {
    border-color: #667eea;
}

.url-input {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    transition: border-color 0.3s;
}

.url-input:focus {
    outline: none;
    border-color: #667eea;
}

.urls-textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-family: monospace;
    resize: vertical;
    margin-bottom: 10px;
    transition: border-color 0.3s;
}

.urls-textarea:focus {
    outline: none;
    border-color: #667eea;
}

.sam-urls-wrapper,
.sam-search-wrapper {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-top: 10px;
}

.extract-url-button {
    width: 100%;
    padding: 12px 20px;
    background: #00e676;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 15px;
}

.extract-url-button:hover {
    background: #00c853;
}

.extract-url-button:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

.extraction-status {
    padding: 15px;
    border-radius: 8px;
    margin-top: 10px;
}

.extraction-status.success {
    color: #00ff88;
}

.extraction-status.error {
    color: #ff5252;
}

.extraction-status.info {
    color: #64b5f6;
}

.extraction-status.loading {
    color: #ffb74d;
}

.extracted-keywords-preview {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.extracted-keywords-preview h4 {
    margin-bottom: 10px;
    color: #333;
    font-size: 0.95em;
}

.extracted-keywords-preview .keywords-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.compare-button {
    width: 100%;
    padding: 15px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.compare-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}

.compare-button:active {
    transform: translateY(0);
}

.compare-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.results-section {
    margin-top: 40px;
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.score-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    text-align: center;
}

.score-card h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.score-circle {
    display: inline-flex;
    align-items: baseline;
    justify-content: center;
    margin: 20px 0;
}

.score-value {
    font-size: 4em;
    font-weight: bold;
    color: #667eea;
    line-height: 1;
}

.score-unit {
    font-size: 2em;
    color: #667eea;
    margin-left: 5px;
}

.score-breakdown {
    margin-top: 30px;
    text-align: left;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.breakdown-item {
    margin-bottom: 20px;
}

.breakdown-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.breakdown-value {
    color: #667eea;
    font-weight: 600;
}

.breakdown-bar {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.breakdown-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.5s ease;
    border-radius: 4px;
}

.keywords-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.keywords-group {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    border: 2px solid #e0e0e0;
}

.keywords-group.common-keywords {
    background: #e8f5e9;
    border-color: #00ff88;
}

.keywords-group h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2em;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

.keywords-group.common-keywords h3 {
    color: #00ff88;
    border-bottom-color: #00ff88;
}

.keywords-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.keyword-tag {
    background: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.9em;
    color: #555;
    border: 1px solid #ddd;
    transition: all 0.2s;
}

.keyword-tag.common {
    background: #00e676;
    color: white;
    border-color: #00ff88;
    font-weight: 600;
}

.keyword-tag:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.summary-section {
    border-radius: 8px;
    padding: 20px;
}

.summary-section h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2em;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

.summary-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.summary-item {
    background: white;
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid #667eea;
}

.summary-item strong {
    display: block;
    color: #667eea;
    margin-bottom: 5px;
    font-size: 0.9em;
}

.summary-item span {
    color: #555;
    font-size: 1.1em;
}

.error-message {
    background: #ffebee;
    color: #ff5252;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #ff5252;
    margin-top: 20px;
}

.keyword-matches-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    border: 2px solid #e0e0e0;
    margin-top: 30px;
}

.keyword-matches-section h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.2em;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

.matches-description {
    color: #666;
    font-size: 0.95em;
    margin-bottom: 15px;
}

.keyword-matches-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.keyword-match-item {
    background: white;
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid #667eea;
    transition: transform 0.2s, box-shadow 0.2s;
}

.keyword-match-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.match-keyword {
    font-weight: 600;
    color: #667eea;
    font-size: 1em;
}

.match-similarity {
    font-weight: 600;
    font-size: 0.9em;
    padding: 4px 10px;
    background: #f0f0f0;
    border-radius: 12px;
}

.match-sentence {
    color: #555;
    line-height: 1.6;
    font-size: 0.95em;
    padding-left: 10px;
    border-left: 2px solid #e0e0e0;
    margin-bottom: 8px;
}

.match-explanation {
    color: #888;
    font-size: 0.85em;
    font-style: italic;
    padding-left: 10px;
    margin-top: 5px;
}

/* Multiple comparison styles */
.sam-text-wrapper {
    position: relative;
    margin-bottom: 15px;
}

.sam-text-wrapper textarea {
    width: 100%;
    padding: 15px;
    padding-right: 50px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s;
}

.sam-text-wrapper textarea:focus {
    outline: none;
    border-color: #667eea;
}

.remove-sam-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.85em;
    transition: background 0.2s;
}

.remove-sam-btn:hover {
    background: #d32f2f;
}

.add-sam-button {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 0.95em;
    margin-top: 10px;
    transition: background 0.2s;
}

.add-sam-button:hover {
    background: #5568d3;
}

.comparison-table-section {
    margin-bottom: 30px;
}

.comparison-table-section h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.8em;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.comparison-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.comparison-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.comparison-table td {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    vertical-align: top;
}

.comparison-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.1);
}

.comparison-table tbody tr:last-child td {
    border-bottom: none;
}

.rank-cell {
    text-align: center;
    width: 80px;
}

.rank-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9em;
}

.rank-badge.rank-1 {
    background: #ffd700;
    color: #333;
}

.rank-badge.rank-2 {
    background: #c0c0c0;
    color: #333;
}

.rank-badge.rank-3 {
    background: #cd7f32;
    color: white;
}

.rank-badge:not(.rank-1):not(.rank-2):not(.rank-3) {
    background: #e0e0e0;
    color: #666;
}

.score-cell {
    font-size: 1.2em;
    font-weight: 600;
    text-align: center;
    width: 100px;
}

.score-cell.high-score {
    color: #00ff88;
}

.score-cell.medium-score {
    color: #ff9800;
}

.score-cell.low-score {
    color: #f44336;
}

.summary-cell {
    max-width: 300px;
}

.summary-preview {
    color: #555;
    line-height: 1.5;
    margin-bottom: 8px;
}

.summary-stats {
    font-size: 0.85em;
    color: #888;
}

.keywords-cell {
    max-width: 200px;
}

.keywords-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.keyword-mini {
    background: #f0f0f0;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    color: #555;
}

.more-keywords {
    color: #888;
    font-size: 0.8em;
    font-style: italic;
}

.view-details-btn {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.85em;
    transition: background 0.2s;
}

.view-details-btn:hover {
    background: #5568d3;
}

.details-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-content {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 30px;
    width: 90%;
    max-width: 1200px;
    min-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2em;
    cursor: pointer;
    color: #888;
    line-height: 1;
}

.close-modal:hover {
    color: #333;
}

.modal-content h2 {
    color: #667eea;
    margin-bottom: 20px;
    padding-right: 40px;
}

.modal-single-column {
    display: flex;
    flex-direction: column;
    gap: 30px;
    margin-top: 20px;
}

.modal-two-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 20px;
    align-items: start;
}

.modal-left-column,
.modal-right-column {
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents grid blowout */
}

.modal-left-column {
    border-right: 2px solid #e0e0e0;
    padding-right: 30px;
}

.modal-right-column {
    padding-left: 30px;
}

.score-matrix {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    border: 2px solid #e0e0e0;
}

.score-matrix h3 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.3em;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

.score-matrix h4 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1em;
    margin-top: 20px;
}

.sam-summary-content {
    color: #555;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.modal-scores {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.modal-score-item {
    color: #555;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.modal-score-item:last-child {
    border-bottom: none;
}

.modal-score-item strong {
    color: #333;
    font-weight: 600;
}

.score-value-large {
    font-size: 1.2em;
    font-weight: 700;
    color: #667eea;
}

.modal-section {
    margin-bottom: 20px;
}

.modal-section h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2em;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

.modal-section h4 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1em;
    font-weight: 600;
}

.modal-section p {
    color: #555;
    line-height: 1.6;
}

.modal-section .keywords-list {
    margin-top: 10px;
}

.modal-section .keyword-matches-list {
    margin-top: 10px;
    max-height: 400px;
    overflow-y: auto;
}

@media (max-width: 1024px) {
    .modal-content {
        min-width: auto;
        width: 95%;
    }
    
    .modal-single-column {
        gap: 20px;
    }
    
    .modal-two-column {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .modal-left-column {
        border-right: none;
        padding-right: 0;
        border-bottom: 2px solid #e0e0e0;
        padding-bottom: 20px;
    }
    
    .modal-right-column {
        padding-left: 0;
        padding-top: 20px;
    }
}

@media (max-width: 768px) {
    .comparison-table {
        font-size: 0.85em;
    }
    
    .comparison-table th,
    .comparison-table td {
        padding: 10px 8px;
    }
    
    .summary-cell,
    .keywords-cell {
        max-width: 150px;
    }
    
    .modal-content {
        padding: 20px;
    }
    
    .modal-scores {
        grid-template-columns: 1fr;
    }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* n8n Links Section Styles */
.n8n-section {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-top: 10px;
}

.n8n-input-options {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    padding: 10px;
    background: white;
    border-radius: 8px;
}

.n8n-json-textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.9em;
    font-family: monospace;
    resize: vertical;
    margin-bottom: 10px;
    transition: border-color 0.3s;
}

.n8n-json-textarea:focus {
    outline: none;
    border-color: #2196f3;
}

.process-n8n-button {
    width: 100%;
    padding: 12px 20px;
    background: #2196f3;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.process-n8n-button:hover {
    background: #1976d2;
}

.process-n8n-button:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

.fetch-n8n-button {
    width: 100%;
    padding: 12px 20px;
    background: #2196f3;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 15px;
}

.fetch-n8n-button:hover {
    background: #1976d2;
}

.fetch-n8n-button:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

.test-n8n-button {
    padding: 8px 16px;
    background: #00e676;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9em;
    cursor: pointer;
    transition: background 0.2s;
}

.test-n8n-button:hover {
    background: #00c853;
}

.n8n-links-container {
    margin-top: 20px;
    padding: 20px;
    border-radius: 8px;
}

.n8n-links-container h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2em;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

.n8n-links-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 15px;
}

.n8n-result-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid #2196f3;
}

.n8n-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 10px;
}

.n8n-result-header strong {
    color: #333;
    font-size: 1em;
}

.notice-id {
    background: #e3f2fd;
    color: #1976d2;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
}

.n8n-meta {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 10px;
}

.n8n-links-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.n8n-link-item {
    padding: 5px 0;
}

.sam-link-tag {
    display: inline-block;
    background: white;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.9em;
    color: #1976d2;
    text-decoration: none;
    border: 1px solid #2196f3;
    transition: all 0.2s;
    word-break: break-all;
    max-width: 100%;
    box-sizing: border-box;
}

.sam-link-tag:hover {
    background: #e3f2fd;
    border-color: #1976d2;
    transform: translateX(3px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.use-links-button {
    width: 100%;
    padding: 12px 20px;
    background: #00e676;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 15px;
}

.use-links-button:hover {
    background: #00c853;
}

.extraction-status code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.9em;
}

@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    header h1 {
        font-size: 2em;
    }

    .keywords-section {
        grid-template-columns: 1fr;
    }

    .score-value {
        font-size: 3em;
    }
}

