/* XiaoLing Sentence Master - Mobile-First Tablet Design */
/* NetDynamic.Net */
/* v3.13 - 2025-11-30 - Added Page 3, reduced panel heights, settings page selector */

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

:root {
    --primary-color: #4a7c59;
    --bubble-bg: #f5e6d3;
    --bubble-border: #d4a574;
    --text-color: #333;
    --white: #ffffff;
    --shadow: 0 4px 6px rgba(0,0,0,0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #fff;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    margin: 0;
    padding: 0;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* ===== TOP BAR ===== */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: var(--shadow);
    z-index: 100;
    position: relative;
}

/* Title View */
.top-bar-title-view {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    position: relative;
    min-height: 44px;
    max-height: 44px;
    overflow: visible;
}

.top-bar-title-view h1 {
    font-size: 26px;
    font-weight: 900;
    font-family: 'Tahoma', 'Verdana', 'Arial Black', sans-serif;
    color: var(--primary-color);
    margin: 0;
    text-align: center;
    letter-spacing: 1.5px;
    flex: 1;
    position: relative;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5), 0 -1px 0 rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    max-height: 54px;
    overflow: visible;
    padding-left: 44px;
    pointer-events: none;
}

.title-avatar {
    height: 54px;
    width: 54px;
    /* border-radius: 50%; */
    /* object-fit: cover; */
    vertical-align: middle;
    flex-shrink: 0;
    margin-top: -2px;
}

.top-bar-title-view .menu-toggle-btn {
    position: absolute;
    left: 0;
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    color: var(--primary-color);
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    border-radius: 50%;
    z-index: 10;
    pointer-events: auto;
}

.top-bar-title-view .menu-toggle-btn:active {
    background: rgba(0, 0, 0, 0.05);
    transform: scale(0.95);
}

/* Buttons View */
.top-bar-buttons-view {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    gap: 20px;
    padding: 0;
}

.top-bar-buttons-view .close-menu {
    position: absolute;
    right: 20px;
    width: 44px;
    height: 44px;
    border: none;
    background: #e91e63;
    color: white;
    font-size: 20px;
    font-weight: normal;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-shadow: var(--shadow);
    padding-left: 3px;
}

.top-bar-buttons-view .close-menu:active {
    transform: scale(0.95);
    background: #c2185b;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.icon-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: var(--shadow);
}

.icon-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* ===== PREVIEW CARD (FULL SCREEN) ===== */
.preview-card {
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 0;
    overflow: auto;
    transition: filter 0.3s ease;
}

.preview-card.dimmed {
    filter: brightness(0.7);
}

.sentence-card {
    position: relative;
    background: var(--primary-color);
    width: 100%;
    min-height: 100%;
    border-radius: 0;
    padding: 20px 10px 40px 10px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 20px;
    box-shadow: none;
    overflow: visible;
}

.preview-card .sentence-card {
    padding-top: var(--card1-vertical-pos, 85px);
}

.slide-up-panel .sentence-card {
    padding-top: var(--card2-vertical-pos, 85px);
    background: #457454; /* Slightly darker than page 1 */
}

.slide-up-panel-3 .sentence-card {
    padding-top: var(--card3-vertical-pos, 85px);
    background: #3f6b4d; /* Slightly darker than page 2 */
}

/* Active indicator for each page */
.active-indicator {
    position: absolute;
    top: 2px;
    right: 2px;
    color: #ff00ff;
    font-size: 10px;
    font-weight: bold;
    padding: 1px 3px;
    z-index: 100;
    pointer-events: none;
    text-transform: uppercase;
}

/* Page 1 active indicator - top right corner */
.preview-card .active-indicator {
    top: 2px;
}

/* ===== WORDS CONTAINER (Chinese + English aligned) ===== */
.words-container {
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    flex-wrap: wrap;
    gap: 2px;
    margin-top: 10px;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Card-specific horizontal positioning */
.preview-card .words-container {
    justify-content: var(--card1-justify, center);
    padding-left: calc((var(--card1-horizontal-pos, 50%) - 50%) * 2);
    padding-right: calc((50% - var(--card1-horizontal-pos, 50%)) * 2);
}

.slide-up-panel .words-container {
    justify-content: var(--card2-justify, center);
    padding-left: calc((var(--card2-horizontal-pos, 50%) - 50%) * 2);
    padding-right: calc((50% - var(--card2-horizontal-pos, 50%)) * 2);
}

.slide-up-panel-3 .words-container {
    justify-content: var(--card3-justify, center);
    padding-left: calc((var(--card3-horizontal-pos, 50%) - 50%) * 2);
    padding-right: calc((50% - var(--card3-horizontal-pos, 50%)) * 2);
}

.word-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    position: relative;
    padding: 5px;
}

/* Group container for compound words */
.group-container {
    display: flex;
    gap: 8px;
    position: relative;
}

/* Character meaning label (shown above bubble in compounds) */
.char-meaning {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: #a0f0f0;
    white-space: nowrap;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    pointer-events: none;
}

/* Adjust bubble position to make room for meaning label */
.group-container.compound .word-bubble {
    position: relative;
}

/* Red U-shaped brace for grouped words (compound words) */
.group-container.compound::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: -5px;
    right: -5px;
    height: 20px;
    border: 6px solid #ff4444;
    border-top: none;
    border-radius: 0 0 12px 12px;
}

/* Draggable indicator */
.word-column.draggable {
    cursor: move;
}

.word-column.dragging {
    opacity: 0.5;
}

.word-column.drag-over {
    outline: 3px dashed #ff4444;
    outline-offset: 5px;
}

/* Compound group bubbles - ungroupable */
.group-container.compound .word-bubble {
    cursor: grab;
    position: relative;
    transition: transform 0.2s, opacity 0.2s;
}

.group-container.compound .word-bubble:active {
    cursor: grabbing;
}

/* Visual hint for compound groups - only show when draggable (Step 2) */
.word-column.draggable .group-container.compound .word-bubble::before {
    content: '↑';
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff6b6b;
    color: white;
    font-size: 12px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    pointer-events: none;
}

/* Combined Pinyin + Character Bubble (like CapCut) */
.word-bubble {
    background: var(--bubble-bg);
    border: 4px solid var(--bubble-border);
    border-radius: 25px;
    padding: 1vmin 1.5vmin;
    font-weight: bold;
    box-shadow: 0 5px 8px rgba(0,0,0,0.25);
    text-align: center;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0px;
    overflow: visible;
    white-space: nowrap;
}

/* Main card (card 1) uses card1 variables */
.preview-card .word-bubble .pinyin {
    font-size: var(--card1-pinyin-size, 6vmin);
    color: #333;
    line-height: 1;
}

.preview-card .word-bubble .character {
    font-size: var(--card1-character-size, 10vmin);
    color: #2c2c2c;
    line-height: 1;
}

/* Second card (card 2) uses card2 variables */
.slide-up-panel .word-bubble .pinyin {
    font-size: var(--card2-pinyin-size, 6vmin);
    color: #333;
    line-height: 1;
}

.slide-up-panel .word-bubble .character {
    font-size: var(--card2-character-size, 10vmin);
    color: #2c2c2c;
    line-height: 1;
}

/* Third card (card 3) uses card3 variables */
.slide-up-panel-3 .word-bubble .pinyin {
    font-size: var(--card3-pinyin-size, 6vmin);
    color: #333;
    line-height: 1;
}

.slide-up-panel-3 .word-bubble .character {
    font-size: var(--card3-character-size, 10vmin);
    color: #2c2c2c;
    line-height: 1;
}

/* English word aligned under bubble */
.preview-card .english-word {
    color: white;
    font-size: var(--card1-english-word-size, 4.5vmin);
    font-weight: 600;
    text-align: center;
}

.slide-up-panel .english-word {
    color: white;
    font-size: var(--card2-english-word-size, 4.5vmin);
    font-weight: 600;
    text-align: center;
}

.slide-up-panel-3 .english-word {
    color: white;
    font-size: var(--card3-english-word-size, 4.5vmin);
    font-weight: 600;
    text-align: center;
}

/* Bubble style variants */
body[data-bubble-style="pill"] .word-bubble {
    border-radius: 50px;
}

body[data-bubble-style="square"] .word-bubble {
    border-radius: 12px;
}

/* ===== NATURAL ENGLISH ROW ===== */
.preview-card .natural-row {
    color: #dc2626 !important;
    font-size: var(--card1-natural-english-size, 9vmin);
    font-weight: 700;
    text-align: center;
    padding: 0 15px 8px 15px;
    margin-top: -20px;
    width: 100%;
    -webkit-text-stroke: var(--card1-natural-stroke-size, 0.7vmin) white !important;
    text-stroke: var(--card1-natural-stroke-size, 0.7vmin) white !important;
    paint-order: stroke fill;
    line-height: 1.2;
}

.slide-up-panel .natural-row {
    color: #dc2626 !important;
    font-size: var(--card2-natural-english-size, 9vmin);
    font-weight: 700;
    text-align: center;
    padding: 0 15px 8px 15px;
    margin-top: -20px;
    width: 100%;
    -webkit-text-stroke: var(--card2-natural-stroke-size, 0.7vmin) white !important;
    text-stroke: var(--card2-natural-stroke-size, 0.7vmin) white !important;
    paint-order: stroke fill;
    line-height: 1.2;
}

.preview-card .natural-row #naturalText {
    color: #dc2626 !important;
    -webkit-text-stroke: var(--card1-natural-stroke-size, 0.7vmin) white !important;
    text-stroke: var(--card1-natural-stroke-size, 0.7vmin) white !important;
}

.slide-up-panel .natural-row #naturalText2 {
    color: #dc2626 !important;
    -webkit-text-stroke: var(--card2-natural-stroke-size, 0.7vmin) white !important;
    text-stroke: var(--card2-natural-stroke-size, 0.7vmin) white !important;
}

/* Card 3 natural row */
.slide-up-panel-3 .natural-row {
    color: #dc2626 !important;
    font-size: var(--card3-natural-english-size, 9vmin);
    font-weight: 700;
    text-align: center;
    padding: 0 15px 8px 15px;
    margin-top: -20px;
    width: 100%;
    -webkit-text-stroke: var(--card3-natural-stroke-size, 0.7vmin) white !important;
    text-stroke: var(--card3-natural-stroke-size, 0.7vmin) white !important;
    paint-order: stroke fill;
    line-height: 1.2;
}

.slide-up-panel-3 .natural-row #naturalText3 {
    color: #dc2626 !important;
    -webkit-text-stroke: var(--card3-natural-stroke-size, 0.7vmin) white !important;
    text-stroke: var(--card3-natural-stroke-size, 0.7vmin) white !important;
}

/* ===== STICKER ROW ===== */
.sticker-row {
    width: 100%;
    position: relative;
    min-height: 33vmin;
}

.sticker {
    width: var(--sticker-size, 220px);
    height: var(--sticker-size, 220px);
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
    position: fixed;
    cursor: move;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    touch-action: none;
    z-index: 40;
}

.emoji-sticker {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--sticker-size, 220px);
    line-height: 1;
    text-align: center;
    user-select: none;
}

.student-name-display {
    position: fixed;
    top: 68px;
    left: 5px;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 4vmin;
    font-weight: 600;
    color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 9999;
}

/* ===== SLIDE-UP PANEL (PAGE 2) ===== */
.slide-up-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100vh;
    background: linear-gradient(135deg, #457454 0%, #3d6a4c 100%); /* Slightly darker green than page 1 */
    transform: translateY(calc(100vh - 64px)); /* Show both tabs: 32px + 32px */
    transition: none; /* No transition - panel stays where dragged */
    z-index: 50;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
    border-radius: 8px 8px 0 0;
    display: flex;
    flex-direction: column;
    touch-action: none;
    pointer-events: auto;
    overflow: visible; /* Allow nested Page 3 to be visible */
}

.slide-up-panel.dragging {
    transition: none;
}

.slide-up-panel.animate {
    transition: transform 0.3s ease-out;
}

/* Page 3 panel - separate fixed panel, follows Page 2 */
.slide-up-panel.slide-up-panel-3 {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(100vh - 64px); /* Height: viewport minus both tabs */
    background: linear-gradient(135deg, #3d6a4c 0%, #356044 100%); /* Slightly darker green than page 2 */
    /* To show 32px tab: translateY = height - 32 = (100vh - 64) - 32 = 100vh - 96 */
    transform: translateY(calc(100vh - 96px)); /* Closed: showing 32px tab */
    z-index: 60; /* Above Page 2 */
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
    pointer-events: none; /* Default: don't intercept touches when closed */
}

/* When Page 3 is open, allow pointer events */
.slide-up-panel.slide-up-panel-3.panel-open {
    pointer-events: auto;
}

/* Always allow pointer events on the pull tab */
.slide-up-panel.slide-up-panel-3 .pull-tab {
    pointer-events: auto;
}

.pull-tab {
    position: relative;
    width: 100%;
    height: 32px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px 8px 0 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
    padding: 0;
}

.pull-tab:active {
    cursor: grabbing;
}

.pull-handle {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 2px;
}

.pull-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.page-settings-btn {
    position: absolute;
    left: 12px;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.page-settings-btn:hover {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.1);
}

.content-indicator {
    font-size: 14px;
    color: #ffd700;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.slide-up-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 20px 20px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.placeholder {
    color: rgba(255, 255, 255, 0.5) !important;
    font-style: italic;
    font-size: 36px;
    -webkit-text-stroke: 0 !important;
    text-stroke: 0 !important;
}

.natural-row .placeholder {
    color: rgba(220, 38, 38, 0.5) !important;
    -webkit-text-stroke: var(--natural-stroke-size, 0.7vmin) rgba(255, 255, 255, 0.5) !important;
    text-stroke: var(--natural-stroke-size, 0.7vmin) rgba(255, 255, 255, 0.5) !important;
}

/* ===== INPUT CONTROLS (OVERLAY) ===== */
.input-controls {
    position: fixed;
    bottom: -50vh;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    padding: 15px 20px 20px;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 30px rgba(0,0,0,0.3);
    max-height: 50vh;
    overflow-y: auto;
    z-index: 150;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: bottom 0.3s ease, transform 0.1s ease;
    /* iOS keyboard fix - use env() safe area and transform for positioning */
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

.input-controls.show {
    bottom: 0;
}

/* iOS keyboard active state - will be controlled by JS */
.input-controls.keyboard-active {
    bottom: 0 !important;
    /* Transform is set dynamically via JS based on visualViewport */
}

.input-controls-2 {
    z-index: 200; /* Above slide-up panel */
    background: rgba(220, 220, 220, 0.98) !important; /* Light gray for page 2 */
}

.input-controls-2.show {
    bottom: 0;
}

.input-controls-3 {
    z-index: 250; /* Above page 3 panel */
    background: rgba(200, 200, 210, 0.98) !important; /* Slightly different gray for page 3 */
}

.input-controls-3.show {
    bottom: 0;
}

.input-controls-3 .input-step {
    width: 100%;
}

.input-controls-3 .input-wrapper input {
    width: 100%;
    box-sizing: border-box;
}

.input-controls-3 label {
    width: 100%;
    display: block;
}

.input-controls-3 .label-with-button label {
    width: auto;
    display: inline;
}

.input-controls-3 .suggestions {
    overflow-x: auto;
    overflow-y: hidden;
    background: #f5f5f5;
    border: none;
    border-radius: 10px;
    margin-top: 8px;
    display: none;
    white-space: nowrap;
    padding: 8px;
    -webkit-overflow-scrolling: touch;
}

.input-controls-3 .suggestions.show {
    display: block;
}

.input-controls-2 .input-step {
    width: 100%;
}

.input-controls-2 .input-wrapper input {
    width: 100%;
    box-sizing: border-box;
}

.input-controls-2 label {
    width: 100%;
    display: block;
}

.input-controls-2 .label-with-button label {
    width: auto;
    display: inline;
}

.input-controls-2 .suggestions {
    overflow-x: auto;
    overflow-y: hidden;
    background: #f5f5f5;
    border: none;
    border-radius: 10px;
    margin-top: 8px;
    display: none;
    white-space: nowrap;
    padding: 8px;
    -webkit-overflow-scrolling: touch;
}

.input-controls-2 .suggestions.show {
    display: block;
}

.input-controls-2 .suggestion-item {
    padding: 12px 18px;
    cursor: pointer;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: 8px;
    margin-right: 6px;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    min-width: 60px;
    vertical-align: top;
    transition: all 0.15s;
}

.input-controls-2 .suggestion-item:last-child {
    margin-right: 0;
}

.input-controls-2 .suggestion-item:active {
    background: var(--primary-color);
    transform: scale(0.95);
}

.input-controls-2 .suggestion-item:active .char {
    color: white;
}

.input-controls-2 .suggestion-item:active .pinyin {
    color: rgba(255,255,255,0.9);
}

.input-controls-2 .suggestion-item .char {
    font-size: 28px;
    font-weight: bold;
    color: #333;
}

.input-controls-2 .suggestion-item .pinyin {
    color: #888;
    font-size: 12px;
}

.input-controls-2 .suggestion-item.add-char-btn {
    background: #f0f0f0;
    border: 2px dashed #999;
}

.input-controls-2 .suggestion-item.add-char-btn:active {
    background: #e0e0e0;
    border-color: #666;
}

.input-controls-2 .suggestion-item.add-char-btn .char {
    color: #666;
}

.input-controls-2 .suggestion-item.add-char-btn .pinyin {
    color: #666;
    font-weight: bold;
}

.close-input-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    width: 36px;
    height: 36px;
    border: none;
    background: #e0e0e0;
    border-radius: 50%;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 250;
}

.close-input-btn:active {
    background: #d0d0d0;
    transform: scale(0.95);
}

/* Step Indicator (Floating on main screen, well above typing area) */
.step-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 25px;
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    transition: bottom 0.3s ease, right 0.3s ease, transform 0.3s ease;
}

.step-indicator.show {
    bottom: 160px;
}

.step-indicator.show.step4-active {
    bottom: 240px;
}

/* Hidden state - slide off to the right */
.step-indicator.hidden {
    transform: translateX(calc(100% + 50vw));
}

/* Hide tab (left arrow) on the step indicator */
.step-hide-tab {
    width: 32px;
    height: 48px;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    margin-right: 10px;
    user-select: none;
}

.step-hide-tab:hover {
    background: rgba(0, 0, 0, 0.5);
}

/* Show tab - appears on right edge when step indicator is hidden */
.step-show-tab {
    position: fixed;
    right: -40px;
    bottom: 160px;
    width: 32px;
    height: 60px;
    background: rgba(0, 0, 0, 0.4);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    z-index: 200;
    transition: right 0.3s ease;
    user-select: none;
}

.step-show-tab:hover {
    background: rgba(0, 0, 0, 0.6);
}

.step-show-tab.show {
    right: 0;
}

.step {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #e0e0e0;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 28px;
    transition: all 0.3s;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}

.step:active {
    transform: scale(0.95);
}

.step.active {
    background: var(--primary-color);
    color: white;
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.step.completed {
    background: #4caf50;
    color: white;
}

.step.clear-btn {
    background: #d97c3a;
    color: white;
    font-size: 20px;
    font-weight: bold;
}

.step.clear-btn:active {
    background: #c96a28;
    transform: scale(1.1) rotate(180deg);
    transition: transform 0.3s ease;
}

/* Step 4 media button - yellow background */
.step[data-step="4"] {
    background: linear-gradient(135deg, #f7d350 0%, #e6b800 100%);
    color: #333;
}

.step[data-step="4"].active {
    background: linear-gradient(135deg, #ffe066 0%, #f7d350 100%);
}

/* Page indicator badge */
.page-indicator {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 11px;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 12px;
    margin-left: 5px;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
    user-select: none;
    letter-spacing: 0.5px;
}

/* Input Steps */
.input-step {
    display: none;
}

.input-step.active {
    display: block;
}

.input-step label {
    display: block;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
    font-size: 11px;
}

.input-step small {
    display: block;
    color: #888;
    font-size: 10px;
    margin-top: 3px;
}

.label-with-button {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 8px;
}

.label-with-button label {
    margin: 0;
}

.input-wrapper input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Suggestions (Horizontal - Android keyboard style) */
.suggestions {
    overflow-x: auto;
    overflow-y: hidden;
    background: #f5f5f5;
    border: none;
    border-radius: 10px;
    margin-top: 8px;
    display: none;
    white-space: nowrap;
    padding: 8px;
    -webkit-overflow-scrolling: touch;
}

.suggestions.show {
    display: block;
}

.suggestion-item {
    padding: 12px 18px;
    cursor: pointer;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: 8px;
    margin-right: 6px;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    min-width: 60px;
    vertical-align: top;
    transition: all 0.15s;
}

.suggestion-item:last-child {
    margin-right: 0;
}

.suggestion-item:active {
    background: var(--primary-color);
    transform: scale(0.95);
}

.suggestion-item:active .char {
    color: white;
}

.suggestion-item:active .pinyin {
    color: rgba(255,255,255,0.9);
}

.suggestion-item .char {
    font-size: 28px;
    font-weight: bold;
    color: #333;
}

.suggestion-item .pinyin {
    color: #888;
    font-size: 12px;
}

.suggestion-item.add-char-btn {
    background: #f0f0f0;
    border: 2px dashed #999;
}

.suggestion-item.add-char-btn:active {
    background: #e0e0e0;
    border-color: #666;
}

.suggestion-item.add-char-btn .char {
    color: #666;
}

.suggestion-item.add-char-btn .pinyin {
    color: #666;
    font-weight: bold;
}

/* Sticker Grid */
.sticker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 6px;
    max-height: 60px;
    overflow-y: auto;
    margin-bottom: 6px;
    padding: 4px;
    background: #f8f8f8;
    border-radius: 8px;
}

.sticker-option {
    width: 50px;
    height: 50px;
    object-fit: contain;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 6px;
    transition: all 0.3s;
}

.sticker-option:active {
    border-color: var(--primary-color);
    transform: scale(0.95);
}

.sticker-option.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(74, 124, 89, 0.5);
}

.no-stickers {
    grid-column: 1 / -1;
    text-align: center;
    color: #999;
    padding: 10px;
    font-size: 11px;
}

/* Buttons */
.step-actions {
    display: flex;
    gap: 6px;
}

.btn-save,
.btn-clear {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    min-height: 36px;
}

.btn-save {
    background: var(--primary-color);
    color: white;
    flex: 2;
}

.btn-save:active {
    transform: scale(0.98);
}

.btn-clear {
    background: #ff6b6b;
    color: white;
    flex: 1;
}

.btn-clear:active {
    transform: scale(0.98);
}

/* ===== MODALS ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: rgba(255, 255, 255, 1);
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    cursor: default;
}

/* Settings modal stays transparent so user can see font changes */
#settingsModal .modal-content,
#pageSettingsModal .modal-content {
    background: rgba(255, 255, 255, 0.5);
}

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

.modal-header h2 {
    font-size: 1.5em;
    color: var(--primary-color);
}

.close-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
}

.close-btn:active {
    background: #e0e0e0;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Settings Tabs */
.settings-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 0;
}

.settings-tab {
    flex: 1;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 15px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
}

.settings-tab:hover {
    color: var(--primary-color);
    background: rgba(74, 124, 89, 0.1);
}

.settings-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Settings Page Selector */
.settings-page-selector {
    display: inline-flex;
    gap: 6px;
    margin-left: 10px;
    vertical-align: middle;
}

.settings-page-selector .page-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e0e0e0;
    color: #666;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.settings-page-selector .page-num:hover {
    background: #d0d0d0;
}

.settings-page-selector .page-num.active {
    background: var(--primary-color);
    color: white;
}

.settings-tab-content {
    display: none;
}

.settings-tab-content.active {
    display: block;
}

/* Settings */
.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

.setting-group select,
.setting-group input[type="color"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 16px;
}

.setting-group input[type="color"] {
    height: 60px;
    cursor: pointer;
}

.setting-group input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #ddd;
    outline: none;
    cursor: pointer;
}

.setting-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.setting-group input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    border: none;
}

/* Saved Cards */
/* Saved Cards Modal - Wider */
.saved-cards-modal-content {
    max-width: 850px !important;
    width: 95% !important;
}

/* Search Controls */
.search-controls {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
    flex-direction: column;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
}

.search-input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: var(--primary-color);
}

.clear-search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border: none;
    background: #e0e0e0;
    color: #666;
    border-radius: 50%;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
}

.clear-search-btn:hover {
    background: #d97c3a;
    color: white;
}

/* Add Text Element Button */
.add-text-btn {
    padding: 4px 8px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.add-text-btn:hover {
    background: #5568d3;
}

.add-text-btn:active {
    background: #4a5bbd;
}

/* Text-Only Bubble */
.text-only-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border-color: #5568d3 !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.text-only-content {
    font-size: calc(var(--card1-english-word-size, 4.5vmin) * 1.0);
    font-weight: 700;
    color: white;
    text-align: center;
    padding: 7px;
    text-transform: capitalize;
    letter-spacing: 0.5px;
}

.slide-up-panel .text-only-content {
    font-size: calc(var(--card2-english-word-size, 4.5vmin) * 1.0);
}

/* Line Break Element - Shows dot inline, then forces wrap after */
.line-break-element {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    cursor: pointer;
}

.line-break-dot {
    color: rgba(255, 255, 255, 0.4);
    font-size: 14px;
    line-height: 1;
}

/* Spacer that forces the actual line break */
.line-break-spacer {
    flex-basis: 100%;
    height: 0;
}

.search-toggle {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.search-toggle-btn {
    flex: 1;
    padding: 8px 16px;
    border: 2px solid #e0e0e0;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    color: #666;
}

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

.search-toggle-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.saved-cards-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 60vh;
    overflow-y: auto;
}

.saved-card-item {
    background: #f8f8f8;
    border-radius: 8px;
    padding: 8px 12px;
    border: 2px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.saved-card-item:hover {
    background: #f0f0f0;
    border-color: var(--primary-color);
}

.saved-card-item .preview-mini {
    font-size: 18px;
    min-width: 120px;
    max-width: 350px;
    text-align: left;
    flex-shrink: 0;
    line-height: 1.4;
}

.saved-card-item .card-info-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.saved-card-item .card-info {
    font-size: 12px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saved-card-item .card-info strong {
    color: var(--primary-color);
}

.saved-card-item .two-page-indicator {
    font-size: 14px;
    margin-left: 4px;
    opacity: 0.7;
}

.saved-card-item .card-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.saved-card-item .load-btn {
    padding: 8px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    background: var(--primary-color);
    color: white;
    transition: all 0.2s;
}

.saved-card-item .load-btn:hover {
    background: var(--secondary-color);
}

.saved-card-item .delete-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    background: #e0e0e0;
    color: #666;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.saved-card-item .delete-btn:hover {
    background: #d97c3a;
    color: white;
}

.delete-btn {
    background: #ff6b6b;
    color: white;
}

/* Color schemes */
body[data-theme="blue"] {
    --primary-color: #4a7c9e;
}

body[data-theme="pink"] {
    --primary-color: #e91e63;
}

body[data-theme="purple"] {
    --primary-color: #9c27b0;
}

body[data-theme="orange"] {
    --primary-color: #ff9800;
}

body[data-theme="red"] {
    --primary-color: #f44336;
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */

/* Landscape tablets */
@media (max-height: 600px) and (orientation: landscape) {
    .sentence-card {
        padding: 20px 15px;
        gap: 20px;
    }

    .word-bubble .pinyin {
        font-size: 24px;
    }

    .word-bubble .character {
        font-size: 40px;
    }

    .english-word {
        font-size: 20px;
    }

    .natural-row {
        font-size: 28px;
    }

    .sticker {
        max-width: 150px;
        max-height: 150px;
    }
}

/* Small phones */
@media (max-width: 400px) {
    .word-bubble .pinyin {
        font-size: 20px;
        padding: 12px 16px;
    }

    .word-bubble .character {
        font-size: 36px;
    }

    .english-word {
        font-size: 18px;
    }

    .natural-row {
        font-size: 24px;
    }

    .sticker {
        max-width: 120px;
        max-height: 120px;
    }
}

/* Phone - Portrait */
@media (max-width: 600px) and (orientation: portrait) {
    .sentence-card {
        padding: 20px 5px;
        gap: 20px;
    }

    .words-container {
        gap: 2px;
    }
}

/* Phone - Landscape */
@media (max-width: 900px) and (orientation: landscape) {
    .sentence-card {
        padding: 10px 5px;
        gap: 20px;
    }

    .words-container {
        gap: 2px;
    }

    .word-bubble {
        border-width: 2px;
    }

    .step-indicator.show {
        bottom: 120px;
    }

    .step-indicator.show.step4-active {
        bottom: 200px;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .app-container {
        max-width: 1920px;
        width: 100%;
        margin: 0 auto;
    }

    .sentence-card {
        gap: 20px;
    }

    .words-container {
        gap: 2px;
    }

    .word-bubble {
        border-width: 5px;
    }

    .step-indicator.show {
        bottom: 180px;
    }

    .step-indicator.show.step4-active {
        bottom: 260px;
    }

    .sticker {
        width: 33vmin;
        height: 33vmin;
    }

    .input-controls {
        max-height: 40vh;
    }
}

/* Delete Sticker Modal Radio Buttons */
.delete-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

.radio-option:hover {
    border-color: var(--primary-color);
    background: #f9f9f9;
}

.radio-option input[type="radio"] {
    width: 28px;
    height: 28px;
    min-width: 28px;
    cursor: pointer;
    margin: 0;
}

.radio-option input[type="radio"]:checked {
    accent-color: var(--primary-color);
}

.radio-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.radio-label strong {
    font-size: 16px;
    color: #333;
}

.radio-label small {
    font-size: 13px;
    color: #666;
    font-weight: normal;
}

/* Mobile optimization */
@media (max-width: 600px) {
    .radio-option input[type="radio"] {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }

    .radio-label strong {
        font-size: 18px;
    }

    .radio-label small {
        font-size: 14px;
    }
}

/* Responsive title */
@media (max-width: 600px) {
    .top-bar-title-view h1 {
        font-size: 20px;
        letter-spacing: 1.5px;
    }
}

@media (max-width: 450px) {
    .top-bar-title-view h1 {
        font-size: 16px;
        letter-spacing: 1px;
    }
}

/* Version Number */
.version-number {
    position: fixed;
    bottom: 4px;
    right: 8px;
    font-size: 10px;
    color: rgba(0, 0, 0, 0.3);
    font-family: monospace;
    z-index: 300;
    pointer-events: none;
    user-select: none;
}
