/* ═══════════════════════════════════════════════
   AI Speech Level-Up - Design System
   ═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ─── CSS Variables ─── */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #0ea5e9;

    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-sub: #64748b;
    --text-muted: #94a3b8;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.10);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.15);

    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --max-width: 900px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', 'Pretendard', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ─── Screen System ─── */
.screen {
    display: none;
    min-height: 100vh;
    animation: fadeIn 0.35s ease;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─── Layout ─── */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
}

.main {
    padding: 32px 0 80px;
}

/* ─── Header ─── */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    font-size: 2rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    font-size: 0.875rem;
    color: var(--text-sub);
    margin-top: 2px;
}

/* ─── Language Switcher ─── */
.lang-switcher {
    display: flex;
    gap: 6px;
    background: var(--bg);
    padding: 4px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.lang-btn {
    background: none;
    border: none;
    padding: 5px 14px;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-sub);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.lang-btn:hover {
    color: var(--text);
    background: var(--surface);
}

.lang-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

.sub-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-center {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-icon {
    font-size: 1.25rem;
}

.header-title {
    font-size: 1.125rem;
    font-weight: 700;
}

.header-right {
    width: 80px;
}

.back-btn {
    background: none;
    border: none;
    color: var(--text-sub);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.back-btn:hover {
    background: var(--bg);
    color: var(--text);
}

/* ─── Cards ─── */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
}

.card-desc {
    font-size: 0.9rem;
    color: var(--text-sub);
    margin-bottom: 20px;
    line-height: 1.7;
}

/* ─── Buttons ─── */
.primary-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: var(--radius-full);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
    transition: var(--transition);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

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

.primary-btn.full-width {
    width: 100%;
    justify-content: center;
}

.ghost-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    background: transparent;
    color: var(--text-sub);
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-arrow {
    font-size: 1.1rem;
}

/* ─── SCREEN 1: Main ─── */
.hero {
    text-align: center;
    padding: 48px 0 40px;
}

.hero-title {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 800;
    line-height: 1.3;
    margin-bottom: 16px;
}

.highlight {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-desc {
    font-size: 1.1rem;
    color: var(--text-sub);
}

/* Mode Grid */
.mode-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 48px;
}

.mode-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 32px 24px;
    cursor: pointer;
    border: 2px solid transparent;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    text-align: center;
}

.mode-card::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: var(--transition);
}

.mode-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: currentColor;
}

.mode-card:hover::before {
    opacity: 0.06;
}

.mode-emoji {
    font-size: 3rem;
    margin-bottom: 16px;
    display: block;
}

.mode-name {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.mode-desc {
    font-size: 0.85rem;
    color: var(--text-sub);
    line-height: 1.6;
}

.mode-badge {
    display: inline-block;
    margin-top: 12px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

/* How It Works */
.how-it-works {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 32px;
    border: 1px solid var(--border);
    margin-bottom: 40px;
}

.how-title {
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 24px;
    color: var(--text-sub);
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

.step-item {
    text-align: center;
}

.step-num {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
}

.step-text {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-sub);
}

.step-arrow {
    color: var(--text-muted);
    font-size: 1.25rem;
}

/* ─── SCREEN 2: Select ─── */
.section-hero {
    text-align: center;
    padding: 32px 0 28px;
}

.section-heading {
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: 10px;
}

.section-desc {
    color: var(--text-sub);
    font-size: 1rem;
}

.situation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

.situation-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px 20px;
    cursor: pointer;
    border: 2px solid var(--border);
    text-align: center;
    transition: var(--transition);
}

.situation-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.situation-emoji {
    font-size: 2.5rem;
    margin-bottom: 12px;
    display: block;
}

.situation-name {
    font-size: 1rem;
    font-weight: 600;
}

.situation-desc {
    font-size: 0.8rem;
    color: var(--text-sub);
    margin-top: 6px;
    line-height: 1.5;
}

/* ─── SCREEN 3: Tips ─── */
.tips-hero {
    text-align: center;
    padding: 32px 0 28px;
}

.ai-badge {
    display: inline-block;
    padding: 6px 16px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.tips-heading {
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: 10px;
}

.tips-subdesc {
    color: var(--text-sub);
    font-size: 1rem;
}

.tips-cards {
    margin-bottom: 32px;
}

.tip-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    display: flex;
    gap: 16px;
    align-items: flex-start;
    transition: var(--transition);
}

.tip-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.tip-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    font-size: 0.875rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tip-body {
    flex: 1;
}

.tip-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.tip-content {
    font-size: 0.9rem;
    color: var(--text-sub);
    line-height: 1.7;
}

.tips-action {
    text-align: center;
    padding: 8px 0 40px;
}

/* ─── SCREEN 4: Script ─── */
.script-method-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    background: var(--surface);
    padding: 6px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-full);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    color: var(--text-sub);
    transition: var(--transition);
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.template-hint {
    margin-bottom: 12px;
}

.hint-btn {
    padding: 8px 16px;
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: #92400e;
    cursor: pointer;
    transition: var(--transition);
}

.hint-btn:hover {
    background: #fde68a;
}

.script-textarea {
    width: 100%;
    min-height: 220px;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.8;
    resize: vertical;
    transition: var(--transition);
    color: var(--text);
}

.script-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.script-btn-row {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.script-btn-row.centered {
    justify-content: center;
}

.improve-btn {
    flex: 1;
    min-width: 180px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: var(--radius-full);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
    transition: var(--transition);
}

.improve-btn:hover {
    transform: translateY(-2px);
}

.improve-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.skip-btn {
    padding: 14px 24px;
    background: transparent;
    color: var(--text-sub);
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

/* Improved Script */
.improved-card {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border-color: var(--success);
}

.compare-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.compare-col {
    background: white;
    border-radius: var(--radius-md);
    padding: 16px;
}

.compare-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-sub);
    margin-bottom: 10px;
}

.improved-label {
    color: var(--success);
}

.compare-text {
    font-size: 0.9rem;
    line-height: 1.8;
    color: var(--text);
    white-space: pre-wrap;
    min-height: 100px;
}

.improved-text {
    color: #065f46;
    font-weight: 500;
}

.compare-arrow {
    display: flex;
    align-items: center;
    font-size: 1.5rem;
    color: var(--success);
    font-weight: 700;
}

.impr-tips {
    background: white;
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 20px;
}

.impr-tips h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--success);
    margin-bottom: 10px;
}

.impr-tips ul {
    list-style: none;
    padding: 0;
}

.impr-tips li {
    padding: 4px 0 4px 20px;
    position: relative;
    font-size: 0.875rem;
    color: var(--text-sub);
    line-height: 1.6;
}

.impr-tips li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: 700;
}

/* Auto Generate */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.form-input,
.form-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    color: var(--text);
    background: white;
    transition: var(--transition);
}

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

.generated-script {
    background: #f8fafc;
    border-radius: var(--radius-md);
    padding: 20px;
    font-size: 0.95rem;
    line-height: 1.9;
    color: var(--text);
    white-space: pre-wrap;
    margin-bottom: 20px;
    min-height: 150px;
    border: 1px solid var(--border);
}

/* ─── SCREEN 5: Record ─── */
.ref-script-card {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-color: var(--warning);
}

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

.ref-title {
    font-size: 1rem;
    font-weight: 700;
}

.toggle-btn {
    padding: 4px 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}

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

.ref-content {
    background: white;
    border-radius: var(--radius-sm);
    padding: 14px;
    font-size: 0.9rem;
    line-height: 1.8;
    max-height: 180px;
    overflow-y: auto;
    white-space: pre-wrap;
}

.record-card {
    text-align: center;
    padding: 48px 28px;
}

.record-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.record-btn {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.4);
    transition: var(--transition);
}

.record-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.5);
}

.record-btn.recording {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    box-shadow: 0 8px 32px rgba(239, 68, 68, 0.4);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 8px 32px rgba(239, 68, 68, 0.4);
    }

    50% {
        box-shadow: 0 8px 48px rgba(239, 68, 68, 0.7);
    }
}

.record-icon {
    font-size: 2.5rem;
}

.record-label {
    font-size: 0.8rem;
    font-weight: 600;
}

.timer {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--danger);
    font-variant-numeric: tabular-nums;
}

.timer-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--danger);
    animation: blink 1s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

.status-msg {
    font-size: 0.9rem;
    color: var(--text-sub);
    min-height: 24px;
}

/* Waveform */
.waveform {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 48px;
    margin-top: 16px;
}

.wave-bar {
    width: 4px;
    background: linear-gradient(to top, var(--primary), var(--secondary));
    border-radius: 2px;
    animation: wave 0.8s ease-in-out infinite;
    height: 8px;
}

.wave-bar:nth-child(1) {
    animation-delay: 0s;
}

.wave-bar:nth-child(2) {
    animation-delay: 0.1s;
}

.wave-bar:nth-child(3) {
    animation-delay: 0.2s;
}

.wave-bar:nth-child(4) {
    animation-delay: 0.3s;
}

.wave-bar:nth-child(5) {
    animation-delay: 0.4s;
}

.wave-bar:nth-child(6) {
    animation-delay: 0.3s;
}

.wave-bar:nth-child(7) {
    animation-delay: 0.2s;
}

.wave-bar:nth-child(8) {
    animation-delay: 0.1s;
}

@keyframes wave {

    0%,
    100% {
        height: 8px;
    }

    50% {
        height: 40px;
    }
}

/* .live-transcript uses default .card styles */

.transcript-text {
    min-height: 80px;
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text);
}

.placeholder {
    color: var(--text-muted);
    font-style: italic;
}

/* ─── SCREEN 6: Results ─── */
.score-card {
    display: flex;
    align-items: center;
    gap: 28px;
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border-color: var(--info);
}

.score-circle {
    position: relative;
    width: 120px;
    height: 120px;
    flex-shrink: 0;
}

.score-svg {
    width: 120px;
    height: 120px;
    transform: rotate(-90deg);
}

.score-bg {
    fill: none;
    stroke: #e0f2fe;
    stroke-width: 10;
}

.score-fill {
    fill: none;
    stroke: url(#scoreGrad);
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease;
}

.score-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.score-num {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

.score-label {
    font-size: 0.75rem;
    color: var(--text-sub);
    font-weight: 600;
}

.score-info {
    flex: 1;
}

.score-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.score-desc {
    font-size: 0.9rem;
    color: var(--text-sub);
    line-height: 1.7;
}

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

.metric-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 20px 16px;
    text-align: center;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.metric-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.metric-name {
    font-size: 0.75rem;
    color: var(--text-sub);
    font-weight: 500;
    margin-bottom: 6px;
}

.metric-val {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.metric-sub {
    font-size: 0.75rem;
    color: var(--text-sub);
    margin-top: 4px;
}

.result-transcript {
    background: #f8fafc;
    border-radius: var(--radius-md);
    padding: 16px;
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--text);
    min-height: 80px;
    border: 1px solid var(--border);
}

.feedback-card {
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    border-color: var(--warning);
}

.mode-feedback-card {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border-color: var(--success);
}

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

.feedback-item {
    background: white;
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.feedback-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.feedback-text {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text);
}

.feedback-text strong {
    color: var(--text);
    font-weight: 700;
    display: block;
    margin-bottom: 4px;
}

.retry-section {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 8px 0 40px;
}

/* ─── Utilities ─── */
.hidden {
    display: none !important;
}

/* ─── Responsive ─── */
@media (max-width: 640px) {
    .mode-grid {
        grid-template-columns: 1fr;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .compare-grid {
        grid-template-columns: 1fr;
    }

    .compare-arrow {
        transform: rotate(90deg);
        margin: 8px auto;
    }

    .score-card {
        flex-direction: column;
        text-align: center;
    }

    .steps-row {
        gap: 4px;
    }

    .step-arrow {
        display: none;
    }

    .card {
        padding: 20px;
    }

    .record-btn {
        width: 100px;
        height: 100px;
    }

    .record-icon {
        font-size: 2rem;
    }
}

/* ═══════════════════════════════════════════════
   API KEY MODAL
   ═══════════════════════════════════════════════ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-box {
    background: var(--surface);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-sub);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--bg);
    color: var(--text);
}

.modal-body {
    padding: 20px 24px;
}

.modal-desc {
    font-size: 0.875rem;
    color: var(--text-sub);
    line-height: 1.7;
    margin-bottom: 16px;
}

.api-key-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.api-key-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--text);
    transition: var(--transition);
}

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

.toggle-eye {
    padding: 12px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
}

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

.api-key-status {
    font-size: 0.875rem;
    min-height: 20px;
    margin-bottom: 12px;
}

.api-link {
    display: inline-block;
    font-size: 0.875rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.api-link:hover {
    text-decoration: underline;
}

.modal-footer {
    display: flex;
    gap: 10px;
    padding: 16px 24px 20px;
    border-top: 1px solid var(--border);
}

.danger-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    background: transparent;
    color: var(--danger);
    border: 2px solid var(--danger);
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.danger-btn:hover {
    background: #fef2f2;
}

/* ─── Settings Button ─── */
.settings-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text);
}

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

.settings-btn-sm {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    opacity: 0.7;
}

.settings-btn-sm:hover {
    opacity: 1;
}

/* Status dot */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.green {
    background: var(--success);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.status-dot.red {
    background: var(--danger);
}

/* API Warning Banner */
.api-warning {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 24px;
    font-size: 0.875rem;
    color: #92400e;
}

.api-warning button {
    background: #f59e0b;
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
}

.api-warning button:hover {
    background: #d97706;
}

/* ═══════════════════════════════════════════════
   AI LOADING STATES
   ═══════════════════════════════════════════════ */

.ai-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 32px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-bottom: 20px;
    text-align: center;
    color: var(--text-sub);
    font-size: 0.95rem;
}

.ai-loading-full {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 60px 20px;
    text-align: center;
}

.ai-loading-full h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.loading-step {
    font-size: 0.9rem;
    color: var(--text-sub);
}

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

.ai-spinner.large {
    width: 60px;
    height: 60px;
    border-width: 4px;
}

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

/* ═══════════════════════════════════════════════
   ANALYSIS METHOD SELECTION
   ═══════════════════════════════════════════════ */

.analysis-method-card {
    background: var(--surface);
    border: 2px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

.method-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 16px;
}

.method-card {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 16px;
    cursor: pointer;
    text-align: center;
    transition: var(--transition);
    position: relative;
}

.method-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.method-card.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, #eef2ff, #f0fdf4);
}

.method-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.method-name {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.method-desc {
    font-size: 0.8rem;
    color: var(--text-sub);
    line-height: 1.5;
    margin-bottom: 10px;
}

.method-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--border);
    color: var(--text-sub);
}

.method-badge.ai {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

/* ═══════════════════════════════════════════════
   GPT FEEDBACK SECTION
   ═══════════════════════════════════════════════ */

.gpt-feedback-card {
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
    border-color: var(--success);
}

.card-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title-row .card-title {
    margin-bottom: 0;
}

.ai-tag {
    display: inline-block;
    padding: 3px 10px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 700;
}

.basic-tag {
    display: inline-block;
    padding: 3px 10px;
    background: var(--bg);
    color: var(--text-sub);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
}

.gpt-overall {
    background: white;
    border-radius: var(--radius-md);
    padding: 16px;
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--text);
    margin-bottom: 16px;
    border-left: 4px solid var(--success);
}

.gpt-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 16px;
}

.gpt-section {
    background: white;
    border-radius: var(--radius-md);
    padding: 16px;
}

.gpt-section h4 {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.gpt-section.strengths h4 {
    color: var(--success);
}

.gpt-section.improvements h4 {
    color: var(--primary);
}

.gpt-section ul {
    list-style: none;
    padding: 0;
}

.gpt-section li {
    font-size: 0.85rem;
    color: var(--text-sub);
    padding: 4px 0 4px 18px;
    position: relative;
    line-height: 1.6;
}

.gpt-section.strengths li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: 700;
}

.gpt-section.improvements li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: 700;
}

.gpt-mode-specific {
    margin-bottom: 12px;
}

.mode-specific-box {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border-radius: var(--radius-md);
    padding: 16px;
    font-size: 0.9rem;
    line-height: 1.7;
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}

.next-step-box {
    background: linear-gradient(135deg, #fdf4ff, #fae8ff);
    border-radius: var(--radius-md);
    padding: 16px;
    font-size: 0.9rem;
    line-height: 1.7;
    color: #7e22ce;
    border-left: 4px solid #a855f7;
}

/* Source badge */
.source-badge {
    display: inline-block;
    padding: 3px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-sub);
}

.source-badge.ai {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
}

/* Analysis badge */
.analysis-badge {
    margin-top: 10px;
}

/* Generated script header */
.generated-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.generated-header .card-title {
    margin-bottom: 0;
}

/* ─── Responsive additions ─── */
@media (max-width: 640px) {
    .method-grid {
        grid-template-columns: 1fr;
    }

    .gpt-sections {
        grid-template-columns: 1fr;
    }

    .api-warning {
        flex-direction: column;
        align-items: flex-start;
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-footer .primary-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ── 표정 분석 카드 ── */
.face-analysis-card {
    border: 1.5px solid #ec4899;
    background: linear-gradient(135deg, #fff0f6 0%, #fdf2f8 100%);
    padding: 16px 20px 0;
    overflow: hidden;
}

.face-analysis-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 14px;
}

.face-analysis-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.face-icon {
    font-size: 2rem;
    line-height: 1;
}

.face-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
}

.face-desc {
    font-size: 0.8rem;
    color: var(--text-sub);
    margin-top: 2px;
}

.face-analysis-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.premium-badge {
    background: linear-gradient(135deg, #f59e0b, #ec4899);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

/* 토글 스위치 */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    cursor: pointer;
}

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

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #d1d5db;
    border-radius: 26px;
    transition: 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked+.toggle-slider {
    background: #ec4899;
}

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

.disabled-toggle {
    opacity: 0.55;
    cursor: not-allowed;
}

/* 준비중 바 */
.coming-soon-bar {
    background: linear-gradient(90deg, #ec4899, #f43f5e);
    color: #fff;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 8px 16px;
    margin: 0 -20px;
    letter-spacing: 0.02em;
}