/* ==============================================
   Custom Fonts - Unified with backend export
   ============================================== */

/* Preview CJK faces are injected by PreviewFontSync (per-batch subset +
   optional 1.3MB Noto pack). Do not @font-face the full OTFs/TTFs here. */

/* ==============================================
   Base Styles
   ============================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 800px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.emoji {
    font-size: 64px;
    text-align: center;
    margin-bottom: 20px;
}

h1 {
    text-align: center;
    color: #333;
    font-size: 48px;
    margin-bottom: 10px;
}

.subtitle {
    text-align: center;
    color: #666;
    font-size: 18px;
    margin-bottom: 30px;
}

.info {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 30px;
}

.info h2 {
    color: #667eea;
    font-size: 20px;
    margin-bottom: 15px;
}

.info p {
    color: #555;
    line-height: 1.6;
    margin-bottom: 8px;
}

/* Demo section */
.demo {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.demo h3 {
    color: #667eea;
    font-size: 18px;
    margin-bottom: 15px;
}

.demo-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 10px;
    transition: border-color 0.3s;
}

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

.demo-button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}

.demo-button:hover {
    transform: translateY(-2px);
}

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

.demo-result {
    margin-top: 15px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    display: none;
}

.demo-result.show {
    display: block;
}

.demo-result .label {
    font-weight: bold;
    color: #667eea;
    margin-top: 10px;
}

.demo-result .value {
    color: #333;
    font-size: 18px;
    margin-bottom: 10px;
}

.demo-result .backend {
    font-size: 12px;
    color: #999;
    font-style: italic;
}

/* Pinyin Demo specific styles */
.pinyin-demo {
    margin-bottom: 30px;
}

.pinyin-demo .controls-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
}

.pinyin-demo .description {
    color: #666;
    margin-bottom: 20px;
    text-align: center;
}

.demo-result .result-row {
    display: flex;
    align-items: baseline;
    margin-bottom: 12px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 6px;
}

.demo-result .result-row .label {
    min-width: 80px;
    font-weight: 600;
    color: #667eea;
    margin: 0;
}

.demo-result .result-row .value {
    flex: 1;
    margin: 0;
}

.demo-result .result-row .value.chinese {
    font-size: 24px;
    font-weight: 500;
}

.demo-result .result-row .value.pinyin {
    font-size: 20px;
    color: #764ba2;
}

/* Error message */
.error-message {
    margin-top: 15px;
    padding: 12px 16px;
    background: #fee;
    border-left: 4px solid #f44;
    border-radius: 4px;
    color: #c33;
    display: flex;
    align-items: center;
    gap: 8px;
}

.error-icon {
    font-size: 20px;
}

/* Button disabled state */
.demo-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Text Processor Demo specific styles */
.text-processor-demo {
    margin-bottom: 30px;
}

.controls-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.toggle-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.toggle-text {
    font-size: 15px;
    font-weight: 500;
    color: #333;
}

.auto-hint {
    font-size: 13px;
    color: #888;
    font-style: italic;
}

.view-mode-btn {
    padding: 8px 16px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.view-mode-btn:hover {
    background: #f8f9fa;
    border-color: #667eea;
}

.view-mode-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

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

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

.result-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.result-header .value.chinese {
    font-size: 20px;
    font-weight: 500;
    color: #333;
}

/* Words grid */
.words-grid {
    margin-top: 20px;
}

.grid-header {
    display: grid;
    grid-template-columns: 1fr 1.5fr 2fr;
    gap: 12px;
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    font-weight: 600;
    color: #555;
    font-size: 14px;
    margin-bottom: 8px;
}

.word-row {
    display: grid;
    grid-template-columns: 1fr 1.5fr 2fr;
    gap: 12px;
    padding: 12px;
    background: #fafbfc;
    border-radius: 6px;
    margin-bottom: 6px;
    transition: background 0.2s;
}

.word-row:hover {
    background: #f0f2f5;
}

.word-chinese {
    font-size: 18px;
    font-weight: 500;
    color: #333;
}

.word-pinyin {
    font-size: 16px;
    color: #764ba2;
}

.word-translations {
    font-size: 15px;
    color: #666;
}

.result-footer {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #f0f0f0;
    text-align: right;
}

.word-count {
    font-size: 14px;
    color: #888;
    font-weight: 500;
}

.demo-button:disabled:hover {
    transform: none;
}

/* Word cards */
.words-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.word-card {
    display: inline-block;
    background: white;
    border: 2px solid #667eea;
    border-radius: 8px;
    padding: 10px 15px;
    text-align: center;
    min-width: 80px;
}

.word-card .hanzi {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.word-card .pinyin {
    font-size: 14px;
    color: #667eea;
    margin-bottom: 5px;
}

.word-card .translation {
    font-size: 12px;
    color: #999;
}

/* Status indicators */
.status {
    padding: 10px;
    margin: 10px 0;
    background: #e8f5e9;
    border-left: 4px solid #4caf50;
    border-radius: 4px;
    color: #2e7d32;
}

.links {
    text-align: center;
    margin-top: 30px;
}

.links a {
    display: inline-block;
    padding: 12px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: bold;
    transition: transform 0.2s;
}

.links a:hover {
    transform: translateY(-2px);
}

/* Progress page */
.phase {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.phase h2 {
    color: #667eea;
    font-size: 20px;
    margin-bottom: 15px;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
}

.progress-text {
    color: #666;
    font-size: 14px;
    margin-bottom: 15px;
}

.task-list {
    list-style: none;
    padding: 0;
}

.task {
    padding: 8px 12px;
    margin: 5px 0;
    background: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
}

.task.completed {
    opacity: 0.7;
}

.task-icon {
    margin-right: 10px;
    font-size: 16px;
}

.task-name {
    color: #333;
    font-size: 14px;
}

/* Word Card Component */
.word-card {
    width: 150px;
    height: 200px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 16px;
    user-select: none;
}

.word-card:hover,
.word-card-hovered {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.word-card:active {
    transform: translateY(-2px);
}

.word-card-selected {
    border: 2px solid #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.word-card-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    text-align: center;
}

.word-card-chinese {
    font-size: 32px;
    font-weight: 700;
    color: #333;
    line-height: 1.2;
    margin-bottom: 8px;
}

.word-card-pinyin {
    font-size: 18px;
    color: #764ba2;
    font-weight: 500;
    margin-bottom: 8px;
}

.word-card-translations {
    font-size: 14px;
    color: #666;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

/* Card Grid Layout */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px;
    margin-top: 20px;
    padding: 20px;
}

/* Collapsible Header */
.collapsible-header {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
    padding: 10px;
    margin: -10px;
    border-radius: 8px;
}

.collapsible-header:hover {
    background: #f0f2f5;
}

.collapsible-header h2 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.collapse-hint {
    font-size: 14px;
    color: #888;
    font-weight: normal;
    margin-left: 8px;
}

.collapsible-content {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Draggable Cards in Text Processor */
.draggable-grid {
    position: relative;
}

.draggable-card {
    position: relative;
    cursor: move;
    transition: all 0.3s ease;
}

.draggable-card.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.draggable-card.drag-over {
    transform: scale(1.05);
}

.draggable-card .drag-handle {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 16px;
    color: #999;
    cursor: grab;
    z-index: 10;
    background: white;
    padding: 4px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.draggable-card:hover .drag-handle {
    opacity: 1;
}

.draggable-card .drag-handle:active {
    cursor: grabbing;
}

.drag-hint {
    font-size: 13px;
    color: #888;
    margin-left: 15px;
    font-weight: normal;
}

/* Drag Demo Component */
.drag-demo {
    margin-bottom: 30px;
}

.drag-cards-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-top: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
}

.drag-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 15px;
    cursor: move;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
}

.drag-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
}

.drag-card.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.drag-card.drag-over {
    border-color: #764ba2;
    border-style: dashed;
    background: #f0f2f5;
}

.drag-card-handle {
    font-size: 20px;
    color: #999;
    cursor: grab;
    user-select: none;
}

.drag-card-handle:active {
    cursor: grabbing;
}

.drag-card-content {
    flex: 1;
}

.drag-card-word {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.drag-card-pinyin {
    font-size: 14px;
    color: #764ba2;
    margin-bottom: 2px;
}

.drag-card-translation {
    font-size: 13px;
    color: #666;
}

.drag-info {
    margin-top: 15px;
    padding: 15px;
    background: #e8f4f8;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.drag-info p {
    margin: 5px 0;
    font-size: 14px;
    color: #333;
}

.tech-info {
    font-size: 12px !important;
    color: #888 !important;
    font-style: italic;
}

/* Processor Layout - Left/Right Split */
.processor-layout {
    display: flex;
    gap: 30px;
    margin-top: 20px;
}

.processor-left {
    flex: 1;
    min-width: 0;
}

.processor-right {
    width: 450px;
    flex-shrink: 0;
}

/* Preview Panel (Right Side) */
.preview-panel {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

.preview-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e0e0e0;
}

.preview-panel-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.preview-hint {
    font-size: 12px;
    color: #888;
    background: white;
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
}

.preview-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #999;
}

.preview-empty .empty-icon {
    font-size: 64px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.preview-empty p {
    margin: 0;
    font-size: 14px;
}

.preview-content {
    display: flex;
    flex-direction: column;
    overflow: visible;
}

/* `PreviewFontSync` renders an empty span purely to host a Leptos effect; it
   must never participate in layout. Without this it still generates a line
   box (~1 line-height) as a sibling before `.preview-section`. On screen that
   is invisible, but in print `.preview-section` starts a *named* page
   (`page: a4-sheet`), and a page-name change forces a break — so that
   invisible line box became a fully blank first sheet with the cards pushed
   to page 2. */
.preview-font-sync {
    display: none !important;
}

.preview-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    padding: 10px;
    background: white;
    border-radius: 8px;
}

.page-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.page-info {
    font-size: 13px;
    color: #666;
    min-width: 50px;
    text-align: center;
}

.preview-grid-inline {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 15px;
}

.preview-card-inline {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    min-height: 100px;
    transition: all 0.2s;
}

.preview-card-inline:hover:not(.preview-card-empty) {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.preview-card-inline.preview-card-empty {
    border-style: dashed;
    border-color: #ddd;
    background: transparent;
}

.preview-card-inline .preview-card-word {
    font-size: 24px;
    font-weight: 700;
    color: #333;
    margin-bottom: 6px;
}

.preview-card-inline .preview-card-pinyin {
    font-size: 14px;
    color: #764ba2;
    font-weight: 500;
    margin-bottom: 4px;
}

.preview-card-inline .preview-card-translations {
    font-size: 11px;
    color: #666;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.preview-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 0;
    background: transparent;
    border-radius: 0;
    margin-top: 5px;  /* Reduced from 15px for tighter layout */
    flex-shrink: 0;
}

.action-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.export-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.export-btn {
    padding: 8px 16px;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.export-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.export-pdf-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.export-pdf-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 87, 108, 0.3);
}

.export-pptx-btn {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.export-pptx-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 172, 254, 0.3);
}

.export-status {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    background: #f0f0f0;
    color: #333;
    white-space: nowrap;
}

.print-btn-inline {
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.print-btn-inline:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.card-count-inline {
    font-size: 12px;
    color: #888;
}

/* Responsive for processor layout */
@media (max-width: 1200px) {
    .processor-layout {
        flex-direction: column;
    }

    .processor-right {
        width: 100%;
    }

    .preview-panel {
        position: static;
        max-height: none;
    }
}

/* Card Preview Component */
.card-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.card-preview-container {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 1200px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.preview-header h2 {
    margin: 0;
    color: #333;
}

.preview-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.preview-btn {
    padding: 8px 16px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.preview-btn:hover:not(:disabled) {
    background: #f0f2f5;
    border-color: #667eea;
}

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

.preview-btn.close-btn {
    background: #ff4444;
    color: white;
    border-color: #ff4444;
}

.preview-btn.close-btn:hover {
    background: #cc0000;
    border-color: #cc0000;
}

.preview-btn.print-btn {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.preview-btn.print-btn:hover {
    background: #5568d3;
    border-color: #5568d3;
}

.page-indicator {
    font-size: 14px;
    color: #666;
    font-weight: 500;
    min-width: 60px;
    text-align: center;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    flex: 1;
    overflow-y: auto;
}

.preview-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    min-height: 180px;
    transition: all 0.3s ease;
}

.preview-card:hover:not(.preview-card-empty) {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.preview-card-empty {
    border-style: dashed;
    border-color: #ddd;
    background: transparent;
}

.preview-card-word {
    font-size: 36px;
    font-weight: 700;
    color: #333;
    margin-bottom: 10px;
}

.preview-card-pinyin {
    font-size: 20px;
    color: #764ba2;
    font-weight: 500;
    margin-bottom: 8px;
}

.preview-card-translations {
    font-size: 15px;
    color: #666;
    line-height: 1.5;
}

.preview-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 2px solid #e0e0e0;
}

.card-count-info {
    font-size: 14px;
    color: #888;
}

.preview-btn-trigger {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
}

.preview-btn-trigger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Print styles */
@media print {
    /* Hide EVERYTHING except the preview content. The DOM under <main> is:
       .page-container.generator-page > .page-nav, .text-processor-container
         > .page-header, .generator-layout > .generator-left, .generator-right
           > .preview-section > .preview-content-wrapper > .preview-content
             > .preview-grid (grid mode) OR .page-preview-container (page mode)
       `.generator-container` named below used to not exist in this DOM at
       all (a stale selector from an earlier layout), which made the
       "hide everything except X" exclusion rules match nothing and hide
       the entire page instead — printing was blank regardless of preview
       mode. Hiding the known unwanted regions by their real class names
       instead, so anything not listed here (i.e. .preview-section and its
       contents) stays visible by default. */
    body > *:not(main),
    nav,
    .page-header,
    .generator-left,
    .input-section,
    .word-list-section,
    .config-panel,
    .preview-header,
    .preview-actions,
    .preview-pagination,
    .zoom-control,
    .preview-mode-toggle,
    .export-buttons,
    .print-btn,
    .page-number,
    .preview-footer {
        display: none !important;
    }

    /* The preview panel can be collapsed (display: none) in the normal UI;
       printing must show its content regardless of that UI state, or
       hitting print while collapsed produces a blank page. */
    .preview-content-wrapper {
        display: flex !important;
    }

    /* Make body and main container full width */
    body {
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
        overflow: visible !important;
    }

    main {
        padding: 0 !important;
        margin: 0 !important;
        background: white !important;
    }

    .page-container,
    .text-processor-container,
    .generator-layout,
    .generator-right {
        display: block !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        background: white !important;
    }

    .preview-section {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        background: white !important;
    }

    /* Page preview mode - each page on a separate printed page */
    .page-preview-container {
        padding: 0 !important;
        margin: 0 !important;
        background: white !important;
    }

    .page-preview-scroll {
        overflow: visible !important;
        padding: 0 !important;
        margin: 0 !important;
        height: auto !important;
    }

    .page-preview-page {
        page-break-after: always;
        page-break-inside: avoid;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        background: white !important;
    }

    .page-preview-page.page-size-a4 {
        page: a4-sheet;
        width: 210mm !important;
        height: 297mm !important;
    }

    .page-preview-page.page-size-letter {
        page: letter-sheet;
        width: 216mm !important;
        height: 279mm !important;
    }

    .preview-section.page-size-a4 {
        page: a4-sheet;
    }

    .preview-section.page-size-letter {
        page: letter-sheet;
    }

    .page-preview-page:last-child {
        page-break-after: auto;
    }

    /* Grid preview mode: only one of .preview-grid / .page-preview-container
       is ever mounted at a time (the app switches between them, it doesn't
       toggle visibility on both), so grid mode must print too — hiding it
       unconditionally here used to produce a blank page whenever the user
       printed while in grid mode. */
    .preview-grid {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow-y: visible !important;
        height: auto !important;
        flex: none !important;
    }

    .preview-card {
        border: 2px solid #333;
        page-break-inside: avoid;
    }

    .preview-card-empty {
        display: none !important;
    }

    /* Ensure cards are visible and properly sized */
    .card-content {
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        height: 100%;
        padding: 10px;
    }

    /* Grid-mode print keeps A4. Page-preview named pages override this. */
    @page {
        size: A4;
        margin: 0;
    }

    @page a4-sheet {
        size: A4;
        margin: 0;
    }

    @page letter-sheet {
        size: letter;
        margin: 0;
    }
}

/* Responsive design for cards */
@media (max-width: 768px) {
    .word-card {
        width: 120px;
        height: 160px;
        padding: 12px;
    }

    .word-card-chinese {
        font-size: 24px;
    }

    .word-card-pinyin {
        font-size: 16px;
    }

    .word-card-translations {
        font-size: 12px;
    }

    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 15px;
    }

    .drag-cards-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 15px;
    }

    .drag-card {
        padding: 12px;
    }

    .drag-card-word {
        font-size: 18px;
    }

    .drag-card-pinyin {
        font-size: 13px;
    }

    .drag-card-translation {
        font-size: 12px;
    }

    /* Preview responsive */
    .preview-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        padding: 15px;
    }

    .preview-card {
        min-height: 150px;
        padding: 15px;
    }

    .preview-card-word {
        font-size: 28px;
    }

    .preview-card-pinyin {
        font-size: 16px;
    }

    .preview-card-translations {
        font-size: 13px;
    }

    .preview-controls {
        flex-wrap: wrap;
    }
}

/* ========================================
   HOME PAGE STYLES
   ======================================== */

.home-page {
    min-height: 100vh;
    padding: 0;
}

.home-topbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    padding: 16px 24px;
    background: white;
}

.home-topbar-email {
    font-size: 14px;
    color: #666;
}

.home-topbar-link {
    font-size: 14px;
    color: #1a73e8;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 8px;
    transition: background 0.2s;
}

.home-topbar-link:hover {
    background: #f0f4ff;
}

.home-topbar-login {
    border: 1px solid #1a73e8;
}

.hero {
    background: white;
    padding: 80px 20px;
    text-align: center;
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
}

.hero-title {
    font-size: 64px;
    margin-bottom: 20px;
}

/* The gradient-clip effect below also clips colored emoji glyphs, turning
   them into a flat gradient-filled box instead of the emoji's own colors
   (seen on Chrome/Windows) — so it's scoped to a span around "ZiCard" only,
   leaving the 🀄 emoji in a plain, unclipped span. */
.hero-title-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 32px;
    color: #333;
    margin-bottom: 15px;
    font-weight: 600;
}

.hero-description {
    font-size: 18px;
    color: #666;
    margin-bottom: 40px;
    line-height: 1.6;
}

.hero-actions {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 32px;
    border-radius: 10px;
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s;
    display: inline-block;
}

.btn-large {
    padding: 16px 40px;
    font-size: 18px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-secondary:hover {
    background: #667eea;
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.features {
    padding: 80px 20px;
    /* Solid band so the six cards sit on purple after the white “三步出卡”. */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.section-title {
    text-align: center;
    font-size: 36px;
    color: white;
    margin-bottom: 50px;
}

.features-grid {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.feature-card {
    background: white;
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    transition: all 0.3s;
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.feature-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.feature-card h3 {
    font-size: 20px;
    color: #333;
    margin-bottom: 10px;
}

.feature-card p {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
}

.tech-stack {
    padding: 80px 20px;
    background: white;
}

.tech-grid {
    max-width: 800px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.tech-item {
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    text-align: center;
    font-size: 14px;
    color: #666;
}

.tech-item strong {
    color: #333;
    display: block;
    margin-bottom: 5px;
}

.home-footer {
    padding: 40px 20px;
    text-align: center;
    color: white;
    font-size: 14px;
}

.home-footer-links {
    margin-top: 12px;
}

.home-footer-links a {
    color: white;
    text-decoration: underline;
}

.how-it-works {
    padding: 64px 20px;
    background: white;
}

.how-it-works .section-title {
    color: #333;
}

.how-grid {
    max-width: 960px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
}

.how-step {
    text-align: center;
    padding: 8px 12px;
}

.how-num {
    width: 36px;
    height: 36px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    line-height: 36px;
    font-weight: 700;
}

.how-step h3 {
    margin-bottom: 8px;
    color: #333;
}

.how-step p {
    color: #666;
    font-size: 14px;
    line-height: 1.6;
}

.legal-page {
    min-height: 100vh;
    background: #f7f7fb;
}

.legal-page .home-footer {
    color: #444;
}

.legal-page .home-footer-links a {
    color: #1a73e8;
}

.legal-article {
    max-width: 720px;
    margin: 0 auto;
    padding: 32px 24px 64px;
    color: #222;
    line-height: 1.7;
}

.legal-article h1 {
    margin-bottom: 8px;
}

.legal-article h2 {
    margin: 28px 0 8px;
    font-size: 20px;
}

.legal-article ul {
    padding-left: 20px;
}

.legal-updated {
    color: #666;
    font-size: 14px;
    margin-bottom: 24px;
}

.auth-legal-note {
    margin-top: 16px;
    font-size: 13px;
    color: #666;
    line-height: 1.5;
}

.auth-legal-note a {
    color: #1a73e8;
}

/* ========================================
   DEMO PAGE STYLES
   ======================================== */

.demo-page {
    padding: 20px;
}

.demo-sections {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.demo-section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.demo-title {
    margin-top: 0;
    margin-bottom: 20px;
    color: #333;
    font-size: 24px;
}

/* Text Processor Container */
.text-processor-container {
    width: 100%;
}

/* ========================================
   AUTH (LOGIN/REGISTER) PAGE STYLES
   ======================================== */

.auth-page {
    min-height: 100vh;
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* Top bar: reuse home-topbar (solid white, full width) but split brand left
   and back-link right instead of the home page's right-only layout. */
.auth-topbar {
    justify-content: space-between;
}

.auth-brand {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    text-decoration: none;
    padding: 4px 8px;
}

.auth-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: white;
    border-radius: 16px;
    padding: 40px 36px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.10);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.auth-card h1, .auth-title {
    margin: 0 0 8px;
    font-size: 24px;
    text-align: center;
    font-weight: 700;
    color: #1a1a1a;
}

.auth-subtitle {
    margin: 0 0 28px;
    color: #666;
    text-align: center;
    font-size: 14px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

.auth-field input {
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 15px;
    transition: border-color 0.18s, box-shadow 0.18s;
}

.auth-field input:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.12);
}

.auth-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
}

.auth-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #555;
    cursor: pointer;
    font-weight: 400;
}

.auth-checkbox input {
    width: auto;
    cursor: pointer;
}

.auth-forgot-link {
    color: #1a73e8;
    text-decoration: none;
}

.auth-forgot-link:hover {
    text-decoration: underline;
}

.auth-error {
    margin: 0;
    color: #d32f2f;
    font-size: 13px;
    text-align: center;
    padding: 8px 12px;
    background: #fef0f0;
    border-radius: 8px;
}

.auth-success {
    margin: 0;
    color: #1e7e34;
    font-size: 13px;
    text-align: center;
    padding: 8px 12px;
    background: #eaf7ed;
    border-radius: 8px;
}

.auth-submit {
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    background: #1a73e8;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s, transform 0.18s;
}

.auth-submit:hover:not(:disabled) {
    background: #1557b0;
}

.auth-submit:active:not(:disabled) {
    transform: scale(0.98);
}

.auth-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-mode-toggle {
    display: block;
    width: 100%;
    margin-top: 20px;
    padding: 10px;
    background: none;
    border: none;
    color: #1a73e8;
    font-size: 14px;
    cursor: pointer;
    text-align: center;
    border-radius: 8px;
    transition: background 0.18s;
}

.auth-mode-toggle:hover {
    background: #f0f4ff;
}

/* ========================================
   PAGE CHROME (nav bar + page header)

   Shared by /generator, /demo and /login. All three sit directly on the
   purple body gradient, so the type here is white-on-gradient rather than
   the dark-on-white used inside the cards.
   ======================================== */

.page-container {
    padding: 20px;
}

.page-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 24px;
    padding: 7px 8px;
    background: rgba(255, 255, 255, 0.13);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 12px;
    /* Progressive enhancement: the translucent bar is legible without it. */
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

/* On /demo the nav lives inside the header rather than above it. */
.page-header .page-nav {
    margin: 18px 0 0;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.92);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.18s, color 0.18s, transform 0.18s;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    transform: translateY(-1px);
}

.nav-link:active {
    transform: none;
}

.nav-link:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Call-to-action variant, e.g. "开始使用 →" on /demo. */
.nav-link.primary {
    background: #fff;
    color: #5a4ba8;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
}

.nav-link.primary:hover {
    background: #fff;
    color: #46379b;
    box-shadow: 0 5px 16px rgba(0, 0, 0, 0.24);
}

/* Logout is a <button> styled as a nav link; pushed to the far right and
   kept subdued until hover so it never competes with navigation. */
.nav-link-button {
    background: none;
    border: none;
    cursor: pointer;
    margin-left: auto;
    color: rgba(255, 255, 255, 0.74);
}

.nav-link-button:hover {
    background: rgba(226, 86, 86, 0.32);
    color: #fff;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    margin: 0 0 8px;
    font-size: clamp(22px, 2.6vw, 32px);
    font-weight: 700;
    line-height: 1.25;
    color: #fff;
    letter-spacing: 0.4px;
    text-shadow: 0 2px 14px rgba(0, 0, 0, 0.24);
}

.page-description {
    margin: 0;
    font-size: 15px;
    color: rgba(255, 255, 255, 0.85);
}

@media (max-width: 640px) {
    .page-nav {
        gap: 4px;
        padding: 6px;
    }

    .nav-link {
        padding: 7px 10px;
        font-size: 13px;
    }
}

/* ========================================
   GENERATOR PAGE STYLES
   ======================================== */

.generator-page {
    padding: 20px;
}

.generator-layout {
    display: flex;
    gap: 20px;
}

.generator-left {
    flex: 1;
    min-width: 0;
}

.generator-middle {
    width: 350px;
    flex-shrink: 0;
}

.generator-right {
    flex: 1;
    min-width: 0;
}

.input-section,
.word-list-section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.preview-section {
    background: transparent;
    border-radius: 12px;
    padding: 25px;
    box-shadow: none;
}

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

.input-section h2,
.word-list-section h2 {
    font-size: 20px;
    color: #333;
    margin-bottom: 15px;
}

.preview-section h2 {
    font-size: 20px;
    color: white;
    margin-bottom: 15px;
}

.section-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 15px;
}

.section-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 8px 12px;
    margin: -8px -12px;
    border-radius: 8px;
    transition: background 0.2s;
}

.section-title-row:hover {
    background: #f5f7fa;
}

.section-title-row h2 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title-row .text-count {
    font-size: 14px;
    font-weight: 400;
    color: #888;
}

.section-title-row .collapse-btn {
    background: none;
    border: none;
    font-size: 16px;
    color: #666;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.section-title-row .collapse-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.section-header h2 {
    margin-bottom: 0;
}

.settings-toggles {
    display: flex;
    gap: 20px;
}

.settings-toggles.hidden {
    display: none;
}

.input-content {
    transition: all 0.3s ease;
}

.input-content.collapsed {
    display: none;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.toggle-checkbox,
.toggle-radio {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #667eea;
}

/* Split-mode radios sit together and read as one control. */
.segment-mode-group {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-right: 14px;
    border-right: 1px solid #e5e7eb;
}

.toggle-text {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

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

.generator-input {
    width: 100%;
    min-height: 200px;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s;
}

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

.status-message {
    margin-top: 15px;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
}

.status-message.loading {
    background: #e3f2fd;
    color: #1976d2;
}

.status-message.error {
    background: #ffebee;
    color: #c62828;
}

/* Word list header with collapse button */
.word-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 8px 12px;
    margin: -12px -12px 12px -12px;
    border-radius: 8px;
    transition: background 0.2s;
}

.word-list-header:hover {
    background: #f5f7fa;
}

.word-list-header h2 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.word-list-header .word-count {
    font-size: 14px;
    font-weight: 400;
    color: #888;
}

.word-list-header .collapse-btn {
    background: none;
    border: none;
    font-size: 16px;
    color: #666;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.word-list-header .collapse-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.word-list-content {
    transition: all 0.3s ease;
    overflow: hidden;
}

.word-list-content.collapsed {
    display: none;
}

.word-list-section .hint {
    font-size: 13px;
    color: #888;
    margin-bottom: 15px;
}

.word-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.word-list-card {
    position: relative;
    cursor: move;
    transition: all 0.2s;
}

.word-list-card .drag-handle {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 16px;
    color: #ccc;
    opacity: 0;
    transition: opacity 0.2s;
}

.word-list-card:hover .drag-handle {
    opacity: 1;
}

.word-list-card.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.word-list-card.drag-over {
    transform: scale(1.05);
}

.preview-section {
    position: static;  /* Normal flow, scrolls with page */
    display: flex;
    flex-direction: column;
}

.preview-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 15px;
}

.preview-header h2 {
    margin-bottom: 0;
}

.refresh-preview-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.refresh-preview-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.preview-empty .hint {
    font-size: 13px;
    color: #888;
    margin-top: 10px;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.preview-card {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    min-height: 120px;
    transition: all 0.2s;
    /* Use container query for responsive font sizing */
    container-type: inline-size;
    container-name: preview-card;
}

.preview-card:hover:not(.preview-card-empty) {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.preview-card.preview-card-empty {
    border-style: dashed;
    border-color: #ddd;
    background: transparent;
}

.preview-card-word {
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
    word-break: break-word;
    overflow-wrap: anywhere;
    /* Responsive font size: min of configured size or container-relative */
    font-size: min(var(--hanzi-size, 28px), 25cqi) !important;
    max-width: 100%;
    line-height: 1.2;
}

.preview-card-pinyin {
    color: #764ba2;
    font-weight: 500;
    margin-bottom: 6px;
    word-break: break-word;
    overflow-wrap: anywhere;
    font-size: min(var(--pinyin-size, 16px), 15cqi) !important;
    max-width: 100%;
}

.preview-card-translations {
    font-size: 12px;
    color: #666;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.preview-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 15px;
    border-top: none;
    background: transparent;
}

.action-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.print-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.card-count {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
}

/* Responsive */
@media (max-width: 1200px) {
    .generator-layout {
        flex-direction: column;
    }

    .generator-right {
        width: 100%;
    }

    .preview-section {
        position: static;
        max-height: none;
    }

    .generator-middle {
        width: 100%;
    }
}

/* Configuration Panel Styles */
.config-panel {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.3s ease;
}

.config-panel.collapsed .config-content {
    display: none;
}

.config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    user-select: none;
}

.config-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.collapse-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.collapse-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.config-content {
    padding: 20px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.config-group {
    margin-bottom: 20px;
}

.config-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
    cursor: help;
}

.config-select,
.config-number {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.config-select:focus,
.config-number:focus {
    outline: none;
    border-color: #667eea;
}

/* Font selector specific styles */
.font-selector {
    font-family: system-ui, -apple-system, sans-serif;
}

.font-preview {
    margin-top: 12px;
    padding: 16px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    text-align: center;
    font-size: 24px;
    font-weight: 500;
    color: #333;
    transition: all 0.3s ease;
}

.font-preview:hover {
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Advanced Layout Limits Styles */
.limits-section {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px;
    margin-top: 8px;
    margin-bottom: 12px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.limits-group {
    margin-bottom: 16px;
}

.limits-group:last-child {
    margin-bottom: 0;
}

.limits-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.limits-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.limits-input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.limits-sublabel {
    font-size: 12px;
    font-weight: 500;
    color: #718096;
}

.limits-input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #d1d9e6;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    transition: all 0.2s ease;
}

.limits-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.limits-input:hover {
    border-color: #a0aec0;
}

/* Preset colors grid */
.preset-colors-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 12px;
}

.preset-color-btn {
    width: 100%;
    height: 40px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.preset-color-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border-color: #667eea;
}

.preset-color-btn.selected {
    border-color: #667eea;
    border-width: 3px;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.preset-color-btn.selected::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #333;
    font-size: 20px;
    font-weight: bold;
    text-shadow: 0 0 2px white, 0 0 4px white;
}

/* Layout Suggestions Styles */
.layout-suggestions {
    margin-bottom: 24px;
}

.no-suggestions {
    padding: 16px;
    text-align: center;
    color: #666;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 14px;
}

.suggestions-container {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.suggestions-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.suggestion-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 14px;
    transition: all 0.2s ease;
}

.suggestion-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.suggestion-card.current {
    border-color: #4caf50;
    background: #f1f8f4;
}

.suggestion-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.suggestion-rank {
    font-size: 20px;
}

.suggestion-title {
    font-weight: 600;
    color: #333;
    font-size: 15px;
    flex: 1;
}

.current-badge {
    background: #4caf50;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.suggestion-details {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 10px;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
}

.detail-label {
    color: #666;
}

.detail-value {
    color: #333;
    font-weight: 500;
}

.detail-value.empty-slots {
    color: #ff9800;
}

.apply-btn {
    width: 100%;
    padding: 10px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.apply-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.apply-btn:active {
    transform: translateY(0);
}

.current-indicator {
    text-align: center;
    color: #4caf50;
    font-weight: 500;
    font-size: 14px;
    padding: 8px;
}


/* Layout Suggestions Modal */
.suggestions-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.suggestions-modal {
    background: #ffffff;
    border-radius: 12px;
    padding: 18px 20px;
    width: min(420px, 90vw);
    max-height: 80vh;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.suggestions-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.suggestions-modal-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.suggestions-modal-close {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    padding: 4px 8px;
}

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

.suggestions-modal-body {
    max-height: 60vh;
    overflow-y: auto;
}

/* Auto-fill + suggestions trigger layout */
.auto-fill-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.auto-fill-actions .auto-fill-btn {
    width: auto;
    flex: 1;
}


.suggestions-trigger-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(102, 126, 234, 0.25);
    background: #f5f5ff;
    color: #555;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.suggestions-trigger-btn:hover {
    background: #ecebff;
    color: #667eea;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.25);
}

/* Editable word card styles */
.editable-word-card {
    width: 100%;
}

.word-list-card.editing {
    background: #f8f9fa;
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.word-list-card.editing .drag-handle {
    display: none;
}

.display-mode {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.word-content {
    flex: 1;
}

.word-chinese {
    font-size: 24px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
}

.word-pinyin {
    font-size: 14px;
    color: #7f8c8d;
    margin-bottom: 4px;
}

.word-translations {
    font-size: 13px;
    color: #95a5a6;
}

.card-actions {
    display: flex;
    gap: 6px;
}

.btn-edit, .btn-delete {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-edit:hover {
    background: #e3f2fd;
    transform: scale(1.1);
}

.btn-delete:hover {
    background: #ffebee;
    transform: scale(1.1);
}

.edit-mode {
    padding: 12px;
}

.edit-field {
    margin-bottom: 12px;
}

.edit-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
}

.edit-input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.edit-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.btn-save, .btn-cancel {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-cancel {
    background: #f5f5f5;
    color: #666;
}

.btn-cancel:hover {
    background: #e0e0e0;
}

.config-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e0e0e0;
    outline: none;
    -webkit-appearance: none;
}

.config-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    transition: transform 0.2s;
}

.config-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.config-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    transition: transform 0.2s;
}

.config-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
}

.config-color {
    width: 100%;
    height: 40px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.2s;
}

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

/* Toggle Switch Styles */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 1px #667eea;
}

.config-actions {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.reset-btn,
.export-btn,
.import-btn {
    width: 100%;
    padding: 12px;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.reset-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 87, 108, 0.3);
}

.export-btn {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.export-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 172, 254, 0.3);
}

.import-btn {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.import-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(67, 233, 123, 0.3);
}

.reset-btn:active,
.export-btn:active,
.import-btn:active {
    transform: translateY(0);
}

/* ============================================
   Preview Mode Toggle Styles
   ============================================ */

.preview-mode-toggle {
    display: flex;
    gap: 8px;
    background: #f0f0f0;
    padding: 4px;
    border-radius: 8px;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    transition: all 0.2s ease;
}

.mode-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.mode-btn.active {
    background: white;
    color: #667eea;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mode-icon {
    font-size: 16px;
}

.mode-label {
    font-size: 13px;
}

/* ============================================
   Page Preview Styles
   ============================================ */

.page-preview-scroll {
    flex: 0 0 auto;
    overflow: visible;  /* Content flows naturally, page scrolls */
    padding: 0;
    background: transparent;
    border-radius: 0;
    margin: 5px 0;
    border: none;
    box-shadow: none;
}

.page-preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    transform-origin: top center;
}

.page-preview-page {
    background: white;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    border: 1px solid #e0e0e0;
}

/* Grid lines overlay */
.grid-lines-overlay {
    position: absolute;
    pointer-events: none;
    z-index: 5;
}

.grid-line-v,
.grid-line-h {
    position: absolute;
    background-color: rgba(102, 126, 234, 0.2);
    pointer-events: none;
}

.grid-line-v {
    width: 1px;
    top: 0;
    bottom: 0;
}

.grid-line-h {
    height: 1px;
    left: 0;
    right: 0;
}

/* Highlight margin area when grid lines are shown */
.page-preview-page.show-grid-lines {
    background: linear-gradient(
        to right,
        rgba(255, 200, 200, 0.05) 0%,
        transparent 5%,
        transparent 95%,
        rgba(255, 200, 200, 0.05) 100%
    ),
    linear-gradient(
        to bottom,
        rgba(255, 200, 200, 0.05) 0%,
        transparent 5%,
        transparent 95%,
        rgba(255, 200, 200, 0.05) 100%
    ),
    white;
}

.page-number {
    position: absolute;
    top: 5px;
    right: 10px;
    font-size: 11px;
    color: #999;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 8px;
    border-radius: 4px;
    z-index: 10;
}

.page-preview-grid {
    display: grid;
    /* Width/height and margins are set inline by the component */
}

.page-preview-card {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 10px;
    overflow: hidden;
}

.page-preview-card-empty {
    border-style: dashed;
    border-color: #ddd;
    background: transparent !important;
}

.page-preview-card-word {
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
    line-height: 1.2;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.page-preview-card-pinyin {
    color: #764ba2;
    font-weight: 500;
    margin-bottom: 6px;
    line-height: 1.2;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.page-preview-card-translations {
    color: #666;
    line-height: 1.4;
    font-size: 0.9em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

/* ============================================
   Zoom Control Styles
   ============================================ */

.zoom-control {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: transparent;
    border-radius: 8px;
    justify-content: center;
}

.zoom-btn {
    min-width: 40px;
    height: 40px;
    border: 2px solid #667eea;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    line-height: 1;
    flex-shrink: 0;
}

.zoom-btn-icon {
    display: block;
    font-size: 24px;
    line-height: 1;
}

.zoom-btn:hover:not(:disabled) {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.zoom-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.zoom-btn-text {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #667eea;
    transition: all 0.2s ease;
}

.zoom-btn-text:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.zoom-level {
    min-width: 50px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: white;
}

/* ============================================
   Preview Header Controls
   ============================================ */

.preview-header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.preview-header-controls.hidden {
    display: none;
}

/* Preview title row with collapse button */
.preview-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 8px 12px;
    margin: -8px -12px;
    border-radius: 8px;
    transition: background 0.2s;
}

.preview-title-row:hover {
    background: #f5f7fa;
}

.preview-title-row h2 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-title-row .preview-count {
    font-size: 14px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.8);
}

.preview-title-row .collapse-btn {
    background: none;
    border: none;
    font-size: 16px;
    color: #666;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.preview-title-row .collapse-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.preview-content-wrapper {
    display: flex;
    flex-direction: column;
    overflow: visible;
    transition: all 0.3s ease;
}

.preview-content-wrapper.collapsed {
    display: none;
}

/* ============================================
   Auto-fill Button Styles
   ============================================ */

.auto-fill-btn {
    width: 100%;
    padding: 10px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.auto-fill-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.auto-fill-btn:active {
    transform: translateY(0);
}

/* ============================================
   Translation Configuration Styles
   ============================================ */

.translation-config {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

.config-section-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
}

.api-key-input-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.api-key-input-group .config-input {
    flex: 1;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.toggle-visibility-btn {
    padding: 8px 12px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
}

.toggle-visibility-btn:hover {
    background: #e0e0e0;
    border-color: #ccc;
}

.test-connection-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.test-connection-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.test-connection-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.test-status {
    margin-top: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 13px;
    text-align: center;
}

/* ============================================
   Config Panel Tab Navigation
   ============================================ */

.config-tabs {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 16px;
    gap: 4px;
}

.config-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    transition: all 0.2s ease;
    flex: 1;
    justify-content: center;
}

.config-tab:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.config-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: rgba(102, 126, 234, 0.08);
}

.config-tab .tab-icon {
    font-size: 16px;
}

.config-tab .tab-label {
    font-size: 13px;
}

/* Responsive: Adjust tabs for medium screens */
@media (max-width: 1200px) {
    .config-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .config-tabs::-webkit-scrollbar {
        display: none;
    }

    .config-tab {
        flex: 1 0 auto;
        min-width: fit-content;
    }
}

/* Responsive: Hide labels on smaller screens */
@media (max-width: 600px) {
    .config-tab .tab-label {
        display: none;
    }

    .config-tab {
        padding: 12px 16px;
        flex: 1;
    }

    .config-tab .tab-icon {
        font-size: 20px;
    }

    .config-tabs {
        justify-content: space-around;
    }
}

/* Very small screens */
@media (max-width: 400px) {
    .config-tab {
        padding: 10px 12px;
    }

    .config-tab .tab-icon {
        font-size: 18px;
    }

    .tab-panel {
        min-height: 150px;
    }
}

.config-tab-content {
    animation: fadeIn 0.2s ease;
}

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

.tab-panel {
    min-height: 200px;
}

/* Advanced Settings Section */
.advanced-settings {
    padding-top: 8px;
}

.advanced-settings .config-section-title {
    margin-bottom: 16px;
}
/* ============================================================
   Ruby annotation (拼音预览 + 多格式复制/导出)
   ============================================================ */

.annotation-section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.annotation-section h2 {
    font-size: 20px;
    color: #333;
    margin-bottom: 15px;
}

.annotation-content {
    transition: all 0.3s ease;
}

.annotation-content.collapsed {
    display: none;
}

.annotation-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.annotation-style-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #555;
}

.annotation-select {
    padding: 5px 8px;
    border: 1px solid #d7dce5;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.annotation-settings-btn,
.annotation-reset-btn {
    background: #f2f4f8;
    border: 1px solid #d7dce5;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
}

.annotation-settings-btn:hover,
.annotation-reset-btn:hover {
    background: rgba(102, 126, 234, 0.12);
    border-color: #667eea;
    color: #667eea;
}

.annotation-hint {
    font-size: 13px;
    color: #999;
}

.annotation-settings {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    padding: 12px 14px;
    margin-bottom: 12px;
    background: #f7f9fc;
    border-radius: 8px;
}

.annotation-settings.hidden {
    display: none;
}

.annotation-settings label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    color: #555;
}

/* ── The ruby preview itself ────────────────────────────────── */

.ruby-preview {
    /* line-height is set inline so the 行间距 slider can drive it; it must be
       generous enough that <rt> from one line never touches the line above. */
    min-height: 90px;
    max-height: 340px;
    overflow-y: auto;
    padding: 18px 16px;
    border: 1px solid #e3e7ef;
    border-radius: 10px;
    background: #fcfdff;
    white-space: pre-wrap;
    word-break: break-word;
}

.ruby-preview-empty {
    color: #aab1bd;
    font-size: 14px;
}

.ruby-unit {
    /* ruby-position/align are the properties that actually put the reading
       above the character and centre it; text-align keeps Safari honest. */
    ruby-position: over;
    ruby-align: center;
    text-align: center;
    margin: 0 1px;
}

.ruby-rt {
    color: #5a6270;
    font-family: "Times New Roman", "Georgia", serif;
    font-weight: 400;
    line-height: 1.25;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.15s;
    user-select: none;
}

.ruby-rt:hover {
    background: rgba(102, 126, 234, 0.16);
    color: #4453c7;
}

.ruby-rt-input {
    width: 6em;
    font-size: inherit;
    font-family: inherit;
    text-align: center;
    padding: 0 2px;
    border: 1px solid #667eea;
    border-radius: 3px;
    outline: none;
    background: white;
    color: #333;
}

.ruby-plain {
    /* Non-Chinese runs share the baseline with the ruby bases. */
    vertical-align: baseline;
}

/* ── Export bar ─────────────────────────────────────────────── */

.annotation-export-bar {
    margin-top: 14px;
}

.annotation-export-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.annotation-export-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.annotation-export-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35);
}

.annotation-export-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.annotation-export-status {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
}

.annotation-export-status.success {
    background: #e8f7ee;
    color: #1f7a44;
}

.annotation-export-status.error {
    background: #fdecec;
    color: #b3261e;
}

@media print {
    .annotation-toolbar,
    .annotation-settings,
    .annotation-export-bar,
    .annotation-section .collapse-btn {
        display: none !important;
    }

    .ruby-preview {
        max-height: none;
        overflow: visible;
        border: none;
        background: white;
    }
}

/* ────────────────────────────────────────────────────────────
   Demo mode (RFC-001): fixed-sample gating styles
   ──────────────────────────────────────────────────────────── */

/* Readonly textarea in demo mode: subtle tint to signal "not editable" */
textarea.generator-input.demo-readonly {
    background: #f6f8fa;
    cursor: default;
    color: #24292f;
}

/* Upgrade CTA banner shown in place of the manual-process button */
.demo-cta-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.9rem;
    margin-top: 0.5rem;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 6px;
    font-size: 0.9rem;
}

.demo-cta-text {
    color: #6b5b00;
}

.demo-cta-link {
    margin-left: auto;
    font-weight: 600;
    color: #b8860b;
    text-decoration: none;
    white-space: nowrap;
}

.demo-cta-link:hover {
    text-decoration: underline;
    color: #9a7300;
}

/* Locked export buttons in demo mode */
.annotation-export-btn.demo-locked {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Hint under the translation source selector in demo mode */
.config-hint.demo-hint {
    margin: 0.4rem 0 0;
    font-size: 0.82rem;
    color: #9a7300;
}

/* Upgrade hint at the bottom of the card preview in demo mode */
.demo-preview-hint {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #6b5b00;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.demo-preview-hint .demo-cta-link {
    margin-left: auto;
}
