body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 13px;
    line-height: 1.4;
    color: #212529;
    background: #f5f7ff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page-header {
    text-align: center;
    margin: 10px 0 10px;
    padding: 0 10px;
}
.page-header h1 {
    font-size: 22px;
    font-weight: 600;
    color: #1E293B;
    margin-bottom: 4px;
}
.subtitle {
    font-size: 13px;
    color: #6c757d;
}

.main-container {
    flex: 1;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto 80px 0;
    padding: 0 10px 10px 10px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.two-column {
    display: flex;
    gap: 10px;
    flex: 1;
    min-height: 0;
}

.column {
    width: 50%;
    display: flex;
    flex-direction: column;
}

.card {
    background: #ffffff;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.card-header {
    background: linear-gradient(135deg, rgba(67, 97, 238, 0.08), rgba(58, 12, 163, 0.08));
    padding: 8px 10px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-header h1, .card-header h2 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}
.card-header h1 i, .card-header h2 i {
    color: #4361ee;
}
.card-header-gradient {
    background: linear-gradient(135deg, rgba(76, 201, 240, 0.1), rgba(58, 12, 163, 0.1));
}

.btn {
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: none;
    background: transparent;
}
.btn-icon {
    width: 24px;
    height: 24px;
    padding: 0;
    justify-content: center;
}
.btn-primary {
    background: #4361ee;
    color: white;
    border: none;
    padding: 6px 12px;
    font-size: 15px;
}
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-copy {
    background: transparent;
    color: #4361ee;
    border: 1px solid #4361ee;
}
.btn-speak {
    background: transparent;
    color: #4361ee;
    border: 1px solid #4361ee;
}
.btn-history {
    background: transparent;
    color: #4361ee;
    border: 1px solid #4361ee;
}
.btn-swap {
    background: #4361ee;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
}
.btn-outline-secondary {
    background: transparent;
    border: 1px solid #e9ecef;
    color: #6c757d;
    padding: 4px 10px;
}
.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}
.btn-close {
    background: transparent;
    border: none;
    color: #6c757d;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-close:hover {
    color: #212529;
}

.icon-white {
    width: 14px;
    height: 14px;
    filter: brightness(0) invert(1);
}
.icon-blue {
    width: 14px;
    height: 14px;
    filter: brightness(0) saturate(100%) invert(30%) sepia(98%) saturate(1554%) hue-rotate(215deg) brightness(97%) contrast(91%);
}

.content-section {
    padding: 5px;
}

.form-group {
    margin-bottom: 5px;
}
.form-row {
    display: flex;
    gap: 5px;
    margin-bottom: 5px;
}
.form-col {
    flex: 1;
    min-width: 0;
}

.form-label {
    font-size: 14px;
    font-weight: bold;
    color: #212529;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 3px;
}
.form-label i {
    color: #4361ee;
    width: 14px;
    font-size: 12px;
}
.required-star {
    color: #e63946;
}

.form-control, .form-select, .language-display-box {
    width: 100%;
    padding: 4px 6px;
    font-size: 13px;
    color: #212529;
    background: white;
    border: 1px solid #abd5ff;
    border-radius: 4px;
    outline: none;
    height: 28px;
    box-sizing: border-box;
}
.form-control:focus, .form-select:focus, .language-display-box:focus-within {
    border-color: #4361ee;
}

.language-display-box {
    display: flex;
    align-items: center;
    padding: 0;
    overflow: hidden;
    cursor: pointer;
}
.language-display-box:hover {
    border-color: #4361ee;
}
.language-display-box.active {
    border-color: #4361ee;
    background: rgba(67, 97, 238, 0.05);
}
.language-icon {
    background: #f8f9fa;
    padding: 4px 6px;
    border-right: 1px solid #e9ecef;
    color: #6c757d;
    font-size: 11px;
    height: 100%;
    display: flex;
    align-items: center;
}
.language-display {
    flex: 1;
    padding: 4px 6px;
    font-size: 12px;
    color: #212529;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.language-arrow {
    color: #6c757d;
    font-size: 9px;
}

.select-container {
    border-radius: 4px;
    padding: 5px;
    border: 1px solid #abd5ff;
}

.select-container.classic-disabled .checkbox-grid {
    opacity: 0.5;
    pointer-events: none;
}

.select-container.five-disabled .five-grid {
    opacity: 0.5;
    pointer-events: none;
}

.select-container.classic-disabled .radio-group,
.select-container.five-disabled .radio-group {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.radio-group {
    display: flex;
    gap: 10px;
    margin-bottom: 1px;
    padding-bottom: 5px;
    border-bottom: 1px dashed #dee2e6;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    font-size: 13px;
    color: #212529;
}

.radio-item input[type="radio"] {
    margin: 0;
    cursor: pointer;
    width: 12px;
    height: 12px;
    accent-color: #4361ee;
}

.radio-item,
.radio-item label,
.radio-item span {
    color: #212529 !important;
}

.checkbox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 2px;
}

.five-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.checkbox-item {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    background-color: transparent;
    transition: background-color 0.2s;
    width: auto;
    flex: 0 0 auto;
    color: #212529;
}

.checkbox-item:hover {
    background-color: rgba(67, 97, 238, 0.05);
}

.checkbox-item input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    accent-color: #4361ee;
}

.checkbox-item input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.checkbox-item.disabled-label {
    cursor: not-allowed;
    opacity: 0.7;
}

.checkbox-item.metal-bg:has(input[type="checkbox"]:checked) {
    background-color: #f5ae00;
    color: white !important;
}

.checkbox-item.wood-bg:has(input[type="checkbox"]:checked) {
    background-color: #2E7D32;
    color: white !important;
}

.checkbox-item.water-bg:has(input[type="checkbox"]:checked) {
    background-color: #1558c0;
    color: white !important;
}

.checkbox-item.fire-bg:has(input[type="checkbox"]:checked) {
    background-color: #ff0000;
    color: white !important;
}

.checkbox-item.earth-bg:has(input[type="checkbox"]:checked) {
    background-color: #cfa100;
    color: white !important;
}

.metal-bg {
    color: #f5ae00;
}
.wood-bg {
    color: #2E7D32;
}
.water-bg {
    color: #1558c0;
}
.fire-bg {
    color: #ff0000;
}
.earth-bg {
    color: #cfa100;
}

.info-bar {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    font-size: 11px;
    color: #6c757d;
}
.info-bar i {
    color: #4361ee;
    font-size: 11px;
}

.action-bar {
    padding: 5px;
    background: #fff;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: center;
}
.action-buttons {
    display: flex;
    gap: 3px;
}

.result-area {
    flex: 1;
    padding: 5px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.result-textarea {
    width: 100%;
    flex: 1;
    padding: 6px;
    font-size: 13px;
    line-height: 1.5;
    color: #212529;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    outline: none;
    font-family: inherit;
    min-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
}
.result-textarea:focus {
    border-color: #4361ee;
}
.result-textarea.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: #6c757d;
    font-style: italic;
}

.metadata-panel {
    padding: 5px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    font-size: 11px;
    color: #6c757d;
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
    margin-bottom: 5px;
}
.metadata-panel.hidden {
    display: none;
}
.metadata-item {
    display: flex;
    align-items: center;
    gap: 3px;
}
.metadata-item i {
    color: #4361ee;
    font-size: 11px;
}
.scheme-highlight {
    color: #4361ee;
    font-weight: bold;
}

.error-message {
    color: #e63946;
    font-size: 11px;
    margin-top: 2px;
    display: none;
}
.error-message.show {
    display: block;
}

.spinner-border {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner 0.75s linear infinite;
}
#loadingSpinner {
    display: none;
}
@keyframes spinner {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9998;
}
.spinner-large {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4361ee;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}
.loading-text {
    color: white;
    font-size: 14px;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.message-toast {
    position: fixed;
    top: 90px;
    right: 20px;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 9999;
    animation: slideIn 0.3s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: none;
}
.message-toast.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.message-toast.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-overlay.show {
    display: flex;
}
.modal {
    background: white;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    width: 450px;
    max-width: 90%;
    max-height: 80%;
}
.modal.modal-large {
    width: 800px;
    max-width: 95%;
}
.modal-header {
    padding: 8px 10px;
    border-bottom: 1px solid #e9ecef;
    background: rgba(67, 97, 238, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 {
    font-size: 13px;
    font-weight: 600;
    margin: 0;
}
.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.modal-search {
    padding: 5px 8px;
    border-bottom: 1px solid #e9ecef;
}
.search-container {
    position: relative;
}
.search-container i {
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-size: 11px;
}
.search-input {
    width: 100%;
    padding: 4px 4px 4px 22px;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    font-size: 12px;
    color: #212529;
    outline: none;
    height: 26px;
    box-sizing: border-box;
}
.search-input:focus {
    border-color: #4361ee;
}
.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}
.modal-body.no-padding {
    padding: 0;
}
.language-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: #fff;
}
.language-item {
    background: white;
    padding: 5px 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    text-align: center;
    margin: 5px 0;
}
.language-item:hover {
    background: rgba(67, 97, 238, 0.05);
}
.language-item.selected {
    background: #4361ee;
    color: white;
}
.language-name {
    font-size: 12px;
    line-height: 1.2;
}
.modal-footer {
    padding: 6px 8px;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: flex-end;
    gap: 5px;
    background: #f8f9fa;
}
.modal-footer.hidden {
    display: none;
}

.history-body {
    padding: 10px;
}
.history-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.history-empty {
    text-align: center;
    color: #6c757d;
    padding: 30px 0;
    font-style: italic;
}
.history-item {
    border: 1px solid #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}
.history-item-header {
    background: #f8f9fa;
    padding: 6px 10px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
}
.history-time {
    color: #6c757d;
}
.history-input {
    font-weight: 600;
    color: #4361ee;
}
.history-item-content {
    padding: 10px;
    font-size: 12px;
    line-height: 1.5;
    background: white;
    max-height: 300px;
    overflow-y: auto;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.name-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 1px;
    min-height: 80px;
}
.name-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}
.pinyin-container {
    position: absolute;
    top: -12px;
    left: -6px;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 2px;
    font-size: 12px;
    color: #1c1f22;
    letter-spacing: 1px;
    white-space: nowrap;
}
.pinyin-syllable {
    display: inline-block;
    text-align: center;
    min-width: 2.5em;
}
.name-item {
    font-size: 27px;
    font-weight: 600;
    color: #4361ee;
    text-align: center;
    line-height: 1.6;
    margin-top: 1px;
    letter-spacing: 5px;
}
.name-char {
    display: inline-block;
    position: relative;
}

.include-character-container {
    display: flex;
    gap: 5px;
    width: 100%;
}

.include-character-container .position-select {
    flex: 1;
    min-width: 0;
    width: auto;
}

.include-character-container .character-input {
    flex: 0 0 60px;
    min-width: 50px;
    width: auto;
    text-align: center;
}

.include-character-container .character-input:focus {
    border-color: #4361ee;
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.include-character-container .character-input:disabled {
    background-color: #f8f9fa;
    border-color: #abd5ff;
    color: #6c757d;
    cursor: not-allowed;
    opacity: 0.7;
}

.include-character-container .character-input.error {
    border-color: #e63946;
    background-color: rgba(230, 57, 70, 0.05);
}

@media (max-width: 1024px) {
    .two-column {
        flex-direction: column;
    }
    .column {
        width: 100%;
    }
    .page-header h1 {
        font-size: 20px;
    }
}

@media (max-width: 768px) {
    .two-column {
        flex-direction: column;
    }
    .column {
        width: 100%;
    }
    .page-header h1 {
        font-size: 18px;
    }
    .language-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .include-character-container {
        flex-direction: row;
    }
    .modal.modal-large {
        width: 95%;
    }
    
    .checkbox-item {
        padding: 2px 4px;
    }
}

@media (max-width: 600px) {
    .checkbox-item {
        padding: 2px 3px;
    }
}

@media (max-width: 450px) {
    .form-row:first-of-type {
        display: flex;
        flex-direction: row;
        gap: 5px;
    }
    
    .form-row:nth-of-type(2) {
        display: flex;
        flex-direction: row;
        gap: 5px;
    }
    
    .form-row:nth-of-type(3) {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }
    
    .form-col {
        box-sizing: border-box;
    }
    
    .form-row:first-of-type .form-col:first-child {
        flex: 0 0 90px;
    }
    
    .form-row:first-of-type .form-col:nth-child(2) {
        flex: 0 0 80px;
    }
    
    .form-row:first-of-type .form-col:last-child {
        flex: 1;
        min-width: 0;
    }
    
    .form-row:nth-of-type(2) .form-col {
        flex: 1 1 0;
        min-width: 0;
    }
    
    .form-row:nth-of-type(3) .form-col {
        width: 100%;
        flex: none;
    }
    
    .name-item {
        font-size: 20px;
    }
    
    .five-grid {
        display: flex;
        flex-wrap: wrap;
        gap: 3px;
    }
    
    .checkbox-grid {
        display: flex;
        flex-wrap: wrap;
        gap: 3px;
    }
    
    .checkbox-item {
        padding: 2px 3px;
        white-space: nowrap;
    }
    
    .include-character-container {
        display: flex;
        flex-direction: row;
        gap: 5px;
        width: 100%;
    }
    
    .include-character-container .position-select {
        flex: 1;
        min-width: 0;
        width: auto;
    }
    
    .include-character-container .character-input {
        flex: 0 0 50px;
        min-width: 40px;
        width: auto;
    }
    
    .history-item-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .metadata-panel {
        gap: 20px;
    }
}