/* Load Noto Sans CJK and Noto Serif CJK fonts from local files for preview */
@font-face {
    font-family: 'Noto Sans SC';
    src: url('./fonts/NotoSansSC-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: block;
}

@font-face {
    font-family: 'Noto Serif SC';
    src: url('./fonts/NotoSerifSC-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: block;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333333;
    margin: 0;
    padding: 0;
}

/* Screen-reader only (a11y descriptions) */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body.index-page {
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    display: flex;
    flex: 1;
    min-height: 0;
    width: 100vw;
    overflow: hidden;
}

/* Left Panel */
.left-panel {
    width: 500px;
    background-color: #f5f5f5;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 2px solid #e0e0e0;
    transition: width 0.3s ease;
}

/* Tablets / iPad: narrower editor so the preview area stays usable */
@media screen and (min-width: 600px) and (max-width: 1366px) {
    body.index-page .left-panel {
        width: 360px;
    }

    body.index-page .left-panel-header {
        padding: 12px 14px;
    }

    body.index-page .left-panel-content {
        padding: 14px;
    }

    body.index-page .import-buttons {
        flex-wrap: wrap;
    }

    body.index-page .left-panel.collapsed {
        width: 0;
    }
}

.left-panel.collapsed {
    width: 0;
    padding: 0;
    border-right: none;
}

.left-panel.collapsed .left-panel-content {
    display: none;
}

.left-panel.collapsed .toggle-panel-btn {
    transform: rotate(180deg);
}

.left-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #f5f5f5;
    border-bottom: 2px solid #e0e0e0;
}

.left-panel-header h2 {
    font-size: 18px;
    color: #333333;
    margin: 0;
}

.toggle-panel-btn {
    background: none;
    border: none;
    color: #666666;
    cursor: pointer;
    font-size: 18px;
    padding: 5px 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, transform 0.3s;
}

.toggle-panel-btn .toggle-panel-icon {
    display: block;
}

.toggle-panel-btn:hover {
    color: #333333;
}

.left-panel-content {
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Expand Panel Button */
.expand-panel-btn {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    background-color: #ffffff;
    color: #333333;
    border: 1px solid #e0e0e0;
    border-radius: 0 10px 10px 0;
    padding: 30px 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    transition: background-color 0.2s;
}

.expand-panel-btn:hover {
    background-color: #f5f5f5;
}

.expand-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    color: inherit;
}

.expand-arrow .expand-chevron-icon {
    display: block;
}

.expand-text {
    font-size: 12px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

.import-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.import-btn {
    flex: 1;
    padding: 11px 12px;
    background-color: #ffffff;
    color: #546e7a;
    border: 1px solid #cfd8dc;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.import-btn:hover {
    background-color: #eceff1;
    border-color: #b0bec5;
    color: #37474f;
}

.import-btn-csv {
    border-left: 3px solid #2e7d32;
}

.import-btn-quizlet {
    border-left: 3px solid #1565c0;
}

.import-btn-anki {
    border-left: 3px solid #78909c;
}

.import-btn-csv:hover {
    border-left-color: #1b5e20;
}

.import-btn-quizlet:hover {
    border-left-color: #0d47a1;
}

.import-btn-anki:hover {
    border-left-color: #546e7a;
}

.clear-all-cards-btn {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    margin-bottom: 20px;
    background-color: transparent;
    color: #994444;
    border: 1px solid #cc8888;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.clear-all-cards-btn:hover:not(:disabled) {
    background-color: #fff5f5;
    border-color: #cc6666;
    color: #cc2222;
}

.clear-all-cards-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.clear-all-cards-modal-buttons {
    flex-wrap: wrap;
}

.clear-all-cards-proceed-btn {
    flex: 1;
    padding: 12px;
    background-color: #cc0000;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
}

.clear-all-cards-proceed-btn:hover {
    background-color: #aa0000;
}

/* Import CSV, Quizlet, Anki buttons share equal width via .import-btn flex: 1 */

.cards-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 20px;
}

.cards-list-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    padding: 20px;
    color: #888888;
    text-align: center;
    font-size: 14px;
}

.card-item {
    background-color: #ffffff;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid #e0e0e0;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}


.card-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.card-number {
    font-weight: bold;
    color: #666666;
    font-size: 12px;
}

.card-actions {
    display: flex;
    gap: 5px;
}

.card-action-btn {
    background: none;
    border: none;
    color: #666666;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 5px;
    transition: color 0.2s;
}

.card-action-btn:hover {
    color: #333333;
}

.card-action-btn.delete-btn {
    color: #ff4444;
    font-size: 12px;
}

.card-action-btn.delete-btn:hover {
    color: #ff6666;
}

.card-field {
    margin-bottom: 10px;
}

.card-field-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.card-field-header .formatting-buttons {
    display: flex;
    gap: 5px;
    position: relative;
    top: 6px;
}

.card-field-header .format-btn {
    padding: 2px 6px;
    background-color: #f5f6f7;
    border: 1px solid #e8e9eb;
    border-radius: 3px;
    color: #8f9194;
    font-size: 11px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.card-field-header .format-btn:not(.format-reset-styling) {
    width: 24px;
    min-width: 24px;
    max-width: 24px;
    height: 24px;
    padding: 0;
}

.card-field-header .format-btn:disabled {
    opacity: 0.38;
    cursor: not-allowed;
}

.card-field-header .format-btn.format-reset-styling {
    width: auto;
    min-width: max-content;
    max-width: none;
    height: 24px;
    padding: 0 12px;
    white-space: nowrap;
    font-size: 11px;
    line-height: 1;
}

.card-field-header .format-btn.format-bold {
    font-weight: bold;
}

.card-field-header .format-btn.format-italic {
    font-style: italic;
}

.card-field-header .format-btn.format-underline {
    text-decoration: underline;
}

.card-field-header .format-btn:hover:not(:disabled) {
    background-color: #eceeef;
    border-color: #dcdfe3;
    color: #6d7074;
}

.card-field-header .format-btn.active {
    background-color: #7aa7d4;
    border-color: #6b9bc9;
    color: #ffffff;
}

.card-field label {
    display: block;
    font-size: 12px;
    color: #666666;
    margin-bottom: 5px;
}

.card-field-input-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.card-add-image-box {
    flex-shrink: 0;
    width: 74px;
    height: 60px;
    min-width: 74px;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px;
    background: transparent;
    border: 1px dashed #b0b0b0;
    border-radius: 4px;
    cursor: pointer;
    color: #868686;
    font-size: 10px;
    line-height: 1.2;
    text-align: center;
}

.card-add-image-box:hover {
    border-color: #2196F3;
    color: #2196F3;
}

.card-add-image-icon {
    font-size: 18px;
}

.card-add-image-label {
    font-size: 9px;
    white-space: nowrap;
}

.card-field-input-row .contenteditable-input {
    flex: 1;
    min-width: 0;
}

.card-field input,
.card-field textarea,
.card-field .contenteditable-input {
    width: 100%;
    padding: 8px;
    background-color: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    color: #333333;
    font-size: 14px;
    font-family: inherit;
}

.card-field textarea {
    resize: vertical;
    min-height: 60px;
}

.contenteditable-input {
    min-height: 60px;
    outline: none;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.contenteditable-input:focus {
    border-color: #2196F3;
    outline: 1px solid #2196F3;
}

.contenteditable-input.is-placeholder {
    color: #b0b0b0;
}

.card-image-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding: 6px;
    background-color: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.card-image-thumbnail {
    max-width: 80px;
    max-height: 60px;
    object-fit: contain;
    border-radius: 4px;
}

.card-remove-image-btn {
    padding: 4px 8px;
    font-size: 12px;
    background-color: #f0f0f0;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    cursor: pointer;
    color: #333;
}

.card-remove-image-btn:hover {
    background-color: #e8e8e8;
}

.card-field-header .format-btn.format-image {
    font-size: 14px;
    padding: 2px 6px;
}


.add-card-btn {
    width: 100%;
    padding: 12px;
    background-color: #2196F3;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.2s;
}

.add-card-btn:hover {
    background-color: #0052a3;
}

/* Main Workspace */
.main-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #f2faff;
    overflow: hidden;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background-color: #d7f0ff;
    border-bottom: 2px solid #bbdefb;
}

/* Alignment profile strip: compact width, flush to the main workspace right edge */
body.index-page .header {
    padding-right: 0;
}

body.index-page .calibration-header-toolbar {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
    /* Match .bottom-controls horizontal inset so Manage Profiles lines up with PRINT */
    padding-right: 30px;
}

.header-left {
    min-width: 0;
    flex: 1 1 auto;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 5px;
}

.header-brand-link {
    text-decoration: none;
    color: inherit;
    user-select: text;
}

.header-brand-link:hover {
    opacity: 0.9;
}

.header-logo {
    height: 48px;
    width: auto;
    flex-shrink: 0;
}

.header-title {
    display: flex;
    flex-direction: column;
    line-height: 0.9;
    margin: 0;
    font-size: 32px;
}

.title-line {
    display: block;
}

.title-flashcard {
    font-weight: 400;
}

.title-printer {
    font-weight: bold;
}

.subtitle {
    font-size: 12px;
    color: #666666;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex-shrink: 1;
    justify-content: flex-end;
}

.calibration-header-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 12px;
    padding: 8px 12px;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    background-color: #f3f4f6;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: none;
}

/* Profile field: label stacks above select (visual group lives inside .calibration-header-toolbar) */
.calibration-profile-picker {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    min-width: 0;
    padding-right: 2px;
}

.calibration-profile-picker label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #757575;
    line-height: 1.25;
}

.calibration-profile-picker .offset-select {
    border-color: #c5c5c5;
    font-weight: 500;
    box-shadow: none;
}

/* No profile chosen — subtle hint without strong warning chrome */
.calibration-profile-picker .offset-select:has(option[value="none"]:checked) {
    border-color: #d4a574;
    background-color: #fffaf3;
    color: #5d4037;
    font-weight: 500;
    box-shadow: none;
}

.calibration-toolbar-divider {
    align-self: stretch;
    width: 1px;
    min-height: 36px;
    margin: 2px 0;
    background: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0),
        rgba(0, 0, 0, 0.08) 25%,
        rgba(0, 0, 0, 0.08) 75%,
        rgba(0, 0, 0, 0)
    );
    flex-shrink: 0;
}

.calibration-info-btn {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    font-style: italic;
    line-height: 1;
    color: #1565c0;
    background-color: #ffffff;
    border: 1px solid #90caf9;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.calibration-info-btn:hover {
    background-color: #e3f2fd;
    border-color: #64b5f6;
    color: #0d47a1;
}

.calibration-info-btn:focus-visible {
    outline: 2px solid #2196f3;
    outline-offset: 2px;
}

.calibration-info-icon {
    display: block;
    margin-top: 1px;
}

.header-right label {
    font-size: 14px;
    color: #666666;
}

.offset-select {
    padding: 8px 12px;
    background-color: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    color: #333333;
    font-size: 14px;
    cursor: pointer;
}

/*
 * Up to 1240px (phones, iPad landscape, narrow windows): calibration stays top-right in a
 * narrow column — same pattern as phone; avoids a full-width row that eats vertical space.
 */
@media screen and (max-width: 1240px) {
    body.index-page .header {
        flex-wrap: nowrap;
        align-items: flex-start;
        column-gap: 10px;
        row-gap: 0;
        padding: 12px 16px;
        padding-right: 0;
    }

    body.index-page .header-left {
        flex: 1 1 0;
        min-width: 0;
        max-width: none;
    }

    body.index-page .header-right {
        flex: 0 0 auto;
        flex-shrink: 0;
        max-width: min(252px, 36vw);
        justify-content: flex-end;
    }

    body.index-page .header-brand {
        gap: 10px;
        margin-bottom: 4px;
        align-items: flex-start;
    }

    body.index-page .header-logo {
        height: 40px;
    }

    body.index-page .header-title {
        font-size: clamp(1.25rem, 3.2vw, 1.75rem);
    }

    body.index-page .subtitle {
        font-size: 11px;
        line-height: 1.35;
        max-width: 100%;
        margin: 0;
    }

    body.index-page .calibration-header-toolbar {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
        width: 100%;
        max-width: 100%;
        align-self: flex-start;
        column-gap: 6px;
        row-gap: 6px;
        padding: 8px 9px;
        padding-right: 30px;
        box-sizing: border-box;
    }

    body.index-page .calibration-profile-picker {
        grid-column: 1 / -1;
        flex: 0 0 auto;
        min-width: 0;
        padding-right: 0;
    }

    body.index-page .calibration-profile-picker label {
        font-size: 10px;
        line-height: 1.2;
        white-space: normal;
    }

    body.index-page .calibration-profile-picker .offset-select {
        font-size: 12px;
        padding: 6px 8px;
        max-width: 100%;
    }

    body.index-page .calibration-toolbar-divider {
        display: none;
    }

    body.index-page .calibration-header-toolbar .calibration-btn {
        min-width: 0;
        white-space: normal;
        hyphens: auto;
        text-align: center;
        line-height: 1.2;
        padding: 7px 6px;
        font-size: 11px;
        font-weight: 600;
        border-radius: 7px;
    }

    body.index-page #calibration-help-btn.calibration-info-btn {
        grid-column: 1;
        align-self: center;
        justify-self: start;
    }

    body.index-page #calibration-test-btn.calibration-btn {
        grid-column: 2;
    }

    body.index-page #manage-profiles-btn.calibration-btn {
        grid-column: 3;
    }
}

/* Phones only: tighter header and calibration column */
@media screen and (max-width: 640px) {
    body.index-page .header {
        column-gap: 8px;
        padding: 10px 12px;
        padding-right: 0;
    }

    body.index-page .header-right {
        max-width: min(200px, 48vw);
    }

    body.index-page .header-brand {
        gap: 8px;
    }

    body.index-page .header-logo {
        height: 34px;
    }

    body.index-page .header-title {
        font-size: 1.25rem;
    }

    body.index-page .subtitle {
        font-size: 11px;
    }

    body.index-page .calibration-header-toolbar {
        column-gap: 4px;
        row-gap: 5px;
        padding: 6px 7px;
        padding-right: 30px;
    }

    body.index-page .calibration-profile-picker label {
        font-size: 9px;
    }

    body.index-page .calibration-profile-picker .offset-select {
        font-size: 11px;
        padding: 5px 6px;
    }

    body.index-page .calibration-header-toolbar .calibration-btn {
        padding: 6px 4px;
        font-size: 10px;
        border-radius: 6px;
        line-height: 1.15;
    }
}

/* Preview Area Wrapper */
.preview-area-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: #f2faff;
}

.preview-headers {
    display: flex;
    gap: 5px;
    padding: 15px 30px 10px 30px;
    background-color: #f2faff;
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
}

.preview-header {
    flex: 1;
    font-size: 18px;
    margin: 0;
    color: #333333;
    text-align: center;
    padding: 0;
}

/* Preview Area */
.preview-area {
    flex: 1;
    display: flex;
    gap: 5px;
    padding: 0 30px 30px 30px;
    overflow-x: hidden;
    overflow-y: auto;
    background-color: #f2faff;
    /* This is the ONLY scrollable container */
}

.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: visible; /* No scrolling here - parent handles it */
    min-width: 0; /* Prevent flex item from overflowing */
    align-items: center; /* Center content horizontally */
    padding-top: 0;
}

.preview-pages-container {
    display: flex;
    flex-direction: column;
    gap: 0;
    align-items: center;
    width: 100%;
    overflow: visible; /* No scrolling here, handled by preview-area */
}

.preview-sheet {
    width: 72%;
    max-width: 72%;
    aspect-ratio: 210 / 297; /* A4 default */
    background-color: #ffffff;
    position: relative;
    border: 2px solid #d0d0d0;
    transition: filter 0.3s, opacity 0.3s;
    flex-shrink: 0;
    overflow: visible; /* Allow cards to be visible */
    box-sizing: border-box;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Softer credit / help lines in the on-screen sheet preview (SVG classes set in createPreviewPage only). */
.preview-sheet svg text.preview-sheet-credit,
.preview-sheet svg text.preview-sheet-credit-help {
    opacity: 0.42;
}

.preview-card.selected {
    z-index: 10;
}

.calibration-btn {
    padding: 7px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s, filter 0.2s;
    white-space: nowrap;
}

#calibration-test-btn.calibration-btn {
    background-color: #ffffff;
    color: #1565c0;
    border: 1px solid #90caf9;
    box-shadow: none;
}

#calibration-test-btn.calibration-btn:hover {
    background-color: #e3f2fd;
    border-color: #64b5f6;
    color: #0d47a1;
}

#manage-profiles-btn.calibration-btn {
    background-color: #ffffff;
    color: #546e7a;
    border: 1px solid #cfd8dc;
    box-shadow: none;
}

#manage-profiles-btn.calibration-btn:hover {
    background-color: #eceff1;
    border-color: #b0bec5;
    color: #37474f;
}

/* Pulsing shadow hint when user has 3+ cards but no calibration profile */
@keyframes calibration-pulse-shadow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 102, 204, 0.35); }
    50% { box-shadow: 0 0 0 8px rgba(0, 102, 204, 0.15); }
}

.calibration-btn.calibration-pulse-hint {
    animation: calibration-pulse-shadow 1.8s ease-in-out infinite;
}

.offset-select.calibration-dropdown-pulse-hint {
    animation: calibration-pulse-shadow 1.8s ease-in-out infinite;
}

.calibration-modal-content {
    max-width: 1600px;
    width: 95%;
    min-width: 800px;
    box-sizing: border-box;
    overflow: auto;
    max-height: 90vh;
}

.cal-adjust-editing-footer {
    margin-top: 20px;
    padding: 16px 0 8px;
    border-top: 1px solid #e0e0e0;
}

.cal-adjust-profile-title {
    margin: 0 0 12px;
    font-size: 15px;
    color: #444;
}

.cal-adjust-profile-title strong {
    color: #111;
}

.cal-adjust-profile-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

/* Match PRINT (green) and + Add Card (blue) */
.cal-update-profile-btn {
    padding: 10px 20px;
    background-color: #00aa00;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 15px;
    font-weight: bold;
    transition: background-color 0.2s;
}

.cal-update-profile-btn:hover {
    background-color: #008800;
}

.cal-save-as-new-trigger-btn {
    padding: 10px 20px;
    background-color: #2196F3;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 15px;
    font-weight: bold;
    transition: background-color 0.2s;
}

.cal-save-as-new-trigger-btn:hover {
    background-color: #0052a3;
}

body.dark-mode .cal-update-profile-btn {
    background-color: #00aa00;
}

body.dark-mode .cal-update-profile-btn:hover {
    background-color: #008800;
}

body.dark-mode .cal-save-as-new-trigger-btn {
    background-color: #2196F3;
}

body.dark-mode .cal-save-as-new-trigger-btn:hover {
    background-color: #0052a3;
}

.cal-save-as-new-section {
    margin-top: 14px;
    padding: 14px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
}

.cal-save-as-new-section label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: #555;
}

.cal-save-as-new-input-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.cal-save-as-new-input-row input[type="text"] {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    font-size: 14px;
}

.cal-save-as-new-section #cal-save-as-new-warning {
    margin-top: 8px;
}

.calibration-instructions-modal {
    max-width: 600px;
    width: 90%;
}

#calibration-help-modal .calibration-help-modal-content {
    max-width: min(560px, 94vw);
}

.calibration-help-gif-wrap {
    margin: 0 0 16px;
    text-align: center;
}

.calibration-help-gif-wrap img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.calibration-instructions {
    margin: 20px 0;
    padding: 20px;
    background-color: #f5f5f5;
    border-radius: 5px;
}

.calibration-instructions p {
    margin-bottom: 15px;
    line-height: 1.6;
    color: #333333;
}

.calibration-instructions p:last-child {
    margin-bottom: 0;
}

.calibration-page-size-control {
    margin: 20px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.calibration-page-size-control label {
    font-size: 14px;
    color: #666666;
}

.calibration-page-size-select {
    padding: 8px 12px;
    background-color: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    color: #333333;
    font-size: 14px;
    cursor: pointer;
}

.info-icon-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: #666666;
    cursor: help;
    transition: color 0.2s;
}

.info-icon-container:hover {
    color: #2196F3;
}

.info-icon-container svg {
    width: 100%;
    height: 100%;
}

.info-icon-container::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 10px 18px;
    background-color: #333333;
    color: #ffffff;
    font-size: 12px;
    font-weight: 500;
    white-space: normal;
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 280px;
    max-width: 320px;
    text-align: center;
    line-height: 1.5;
    margin-bottom: 8px;
}

.info-icon-container::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-2px);
    border: 6px solid transparent;
    border-top-color: #333333;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1001;
}

.info-icon-container:hover::after,
.info-icon-container:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(-12px);
}

.info-icon-container:hover::before {
    transform: translateX(-50%) translateY(-6px);
}

/* Dark mode tooltip styles */
body.dark-mode .info-icon-container::after {
    background-color: #4a4a4a;
    color: #ffffff;
    border: 1px solid #5a5a5a;
}

body.dark-mode .info-icon-container::before {
    border-top-color: #4a4a4a;
}

body.dark-mode .info-icon-container {
    color: #aaaaaa;
}

body.dark-mode .info-icon-container:hover {
    color: #0066cc;
}

.calibration-test-controls {
    margin: 20px 0;
    display: flex;
    gap: 10px;
    align-items: center;
}

.calibration-action-btn {
    padding: 12px 24px;
    background-color: #2196F3;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.2s;
    flex: 1;
}

.calibration-action-btn:hover {
    background-color: #1976D2;
}

.calibration-next-btn {
    padding: 12px 24px;
    background-color: #4caf50;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.2s;
    flex: 1;
}

.calibration-next-btn:hover {
    background-color: #45a049;
}

.calibration-visual-area {
    display: flex;
    gap: 30px;
    margin: 30px 0;
    align-items: flex-start;
    flex-wrap: wrap;
}

.calibration-preview-container {
    flex: 1;
    min-width: 300px;
}

.calibration-preview-sheet {
    width: 100%;
    aspect-ratio: 210 / 297;
    background-color: #ffffff;
    position: relative;
    border: 2px solid #d0d0d0;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    filter: brightness(1.1) contrast(0.9);
    opacity: 0.95;
}

.calibration-preview-sheet::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.1) 100%);
    pointer-events: none;
    z-index: 1;
}

.calibration-blue-rect {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 23.81%;
    aspect-ratio: 1;
    background-color: #b3e5fc;
    border: 0.5px solid #000;
    z-index: 2;
    opacity: 0.8;
}

.calibration-red-rect {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 23.81%;
    aspect-ratio: 1;
    background-color: #ff0000;
    border: 0.05px solid rgba(0, 0, 0, 0.5);
    cursor: move;
    z-index: 1;
    opacity: 0.6;
    transition: transform 0.1s;
}

.calibration-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    box-sizing: border-box;
    pointer-events: none;
}

.calibration-blue-rect .calibration-grid {
    border: 0.05px solid #000;
}

.calibration-red-rect .calibration-grid {
    border: 0.05px solid rgba(0, 0, 0, 0.5);
}

.grid-cell {
    border: 0.05px solid #000;
    box-sizing: border-box;
}

.calibration-red-rect .grid-cell {
    border-color: rgba(0, 0, 0, 0.5);
}

.calibration-letter {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 25px;
    font-weight: bold;
    color: #000;
    z-index: 3;
    pointer-events: none;
    font-family: Arial, sans-serif;
    line-height: 1;
}

.calibration-red-rect .calibration-letter {
    color: rgba(0, 0, 0, 0.5);
}

.calibration-red-rect:hover {
    opacity: 0.8;
}

.calibration-offset-controls {
    flex: 1;
    min-width: 250px;
}

.calibration-instructions-text {
    margin: 0 0 50px 0;
    padding: 14px 16px;
    background-color: #f8f9fa;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    color: #444444;
    font-size: 14px;
    line-height: 1.55;
}

.calibration-instructions-text p {
    margin: 0 0 10px 0;
}

.calibration-instructions-text p:last-child {
    margin-bottom: 0;
}

.offset-control-group {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.offset-control-group label {
    min-width: 100px;
    font-size: 14px;
    color: #666666;
}

.offset-control-group input[type="number"] {
    flex: 1;
    padding: 8px;
    background-color: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    color: #333333;
    font-size: 14px;
    min-width: 80px;
}

.offset-control-group input[type="checkbox"] {
    margin-right: 5px;
}

.nudge-btn {
    padding: 6px 12px;
    background-color: #f0f0f0;
    color: #333333;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s;
    min-width: 40px;
}

.nudge-btn:hover {
    background-color: #e8e8e8;
}

.calibration-profile-save {
    margin: 20px 0;
    padding: 15px;
    background-color: #f5f5f5;
    border-radius: 5px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
    width: 100%;
    box-sizing: border-box;
    flex-direction: row;
}

.profile-name-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 150px;
    width: 100%;
}

.label-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.calibration-profile-save label {
    font-size: 14px;
    color: #666666;
    flex-shrink: 0;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-row input[type="text"] {
    flex: 1;
}

.profile-name-warning {
    background-color: #ffffff;
    color: #cc0000;
    font-size: 13px;
    padding: 6px 10px;
    margin: 0;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    visibility: hidden;
    white-space: nowrap;
    flex-shrink: 0;
}

.calibration-profile-save input[type="text"] {
    padding: 8px;
    background-color: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    color: #333333;
    font-size: 14px;
    box-sizing: border-box;
    height: 36px;
}

.calibration-profile-save input[type="text"].error {
    border: 2px solid #cc0000;
}

.calibration-profile-save .save-btn {
    flex: 0 0 auto;
    padding: 8px 16px;
    background-color: #2196F3;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    height: 36px;
    white-space: nowrap;
}

.calibration-profile-save .save-btn:disabled {
    background-color: #cccccc;
    color: #999999;
    cursor: not-allowed;
}

.calibration-profile-save .save-btn:disabled:hover {
    background-color: #cccccc;
}

.save-btn:disabled {
    background-color: #cccccc;
    color: #999999;
    cursor: not-allowed;
}

.save-btn:disabled:hover {
    background-color: #cccccc;
}

.profiles-list {
    max-height: 400px;
    overflow-y: auto;
    margin: 20px 0;
}

.profile-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: #ffffff;
    border-radius: 5px;
    margin-bottom: 10px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.profile-info {
    flex: 1;
}

.profile-name {
    font-size: 16px;
    font-weight: bold;
    color: #333333;
    margin-bottom: 5px;
}

.profile-details {
    font-size: 12px;
    color: #666666;
}

.profile-actions {
    display: flex;
    gap: 10px;
}

.profile-select-btn,
.profile-delete-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.profile-select-btn {
    background-color: #2196F3;
    color: #ffffff;
}

.profile-select-btn:hover {
    background-color: #1976D2;
}

.profile-edit-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
    background-color: #00aa00;
    color: #ffffff;
}

.profile-edit-btn:hover {
    background-color: #008800;
}

.profile-delete-btn {
    background-color: #cc0000;
    color: #ffffff;
}

.profile-delete-btn:hover {
    background-color: #aa0000;
}

.cards-container {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: visible; /* Allow cards to be visible */
    box-sizing: border-box;
}

.preview-card {
    background-color: #ffffff;
    border: 2px solid #cccccc;
    border-radius: 5px;
    padding: 15px;
    min-width: 0; /* Allow flex shrinking */
    max-width: 100%; /* Prevent overflow */
    text-align: center;
    color: #000000;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
}

.preview-card:hover {
    border-color: #2196F3;
}

.preview-card.selected {
    border-color: #2196F3;
    border-width: 3px;
}

/* Bottom Controls */
.bottom-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 30px;
    background-color: #ffffff;
    border-top: 2px solid #bbdefb;
}

/* Card size, paper size, font share equal horizontal space; PRINT stays at the end */
.bottom-controls-cluster {
    flex: 1;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: center;
    column-gap: 12px;
}

.bottom-controls-cluster > .card-size-control,
.bottom-controls-cluster > .paper-size-control {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.bottom-controls-cluster > .font-control {
    justify-self: center;
}

.card-size-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Card size: same pill + label pattern as Font control; native select styled to match */
.card-size-font-control {
    gap: 8px;
    padding: 4px 10px 4px 12px;
}

.card-size-font-control .card-size-select {
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
    padding: 2px 22px 2px 4px;
    min-width: 4.25em;
    border: none;
    border-radius: 4px;
    background-color: transparent;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2378909c' d='M1.41 0 6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 4px center;
    background-size: 10px auto;
    font-size: 14px;
    font-weight: 600;
    color: #212121;
    cursor: pointer;
    line-height: 1.3;
}

.card-size-font-control .card-size-select:hover {
    color: #1565c0;
}

.card-size-font-control .card-size-select:focus {
    outline: none;
}

.card-size-font-control:focus-within {
    outline: 2px solid #2196f3;
    outline-offset: 2px;
}

.paper-size-control {
    display: flex;
    align-items: center;
    gap: 15px;
}

.font-control {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 12px 6px 10px;
    border: 1px solid #cfd8dc;
    border-radius: 999px;
    background-color: #fafafa;
    transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}

.font-control:hover {
    border-color: #90caf9;
    background-color: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.font-control:focus {
    outline: 2px solid #2196f3;
    outline-offset: 2px;
}

.font-control:focus:not(:focus-visible) {
    outline: none;
}

.font-control:focus-visible {
    outline: 2px solid #2196f3;
    outline-offset: 2px;
}

.font-control .font-control-label {
    font-size: 13px;
    color: #757575;
    font-weight: 500;
}

.font-display-text {
    font-size: 14px;
    color: #212121;
    font-weight: 600;
    text-decoration: none;
}

.font-display-text:hover {
    color: #1565c0;
}

.font-display-chevron {
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 2px;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid #78909c;
    flex-shrink: 0;
}

.font-control:hover .font-display-chevron {
    border-top-color: #546e7a;
}

.paper-size-control label {
    font-size: 14px;
    color: #666666;
}

.paper-size-select {
    padding: 8px 12px;
    background-color: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    color: #333333;
    font-size: 14px;
    cursor: pointer;
}

.card-size-control label {
    font-size: 14px;
    color: #666666;
}

/* Legacy: range slider removed in favor of card-size-select */
.slider {
    width: 200px;
    height: 6px;
    background-color: #e0e0e0;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background-color: #2196F3;
    border-radius: 50%;
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background-color: #2196F3;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.action-buttons {
    display: flex;
    flex-shrink: 0;
    gap: 15px;
}

.export-btn {
    padding: 12px 24px;
    background-color: #2196F3;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.2s;
}

.export-btn:hover {
    background-color: #1976D2;
}

.print-btn {
    padding: 12px 24px;
    background-color: #00aa00;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.2s;
}

.print-btn:hover {
    background-color: #008800;
}

/* Print Menu Modal */
.print-menu-modal {
    max-width: 750px;
    width: 90%;
    padding: 0;
}

.modal-content.print-menu-modal {
    max-width: 750px;
}

.print-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid #e0e0e0;
}

.print-menu-header h2 {
    margin: 0;
    font-size: 20px;
    color: #333333;
}

.close-print-menu-btn {
    background: none;
    border: none;
    color: #666666;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 1;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-print-menu-btn:hover {
    color: #333333;
}

.print-menu-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    padding: 30px;
}

.print-menu-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 120px;
}

.print-menu-option:hover {
    background-color: #f5f5f5;
    border-color: #cccccc;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.print-menu-option#print-option {
    background-color: #4caf50;
    border-color: #4caf50;
    color: #ffffff;
}

.print-menu-option#print-option:hover {
    background-color: #45a049;
    border-color: #45a049;
}

.print-menu-icon {
    font-size: 40px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.print-menu-icon svg {
    width: 100%;
    height: 100%;
}

.print-menu-option#print-option .print-menu-icon {
    color: #ffffff;
}

.print-menu-option:not(#print-option) .print-menu-icon {
    color: #666666;
}

.print-menu-label {
    font-size: 14px;
    color: #333333;
    text-align: center;
    font-weight: 500;
}

.print-menu-option#print-option .print-menu-label {
    color: #ffffff;
}

body.dark-mode .print-menu-header {
    border-bottom: 1px solid #5a5a5a;
}

body.dark-mode .print-menu-header h2 {
    color: #ffffff;
}

body.dark-mode .close-print-menu-btn {
    color: #aaaaaa;
}

body.dark-mode .close-print-menu-btn:hover {
    color: #ffffff;
}

body.dark-mode .print-menu-option {
    background-color: #4a4a4a;
    border-color: #5a5a5a;
}

body.dark-mode .print-menu-option:hover {
    background-color: #5a5a5a;
    border-color: #6a6a6a;
}

body.dark-mode .print-menu-label {
    color: #ffffff;
}

/* Custom Tooltips for Print Menu Options */
.print-menu-option {
    position: relative;
}

.print-menu-option::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 10px 18px;
    background-color: #333333;
    color: #ffffff;
    font-size: 12px;
    font-weight: 500;
    white-space: normal;
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 280px;
    max-width: 320px;
    text-align: center;
    line-height: 1.5;
}

.print-menu-option::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-2px);
    border: 6px solid transparent;
    border-top-color: #333333;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1001;
}

.print-menu-option:hover::after,
.print-menu-option:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(-12px);
}

.print-menu-option:hover::before {
    transform: translateX(-50%) translateY(-6px);
}

/* Dark mode tooltip styles */
body.dark-mode .print-menu-option::after {
    background-color: #4a4a4a;
    color: #ffffff;
    border: 1px solid #5a5a5a;
}

body.dark-mode .print-menu-option::before {
    border-top-color: #4a4a4a;
}

/* Tooltip for preview cards */
.preview-card-tooltip {
    position: fixed;
    padding: 10px 18px;
    background-color: #333333;
    color: #ffffff;
    font-size: 12px;
    font-weight: 500;
    white-space: normal;
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    max-width: 280px;
    text-align: center;
    line-height: 1.5;
    transform: translateX(-50%) translateY(-8px);
}

.preview-card-tooltip.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-12px);
}

.preview-card-tooltip::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #333333;
}

/* Dark mode tooltip styles for preview cards */
body.dark-mode .preview-card-tooltip {
    background-color: #4a4a4a;
    color: #ffffff;
    border: 1px solid #5a5a5a;
}

body.dark-mode .preview-card-tooltip::before {
    border-top-color: #4a4a4a;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: #ffffff;
    padding: 30px;
    border-radius: 10px;
    max-width: 500px;
    width: 90%;
    color: #333333;
    box-sizing: border-box;
    overflow: auto;
    max-height: 90vh;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #333333;
}

.modal-content p {
    margin-bottom: 10px;
    color: #666666;
    line-height: 1.6;
}

/* Match toggle colors: Flashcard = blue, Game = purple, Document = orange */
.printer-choice-option.printer-choice-option-flashcard {
    background-color: #2196F3;
    border-color: #2196F3;
}

.printer-choice-option.printer-choice-option-flashcard .printer-choice-label,
.printer-choice-option.printer-choice-option-flashcard .printer-choice-desc {
    color: #ffffff;
}

.printer-choice-option.printer-choice-option-game {
    background-color: #9C27B0;
    border-color: #9C27B0;
}

.printer-choice-option.printer-choice-option-game .printer-choice-label,
.printer-choice-option.printer-choice-option-game .printer-choice-desc {
    color: #ffffff;
}

.printer-choice-option.printer-choice-option-document {
    background-color: #FF9800;
    border-color: #FF9800;
}

.printer-choice-option.printer-choice-option-document .printer-choice-label,
.printer-choice-option.printer-choice-option-document .printer-choice-desc {
    color: #ffffff;
}

.printer-choice-option:hover {
    filter: brightness(1.08);
}

.printer-choice-label {
    font-weight: 600;
    color: #333333;
    font-size: 16px;
}

.printer-choice-desc {
    font-size: 13px;
    color: #666666;
    margin-top: 4px;
}

body.dark-mode .printer-choice-option.printer-choice-option-flashcard {
    background-color: #1976D2;
    border-color: #1976D2;
}

body.dark-mode .printer-choice-option.printer-choice-option-game {
    background-color: #7B1FA2;
    border-color: #7B1FA2;
}

body.dark-mode .printer-choice-option.printer-choice-option-document {
    background-color: #F57C00;
    border-color: #F57C00;
}

body.dark-mode .printer-choice-option:hover {
    filter: brightness(1.15);
}

body.dark-mode .printer-choice-label {
    color: #ffffff;
}

body.dark-mode .printer-choice-desc {
    color: #aaaaaa;
}

.calibration-options {
    margin: 20px 0;
}

.calibration-options label {
    display: block;
    margin-bottom: 10px;
    padding: 10px;
    background-color: #f5f5f5;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.calibration-options label:hover {
    background-color: #e8e8e8;
}

.calibration-options input[type="radio"] {
    margin-right: 10px;
}

.fine-tune-controls {
    margin: 20px 0;
    padding: 15px;
    background-color: #f5f5f5;
    border-radius: 5px;
}

.fine-tune-controls label {
    display: block;
    margin-bottom: 5px;
    color: #666666;
}

.fine-tune-controls input[type="number"] {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    background-color: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    color: #333333;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.save-btn {
    flex: 1;
    padding: 12px;
    background-color: #2196F3;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
}

.save-btn:hover {
    background-color: #1976D2;
}

.cancel-btn {
    flex: 1;
    padding: 12px;
    background-color: #f0f0f0;
    color: #333333;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
}

.cancel-btn:hover {
    background-color: #e8e8e8;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #f0f0f0;
}

::-webkit-scrollbar-thumb {
    background: #cccccc;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #b0b0b0;
}

/* Style Menu */
.style-menu {
    position: fixed;
    background-color: #ffffff;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 0;
    z-index: 1000;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    min-width: 250px;
    max-width: 300px;
}

.style-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #fafafa;
    border-bottom: 2px solid #e0e0e0;
    border-radius: 8px 8px 0 0;
}

.style-menu-header h3 {
    margin: 0;
    font-size: 16px;
    color: #333333;
}

.style-menu-subtitle {
    color: #666666;
    font-weight: normal;
}

.close-style-menu-btn {
    background: none;
    border: none;
    color: #666666;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    line-height: 1;
    transition: color 0.2s;
}

.close-style-menu-btn:hover {
    color: #333333;
}

.style-menu-content {
    padding: 20px;
}

.style-control-group {
    margin-bottom: 20px;
}

.style-control-group:last-child {
    margin-bottom: 0;
}

.style-control-group label {
    display: block;
    font-size: 12px;
    color: #666666;
    margin-bottom: 8px;
}

.style-select,
.style-input {
    width: 100%;
    padding: 8px;
    background-color: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    color: #333333;
    font-size: 14px;
    font-family: inherit;
}

.color-input {
    width: 100%;
    height: 40px;
    padding: 0;
    background: none;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    cursor: pointer;
}

.formatting-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.alignment-buttons {
    display: flex;
    gap: 5px;
}

.align-btn {
    flex: 1;
    padding: 8px 12px;
    background-color: #f0f0f0;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    color: #333333;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 10;
    /* Ensure button is always on top and clickable */
    isolation: isolate;
}

.align-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    pointer-events: none;
}

.align-btn:hover {
    background-color: #e8e8e8;
    z-index: 11;
}

.align-btn.active {
    background-color: #2196F3;
    border-color: #2196F3;
    color: #ffffff;
}

/* Tooltips for alignment buttons */
.align-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 8px 12px;
    background-color: #333333;
    color: #ffffff;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s 0.1s, transform 0.15s 0.1s;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-bottom: 8px;
    /* Ensure tooltip doesn't interfere with clicks */
    will-change: opacity, transform;
}

.align-btn::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-2px);
    border: 6px solid transparent;
    border-top-color: #333333;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s 0.1s, transform 0.15s 0.1s;
    z-index: 1001;
    /* Ensure tooltip arrow doesn't interfere with clicks */
    will-change: opacity, transform;
}

.align-btn:hover::after,
.align-btn:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(-12px);
}

.align-btn:hover::before {
    transform: translateX(-50%) translateY(-6px);
}

/* Dark mode tooltip styles */
body.dark-mode .align-btn::after {
    background-color: #4a4a4a;
    color: #ffffff;
    border: 1px solid #5a5a5a;
}

body.dark-mode .align-btn::before {
    border-top-color: #4a4a4a;
}


/* Font & Size popup (from bottom bar) */
.font-size-popup {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.font-size-popup-content {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    min-width: 280px;
    overflow: hidden;
}

.font-size-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid #e0e0e0;
}

.font-size-popup-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333333;
}

.close-font-size-popup-btn {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: #666666;
    cursor: pointer;
    padding: 0 4px;
}

.close-font-size-popup-btn:hover {
    color: #333333;
}

.font-size-popup-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.font-size-popup-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.font-size-popup-row label {
    font-size: 14px;
    color: #333333;
}

.font-size-popup-select {
    padding: 8px 12px;
    background-color: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    color: #333333;
    font-size: 14px;
    cursor: pointer;
    min-width: 100px;
}

.font-size-popup-footer {
    padding: 12px 16px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
}

.font-size-popup-save-btn {
    padding: 8px 20px;
    background-color: #2196F3;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.font-size-popup-save-btn:hover {
    background-color: #1976D2;
}

.format-btn {
    flex: 1;
    padding: 10px;
    background-color: #f0f0f0;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    color: #333333;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

.format-btn:hover {
    background-color: #e8e8e8;
}

.format-btn.active {
    background-color: #2196F3;
    color: #ffffff;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.style-action-btn {
    flex: 1;
    padding: 10px;
    background-color: #f0f0f0;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    color: #333333;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.style-action-btn:hover {
    background-color: #e8e8e8;
}

/* Quizlet Import Modal */
.quizlet-import-input-container {
    margin: 20px 0;
}

.quizlet-import-input-container label {
    display: block;
    margin-bottom: 10px;
    font-size: 14px;
    color: #666666;
}

.quizlet-text-input {
    width: 100%;
    min-height: 200px;
    padding: 12px;
    background-color: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    color: #333333;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.quizlet-text-input:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.quizlet-text-input::placeholder {
    color: #999999;
}

/* Footer */
.footer {
    background-color: #424242;
    border-top: 2px solid #616161;
    padding: 10px 20px;
    text-align: center;
    position: relative;
    z-index: 100;
}

.footer-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    position: relative;
}

.footer-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.footer.footer-split .footer-content {
    justify-content: center;
}

/* Keep footer height driven by the centered links (original behavior).
   Left/right button groups are positioned like "floating" side controls. */
.footer.footer-split .footer-left,
.footer.footer-split .footer-right {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer.footer-split .footer-left {
    left: 20px;
}

.footer.footer-split .footer-right {
    right: 10px;
}

.footer.footer-split .footer-buttons {
    position: static;
    left: auto;
    top: auto;
    transform: none;
}

.footer.footer-split .footer-links {
    justify-content: center;
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.footer-copyright {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.2;
}

.theme-toggle-btn,
.feedback-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background-color: #616161;
    color: #ffffff;
    border: 1px solid #757575;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.theme-toggle-btn:hover,
.feedback-btn:hover {
    background-color: #757575;
}

.theme-icon,
.feedback-icon {
    font-size: 14px;
}

.theme-text,
.feedback-text {
    font-weight: 500;
}

/* Feedback modal */
.feedback-modal-content {
    max-width: 640px;
    width: 95%;
    padding: 0;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.feedback-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.feedback-modal-header h2 {
    margin: 0;
    font-size: 18px;
}

.close-feedback-modal-btn {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #666666;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.2s;
}

.close-feedback-modal-btn:hover {
    color: #333333;
}

.feedback-form-iframe {
    flex: 1;
    width: 100%;
    min-height: 500px;
    border: none;
}

/* Import Anki modal */
.import-anki-modal-content {
    max-width: 480px;
    width: 90%;
    padding: 24px;
}

.import-anki-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e0e0e0;
}

.import-anki-modal-header h2 {
    margin: 0;
    font-size: 18px;
}

.close-import-anki-modal-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666666;
    line-height: 1;
    padding: 0 4px;
}

.close-import-anki-modal-btn:hover {
    color: #333333;
}

.import-anki-instructions {
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
}

.import-anki-instructions ol {
    margin: 8px 0 12px 20px;
}

.import-anki-instructions li {
    margin-bottom: 4px;
}

.import-anki-drop-zone {
    border: 3px dashed #999999;
    border-radius: 8px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    background-color: #fafafa;
    transition: background-color 0.2s, border-color 0.2s;
}

.import-anki-drop-zone:hover,
.import-anki-drop-zone.drag-over {
    background-color: #f0f0f0;
    border-color: #2196F3;
}

.import-anki-drop-zone-text {
    font-size: 16px;
    color: #666666;
}

body.dark-mode .import-anki-modal-header {
    border-bottom-color: #4a4a4a;
}

body.dark-mode .close-import-anki-modal-btn {
    color: #aaaaaa;
}

body.dark-mode .close-import-anki-modal-btn:hover {
    color: #ffffff;
}

body.dark-mode .import-anki-drop-zone {
    background-color: #2a2a2a;
    border-color: #5a5a5a;
}

body.dark-mode .import-anki-drop-zone:hover,
body.dark-mode .import-anki-drop-zone.drag-over {
    background-color: #333333;
    border-color: #0066cc;
}

body.dark-mode .import-anki-drop-zone-text {
    color: #aaaaaa;
}

.footer-link {
    color: #e0e0e0;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.footer-link:hover {
    color: #ffffff;
}

.footer-link:not([href]) {
    color: #999999;
    cursor: default;
    pointer-events: none;
}

.footer-separator {
    color: #757575;
    font-size: 14px;
}

/* Tutorial Overlay */
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tutorial-popup {
    position: absolute;
    background-color: #ffffff;
    border: 3px solid #4caf50;
    border-radius: 8px;
    padding: 20px;
    max-width: 350px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 2001;
    /* Position will be set by JavaScript */
}

#tutorial-popup-step2 {
    max-width: min(400px, 92vw);
}

.tutorial-calibration-gif {
    margin: 10px 0 12px;
}

.tutorial-calibration-gif img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Speech bubble pointer pointing to the right (towards Card Editor) - Step 1 */
.tutorial-popup::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 15px solid transparent;
    border-bottom: 15px solid transparent;
    border-right: 20px solid #4caf50;
}

.tutorial-popup::after {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 13px solid transparent;
    border-bottom: 13px solid transparent;
    border-right: 18px solid #ffffff;
    margin-right: -3px;
}

/* Speech bubble pointer pointing to the right (towards Calibration buttons) - Step 2 */
#tutorial-popup-step2::before {
    right: auto;
    left: 100%;
    top: 22%;
    transform: translateY(-50%);
    border-right: none;
    border-left: 20px solid #4caf50;
    border-top: 15px solid transparent;
    border-bottom: 15px solid transparent;
}

#tutorial-popup-step2::after {
    right: auto;
    left: 100%;
    top: 22%;
    transform: translateY(-50%);
    border-right: none;
    border-left: 18px solid #ffffff;
    border-top: 13px solid transparent;
    border-bottom: 13px solid transparent;
    margin-right: 0;
    margin-left: -3px;
}

/* Speech bubble pointer pointing down (towards preview area) - Step 3 */
#tutorial-popup-step3::before {
    right: auto;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    border-top: 20px solid #4caf50;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-bottom: none;
}

#tutorial-popup-step3::after {
    right: auto;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    border-top: 18px solid #ffffff;
    border-left: 13px solid transparent;
    border-right: 13px solid transparent;
    border-bottom: none;
    margin-top: -3px;
}

/* Speech bubble pointer pointing down (towards Export/Print buttons) - Step 4 */
#tutorial-popup-step4::before {
    right: auto;
    left: var(--arrow-position, 50%);
    top: 100%;
    transform: translateX(-50%);
    border-top: 20px solid #4caf50;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-bottom: none;
}

#tutorial-popup-step4::after {
    right: auto;
    left: var(--arrow-position, 50%);
    top: 100%;
    transform: translateX(-50%);
    border-top: 18px solid #ffffff;
    border-left: 13px solid transparent;
    border-right: 13px solid transparent;
    border-bottom: none;
    margin-top: -3px;
}

.tutorial-content {
    margin-bottom: 15px;
}

.tutorial-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.tutorial-emoji {
    font-size: 18px;
}

.tutorial-title {
    font-size: 16px;
    color: #000000;
    font-weight: bold;
}

.tutorial-text {
    font-size: 14px;
    color: #333333;
    line-height: 1.5;
    margin-bottom: 10px;
}

.tutorial-tip {
    font-size: 12px;
    color: #666666;
    line-height: 1.4;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e0e0e0;
}

.tutorial-close-btn {
    width: 100%;
    padding: 10px;
    background-color: #4caf50;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

.tutorial-close-btn:hover {
    background-color: #45a049;
}

/* Dark Mode Styles */
body.dark-mode {
    background-color: #2a2a2a;
    color: #ffffff;
}

body.dark-mode .left-panel {
    background-color: #3a3a3a;
    border-right: 2px solid #545454;
}

body.dark-mode .left-panel-header {
    background-color: #2a2a2a;
    border-bottom: 2px solid #1a1a1a;
}

body.dark-mode .left-panel-header h2 {
    color: #ffffff;
}

body.dark-mode .toggle-panel-btn {
    color: #aaaaaa;
}

body.dark-mode .toggle-panel-btn:hover {
    color: #ffffff;
}

body.dark-mode .expand-panel-btn {
    background-color: #3a3a3a;
    color: #ffffff;
    border: 1px solid #5a5a5a;
}

body.dark-mode .expand-panel-btn:hover {
    background-color: #4a4a4a;
}

body.dark-mode .import-btn {
    background-color: #3a3a3a;
    color: #b0bec5;
    border: 1px solid #757575;
}

body.dark-mode .import-btn:hover {
    background-color: #454545;
    border-color: #9e9e9e;
    color: #eceff1;
}

body.dark-mode .import-btn-csv {
    border-left-color: #66bb6a;
}

body.dark-mode .import-btn-quizlet {
    border-left-color: #64b5f6;
}

body.dark-mode .import-btn-anki {
    border-left-color: #90a4ae;
}

body.dark-mode .import-btn-csv:hover {
    border-left-color: #81c784;
}

body.dark-mode .import-btn-quizlet:hover {
    border-left-color: #90caf9;
}

body.dark-mode .import-btn-anki:hover {
    border-left-color: #b0bec5;
}

body.dark-mode .clear-all-cards-btn {
    color: #ee8888;
    border-color: #885555;
    background-color: transparent;
}

body.dark-mode .clear-all-cards-btn:hover:not(:disabled) {
    background-color: rgba(255, 80, 80, 0.12);
    border-color: #aa6666;
    color: #ffaaaa;
}

body.dark-mode .clear-all-cards-proceed-btn {
    background-color: #b22222;
}

body.dark-mode .clear-all-cards-proceed-btn:hover {
    background-color: #991111;
}

body.dark-mode .cards-list-empty {
    color: #8a8a8a;
}

body.dark-mode .card-item {
    background-color: #4a4a4a;
    border: 1px solid #5a5a5a;
}

body.dark-mode .card-number {
    color: #aaaaaa;
}

body.dark-mode .card-action-btn {
    color: #aaaaaa;
}

body.dark-mode .card-action-btn:hover {
    color: #ffffff;
}

body.dark-mode .card-field-header .format-btn {
    background-color: #3d3d3d;
    border: 1px solid #4a4a4a;
    color: #a3a3a3;
}

body.dark-mode .card-field-header .format-btn:hover:not(:disabled) {
    background-color: #474747;
    border-color: #555555;
    color: #c4c4c4;
}

body.dark-mode .card-field-header .format-btn.active {
    background-color: #4a7aad;
    border-color: #3d6d9e;
    color: #ffffff;
}

body.dark-mode .card-field-header .format-btn:disabled {
    opacity: 0.38;
    color: #7a7a7a;
}

body.dark-mode .card-field label {
    color: #aaaaaa;
}

body.dark-mode .card-field input,
body.dark-mode .card-field textarea,
body.dark-mode .card-field .contenteditable-input {
    background-color: #3a3a3a;
    border: 1px solid #5a5a5a;
    color: #ffffff;
}

body.dark-mode .contenteditable-input:focus {
    border-color: #0066cc;
    outline: 1px solid #0066cc;
}

body.dark-mode .contenteditable-input.is-placeholder {
    color: #6a6a6a;
}

body.dark-mode .card-image-preview {
    background-color: #3a3a3a;
    border-color: #5a5a5a;
}

body.dark-mode .card-remove-image-btn {
    background-color: #4a4a4a;
    border-color: #5a5a5a;
    color: #e0e0e0;
}

body.dark-mode .card-remove-image-btn:hover {
    background-color: #5a5a5a;
}

body.dark-mode .card-add-image-box {
    border-color: #5a5a5a;
    color: #aaaaaa;
}

body.dark-mode .card-add-image-box:hover {
    border-color: #0066cc;
    color: #0066cc;
}

body.dark-mode .add-card-btn {
    background-color: #2196F3;
}

body.dark-mode .add-card-btn:hover {
    background-color: #0052a3;
}

body.dark-mode .main-workspace {
    background-color: #2a2a2a;
}

body.dark-mode .header {
    background-color: #1a1a1a;
    border-bottom: 2px solid #3a3a3a;
}

body.dark-mode .subtitle {
    color: #aaaaaa;
}

body.dark-mode .header-right label {
    color: #aaaaaa;
}

body.dark-mode .calibration-header-toolbar {
    background-color: #353535;
    border-color: #4a4a4a;
    box-shadow: none;
}

body.dark-mode .calibration-profile-picker label {
    color: #9e9e9e;
}

body.dark-mode .calibration-profile-picker .offset-select {
    border-color: #5a5a5a;
    box-shadow: none;
}

body.dark-mode .calibration-profile-picker .offset-select:has(option[value="none"]:checked) {
    border-color: #8d6e63;
    background-color: rgba(255, 183, 77, 0.08);
    color: #ffcc80;
    box-shadow: none;
}

body.dark-mode .calibration-toolbar-divider {
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0),
        rgba(255, 255, 255, 0.1) 25%,
        rgba(255, 255, 255, 0.1) 75%,
        rgba(255, 255, 255, 0)
    );
}

body.dark-mode .offset-select {
    background-color: #3a3a3a;
    border: 1px solid #5a5a5a;
    color: #ffffff;
}

body.dark-mode .preview-area {
    background-color: #2a2a2a;
}

body.dark-mode .preview-area-wrapper {
    background-color: #2a2a2a;
}

body.dark-mode .preview-headers {
    background-color: #2a2a2a;
}

body.dark-mode .preview-header {
    color: #ffffff;
}

body.dark-mode .preview-sheet {
    border: 2px solid #5a5a5a;
}

body.dark-mode #calibration-test-btn.calibration-btn {
    background-color: #3a3a3a;
    color: #90caf9;
    border-color: #5c6bc0;
    box-shadow: none;
}

body.dark-mode #calibration-test-btn.calibration-btn:hover {
    background-color: #424242;
    border-color: #7986cb;
    color: #bbdefb;
}

body.dark-mode #manage-profiles-btn.calibration-btn {
    background-color: #3a3a3a;
    color: #b0bec5;
    border: 1px solid #5a5a5a;
    box-shadow: none;
}

body.dark-mode #manage-profiles-btn.calibration-btn:hover {
    background-color: #454545;
    border-color: #78909c;
    color: #eceff1;
}

body.dark-mode .calibration-info-btn {
    background-color: #3a3a3a;
    color: #90caf9;
    border-color: #5c6bc0;
    box-shadow: none;
}

body.dark-mode .calibration-info-btn:hover {
    background-color: #424242;
    border-color: #7986cb;
    color: #bbdefb;
}

body.dark-mode .calibration-instructions {
    background-color: #4a4a4a;
}

body.dark-mode .calibration-instructions p {
    color: #ffffff;
}

body.dark-mode .calibration-action-btn {
    background-color: #0066cc;
}

body.dark-mode .calibration-action-btn:hover {
    background-color: #0052a3;
}

body.dark-mode .calibration-preview-sheet {
    border: 2px solid #5a5a5a;
}

body.dark-mode .calibration-instructions-text {
    background-color: #2d3238;
    border-color: #404750;
    color: #d8dce3;
}

body.dark-mode .offset-control-group label {
    color: #aaaaaa;
}

body.dark-mode .offset-control-group input[type="number"] {
    background-color: #4a4a4a;
    border: 1px solid #5a5a5a;
    color: #ffffff;
}

body.dark-mode .nudge-btn {
    background-color: #4a4a4a;
    color: #ffffff;
    border: 1px solid #5a5a5a;
}

body.dark-mode .nudge-btn:hover {
    background-color: #5a5a5a;
}

body.dark-mode .calibration-profile-save {
    background-color: #4a4a4a;
}

body.dark-mode .calibration-profile-save label {
    color: #aaaaaa;
}

body.dark-mode .calibration-profile-save input[type="text"] {
    background-color: #3a3a3a;
    border: 1px solid #5a5a5a;
    color: #ffffff;
}

body.dark-mode .calibration-profile-save .save-btn:disabled {
    background-color: #666666;
    color: #aaaaaa;
}

body.dark-mode .calibration-profile-save .save-btn:disabled:hover {
    background-color: #666666;
}

body.dark-mode .save-btn:disabled {
    background-color: #666666;
    color: #aaaaaa;
}

body.dark-mode .save-btn:disabled:hover {
    background-color: #666666;
}

body.dark-mode .calibration-profile-save .save-btn {
    background-color: #0066cc;
}

body.dark-mode .profile-item {
    background-color: #4a4a4a;
    border: 1px solid #5a5a5a;
}

body.dark-mode .profile-name {
    color: #ffffff;
}

body.dark-mode .profile-details {
    color: #aaaaaa;
}

body.dark-mode .profile-select-btn {
    background-color: #0066cc;
}

body.dark-mode .profile-select-btn:hover {
    background-color: #0052a3;
}

body.dark-mode .preview-card:hover {
    border-color: #0066cc;
}

body.dark-mode .preview-card.selected {
    border-color: #0066cc;
}

body.dark-mode .bottom-controls {
    background-color: #1a1a1a;
    border-top: 2px solid #3a3a3a;
}

body.dark-mode .paper-size-control label {
    color: #aaaaaa;
}

body.dark-mode .paper-size-select {
    background-color: #3a3a3a;
    border: 1px solid #5a5a5a;
    color: #ffffff;
}

body.dark-mode .card-size-control label {
    color: #aaaaaa;
}

body.dark-mode .card-size-font-control .card-size-select {
    color: #e0e0e0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2390a4ae' d='M1.41 0 6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
}

body.dark-mode .card-size-font-control .card-size-select:hover {
    color: #90caf9;
}

body.dark-mode .font-control {
    background-color: #2a2a2a;
    border-color: #5a5a5a;
}

body.dark-mode .font-control:hover {
    border-color: #64b5f6;
    background-color: #333333;
}

body.dark-mode .font-control .font-control-label {
    color: #aaaaaa;
}

body.dark-mode .font-display-text {
    color: #e0e0e0;
}

body.dark-mode .font-display-text:hover {
    color: #90caf9;
}

body.dark-mode .font-display-chevron {
    border-top-color: #90a4ae;
}

body.dark-mode .font-control:hover .font-display-chevron {
    border-top-color: #cfd8dc;
}

body.dark-mode .font-size-popup-content {
    background-color: #2a2a2a;
}

body.dark-mode .font-size-popup-header {
    border-bottom-color: #3a3a3a;
}

body.dark-mode .font-size-popup-header h3 {
    color: #ffffff;
}

body.dark-mode .close-font-size-popup-btn {
    color: #aaaaaa;
}

body.dark-mode .close-font-size-popup-btn:hover {
    color: #ffffff;
}

body.dark-mode .font-size-popup-body {
    border-color: #3a3a3a;
}

body.dark-mode .font-size-popup-row label {
    color: #e0e0e0;
}

body.dark-mode .font-size-popup-select {
    background-color: #3a3a3a;
    border-color: #5a5a5a;
    color: #ffffff;
}

body.dark-mode .font-size-popup-footer {
    border-top-color: #3a3a3a;
}

body.dark-mode .font-size-popup-save-btn {
    background-color: #0066cc;
}

body.dark-mode .font-size-popup-save-btn:hover {
    background-color: #0052a3;
}

body.dark-mode .slider {
    background-color: #3a3a3a;
}

body.dark-mode .slider::-webkit-slider-thumb {
    background-color: #0066cc;
}

body.dark-mode .slider::-moz-range-thumb {
    background-color: #0066cc;
}

body.dark-mode .export-btn {
    background-color: #0066cc;
}

body.dark-mode .export-btn:hover {
    background-color: #0052a3;
}

body.dark-mode .modal {
    background-color: rgba(0, 0, 0, 0.7);
}

body.dark-mode .modal-content {
    background-color: #3a3a3a;
    color: #ffffff;
}

body.dark-mode .modal-content h2 {
    color: #ffffff;
}

body.dark-mode .modal-content p {
    color: #aaaaaa;
}

body.dark-mode .calibration-options label {
    background-color: #4a4a4a;
}

body.dark-mode .calibration-options label:hover {
    background-color: #5a5a5a;
}

body.dark-mode .fine-tune-controls {
    background-color: #4a4a4a;
}

body.dark-mode .fine-tune-controls label {
    color: #aaaaaa;
}

body.dark-mode .fine-tune-controls input[type="number"] {
    background-color: #3a3a3a;
    border: 1px solid #5a5a5a;
    color: #ffffff;
}

body.dark-mode .save-btn {
    background-color: #0066cc;
}

body.dark-mode .save-btn:hover {
    background-color: #0052a3;
}

body.dark-mode .cancel-btn {
    background-color: #4a4a4a;
    color: #ffffff;
}

body.dark-mode .cancel-btn:hover {
    background-color: #5a5a5a;
}

body.dark-mode ::-webkit-scrollbar-track {
    background: #2a2a2a;
}

body.dark-mode ::-webkit-scrollbar-thumb {
    background: #5a5a5a;
}

body.dark-mode ::-webkit-scrollbar-thumb:hover {
    background: #6a6a6a;
}

body.dark-mode .style-menu {
    background-color: #3a3a3a;
    border: 2px solid #5a5a5a;
}

body.dark-mode .style-menu-header {
    background-color: #2a2a2a;
    border-bottom: 2px solid #1a1a1a;
}

body.dark-mode .style-menu-header h3 {
    color: #ffffff;
}

body.dark-mode .style-menu-subtitle {
    color: #aaaaaa;
}

body.dark-mode .close-style-menu-btn {
    color: #aaaaaa;
}

body.dark-mode .close-style-menu-btn:hover {
    color: #ffffff;
}

body.dark-mode .style-control-group label {
    color: #aaaaaa;
}

body.dark-mode .style-select,
body.dark-mode .style-input {
    background-color: #4a4a4a;
    border: 1px solid #5a5a5a;
    color: #ffffff;
}

body.dark-mode .color-input {
    border: 1px solid #5a5a5a;
}

body.dark-mode .align-btn {
    background-color: #4a4a4a;
    border: 1px solid #5a5a5a;
    color: #ffffff;
}

body.dark-mode .align-btn:hover {
    background-color: #5a5a5a;
}

body.dark-mode .align-btn.active {
    background-color: #0066cc;
    border-color: #0066cc;
}


body.dark-mode .format-btn {
    background-color: #4a4a4a;
    border: 1px solid #5a5a5a;
    color: #ffffff;
}

body.dark-mode .format-btn:hover {
    background-color: #5a5a5a;
}

body.dark-mode .format-btn.active {
    background-color: #0066cc;
}

body.dark-mode .style-action-btn {
    background-color: #4a4a4a;
    border: 1px solid #5a5a5a;
    color: #ffffff;
}

body.dark-mode .style-action-btn:hover {
    background-color: #5a5a5a;
}

body.dark-mode .quizlet-import-input-container label {
    color: #aaaaaa;
}

body.dark-mode .quizlet-text-input {
    background-color: #3a3a3a;
    border: 1px solid #5a5a5a;
    color: #ffffff;
}

body.dark-mode .quizlet-text-input:focus {
    border-color: #0066cc;
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);
}

body.dark-mode .quizlet-text-input::placeholder {
    color: #666666;
}

body.dark-mode .footer {
    background-color: #1a1a1a;
    border-top: 2px solid #3a3a3a;
}

body.dark-mode .footer-link {
    color: #aaaaaa;
}

body.dark-mode .footer-link:hover {
    color: #ffffff;
}

body.dark-mode .footer-link:not([href]) {
    color: #666666;
}

body.dark-mode .footer-separator {
    color: #4a4a4a;
}

body.dark-mode .footer-copyright {
    color: rgba(255, 255, 255, 0.42);
}

body.dark-mode .theme-toggle-btn {
    background-color: #4a4a4a;
    color: #ffffff;
    border: 1px solid #5a5a5a;
}

body.dark-mode .theme-toggle-btn:hover {
    background-color: #5a5a5a;
}

body.dark-mode .feedback-btn {
    background-color: #4a4a4a;
    color: #ffffff;
    border: 1px solid #5a5a5a;
}

body.dark-mode .feedback-btn:hover {
    background-color: #5a5a5a;
}

body.dark-mode .feedback-modal-header {
    border-bottom-color: #4a4a4a;
}

body.dark-mode .close-feedback-modal-btn {
    color: #aaaaaa;
}

body.dark-mode .close-feedback-modal-btn:hover {
    color: #ffffff;
}

body.dark-mode .tutorial-overlay {
    background-color: rgba(0, 0, 0, 0.7);
}

/* Page Size Warning Popup */
.page-size-warning-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #ffc107;
    color: #333333;
    padding: 20px 30px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
    max-width: 500px;
    text-align: center;
    line-height: 1.5;
}

.page-size-warning-popup.show {
    opacity: 1;
    pointer-events: auto;
}

.page-size-warning-popup.fade-out {
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

/* Dark mode for page size warning popup */
body.dark-mode .page-size-warning-popup {
    background-color: #ff9800;
    color: #ffffff;
}

/* Toast notification for share / import profile */
.flashcard-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    background-color: #323232;
    color: #ffffff;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    max-width: 90vw;
}

body.dark-mode .flashcard-toast {
    background-color: #424242;
}
