/* ============================================
   SUPER LOOP - Dark Theme / Tablet Landscape
   Font: Manrope + Material Symbols Outlined
   Primary: #f2930d (Orange)
   Accent: #5c7cfa (Vivid Blue)
   Background: #000000
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #f2930d;
    --primary-dark: #d17e0a;
    --accent: #5c7cfa;
    --accent-dark: #4a6ae0;
    --bg: #000000;
    --bg-card: #0a0a0a;
    --bg-elevated: #141414;
    --bg-highlight: #140e04;
    --text: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.5);
    --text-dim: rgba(255, 255, 255, 0.3);
    --text-faint: rgba(255, 255, 255, 0.15);
    --border: rgba(255, 255, 255, 0.1);
    --border-light: rgba(255, 255, 255, 0.2);
    --danger: #f44336;
    --success: #4caf50;
    --top-bar-h: 56px;
    --bottom-bar-h: 218px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-full: 9999px;
}

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    user-select: none;
    -webkit-user-select: none;
}

.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;
}

.hidden {
    display: none !important;
}

/* Material Symbols */
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    font-size: 24px;
    line-height: 1;
    vertical-align: middle;
}

.material-symbols-outlined.filled {
    font-variation-settings: 'FILL' 1, 'wght' 700, 'GRAD' 0, 'opsz' 24;
}

.material-symbols-outlined.text-sm {
    font-size: 18px;
}

/* --- Top Bar --- */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--top-bar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

.top-bar-left,
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.top-bar-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text);
    text-align: center;
    flex: 1;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    background: none;
    color: var(--text);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.icon-btn:active {
    background: rgba(255, 255, 255, 0.1);
}

/* --- Main Layout (Tablet Landscape) --- */
.main-layout {
    position: fixed;
    top: var(--top-bar-h);
    left: 0;
    right: 0;
    bottom: var(--bottom-bar-h);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    overflow: hidden;
}

/* Left Panel - Video */
.panel-left {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    overflow: hidden;
}
.panel-left.hidden {
    display: none !important;
}
.panel-left.hidden + .panel-right {
    grid-column: 1 / -1;
}

.player-wrapper {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    flex-shrink: 0;
    position: relative;
}

.player-wrapper #player {
    width: 100%;
    height: 100%;
}


.player-info-bar {
    flex: 1;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

/* Time info bar - fixed height block */
.time-info-bar {
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg-highlight);
}

.time-info-text {
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.time-info-placeholder {
    color: var(--text-faint);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 3px;
    text-transform: uppercase;
}

.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.tool-btn.loading .material-symbols-outlined {
    animation: spin 1s linear infinite;
}

.error-msg {
    padding: 12px 16px;
    background: rgba(244, 67, 54, 0.15);
    border: 1px solid rgba(244, 67, 54, 0.3);
    border-radius: var(--radius-sm);
    color: #ff6b6b;
    font-size: 13px;
    font-weight: 500;
}

/* Right Panel - Script */
.panel-right {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.script-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Caption Mode Toggle Bar */
.caption-mode-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.caption-mode-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.caption-mode-toggle {
    padding: 4px 12px;
    border: 1px solid var(--primary);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--primary);
    font-family: 'Manrope', sans-serif;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}

.caption-mode-toggle:hover {
    background: var(--primary);
    color: #000;
}

/* Mode Tab Bar (YouTube 원본 / TTS) */
.mode-tab-bar {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.mode-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 6px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-family: 'Manrope', sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-tab .material-symbols-outlined {
    font-size: 18px;
}

.mode-tab.active {
    background: var(--primary);
    color: #000;
    font-weight: 700;
}

.mode-tab:not(.active):active {
    background: rgba(255, 255, 255, 0.1);
}

.mode-tab .mode-tab-badge {
    font-size: 10px;
    padding: 1px 5px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-muted);
    font-weight: 700;
    margin-left: 2px;
}

.mode-tab.active .mode-tab-badge {
    background: rgba(0, 0, 0, 0.2);
    color: #000;
}

/* 대화 모드 토글 */
.dialogue-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
}
.dialogue-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}
.dialogue-toggle-label {
    user-select: none;
}

/* 화자 표시 (스크립트 아이템) */
.speaker-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 8px;
    margin-right: 6px;
    vertical-align: middle;
}
.speaker-badge.speaker-a {
    background: #5c7cfa;
    color: #fff;
}
.speaker-badge.speaker-b {
    background: #f06595;
    color: #fff;
}

/* AI 스크립트 생성 */
.ai-generate-open-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 10px 16px;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #5c7cfa, #845ef7);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    justify-content: center;
}
.ai-generate-open-btn .material-symbols-outlined {
    font-size: 18px;
}
.ai-generate-sheet {
    max-width: 440px;
}
.ai-generate-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 14px;
    color: var(--text-primary);
}
.ai-generate-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.ai-preset-chip {
    padding: 6px 14px;
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}
.ai-preset-chip:hover, .ai-preset-chip.active {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
}
.ai-generate-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface-2);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 14px;
    box-sizing: border-box;
}
.ai-generate-input::placeholder {
    color: var(--text-tertiary);
}
.ai-generate-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}
.ai-option-group {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ai-option-label {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 50px;
}
.ai-option-btns {
    display: flex;
    gap: 6px;
}
.ai-opt-btn {
    padding: 5px 12px;
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.ai-opt-btn.active {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
    font-weight: 600;
}

/* Script Items - Cascading opacity like reference */
.script-item {
    padding: 12px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    position: relative;
    flex-shrink: 0;
}

.script-item .timestamp {
    display: none; /* Hidden in new design - cleaner look */
}

.script-item .text {
    font-size: 16px;
    font-weight: 500;
    line-height: 1.5;
    color: var(--text);
    transition: all 0.2s;
}

/* Inactive items: faded with varying opacity */
.script-item {
    opacity: 0.25;
}

.script-item:hover {
    opacity: 0.6;
    background: rgba(255, 255, 255, 0.03);
}

/* Selected item */
.script-item.selected {
    opacity: 1;
    background: var(--bg-highlight);
    border-color: transparent;
}

.script-item.selected .text {
    color: var(--primary);
    font-size: 18px;
    font-weight: 700;
}

/* Active (playing) item */
.script-item.active {
    opacity: 1;
}

.script-item.active .text {
    color: var(--primary);
    font-weight: 700;
}

.script-item.active.selected {
    opacity: 1;
}

/* Adjacent items get slightly more opacity for cascading effect */
.script-item.selected + .script-item {
    opacity: 0.5;
}

.script-item.selected + .script-item + .script-item {
    opacity: 0.35;
}

/* Translation text */
.translation-text {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.4;
    margin-left: 28px;
}

.script-item.selected .translation-text {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.6);
}

.script-item.active .translation-text {
    color: rgba(255, 255, 255, 0.6);
}

@media (min-width: 1024px) {
    .translation-text {
        font-size: 18px;
    }
    .script-item.selected .translation-text {
        font-size: 20px;
    }
}

/* Loop badge */
.loop-badge {
    position: absolute;
    top: 8px;
    right: 12px;
    background: var(--primary);
    color: #000;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    line-height: 1.5;
}

/* Scrollbar styling */
.script-container::-webkit-scrollbar {
    width: 4px;
}

.script-container::-webkit-scrollbar-track {
    background: transparent;
}

.script-container::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

/* --- Bottom Controls --- */
.bottom-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-bar-h);
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding: 12px 20px;
    padding-bottom: max(30px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
}

/* Timing Buttons Row */
.timing-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.timing-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s;
}

.timing-btn:active,
.timing-btn.key-pressed {
    background: rgba(242, 147, 13, 0.15);
    border-color: var(--primary);
    box-shadow: 0 0 8px var(--primary);
    transform: scale(0.92);
}

.timing-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 2px;
    letter-spacing: 0.5px;
}

.timing-value {
    font-size: 14px;
    font-weight: 700;
}

/* Word Selector (inline under selected sentence) */
.word-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.25);
    border-top: 1px solid var(--border-light);
    animation: wordSelectorIn 0.2s ease-out;
}

@keyframes wordSelectorIn {
    from { opacity: 0; max-height: 0; padding: 0 12px; }
    to { opacity: 1; max-height: 200px; padding: 10px 12px; }
}

.word-chip {
    padding: 6px 10px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    border: 1.5px solid transparent;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.15s;
    min-height: 36px;
    display: flex;
    align-items: center;
}

.word-chip:active {
    transform: scale(0.93);
}

.word-chip.in-range {
    background: rgba(242, 147, 13, 0.15);
    border-color: rgba(242, 147, 13, 0.3);
    color: var(--primary);
}

.word-chip.range-start {
    background: rgba(242, 147, 13, 0.3);
    border-color: var(--primary);
    color: #fff;
    font-weight: 700;
}

.word-chip.range-end {
    background: rgba(242, 147, 13, 0.3);
    border-color: var(--primary);
    color: #fff;
    font-weight: 700;
}

.word-selector-time {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 6px 8px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    background: rgba(0, 0, 0, 0.25);
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
    letter-spacing: 0.5px;
}

.ws-adjust-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ws-adjust-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1.5px solid rgba(242, 147, 13, 0.4);
    background: rgba(242, 147, 13, 0.1);
    color: var(--primary);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.12s;
}

.ws-adjust-btn:active {
    background: rgba(242, 147, 13, 0.3);
    transform: scale(0.9);
}

.word-selector-hint {
    display: none;
}

/* Action Buttons Row */
.action-row {
    display: flex;
    gap: 10px;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 56px;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.15s;
    font-size: 32px;
}

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

.action-btn .material-symbols-outlined {
    font-size: 32px;
}

.primary-btn {
    flex: 2;
    background: var(--primary);
    color: #000;
}

.primary-btn:active:not(:disabled),
.primary-btn.key-pressed {
    filter: brightness(0.7);
    transform: scale(0.9);
    box-shadow: 0 0 12px var(--primary);
}

.primary-btn:disabled {
    background: rgba(242, 147, 13, 0.3);
}

.secondary-btn {
    flex: 1;
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border-light);
}

.secondary-btn:active:not(:disabled),
.secondary-btn.key-pressed {
    background: rgba(242, 147, 13, 0.15);
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary);
    transform: scale(0.9);
}

.secondary-btn .material-symbols-outlined {
    font-size: 24px;
}

/* 핸즈프리 버튼 */
.handsfree-btn {
    flex: 1;
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border-light);
}
.handsfree-btn.active {
    background: linear-gradient(135deg, #5c7cfa, #845ef7);
    color: #fff;
    border-color: #5c7cfa;
    animation: handsfree-pulse 2s ease-in-out infinite;
}
@keyframes handsfree-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(92, 124, 250, 0.4); }
    50% { box-shadow: 0 0 12px 4px rgba(92, 124, 250, 0.3); }
}
.handsfree-btn .material-symbols-outlined {
    font-size: 24px;
}
.handsfree-btn {
    position: relative;
}
.handsfree-label {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 8px;
    font-weight: 700;
    letter-spacing: -0.5px;
    opacity: 0.8;
}
#handsfree-ko-btn.active {
    background: linear-gradient(135deg, #20c997, #12b886);
    color: #fff;
    border-color: #20c997;
    animation: handsfree-ko-pulse 2s ease-in-out infinite;
}
@keyframes handsfree-ko-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(32, 201, 151, 0.4); }
    50% { box-shadow: 0 0 12px 4px rgba(32, 201, 151, 0.3); }
}

/* Custom time button states */
.custom-time-btn-state1 {
    background: var(--accent) !important;
    color: white !important;
}

.custom-time-btn-state2 {
    background: var(--danger) !important;
    color: white !important;
}

/* Toolbar Row */
.toolbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
}

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

.tool-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    position: relative;
    font-family: 'Manrope', sans-serif;
}

.tool-btn:active {
    background: rgba(255, 255, 255, 0.1);
}

.tool-btn.active {
    color: var(--primary);
}

.tool-btn .material-symbols-outlined {
    font-size: 22px;
    font-variation-settings: 'opsz' 20;
}

.tool-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.loop-count-badge {
    position: absolute;
    top: -2px;
    right: -4px;
    font-size: 8px;
    font-weight: 800;
    color: var(--text);
    pointer-events: none;
}

.bookmark-count-badge {
    font-size: 10px;
    font-weight: 700;
    color: var(--primary);
}

/* --- Shortcuts Popup --- */
.shortcuts-popup {
    position: fixed;
    bottom: calc(var(--bottom-bar-h) + 8px);
    right: 20px;
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 14px 18px;
    z-index: 200;
    animation: fadeIn 0.15s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.shortcuts-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 16px;
    align-items: center;
}

.shortcut-key {
    font-size: 11px;
    font-weight: 700;
    color: var(--text);
    background: rgba(255, 255, 255, 0.1);
    padding: 3px 8px;
    border-radius: 4px;
    text-align: center;
    white-space: nowrap;
}

.shortcut-desc {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

/* --- Modals --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s ease;
}

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

.modal-sheet {
    width: 100%;
    max-width: 640px;
    max-height: 85vh;
    overflow-y: auto;
    background: rgba(20, 20, 20, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid var(--border-light);
    border-radius: 24px 24px 0 0;
    padding: 20px 24px 32px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-handle {
    width: 48px;
    height: 5px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
    margin: 0 auto 20px;
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

/* URL Input Modal */
.modal-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.url-input-group {
    position: relative;
}

.url-input-group input {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 44px 16px 16px;
    color: var(--text);
    font-family: 'Manrope', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.url-input-group input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.url-input-group input:focus {
    border-color: var(--accent);
}

.url-clear-btn {
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.15s;
}

.url-clear-btn .material-symbols-outlined {
    font-size: 14px;
}

.url-clear-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.input-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.3);
    font-size: 20px;
}

.load-btn {
    width: 100%;
    padding: 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-family: 'Manrope', sans-serif;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}

.load-btn:hover {
    background: var(--accent-dark);
}

.load-btn:active {
    filter: brightness(0.9);
}

/* History Section in Modal */
.history-section {
    margin-top: 20px;
}

.history-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding-left: 2px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 50vh;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.15);
}

.history-thumb {
    width: 80px;
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.history-item .history-title {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
    padding: 0;
    text-transform: none;
    letter-spacing: normal;
    flex: 1;
    min-width: 0;
}

.history-item .history-delete {
    color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    transition: all 0.15s;
}

.history-item .history-delete:hover {
    color: var(--danger);
    background: rgba(244, 67, 54, 0.15);
}

.history-toggle {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    border: 1px solid rgba(92, 124, 250, 0.4);
    border-radius: var(--radius-full);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    background: none;
}

.history-toggle:hover {
    background: rgba(92, 124, 250, 0.1);
}

/* Custom History Icon */
.history-icon {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(242, 147, 13, 0.15);
    border-radius: 6px;
    flex-shrink: 0;
}
.history-icon .material-symbols-outlined {
    font-size: 22px;
    color: var(--primary);
}
.history-icon-reels {
    flex-direction: column;
    gap: 1px;
}
.history-icon-reels .material-symbols-outlined {
    font-size: 18px;
}
.history-icon-label {
    font-size: 9px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 0.3px;
}

/* 릴스 TTS 변환 완료된 항목 (차별화된 색상) */
.history-icon-reels-tts {
    background: rgba(34, 197, 94, 0.18);
}
.history-icon-reels-tts .material-symbols-outlined,
.history-icon-reels-tts .history-icon-label {
    color: #22c55e;
}

/* 이름 변경 버튼 */
.history-rename {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-dim);
    margin-right: 4px;
    flex-shrink: 0;
}
.history-rename:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text);
}
.history-rename .material-symbols-outlined {
    font-size: 16px;
}

/* TTS 변환 시간 표시 */
.history-tts-time {
    font-size: 11px;
    color: rgba(34, 197, 94, 0.85);
    margin-left: 4px;
}

/* YouTube 히스토리용 meta wrap (title + tts time) */
.history-meta-wrap {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    gap: 2px;
}
.history-meta-wrap .history-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.history-meta-wrap .history-tts-time {
    margin-left: 0;
}
.history-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.history-meta .history-title {
    margin: 0;
    padding: 0;
}
.history-meta-sub {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0;
    text-transform: none;
}
.history-tts-badge {
    font-size: 9px;
    font-weight: 700;
    color: var(--primary);
    background: rgba(242, 147, 13, 0.15);
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 6px;
}
.history-netflix-badge {
    color: #e50914;
    background: rgba(229, 9, 20, 0.12);
}

/* 오프라인 뱃지 & 저장 버튼 */
.history-offline-badge {
    font-size: 9px;
    font-weight: 700;
    color: #4caf50;
    background: rgba(76, 175, 80, 0.15);
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 6px;
    cursor: pointer;
}
.history-offline-btn {
    font-size: 14px;
    color: #888;
    margin-left: 6px;
    cursor: pointer;
    padding: 2px 4px;
    transition: color 0.2s;
}
.history-offline-btn:hover {
    color: var(--primary);
}

/* 스트리밍 로딩 프로그레스 바 */
.streaming-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 28px;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    overflow: hidden;
}
.streaming-bar.visible {
    opacity: 1;
    pointer-events: auto;
}
.streaming-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, rgba(242, 147, 13, 0.25), rgba(242, 147, 13, 0.15));
    transition: width 0.5s ease;
    width: 0%;
}
/* 문장 번호 */
.sentence-num {
    font-size: 15px;
    color: #555;
    margin-right: 6px;
    font-weight: 700;
    min-width: 22px;
    display: inline-block;
    vertical-align: middle;
}

/* 변환 완료하기 버튼 */
.caption-complete-btn {
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: var(--primary);
    border: none;
    border-radius: 4px;
    padding: 2px 8px;
    margin-left: 8px;
    cursor: pointer;
    vertical-align: middle;
}
.caption-complete-btn:active {
    opacity: 0.7;
}

.streaming-bar-text {
    position: relative;
    z-index: 1;
    font-size: 11px;
    color: var(--primary);
    font-weight: 600;
    white-space: nowrap;
}

/* 스트리밍 토스트 */
.streaming-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
}
/* 오프라인 뷰 */
.offline-view {
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg);
}
.offline-view-header {
    text-align: center;
    padding: 20px 0 12px;
}
.offline-view-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}
.offline-view-desc {
    font-size: 13px;
    color: #888;
    margin: 4px 0 0;
}
.offline-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.offline-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--card);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}
.offline-item:active {
    background: rgba(255,255,255,0.08);
}
.offline-item-thumb {
    width: 80px;
    height: 45px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}
.offline-item-icon {
    width: 45px;
    height: 45px;
    border-radius: 8px;
    background: rgba(242, 147, 13, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--primary);
}
.offline-item-info {
    flex: 1;
    min-width: 0;
}
.offline-item-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.offline-item-sub {
    font-size: 11px;
    color: #888;
    margin-top: 3px;
}
.offline-item-delete {
    font-size: 18px;
    color: #666;
    cursor: pointer;
    padding: 4px 8px;
    flex-shrink: 0;
}
.offline-item-delete:hover {
    color: #e53935;
}

.streaming-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* TTS 로딩 모달 */
#tts-loading-overlay {
    z-index: 10000;
}
.tts-loading-spinner {
    width: 40px; height: 40px; margin: 0 auto;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: tts-spin 0.8s linear infinite;
}
@keyframes tts-spin { to { transform: rotate(360deg); } }
.tts-loading-progress-wrap {
    width: 100%; height: 10px; background: rgba(255,255,255,0.1);
    border-radius: 5px; margin-top: 16px; overflow: hidden;
}
.tts-loading-progress-bar {
    height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), #f5b731);
    border-radius: 5px; transition: width 0.4s ease;
}

/* Speed Modal */
.speed-sheet {
    max-width: 480px;
    padding-bottom: 40px;
}

.speed-modal-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    text-align: center;
    margin-bottom: 20px;
}

.speed-btns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.speed-btn {
    padding: 14px 8px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-family: 'Manrope', sans-serif;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}

.speed-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.speed-btn:active {
    transform: scale(0.97);
}

.speed-btn.active {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
    font-weight: 800;
}

/* Repeat Count Modal */
.repeat-modal-desc {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
    margin-bottom: 16px;
}

.repeat-btns {
    grid-template-columns: repeat(4, 1fr);
}

/* Bookmarks Modal */
.bookmarks-sheet {
    max-width: 560px;
    max-height: 60vh;
    display: flex;
    flex-direction: column;
}

.bookmarks-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bookmarks-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 30px;
    font-size: 14px;
}

.bookmark-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.bookmark-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-light);
}

.bookmark-item .bookmark-time {
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    min-width: 110px;
    font-variant-numeric: tabular-nums;
}

.bookmark-item .bookmark-text {
    flex: 1;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bookmark-item .bookmark-delete {
    color: rgba(255, 255, 255, 0.25);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 4px;
    flex-shrink: 0;
    border-radius: 50%;
    transition: all 0.15s;
}

.bookmark-item .bookmark-delete:hover {
    color: var(--danger);
    background: rgba(244, 67, 54, 0.15);
}

/* --- Modal Tabs --- */
.modal-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.modal-tab {
    flex: 1;
    padding: 12px 6px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-family: 'Manrope', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}

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

.modal-tab:hover:not(.active) {
    color: rgba(255, 255, 255, 0.7);
}

/* Reels & TikTok hint */
.reels-hint {
    color: var(--text-muted);
    font-size: 12px;
    margin: -4px 0 12px;
    padding: 0 4px;
    line-height: 1.4;
}


/* Custom Script Textarea */
#custom-text-input {
    width: 100%;
    min-height: 160px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    color: var(--text);
    font-family: 'Manrope', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    outline: none;
}

#custom-text-input:focus {
    border-color: var(--accent);
}

#custom-text-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

/* Custom Mode Visual */
.custom-mode-visual {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-shrink: 0;
}

.custom-mode-icon {
    font-size: 56px !important;
    color: var(--text-dim);
}

.custom-mode-label {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.custom-mode-status {
    font-size: 12px;
    color: var(--text-dim);
}

/* TTS Progress Bar */
.tts-progress-bar {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.tts-progress-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

#tts-progress-text {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
}

.tts-cancel-btn {
    padding: 4px 12px;
    border: 1px solid var(--danger);
    border-radius: var(--radius-full);
    background: none;
    color: var(--danger);
    font-family: 'Manrope', sans-serif;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}

.tts-cancel-btn:hover {
    background: rgba(244, 67, 54, 0.15);
}

.tts-progress-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.tts-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.tts-log-area {
    margin-top: 6px;
    max-height: 80px;
    overflow-y: auto;
    font-size: 10px;
    font-family: 'SF Mono', 'Menlo', monospace;
    line-height: 1.5;
    color: var(--text-muted);
    scrollbar-width: thin;
}
.tts-log-area::-webkit-scrollbar { height: 0; width: 3px; }
.tts-log-area::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
.tts-log-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tts-log-line.error { color: #ff6b6b; }
.tts-log-line.success { color: #51cf66; }
.tts-log-line.warn { color: #ffd43b; }
.tts-log-line .log-time { color: rgba(255,255,255,0.3); margin-right: 6px; }
.tts-log-line .log-elapsed { color: var(--accent); margin-left: 4px; }

/* TTS Confirm Dialog */
.tts-confirm-sheet {
    max-width: 400px;
    text-align: center;
}

.tts-confirm-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
}

.tts-confirm-msg {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 20px;
    white-space: pre-line;
}

/* TTS Cost Info */
.tts-cost-info {
    margin-bottom: 20px;
}

.cost-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 16px;
    text-align: left;
}

.cost-header {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cost-row {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.cost-row:last-of-type {
    border-bottom: none;
}

.cost-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}

.cost-desc {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 4px;
}

.cost-detail {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.cost-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
}

.cost-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.cost-total span:last-child {
    color: var(--accent);
    font-size: 16px;
}

.cost-note {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 10px;
    opacity: 0.7;
}

/* Cleanup Review Modal */
.cleanup-review-sheet {
    max-width: 500px;
}

.cleanup-review-summary {
    font-size: 14px;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 16px;
    text-align: center;
}

.cleanup-review-list {
    max-height: 50vh;
    overflow-y: auto;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 8px;
}

.cleanup-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
}

.cleanup-item:nth-child(odd) {
    background: rgba(255, 255, 255, 0.03);
}

.cleanup-num {
    min-width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    flex-shrink: 0;
}

.cleanup-text {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
    padding-top: 3px;
}

/* Cost History Modal */
.cost-history-sheet {
    max-width: 500px;
}

.cost-history-summary {
    text-align: center;
    padding: 16px 0;
}

.cost-summary-total {
    font-size: 22px;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 4px;
}

.cost-summary-breakdown {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.cost-summary-count {
    font-size: 12px;
    color: var(--text-muted);
}

.cost-history-filters {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
}

.cost-filter-btn {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-family: 'Manrope', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.cost-filter-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.cost-history-list {
    max-height: 50vh;
    overflow-y: auto;
}

.cost-date-group {
    margin-bottom: 14px;
}

.cost-date-header {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.cost-record-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 12px;
}

.cost-record-title {
    flex: 1;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cost-record-info {
    color: var(--text-muted);
    font-size: 11px;
}

.cost-record-value {
    color: var(--accent);
    font-weight: 600;
    white-space: nowrap;
}

.cost-empty {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 14px;
}

.cost-krw {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.85em;
}

.tts-confirm-actions {
    display: flex;
    gap: 10px;
}

.tts-confirm-cancel,
.tts-confirm-ok {
    flex: 1;
    padding: 14px;
    border-radius: var(--radius);
    font-family: 'Manrope', sans-serif;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}

.tts-confirm-cancel {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-light);
    color: var(--text);
}

.tts-confirm-ok {
    background: var(--accent);
    border: none;
    color: white;
}

.tts-confirm-cancel:hover {
    background: rgba(255, 255, 255, 0.15);
}

.tts-confirm-ok:hover {
    background: var(--accent-dark);
}

.delete-confirm-danger {
    background: var(--danger) !important;
}
.delete-confirm-danger:hover {
    background: #d32f2f !important;
}

/* TTS Restore Loading Modal */
.tts-loading-sheet {
    max-width: 320px;
    text-align: center;
    padding: 36px 30px 28px;
}

.tts-loading-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
}

.tts-loading-progress {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.tts-loading-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.tts-loading-pct {
    font-size: 22px;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 6px;
}

.tts-loading-sub {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Summary Modal */
.summary-sheet {
    max-width: 440px;
    max-height: 80vh;
    overflow-y: auto;
}

.summary-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.4;
}

.summary-difficulty {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    background: var(--accent);
    color: white;
    margin-bottom: 14px;
}

.summary-text {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 18px;
}

.summary-section {
    margin-bottom: 16px;
}

.summary-section h4 {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-points {
    list-style: none;
    padding: 0;
    margin: 0;
}

.summary-points li {
    font-size: 13px;
    color: var(--text);
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
    line-height: 1.5;
}

.summary-points li::before {
    content: '•';
    color: var(--accent);
    font-weight: 800;
    margin-right: 8px;
}

.summary-expressions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.summary-expr-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
}

.summary-expr-en {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.summary-expr-ko {
    font-size: 12px;
    color: var(--text-muted);
}

@keyframes summary-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* --- Responsive: Portrait / Smaller tablets --- */
@media (max-width: 900px) {
    .main-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .panel-left {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .player-wrapper {
        max-height: 35vh;
    }

    .player-info-bar {
        padding: 8px 16px;
    }
}

@media (max-width: 600px) {
    :root {
        --bottom-bar-h: 220px;
    }

    .top-bar-title {
        font-size: 16px;
    }

    .action-btn {
        height: 50px;
    }

    .script-item .text {
        font-size: 14px;
    }

    .script-item.selected .text {
        font-size: 16px;
    }

    .toolbar-row {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-wrap: nowrap;
        justify-content: flex-start;
        padding: 0 8px;
    }

    .toolbar-row::-webkit-scrollbar {
        display: none;
    }

    .toolbar-left,
    .toolbar-right {
        flex-shrink: 0;
        gap: 4px;
    }

    .tool-btn {
        padding: 6px;
        flex-shrink: 0;
    }

    /* 문장공부 모바일 */
    .ss-container { padding: 8px 12px; }
    .ss-card { padding: 12px 8px; }
    .ss-sentence { font-size: 20px; line-height: 1.5; }
    .ss-chips-wrap { margin-top: 12px; padding-top: 10px; }
    .ss-actions { padding: 4px 0; flex-shrink: 0; }
    .ss-counter { flex-shrink: 0; }
}

/* 문장공부 모드: 하단 컨트롤 축소 */
body.ss-mode .bottom-controls {
    --bottom-bar-h: 170px;
    height: 170px;
    padding: 8px 16px;
    gap: 6px;
}
body.ss-mode .main-layout {
    bottom: 170px;
}
body.ss-mode .action-btn {
    height: 44px;
    font-size: 26px;
}
body.ss-mode .action-btn .material-symbols-outlined {
    font-size: 26px;
}
body.ss-mode .action-row {
    gap: 8px;
}
body.ss-mode .toolbar-row {
    gap: 2px;
}

/* Large landscape tablets (1024px+) */
@media (min-width: 1024px) {
    .main-layout {
        grid-template-columns: 55% 45%;
    }

    .bottom-controls {
        padding: 12px 32px;
        align-items: center;
    }

    .timing-row {
        max-width: 480px;
        width: 100%;
    }

    .action-row {
        max-width: 560px;
        width: 100%;
    }

    .toolbar-row {
        justify-content: center;
        gap: 8px;
    }

    .toolbar-left,
    .toolbar-right {
        gap: 8px;
    }

    .script-item .text {
        font-size: 26px;
        line-height: 1.4;
    }

    .script-item.selected .text {
        font-size: 29px;
    }
}

/* Tutor Button (in script items) */
.tutor-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    background: rgba(92, 124, 250, 0.15);
    color: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    margin-left: 6px;
    vertical-align: middle;
    padding: 0;
    flex-shrink: 0;
    transition: all 0.15s;
    opacity: 0;
}
.tutor-btn .material-symbols-outlined {
    font-size: 14px;
}
.script-item:hover .tutor-btn,
.script-item.selected .tutor-btn,
.script-item.active .tutor-btn {
    opacity: 1;
}
.tutor-btn:hover {
    background: var(--accent);
    color: #fff;
}

/* Tutor Modal */
.tutor-sheet {
    max-width: 520px;
    max-height: 80vh;
}
.tutor-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.tutor-header-icon {
    color: var(--accent);
    font-size: 22px !important;
}
.tutor-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}
.tutor-sentence {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
    padding: 10px 14px;
    background: rgba(242, 147, 13, 0.1);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    line-height: 1.5;
}
.tutor-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 30px;
    color: var(--text-muted);
    font-size: 14px;
}
.tutor-content {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.tutor-section {
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.tutor-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
    margin-bottom: 6px;
}
.tutor-meaning {
    font-size: 14px;
    color: var(--text);
    line-height: 1.5;
}
.tutor-pattern {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    font-family: 'Courier New', monospace;
    margin-bottom: 6px;
    padding: 4px 8px;
    background: rgba(242, 147, 13, 0.1);
    border-radius: 4px;
    display: inline-block;
}
.tutor-grammar {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.6;
}
.tutor-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.tutor-keyword {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    font-size: 12px;
}
.tutor-keyword-en {
    font-weight: 700;
    color: var(--text);
}
.tutor-keyword-ko {
    color: var(--text-muted);
}
.tutor-examples {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.tutor-example {
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.04);
    border-left: 3px solid var(--accent);
    border-radius: 0 4px 4px 0;
}
.tutor-example-en {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}
.tutor-example-ko {
    font-size: 12px;
    color: var(--text-muted);
}

/* Settings Modal */
.settings-sheet {
    max-width: 420px;
    text-align: left;
}
.settings-section {
    margin-top: 8px;
}
.settings-section-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}
.settings-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
    word-break: break-all;
}
.settings-reset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 14px;
    border-radius: var(--radius);
    background: #e53935;
    border: none;
    color: white;
    font-family: 'Manrope', sans-serif;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}
.settings-reset-btn:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-dim);
    cursor: not-allowed;
}
.settings-reset-btn:not(:disabled):hover {
    background: #c62828;
}
.settings-reset-btn .material-symbols-outlined {
    font-size: 20px;
}
.settings-hint {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 10px;
    line-height: 1.6;
}

.settings-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    cursor: pointer;
}
.settings-toggle-label {
    font-size: 13px;
    color: var(--text);
}
.settings-toggle-input { display: none; }
.settings-toggle-switch {
    width: 44px;
    height: 24px;
    background: rgba(255,255,255,0.15);
    border-radius: 12px;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}
.settings-toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 20px; height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}
.settings-toggle-input:checked + .settings-toggle-switch {
    background: var(--accent);
}
.settings-toggle-input:checked + .settings-toggle-switch::after {
    transform: translateX(20px);
}

/* ===== 문장공부 모드 ===== */
.ss-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 16px;
    min-height: 0;
    overflow: hidden;
}

.ss-repeat-badge {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 4px;
    min-height: 16px;
}

.ss-counter {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 8px;
    padding: 6px 16px;
    border: 1px solid rgba(242, 147, 13, 0.3);
    border-radius: 20px;
    align-self: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.ss-counter:active {
    background: rgba(242, 147, 13, 0.1);
}

.ss-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    text-align: center;
    padding: 24px 16px;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.ss-sentence {
    font-size: 26px;
    font-weight: 800;
    line-height: 1.6;
    color: #fff;
    word-break: keep-all;
}

.ss-chips-wrap {
    width: 100%;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.ss-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
}
.ss-chips .word-chip {
    font-size: 13px;
    padding: 5px 9px;
    min-height: 30px;
    border-radius: 14px;
}
.ss-fine-tune {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    padding-top: 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: 0.5px;
}

.ss-translate-modal .modal-sheet {
    padding: 24px 24px 36px;
    text-align: center;
}
.ss-translate-modal .ss-trans-en {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    line-height: 1.6;
    margin-bottom: 16px;
}
.ss-translate-modal .ss-trans-ko {
    font-size: 16px;
    color: var(--text-muted);
    line-height: 1.6;
}

.ss-actions {
    display: flex;
    gap: 6px;
    padding: 4px 0;
}

.ss-btn {
    flex: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.ss-btn .material-symbols-outlined { font-size: 18px; }
.ss-btn:active { transform: scale(0.95); }
.ss-btn-nav {
    flex: 0 0 36px;
    padding: 8px 0;
    font-size: 0;
}
.ss-btn-nav .material-symbols-outlined { font-size: 18px; }
.ss-btn-translate.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(242, 147, 13, 0.08);
}
.ss-btn-done {
}
.ss-btn-done:active {
}
.ss-btn-tutor .material-symbols-outlined {
    color: #8b5cf6;
}

/* 손글씨 쓰기 영역 */
.ss-writing-area {
    position: relative;
    margin: 12px 16px 16px;
    height: 150px;
    background: #000;
    border: 1px solid #1f2937;
    border-radius: 10px;
    overflow: hidden;
    touch-action: none;
    display: none;
}
body.ss-speaking .ss-writing-area {
    display: block;
}
.ss-writing-area canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: crosshair;
}
.ss-writing-tool {
    position: absolute;
    top: 8px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.ss-writing-tool:hover { background: rgba(255,255,255,0.22); }
.ss-writing-tool:active { background: rgba(255,255,255,0.32); }
.ss-writing-tool.active { background: rgba(96,165,250,0.45); color: #fff; }
.ss-writing-tool .material-symbols-outlined { font-size: 20px; }
.ss-writing-eraser { right: 50px; }
.ss-writing-clear { right: 8px; }

/* 말하기공부: 한글 문장 글자 크기 줄이기 */
body.ss-speaking .ss-sentence { font-size: 20.8px; }

/* 말하기공부: 높이 확보를 위해 여백/구분선 줄이기 */
body.ss-speaking .ss-chips-wrap {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}
body.ss-speaking .ss-card {
    padding: 8px 16px 4px;
}
body.ss-speaking .ss-counter {
    margin-bottom: 4px;
}
body.ss-speaking .ss-repeat-badge {
    display: none;
}

/* 튜터 모달 */
.ss-tutor-modal .tutor-sheet {
    max-height: 85vh;
    overflow-y: auto;
}
.tutor-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.tutor-header .material-symbols-outlined {
    color: #8b5cf6;
    font-size: 24px;
}
.tutor-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}
.tutor-sentence {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
    padding: 12px 14px;
    background: rgba(242, 147, 13, 0.08);
    border-radius: 8px;
    margin-bottom: 16px;
    line-height: 1.5;
}
.tutor-section {
    margin-bottom: 18px;
}
.tutor-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}
.tutor-section-body {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
}
.tutor-pattern {
    font-family: 'Menlo', 'Courier New', monospace;
    background: rgba(255,255,255,0.05);
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--text);
}
.tutor-keyword {
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.tutor-keyword:last-child { border-bottom: none; }
.tutor-keyword strong {
    color: var(--primary);
    margin-right: 6px;
}
.tutor-keyword-note {
    color: var(--text-dim);
    font-size: 12px;
}
.tutor-example {
    padding: 8px 0;
}
.tutor-example-en {
    color: var(--text);
    margin-bottom: 2px;
}
.tutor-example-ko {
    color: var(--text-muted);
    font-size: 13px;
}
.tutor-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.tutor-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: #8b5cf6;
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.tutor-error {
    color: #ef4444;
    text-align: center;
    padding: 20px;
}

/* 문장공부 복사 토스트 */
.ss-copy-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 13px;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}
.ss-copy-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 릴스 설명 모달 */
.reels-desc-modal .tutor-sheet {
    max-height: 85vh;
    overflow-y: auto;
}
.reels-desc-uploader {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(139, 92, 246, 0.15);
    color: #c4b5fd;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px;
}
.reels-desc-text {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
}
.ss-counter {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* 문장 리스트 모달 */
.ss-list-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.ss-list-tab {
    flex: 1;
    padding: 10px 0;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
}
.ss-list-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.ss-list-items {
    max-height: 50vh;
    overflow-y: auto;
}
.ss-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 14px;
    color: var(--text);
    line-height: 1.4;
}
.ss-list-item .ss-list-text {
    flex: 1;
    word-break: break-word;
}
.ss-list-item .ss-list-num {
    flex-shrink: 0;
    font-size: 11px;
    color: var(--text-muted);
    min-width: 24px;
}
.ss-list-restore-btn {
    flex-shrink: 0;
    padding: 4px 10px;
    border: 1px solid var(--primary);
    border-radius: 8px;
    background: none;
    color: var(--primary);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}
.ss-list-restore-btn:active {
    background: rgba(242, 147, 13, 0.15);
}

/* ===== Study Stats Full-screen Modal ===== */
.stats-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.stats-fullscreen-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.stats-fullscreen-header h3 {
    font-size: 18px;
    font-weight: 800;
    margin: 0;
}

.stats-fullscreen-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

/* 월별 캘린더 */
.stats-calendar-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 15px;
    font-weight: 700;
}

.stats-calendar-nav .icon-btn {
    width: 32px;
    height: 32px;
}

.stats-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-top: 8px;
}

.stats-cal-header {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-align: center;
    padding: 6px 0;
}

.stats-cal-header.sun { color: #e74c3c; }
.stats-cal-header.sat { color: #3498db; }

.stats-cal-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    padding: 6px 2px;
    min-height: 44px;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.35);
    cursor: pointer;
    transition: background 0.15s;
    gap: 2px;
}

.stats-cal-day.empty {
    cursor: default;
    min-height: 0;
    padding: 0;
}

.stats-cal-day.today .stats-cal-num {
    background: var(--primary);
    color: #000;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.stats-cal-day.has-study {
    color: #fff;
}

.stats-cal-num {
    font-size: 13px;
    line-height: 1;
}

.stats-cal-time {
    font-size: 9px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    white-space: nowrap;
}

/* 학습량에 따른 배경 강도 */
.stats-cal-day.study-lv1 { background: rgba(242, 147, 13, 0.06); }
.stats-cal-day.study-lv2 { background: rgba(242, 147, 13, 0.12); }
.stats-cal-day.study-lv3 { background: rgba(242, 147, 13, 0.20); }
.stats-cal-day.study-lv4 { background: rgba(242, 147, 13, 0.30); }

.stats-cal-summary {
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.04);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.5;
}

.stats-cal-summary strong {
    color: var(--primary);
    font-weight: 700;
}

.stats-summary-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.stats-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 12px;
    text-align: center;
}

.stats-card-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 4px;
}

.stats-card-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}

.stats-section {
    margin-bottom: 16px;
}

.stats-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.stats-empty {
    font-size: 12px;
    color: var(--text-faint);
    text-align: center;
    padding: 12px 0;
}

.stats-top-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.stats-clickable {
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}
.stats-clickable:active {
    background: rgba(242, 147, 13, 0.1);
}

.stats-top-rank {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(242, 147, 13, 0.15);
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stats-top-rank.gold { background: rgba(255, 215, 0, 0.2); color: #ffd700; }
.stats-top-rank.silver { background: rgba(192, 192, 192, 0.15); color: #c0c0c0; }
.stats-top-rank.bronze { background: rgba(205, 127, 50, 0.15); color: #cd7f32; }

.stats-top-info {
    flex: 1;
    min-width: 0;
}

.stats-top-text {
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stats-top-translation {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stats-mode-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    vertical-align: middle;
}
.mode-yt { background: rgba(255,0,0,0.15); color: #ff4444; }
.mode-tts { background: rgba(0,150,255,0.15); color: #4da6ff; }
.mode-custom { background: rgba(0,200,100,0.15); color: #4dca7a; }
.mode-ai { background: rgba(180,80,255,0.15); color: #b366ff; }
.mode-xlsx { background: rgba(255,165,0,0.15); color: #ffa500; }

.stats-top-meta {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}

.stats-top-count {
    font-size: 14px;
    font-weight: 800;
    color: var(--primary);
    flex-shrink: 0;
}

.stats-script-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.stats-script-info {
    flex: 1;
    min-width: 0;
}

.stats-script-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stats-script-detail {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}

.stats-script-bar {
    width: 80px;
    height: 6px;
    border-radius: 3px;
    background: rgba(255,255,255,0.08);
    overflow: hidden;
    flex-shrink: 0;
}

.stats-script-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--primary);
    transition: width 0.3s;
}

.stats-daily-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 100px;
    padding: 8px 0;
}

.stats-more-btn {
    width: 100%;
    padding: 12px;
    margin-top: 8px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.stats-day-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stats-day-bar {
    width: 100%;
    min-height: 2px;
    border-radius: 3px 3px 0 0;
    background: var(--primary);
    opacity: 0.8;
    transition: height 0.3s;
}

.stats-day-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}

.stats-day-value {
    font-size: 11px;
    color: #fff;
    font-weight: 600;
}

/* ===== 햄버거 메뉴 드로어 ===== */
.menu-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 400;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}
.menu-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.menu-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background: var(--bg-card);
    z-index: 401;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
}
.menu-drawer.open {
    transform: translateX(0);
}

.menu-drawer-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid var(--border-color);
}
.menu-drawer-logo {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.menu-nav {
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.menu-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-family: inherit;
}
.menu-nav-item:hover {
    background: var(--bg-hover);
}
.menu-nav-item.active {
    background: rgba(242, 147, 13, 0.12);
    color: var(--primary);
    font-weight: 600;
}
.menu-nav-item .material-symbols-outlined {
    font-size: 22px;
}

/* ===== 채팅 뷰 ===== */
.chat-view {
    position: fixed;
    top: var(--top-bar-h, 52px);
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
    z-index: 10;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
}

.chat-welcome {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.chat-welcome-icon {
    font-size: 48px;
    color: var(--primary);
    margin-bottom: 12px;
}
.chat-welcome h3 {
    font-size: 20px;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.chat-welcome p {
    font-size: 14px;
    line-height: 1.6;
}

/* Session bar */
.chat-session-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
    flex-shrink: 0;
}
.chat-session-name {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-session-history-btn,
.chat-session-new-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.chat-session-history-btn:hover,
.chat-session-new-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text);
}
.chat-session-history-btn .material-symbols-outlined,
.chat-session-new-btn .material-symbols-outlined {
    font-size: 20px;
}

/* Session list panel */
.chat-session-list {
    max-height: 50vh;
    overflow-y: auto;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
    flex-shrink: 0;
}
.chat-session-list-inner {
    padding: 4px 0;
}
.chat-session-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.12s;
    border-left: 3px solid transparent;
}
.chat-session-item:hover {
    background: rgba(255,255,255,0.05);
}
.chat-session-item.active {
    background: rgba(242,147,13,0.1);
    border-left-color: var(--primary);
}
.chat-session-item-name {
    flex: 1;
    font-size: 13px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-session-item-date {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.chat-session-item-delete {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
}
.chat-session-item:hover .chat-session-item-delete {
    opacity: 1;
}
.chat-session-item-delete:hover {
    color: var(--danger);
    background: rgba(244,67,54,0.1);
}
.chat-session-item-delete .material-symbols-outlined {
    font-size: 16px;
}
.chat-session-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* 유저 말풍선 */
.chat-bubble-user {
    align-self: flex-end;
    max-width: 80%;
}
.chat-bubble-content {
    background: var(--primary);
    color: #000;
    padding: 10px 14px;
    border-radius: 16px 16px 4px 16px;
    font-size: 15px;
    line-height: 1.5;
    font-weight: 500;
}
.chat-lang-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    background: rgba(0,0,0,0.15);
    padding: 1px 6px;
    border-radius: 4px;
    margin-right: 6px;
    vertical-align: middle;
}

/* 튜터 카드 */
.chat-bubble-tutor {
    align-self: flex-start;
    max-width: 90%;
    display: flex;
    gap: 8px;
}
.chat-tutor-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.chat-tutor-avatar .material-symbols-outlined {
    font-size: 18px;
    color: #000;
}
.chat-tutor-body {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px 16px 16px 16px;
    padding: 14px;
    flex: 1;
    min-width: 0;
}

/* 번역 영역 */
.chat-card-translation {
    margin-bottom: 12px;
}
.chat-card-en {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 4px;
}
.chat-card-ko {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* TTS 재생 버튼 */
.chat-card-tts-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.chat-tts-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-family: inherit;
}
.chat-tts-btn:hover {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
}
.chat-tts-btn .material-symbols-outlined {
    font-size: 16px;
}
.chat-tts-btn.playing {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
}

/* 반복 횟수 버튼 */
.chat-repeat-btn {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: var(--bg-hover);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    margin-left: auto;
    transition: background 0.15s;
}
.chat-repeat-btn:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}
.chat-repeat-btn .material-symbols-outlined {
    font-size: 14px;
}

/* 문장 분석 (breakdown) */
.chat-card-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: baseline;
}
.chat-chunk {
    display: inline-block;
    background: rgba(242, 147, 13, 0.08);
    border: 1px solid rgba(242, 147, 13, 0.2);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.4;
}
.chat-chunk strong {
    color: var(--text-primary);
}
.chat-chunk small {
    color: var(--text-muted);
    margin-left: 3px;
    font-size: 11px;
}

/* 한→영 변환 과정 */
.chat-card-transformation {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}
.chat-trans-step {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 8px;
    color: var(--text-primary);
    font-weight: 500;
}
.chat-trans-arrow {
    color: var(--primary);
    font-weight: 700;
    font-size: 14px;
}

/* 상세 정보 */
.chat-card-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.chat-card-section {
    padding: 8px 0;
    border-top: 1px solid var(--border-color);
}
.chat-card-section:first-child {
    border-top: none;
}
.chat-card-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.chat-card-pattern {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Manrope', monospace;
}
.chat-card-grammar {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}
.chat-card-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.chat-keyword {
    display: inline-block;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}
.chat-keyword small {
    color: var(--text-muted);
    margin-left: 4px;
    font-weight: 400;
}

/* 예문 */
.chat-example {
    margin-top: 6px;
}
.chat-example-en {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}
.chat-example-ko {
    font-size: 12px;
    color: var(--text-muted);
}

/* 로딩 애니메이션 */
.chat-loading-dots {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}
.chat-loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: chat-dot-pulse 1.4s infinite ease-in-out;
}
.chat-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chat-dot-pulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* 에러 */
.chat-error .chat-tutor-avatar {
    background: #e74c3c;
}
.chat-error-msg {
    color: #e74c3c;
    font-size: 13px;
}

/* Type selector chips */
.chat-type-popup {
    display: flex;
    gap: 6px;
    padding: 5px 16px;
}
.chat-type-popup.hidden { display: none; }
.chat-type-option {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 10px;
    border: 1px solid var(--border-light);
    border-radius: 14px;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.1s;
}
.chat-type-option:hover, .chat-type-option:active {
    background: rgba(242,147,13,0.12);
    border-color: var(--primary);
    color: var(--primary);
}
.chat-type-option .material-symbols-outlined {
    font-size: 13px;
}

/* 입력창 */
.chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
}
.chat-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--border-light);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 15px;
    font-family: inherit;
    background: var(--bg-elevated);
    color: var(--text);
    outline: none;
    min-height: 42px;
    max-height: 120px;
    line-height: 1.4;
}
.chat-input:focus {
    border-color: var(--primary);
    background: #1a1a1a;
}
.chat-input::placeholder {
    color: var(--text-muted);
}
.chat-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity 0.15s;
}
.chat-send-btn:hover {
    opacity: 0.85;
}
.chat-send-btn .material-symbols-outlined {
    font-size: 20px;
}
.chat-mic-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s;
}
.chat-mic-btn:hover { color: var(--text-primary); }
.chat-mic-btn.recording {
    background: #e74c3c;
    border-color: #e74c3c;
    color: #fff;
    animation: mic-pulse 1s infinite;
}
@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(231,76,60,0.4); }
    50% { box-shadow: 0 0 0 8px rgba(231,76,60,0); }
}
.chat-mic-btn .material-symbols-outlined { font-size: 20px; }

/* Conversation bubble (자연어 대화) */
.chat-conv-body {
    background: var(--bg-elevated) !important;
    border: 1px solid var(--border) !important;
}
.chat-conv-message {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text);
    white-space: pre-wrap;
}
.chat-conv-english {
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(92, 124, 250, 0.1);
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 8px;
}
.chat-conv-tts {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px;
    padding: 0 !important;
    border-radius: 50% !important;
    border: 1px solid var(--accent) !important;
    background: transparent !important;
    color: var(--accent) !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.chat-conv-tts .material-symbols-outlined { font-size: 16px; }
.chat-conv-repeat {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    border-radius: 14px;
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    vertical-align: middle;
}
.chat-conv-repeat:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Review delete button */
.review-delete-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    margin-left: 4px;
    vertical-align: middle;
    opacity: 0;
    transition: opacity 0.12s;
}
.script-item:hover .review-delete-btn { opacity: 1; }
.review-delete-btn:hover {
    color: var(--danger);
    background: rgba(244,67,54,0.1);
}
.review-delete-btn .material-symbols-outlined { font-size: 16px; }

/* Review detail panel */
.review-detail-panel {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
    max-height: 35vh;
    overflow-y: auto;
}
.review-detail-panel.hidden { display: none; }
.review-detail-section {
    margin-bottom: 10px;
}
.review-detail-section:last-child { margin-bottom: 0; }
.review-detail-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    margin-bottom: 4px;
}
.review-detail-text {
    font-size: 13px;
    color: var(--text);
    line-height: 1.5;
}
.review-detail-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}
.review-detail-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text);
}
.review-detail-chip small {
    color: var(--text-muted);
    font-size: 11px;
}
.review-detail-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 8px;
}

/* Confirm modal */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.15s;
}
.confirm-overlay.open { opacity: 1; }
.confirm-modal {
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 24px;
    max-width: 320px;
    width: 85%;
}
.confirm-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
}
.confirm-text {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 20px;
}
.confirm-btns {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.confirm-btn {
    padding: 8px 20px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.confirm-cancel {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-light);
}
.confirm-ok {
    background: var(--danger);
    color: #fff;
}

/* Menu divider */
.menu-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 16px;
}

/* Netflix Excel Upload */
.netflix-upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 28px 16px;
    border: 2px dashed var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.netflix-upload-area:hover,
.netflix-upload-area.drag-over {
    border-color: var(--accent);
    background: rgba(242, 147, 13, 0.06);
}
.netflix-upload-text {
    font-size: 13px;
    color: var(--text-muted);
}

/* Extra-wide screens */
@media (min-width: 1400px) {
    .main-layout {
        grid-template-columns: 60% 40%;
    }
}
