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

:root {
    --primary: #667eea;
    --primary-dark: #5568d3;
    --secondary: #764ba2;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --border-radius: 12px;
    --transition: all 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', Roboto, sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.textransform-container {
    background: white;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 40px;
}

.textransform-container header {
    text-align: center;
    margin-bottom: 28px;
}

.textransform-container .header-top {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 8px;
    position: relative;
}

.textransform-container .back-home {
    position: absolute;
    left: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    background: #f5f5f5;
    border-radius: 8px;
    transition: var(--transition);
    text-decoration: none;
    border: 1px solid #e0e0e0;
}

.textransform-container .back-home:hover {
    color: var(--primary);
    background: #e8edff;
    border-color: var(--primary);
}

.textransform-container .back-home svg {
    width: 20px;
    height: 20px;
}

.textransform-container header h1 {
    font-size: 2rem;
    color: var(--primary);
    margin: 0;
    font-weight: 700;
}

.textransform-container .language-switcher {
    position: absolute;
    right: 0;
}

.textransform-container .language-select {
    padding: 8px 12px;
    font-size: 0.875rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    color: #333;
    cursor: pointer;
    outline: none;
    transition: var(--transition);
}

.textransform-container .language-select:hover,
.textransform-container .language-select:focus {
    border-color: var(--primary);
}

.textransform-container .subtitle {
    color: #666;
    font-size: 1rem;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar .btn-icon {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e0e0e0;
    background: #f9f9f9;
    border-radius: 8px;
    color: #666;
    cursor: pointer;
    transition: var(--transition);
}

.toolbar .btn-icon:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
    background: #e8edff;
}

.toolbar .btn-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.toolbar .btn-icon svg {
    width: 18px;
    height: 18px;
}

.stat-label {
    font-size: 0.8125rem;
    color: #666;
    margin-left: 4px;
}

/* Transform container: input | output */
.transform-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 28px;
}

.panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.panel-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #555;
    margin: 0;
}

.panel-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid #e0e0e0;
    background: #fff;
    border-radius: 8px;
    color: #666;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.panel-copy-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #e8edff;
}

.panel-copy-btn svg {
    width: 16px;
    height: 16px;
}

.input-wrapper,
.output-wrapper {
    position: relative;
}

.text-area {
    width: 100%;
    min-height: 160px;
    padding: 14px 16px;
    font-size: 0.9375rem;
    line-height: 1.6;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    resize: vertical;
    outline: none;
    transition: border-color var(--transition);
    font-family: inherit;
}

.text-area:focus {
    border-color: var(--primary);
}

.text-area-readonly {
    background: #f9f9f9;
    cursor: default;
}

.text-area-readonly:focus {
    border-color: #e0e0e0;
}

/* Recent history (bottom) */
.recent-history {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #eee;
}

.recent-history-title {
    font-size: 1rem;
    font-weight: 600;
    color: #444;
    margin-bottom: 12px;
}

.recent-history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.recent-history-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 8px;
    font-size: 0.875rem;
}

.recent-history-item .text-pair {
    flex: 1;
    min-width: 120px;
}

.recent-history-item .original,
.recent-history-item .result {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.recent-history-item .original { color: #555; }
.recent-history-item .result { color: #333; margin-top: 4px; }

.recent-history-item .copy-btns {
    display: flex;
    gap: 6px;
}

.recent-history-item .copy-btn {
    padding: 6px 12px;
    font-size: 0.8125rem;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 6px;
    color: #555;
    cursor: pointer;
    transition: var(--transition);
}

.recent-history-item .copy-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.recent-history-empty {
    color: #999;
    font-size: 0.875rem;
    padding: 12px 0;
}

/* Groups section */
.groups-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.group-card {
    border: 1px solid #e8e8e8;
    border-radius: var(--border-radius);
    padding: 18px 20px;
    background: #fafafa;
}

.group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.group-title {
    font-size: 1rem;
    font-weight: 600;
    color: #444;
    margin: 0;
}

.group-order-btns,
.btn-order-btns {
    display: flex;
    align-items: center;
    gap: 2px;
}

.order-btn {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e0e0e0;
    background: #fff;
    border-radius: 6px;
    color: #666;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

.order-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #e8edff;
}

.group-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}

.transform-btn {
    padding: 10px 14px;
    font-size: 0.8125rem;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 8px;
    color: #444;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.transform-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #e8edff;
}

.transform-btn.recommended {
    border-color: var(--primary);
    background: #e8edff;
    color: var(--primary);
    font-weight: 600;
}

.transform-btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border: none;
}

.transform-btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--secondary) 100%);
    color: white;
}

/* Footer */
.textransform-container footer {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    text-align: center;
    color: #666;
    font-size: 0.875rem;
}

/* Shortcuts overlay */
.shortcuts-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.shortcuts-overlay[hidden] {
    display: none;
}

.shortcuts-modal {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.shortcuts-modal h3 {
    margin-bottom: 16px;
    font-size: 1.25rem;
    color: #333;
}

.shortcuts-modal ul {
    list-style: none;
    margin-bottom: 20px;
}

.shortcuts-modal li {
    padding: 8px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9375rem;
    border-bottom: 1px solid #f0f0f0;
}

.shortcuts-modal li:last-child {
    border-bottom: none;
}

.shortcuts-modal kbd {
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8125rem;
    margin-left: 8px;
}

.btn-secondary {
    padding: 10px 20px;
    font-size: 0.9375rem;
    border: 1px solid #e0e0e0;
    background: #f5f5f5;
    border-radius: 8px;
    color: #555;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Responsive */
@media (max-width: 1023px) {
    .transform-container {
        grid-template-columns: 1fr;
    }
}

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

    .textransform-container .header-top {
        flex-wrap: wrap;
        gap: 10px;
    }

    .textransform-container .back-home {
        position: static;
        order: -1;
    }

    .textransform-container header h1 {
        font-size: 1.6rem;
        order: 0;
        flex: 1;
        text-align: center;
    }

    .textransform-container .language-switcher {
        position: static;
        order: 1;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-left {
        justify-content: flex-start;
    }

    .toolbar-right {
        justify-content: space-between;
    }

    .group-buttons {
        grid-template-columns: 1fr;
    }
}
