* {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    margin: 0;
    padding: 20px;
    background: #f8f9fa;
    color: #2c3e50;
}

.header-bar {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

.utility-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.utility-btn {
    padding: 8px 16px;
    border: 2px solid #4a90e2;
    border-radius: 20px;
    background: white;
    color: #4a90e2;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.utility-btn:hover {
    background: #4a90e2;
    color: white;
    transform: translateY(-1px);
}

.page-title {
    color: #2c3e50;
    font-size: 22px;
    font-weight: 600;
    margin: 8px 0 6px 0;
}

.page-desc {
    color: #7f8c8d;
    font-size: 14px;
    margin: 0;
}

.main-container {
    max-width: 800px;
    margin: 0 auto;
}

.input-card {
    background: white;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

.input-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.input-row input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e8ecef;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
    color: #2c3e50;
    background: #fbfcfd;
}

.input-row input:focus {
    border-color: #4a90e2;
    background: white;
}

.input-row input.has-error {
    border-color: #e74c3c;
    background: #fdf2f0;
}

.input-error {
    color: #e74c3c;
    font-size: 13px;
    margin-top: 8px;
    display: none;
}

.input-error.show {
    display: block;
}

.primary-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    background: #4a90e2;
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    white-space: nowrap;
}

.primary-btn:hover {
    background: #357abd;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74,144,226,0.3);
}

.primary-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.loading-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 6px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.result-card {
    background: white;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

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

.result-card h3 {
    margin: 0 0 12px 0;
    color: #2c3e50;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.result-card h3::before {
    content: "";
    width: 4px;
    height: 16px;
    background: #2ecc71;
    border-radius: 2px;
}

.result-card h3.multi-lang::before {
    background: #9b59b6;
}

.ety-section {
    margin-bottom: 12px;
    padding: 12px 14px;
    background: #f8f9fa;
    border-left: 3px solid #4a90e2;
    border-radius: 4px;
    line-height: 1.7;
    font-size: 14px;
    color: #34495e;
}

.ety-section .ety-word {
    font-weight: 600;
    color: #2c3e50;
    font-size: 15px;
    margin-bottom: 6px;
}

.ety-section p {
    margin: 4px 0;
}

.ety-section a {
    color: #4a90e2;
    text-decoration: none;
}

.ety-section a:hover {
    text-decoration: underline;
}

.multi-lang-item {
    margin-bottom: 10px;
    padding: 10px 14px;
    background: #f8f9fa;
    border-left: 3px solid #9b59b6;
    border-radius: 4px;
    font-size: 14px;
    color: #34495e;
    line-height: 1.6;
}

.multi-lang-item strong {
    display: inline-block;
    margin-bottom: 4px;
    color: #2c3e50;
}

.multi-lang-item p {
    margin: 4px 0 0 0;
}

.multi-lang-item .lang-name {
    font-weight: 600;
    color: #8e44ad;
    margin-right: 8px;
}

.ety-chain {
    margin-top: 8px;
    padding-left: 4px;
}

.chain-step {
    padding: 6px 10px;
    background: #f0f4f8;
    border-radius: 6px;
    margin: 4px 0;
}

.chain-word {
    font-weight: 600;
    color: #2c3e50;
    margin-right: 8px;
    font-size: 13px;
}

.chain-ety {
    display: block;
    margin-top: 2px;
    font-size: 13px;
    color: #555;
    line-height: 1.5;
}

.chain-arrow {
    text-align: center;
    color: #9b59b6;
    font-size: 14px;
    line-height: 1;
    margin: 2px 0;
}

.error-state {
    color: #e74c3c;
    font-size: 14px;
    padding: 12px;
    background: #fdf2f0;
    border-left: 3px solid #e74c3c;
    border-radius: 4px;
}

.empty-state {
    color: #95a5a6;
    font-size: 14px;
    padding: 16px;
    text-align: center;
    font-style: italic;
}

@media (max-width: 600px) {
    body { padding: 12px; }
    .input-row {
        flex-direction: column;
    }
    .input-row input { width: 100%; }
    .primary-btn { width: 100%; }
}

/* Dark Mode */
[data-theme="dark"] body {
    background: #1a1a2e;
    color: #e0e0e0;
}

[data-theme="dark"] .header-bar {
    background: #16213e;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

[data-theme="dark"] .page-title {
    color: #e8e8e8;
}

[data-theme="dark"] .page-desc {
    color: #999;
}

[data-theme="dark"] .utility-btn {
    background: #1a1a2e;
    border-color: #3a6db5;
    color: #6cb4e8;
}

[data-theme="dark"] .utility-btn:hover {
    background: #3a6db5;
    color: #fff;
}

[data-theme="dark"] .input-card,
[data-theme="dark"] .result-card {
    background: #16213e;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

[data-theme="dark"] .input-row input {
    background: #1a1a2e;
    border-color: #444;
    color: #e0e0e0;
}

[data-theme="dark"] .input-row input:focus {
    border-color: #4a90e2;
    background: #1e2a45;
}

[data-theme="dark"] .input-row input.has-error {
    border-color: #e74c3c;
    background: #2a1a1a;
}

[data-theme="dark"] .primary-btn {
    background: #3a6db5;
}

[data-theme="dark"] .primary-btn:hover {
    background: #2a5a9a;
}

[data-theme="dark"] .result-card h3 {
    color: #e8e8e8;
}

[data-theme="dark"] .ety-section {
    background: #1a1a2e;
    border-left-color: #3a6db5;
    color: #c0c0c0;
}

[data-theme="dark"] .ety-section .ety-word {
    color: #e8e8e8;
}

[data-theme="dark"] .multi-lang-item {
    background: #1a1a2e;
    border-left-color: #7d3c98;
    color: #c0c0c0;
}

[data-theme="dark"] .multi-lang-item strong {
    color: #e8e8e8;
}

[data-theme="dark"] .multi-lang-item .lang-name {
    color: #bb8fce;
}

[data-theme="dark"] .chain-step {
    background: #1e2a3e;
}

[data-theme="dark"] .chain-word {
    color: #e8e8e8;
}

[data-theme="dark"] .chain-ety {
    color: #aaa;
}

[data-theme="dark"] .chain-arrow {
    color: #bb8fce;
}

[data-theme="dark"] .error-state {
    background: #2a1a1a;
    color: #f1948a;
}

[data-theme="dark"] .ety-section a {
    color: #6cb4e8;
}
