@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css');

html {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    position: relative;
}

/* ─── Tokens ─────────────────────────────────────────────────────────── */
:root {
    --accent: #5b5bd6;
    --accent-hover: #4a4ac4;
    --accent-dim: rgba(91, 91, 214, 0.1);
    --accent-border: rgba(91, 91, 214, 0.25);

    --bg: #f5f5fa;
    --bg-2: #ededf5;
    --surface: #ffffff;
    --surface-2: #f8f8fc;
    --surface-hover: #f0f0f8;

    --border: #e0e0ee;
    --border-2: #ebebf5;

    --text-1: #1a1a2e;
    --text-2: #525278;
    --text-3: #7272a0;

    --green: #1a8f60;
    --red: #c53030;
    --red-dim: rgba(197, 48, 48, 0.08);

    --font-body: 'Pretendard', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-en: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 18px;
    --r-xl: 24px;
    --r-full: 999px;

    --shadow-sm: 0 1px 4px rgba(91,91,214,0.08), 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 16px rgba(91,91,214,0.10), 0 2px 6px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 32px rgba(91,91,214,0.12), 0 4px 12px rgba(0,0,0,0.08);

    /* ─── Toss / Safe Area ───────────────────────────────────────────── */
    --sat: env(safe-area-inset-top);
    --sar: env(safe-area-inset-right);
    --sab: env(safe-area-inset-bottom);
    --sal: env(safe-area-inset-left);
}

/* ─── Base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text-1);
    margin: 0;
    padding: var(--sat) var(--sar) var(--sab) var(--sal);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    touch-action: pan-y pan-x;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    line-height: 1.6;
    font-size: 15px;
}

body input, body textarea, body .chat-input,
body .chat-message-text, body .chat-messages {
    -webkit-user-select: text;
    user-select: text;
}

/* ─── Scrollbar ──────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ─── Container ──────────────────────────────────────────────────────── */
.container {
    padding: calc(var(--sat) + 60px) 1.25rem calc(var(--sab) + 80px);
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
    text-align: center;
    min-height: 100vh;
    min-height: 100dvh;
}

@media (max-width: 768px) {
    .container { max-width: 100%; margin: 0; padding: calc(var(--sat) + 50px) 0.9rem calc(var(--sab) + 75px); }
}

/* ─── Toss Header ────────────────────────────────────────────────────── */
.toss-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--sat) + 56px);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: var(--sat);
    z-index: 1000;
    border-bottom: 1px solid var(--border-2);
}

.toss-header-left {
    position: absolute;
    left: 12px;
    bottom: 0;
    height: 56px;
    display: flex;
    align-items: center;
}

.back-btn {
    background: transparent;
    border: none;
    color: var(--text-1);
    font-size: 1.5rem;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    line-height: 1;
}

.back-btn:hover { background: var(--surface-hover); }

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

.toss-header-logo {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    object-fit: cover;
}

.toss-header-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-1);
    margin: 0;
    font-family: var(--font-body);
}

/* ─── Floating Tabbar ───────────────────────────────────────────────── */
.floating-tabbar {
    position: fixed;
    bottom: calc(var(--sab) + 16px);
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 400px;
    z-index: 1000;
}

.floating-tabbar .nav-links {
    display: flex;
    background: #1a1a2e;
    padding: 6px;
    border-radius: var(--r-full);
    gap: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    border: none;
}

@media (max-width: 768px) {
    .floating-tabbar { width: calc(100% - 24px); }
}

/* ─── Nav ────────────────────────────────────────────────────────────── */
.header-section { display: none; }

.nav-links {
    display: flex;
    background: var(--surface);
    padding: 5px;
    border-radius: var(--r-full);
    gap: 2px;
    width: 100%;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-2);
}

.nav-link {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 8px;
    font-size: 0.84rem;
    font-weight: 600;
    font-family: var(--font-body);
    color: var(--text-2);
    text-decoration: none;
    border-radius: var(--r-full);
    transition: background 0.15s, color 0.15s;
    background: transparent;
    white-space: nowrap;
    gap: 5px;
    cursor: pointer;
    border: none;
}

.nav-link:hover { color: var(--text-1); background: var(--surface-2); }
.nav-link.active { background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(91,91,214,0.4); }
.floating-tabbar .nav-link { color: rgba(255,255,255,0.45); font-size: 0.9rem; letter-spacing: 0.01em; }
.floating-tabbar .nav-link:hover { color: rgba(255,255,255,0.8); background: rgba(255,255,255,0.08); }
.floating-tabbar .nav-link.active { background: #fff; color: #1a1a2e; box-shadow: none; }
.nav-link span { display: inline-block; }

.settings-link {
    flex: 0 0 auto;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border-radius: var(--r-full);
    text-decoration: none;
    font-size: 1rem;
    margin-left: 2px;
    border: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    color: var(--text-3);
}

.settings-link:hover { background: var(--surface-2); color: var(--text-2); }
.settings-link.active { background: var(--accent); color: #fff; }

.nav-auth-btn {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    color: #fff;
    background: var(--accent);
    border: none;
    transition: background 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}
.nav-auth-btn:hover { background: #4a4abf; box-shadow: 0 2px 8px rgba(91,91,214,0.4); }
.nav-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
}

@media (max-width: 768px) {
    .nav-link { padding: 9px 4px; font-size: 0.78rem; }
    .nav-link span { display: none; }
    .floating-tabbar .nav-link { padding: 11px 8px; font-size: 0.88rem; }
    .floating-tabbar .nav-link span { display: inline-block; }
    .settings-link { width: 34px; }
    .nav-auth-btn { padding: 6px 8px; font-size: 0.78rem; }
    .nav-auth-btn span { display: none; }
}

/* ─── Admin Submenu ─────────────────────────────────────────────────── */
.admin-submenu {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    padding: 5px;
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--r-full);
    box-shadow: var(--shadow-sm);
    animation: fadeSlideDown 0.15s ease-out;
}

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

.admin-menu-item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 9px 8px;
    font-size: 0.84rem;
    font-weight: 600;
    font-family: var(--font-body);
    color: var(--text-2);
    text-decoration: none;
    border-radius: var(--r-full);
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.admin-menu-item:hover { color: var(--text-1); background: var(--surface-2); }
.admin-menu-item.active { background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(91,91,214,0.4); }

@media (max-width: 768px) {
    .admin-menu-item { font-size: 0.78rem; padding: 9px 4px; }
    .admin-menu-item span { display: none; }
}

/* ─── Page Header ────────────────────────────────────────────────────── */
.trends-page-header, .topic-page-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.page-header-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.trends-page-header h2, .topic-page-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-1);
    margin: 0;
    letter-spacing: -0.02em;
}

.trends-subtitle, .topic-subtitle {
    color: var(--text-3);
    font-size: 0.8rem;
    margin: 0;
    font-weight: 400;
}

.trends-page-header .header-text, .topic-page-header .header-text {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
}

/* ─── Trend Cards ────────────────────────────────────────────────────── */
.realtime-trends-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 0.5rem;
    text-align: left;
}

.trends-date-header {
    padding: 6px 4px;
}

.trends-date-header h3 {
    margin: 0;
    font-family: var(--font-body);
    font-size: 0.88rem;
    color: var(--text-2);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 7px;
}

.trends-date-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.realtime-trend-card {
    background: var(--surface);
    padding: 16px 18px;
    border-radius: var(--r-lg);
    border: 1px solid var(--border-2);
    box-shadow: var(--shadow-sm);
    transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
}

.realtime-trend-card:hover {
    background: var(--surface-2);
    box-shadow: var(--shadow-md);
    border-color: var(--border);
}

.trend-card-top {
    flex-shrink: 0;
    width: 68px;
    display: flex;
    justify-content: center;
}

.trend-category {
    padding: 3px 8px;
    border-radius: var(--r-full);
    font-size: 0.63rem;
    font-weight: 700;
    font-family: var(--font-body);
    text-transform: uppercase;
    text-align: center;
    width: 100%;
    letter-spacing: 0.04em;
    background: var(--surface-2);
    color: var(--text-3);
    border: 1px solid var(--border);
}

.trend-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }

.trend-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-1);
    line-height: 1.45;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trend-card-keywords { display: flex; flex-wrap: wrap; gap: 5px; }
.trend-keyword { color: var(--text-3); font-size: 0.7rem; }
.trend-keyword::before { content: "#"; }

.trend-card-footer { flex-shrink: 0; display: flex; flex-direction: row; align-items: center; gap: 8px; }

.trend-card-time {
    font-size: 0.85rem;
    color: var(--text-2);
    font-family: var(--font-body);
    font-weight: 500;
    margin-right: auto;
}


.trend-start-btn {
    background: var(--surface-2);
    color: var(--text-2);
    border: 1px solid var(--border);
    padding: 7px 16px;
    border-radius: var(--r-full);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
    box-shadow: none;
}

.realtime-trend-card:hover .trend-start-btn {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(91,91,214,0.35);
}

/* 카테고리 색상 */
.trend-category.cat-정치  { background: rgba(76,175,128,0.1); color: #4caf80; border-color: rgba(76,175,128,0.2); }
.trend-category.cat-테크  { background: rgba(136,120,240,0.1); color: #8878f0; border-color: rgba(136,120,240,0.2); }
.trend-category.cat-스포츠 { background: rgba(74,159,212,0.1); color: #4a9fd4; border-color: rgba(74,159,212,0.2); }
.trend-category.cat-연애  { background: rgba(212,112,184,0.1); color: #d470b8; border-color: rgba(212,112,184,0.2); }
.trend-category.cat-금융  { background: rgba(200,146,42,0.1); color: #c8922a; border-color: rgba(200,146,42,0.2); }
.trend-category.cat-전체  { background: rgba(204,80,80,0.1); color: #cc5050; border-color: rgba(204,80,80,0.2); }
.trend-category.cat-일반  { background: var(--surface-2); color: var(--text-3); border-color: var(--border); }
.trend-category.cat-팝송  { background: rgba(255,105,180,0.1); color: #ff69b4; border-color: rgba(255,105,180,0.2); }
.trend-category.cat-퍼즐  { background: rgba(91,91,214,0.1); color: var(--accent); border-color: rgba(91,91,214,0.2); }

.puzzle-card-date { font-size: 0.75rem; color: var(--text-3); margin-left: auto; }

.badge-biz { background: rgba(76,175,128,0.1); color: #4caf80; border: 1px solid rgba(76,175,128,0.2); }
.badge-ent { background: rgba(200,146,42,0.1); color: #c8922a; border: 1px solid rgba(200,146,42,0.2); }
.badge-spt { background: rgba(74,159,212,0.1); color: #4a9fd4; border: 1px solid rgba(74,159,212,0.2); }
.badge-tec { background: rgba(136,120,240,0.1); color: #8878f0; border: 1px solid rgba(136,120,240,0.2); }
.badge-top { background: rgba(204,80,80,0.1); color: #cc5050; border: 1px solid rgba(204,80,80,0.2); }

/* ─── Single-row card (팝송 / 퍼즐) ─────────────────────────────────── */
.trend-card-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
}

.row-date {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: var(--text-3);
    font-family: var(--font-ui);
    min-width: 80px;
}

.row-title {
    flex: 1;
    min-width: 0;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 768px) {
    .realtime-trend-card { flex-direction: column; align-items: flex-start; padding: 16px; gap: 10px; }
    .trend-card-top { width: auto; }
    .trend-card-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
    .trend-card-footer { width: 100%; flex-wrap: wrap; }
    .trend-card-time { width: 100%; margin-right: 0; }
    .trend-start-btn { flex: 1; text-align: center; padding: 10px; }
    .trend-card-row { flex-wrap: wrap; }
    .row-date { min-width: unset; }
    .row-title { width: 100%; white-space: normal; }
}

/* ─── Empty State ────────────────────────────────────────────────────── */
.trends-empty-state {
    text-align: center;
    padding: 3.5rem 2rem;
    background: var(--surface);
    border-radius: var(--r-xl);
    border: 1px solid var(--border-2);
    box-shadow: var(--shadow-sm);
}

.empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.trends-empty-state h3 { font-family: var(--font-body); font-size: 1.1rem; font-weight: 700; color: var(--text-1); margin-bottom: 0.4rem; }
.trends-empty-state p { color: var(--text-3); margin-bottom: 1.5rem; font-size: 0.88rem; line-height: 1.6; }

.go-settings-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 11px 24px;
    border-radius: var(--r-full);
    font-size: 0.9rem;
    font-weight: 700;
    font-family: var(--font-body);
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 8px rgba(91,91,214,0.35);
}

.go-settings-btn:hover { background: var(--accent-hover); box-shadow: 0 4px 14px rgba(91,91,214,0.45); }

/* ─── Load More ──────────────────────────────────────────────────────── */
.load-more-container { display: flex; justify-content: center; margin: 1.5rem 0 2rem; }

.load-more-btn {
    background: transparent;
    color: var(--text-2);
    border: 1px solid var(--border);
    padding: 10px 24px;
    border-radius: var(--r-full);
    font-size: 0.88rem;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 180px;
}

.load-more-btn:hover { background: var(--surface); color: var(--text-1); border-color: var(--border); }
.load-more-btn .more-count { font-size: 0.74rem; opacity: 0.6; font-weight: 400; }

/* ─── Topic Setup ────────────────────────────────────────────────────── */
.setup-section { width: 100%; }
.setup-container { display: flex; gap: 20px; align-items: stretch; text-align: left; }
.setup-left { flex: 1.5; display: flex; flex-direction: column; gap: 16px; }
.setup-right { flex: 1; background: var(--surface); border-radius: var(--r-xl); border: 1px solid var(--border-2); padding: 16px; height: 500px; display: flex; flex-direction: column; box-shadow: var(--shadow-sm); }

.input-group { display: flex; flex-direction: column; gap: 7px; }
.input-group label { font-size: 0.78rem; font-weight: 700; font-family: var(--font-body); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.07em; }

textarea {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-md);
    font-size: 0.95rem;
    background: var(--surface);
    color: var(--text-1);
    resize: none;
    font-family: var(--font-body);
    line-height: 1.65;
    min-height: 200px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

@media (max-width: 768px) { textarea { font-size: 16px !important; } }
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
textarea::placeholder { color: var(--text-3); }

select {
    width: 100%;
    padding: 13px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-md);
    font-size: 0.95rem;
    background: var(--surface);
    color: var(--text-1);
    cursor: pointer;
    font-weight: 600;
    font-family: var(--font-body);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7' viewBox='0 0 11 7'%3E%3Cpath d='M1 1l4.5 4.5L10 1' stroke='%2350506a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 34px;
}

@media (max-width: 768px) { select { font-size: 16px !important; } }
select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
select option { background: var(--surface); color: var(--text-1); }

/* ─── Toss Loading Spinner ───────────────────────────────────────────── */
.toss-loader {
    width: 40px;
    height: 40px;
    border: 4px solid var(--bg-2);
    border-top: 4px solid var(--accent);
    border-radius: 50%;
    animation: toss-spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes toss-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.toss-loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* ─── Buttons (TDS Refinement) ───────────────────────────────────────── */
button, .btn-primary, .start-btn, .go-settings-btn {
    border-radius: 14px !important; /* TDS standard is often 14px or 16px for large buttons */
    font-weight: 700;
    letter-spacing: -0.01em;
}

.nav-link, .nav-links, .admin-submenu, .admin-menu-item {
    border-radius: var(--r-full) !important; /* Keep rounded for tab-like elements */
}

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

/* ─── Learning Card ──────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--r-xl);
    padding: 1.75rem;
    margin-top: 0.5rem;
    text-align: left;
    box-shadow: var(--shadow-md);
    animation: fadeIn 0.25s ease-out;
}

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

.english-container {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-2);
}

.english-sentence {
    font-family: var(--font-en);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-1);
    line-height: 1.5;
    flex: 1;
    letter-spacing: 0.01em;
    word-spacing: 0.04em;
}

.tts-btn {
    background: transparent;
    color: var(--text-3);
    border: 1.5px solid var(--border);
    font-size: 0.95rem;
    cursor: pointer;
    width: 36px; height: 36px;
    border-radius: var(--r-full);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
    padding: 0; flex-shrink: 0; box-shadow: none;
}

.tts-btn:hover:not(:disabled) { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
.tts-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.tts-btn.playing { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); animation: ttsPulse 1.5s ease-in-out infinite; }

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

.korean-sentence {
    font-size: 1.05rem;
    color: var(--text-2);
    margin-bottom: 1.25rem;
    line-height: 1.7;
    font-weight: 500;
}

/* ─── Content Sections ───────────────────────────────────────────────── */
.structure-section, .explanation-section, .voca-section {
    background: var(--surface-2);
    border: none;
    border-radius: var(--r-lg);
    margin-bottom: 0.9rem;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.section-label {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0.85rem 1.4rem;
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0;
    border-bottom: 1px solid var(--border-2);
}
.structure-section   .section-label { color: var(--green);  background: rgba(26,143,96,0.08); }
.explanation-section .section-label { color: var(--accent); background: rgba(91,91,214,0.08); }
.voca-section        .section-label { color: #b8820a;       background: rgba(184,130,10,0.08); }

.section-label::before {
    content: '';
    display: block;
    width: 3px;
    height: 14px;
    border-radius: var(--r-full);
    flex-shrink: 0;
}
.structure-section   .section-label::before { background: var(--green); }
.explanation-section .section-label::before { background: var(--accent); }
.voca-section        .section-label::before { background: #d49a28; }

.section-body {
    padding: 1.2rem 1.4rem;
    font-size: 1rem;
    line-height: 1.9;
    color: var(--text-1);
}

/* 문장 구조 형식 뱃지 */
.struct-form-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--r-full);
    font-size: 0.73rem;
    font-weight: 700;
    font-family: var(--font-body);
    background: rgba(26,143,96,0.10);
    color: var(--green);
    margin-right: 8px;
    vertical-align: middle;
}
.stag { font-weight: 600; color: var(--text-1); }
.stag-s, .stag-v, .stag-o, .stag-c, .stag-m { color: var(--text-1); }

/* AI 설명 포인트 */
.exp-point {
    display: flex;
    gap: 0.85rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border-2);
    line-height: 1.75;
}
.exp-point:last-child { border-bottom: none; padding-bottom: 0; }
.exp-point:first-child { padding-top: 0; }
.exp-num {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: var(--r-full);
    background: var(--accent);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    font-family: var(--font-body);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}
.exp-text { color: var(--text-1); font-size: 1rem; flex: 1; }

/* 어휘 리스트 */
.voca-list { display: flex; flex-direction: column; }
.voca-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-2);
}
.voca-item:first-child { padding-top: 0; }
.voca-item:last-child  { border-bottom: none; padding-bottom: 0; }

.voca-head { display: flex; align-items: baseline; gap: 6px; }
.voca-word {
    font-family: var(--font-en);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-1);
}
.voca-pos {
    font-size: 0.7rem;
    font-family: var(--font-body);
    font-weight: 600;
    color: #b8820a;
}
.voca-mean { color: var(--text-2); font-size: 1rem; }
.voca-tip  { font-size: 0.82rem; color: var(--text-3); margin-top: 0.1rem; }

/* ─── Controls ───────────────────────────────────────────────────────── */
.controls { margin-top: 1.5rem; display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.controls button { min-width: 136px; padding: 12px 22px; font-size: 0.92rem; border-radius: var(--r-full); }

#reveal-btn { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); box-shadow: none; }
#reveal-btn:hover { background: var(--accent-dim); box-shadow: none; }
#next-btn { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); box-shadow: none; }
#next-btn:hover { background: var(--accent-dim); box-shadow: none; }
#finish-btn { background: var(--surface-2); color: var(--text-2); border: 1.5px solid var(--border); box-shadow: none; }
#finish-btn:hover { background: var(--surface-hover); color: var(--text-1); box-shadow: none; }

.progress {
    font-family: var(--font-body);
    font-weight: 700;
    color: var(--text-2);
    display: inline-block;
    padding: 6px 16px;
    border-radius: var(--r-full);
    font-size: 0.85rem;
    margin-bottom: 14px;
    background: var(--surface);
    border: 1px solid var(--border-2);
    box-shadow: var(--shadow-sm);
}

/* ─── Misc Buttons ───────────────────────────────────────────────────── */
.btn-text {
    background: none !important; border: none !important;
    color: var(--text-3) !important; font-size: 0.83rem !important;
    font-weight: 600 !important; cursor: pointer; padding: 7px !important;
    box-shadow: none !important; text-decoration: underline; text-underline-offset: 3px;
    border-radius: 0 !important;
}
.btn-text:hover { color: var(--text-2) !important; box-shadow: none !important; }

.btn-primary {
    background: var(--accent); color: #fff; border: none;
    padding: 11px 22px; border-radius: var(--r-full); font-weight: 700;
    font-family: var(--font-body); cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 8px rgba(91,91,214,0.3);
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 14px rgba(91,91,214,0.4); }

.quiz-start-controls { display: flex; align-items: center; gap: 8px; }

/* ─── Quiz ───────────────────────────────────────────────────────────── */
.quiz-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--border-2);
}

.quiz-header h2 { margin: 0; font-family: var(--font-body); color: var(--text-1); font-size: 1.45rem; font-weight: 800; letter-spacing: -0.02em; }
.quiz-progress { font-weight: 600; color: var(--text-3); font-size: 0.88rem; }

.quiz-loading {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 60px 0; color: var(--text-3); font-size: 0.9rem;
}

.quiz-loading .spinner {
    width: 30px; height: 30px;
    border: 2.5px solid var(--border); border-top: 2.5px solid var(--accent);
    border-radius: 50%; animation: spin 0.9s linear infinite; margin-bottom: 16px;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.quiz-question-type {
    display: inline-block; padding: 4px 12px; border-radius: var(--r-full);
    font-size: 0.72rem; font-weight: 700; font-family: var(--font-body);
    margin-bottom: 12px; background: var(--accent-dim); color: var(--accent);
    border: 1px solid var(--accent-border); letter-spacing: 0.04em; text-transform: uppercase;
}

.quiz-question { font-family: var(--font-body); font-size: 1.2rem; font-weight: 700; margin-bottom: 20px; line-height: 1.55; color: var(--text-1); letter-spacing: -0.01em; }

.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }

.quiz-option-btn {
    padding: 14px 16px; font-size: 0.93rem; font-weight: 500;
    background: var(--surface); border: 1.5px solid var(--border);
    border-radius: var(--r-md); cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
    color: var(--text-1); text-align: left; font-family: var(--font-body);
    box-shadow: none;
}

.quiz-option-btn:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.quiz-option-btn.correct { background: rgba(26,143,96,0.08); border-color: rgba(26,143,96,0.30); color: var(--green); }
.quiz-option-btn.wrong { background: var(--red-dim); border-color: rgba(224,85,85,0.35); color: var(--red); }

.quiz-input-container { display: flex; flex-direction: column; align-items: center; gap: 20px; margin-bottom: 20px; }

.quiz-char-boxes { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; }

.char-box {
    width: 44px; height: 50px;
    border: 1.5px solid var(--border); border-radius: var(--r-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; font-weight: 800; font-family: var(--font-en);
    text-transform: uppercase; background: var(--surface); color: var(--text-1);
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s; cursor: pointer;
}

.char-box.empty { background: var(--bg-2); border-color: var(--border-2); }
.char-box.focused { border-color: var(--accent); background: var(--accent-dim); box-shadow: 0 0 0 3px var(--accent-dim); }
.char-box.hint { background: var(--bg-2); color: var(--text-3); cursor: default; }
.char-box.correct { background: rgba(26,143,96,0.08); border-color: rgba(26,143,96,0.30); color: var(--green); }
.char-box.wrong { background: var(--red-dim); border-color: rgba(224,85,85,0.35); color: var(--red); }

#quiz-submit-btn { padding: 11px 28px; font-size: 0.92rem; border-radius: var(--r-full); }

.quiz-feedback {
    padding: 13px 16px; border-radius: var(--r-md); margin-bottom: 16px;
    font-weight: 700; font-size: 0.93rem; text-align: center;
    animation: fadeIn 0.25s ease-out; font-family: var(--font-body);
}

.quiz-feedback.success { background: rgba(26,143,96,0.08); color: var(--green); border: 1.5px solid rgba(26,143,96,0.25); }
.quiz-feedback.error { background: var(--red-dim); color: var(--red); border: 1.5px solid rgba(224,85,85,0.25); }
.quiz-controls { margin-top: 1.25rem; }

@media (max-width: 768px) { .quiz-options { grid-template-columns: 1fr; } }

/* ─── History ────────────────────────────────────────────────────────── */
#review-section { width: 100%; max-width: 800px; margin: 0 auto; animation: fadeIn 0.25s ease-out; }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border-2); }
.section-header h2 { margin: 0; font-family: var(--font-body); color: var(--text-1); font-size: 1.2rem; font-weight: 700; }

.history-list { display: flex; flex-direction: column; gap: 6px; }

.history-item {
    background: var(--surface); padding: 14px 18px;
    display: flex; justify-content: space-between; align-items: center;
    cursor: pointer; transition: background 0.15s, box-shadow 0.15s; border: 1px solid var(--border-2);
    border-radius: var(--r-md); box-shadow: var(--shadow-sm);
}

.history-item:hover { background: var(--surface-2); box-shadow: var(--shadow-md); }
.history-info { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.history-topic { font-size: 0.93rem; font-weight: 600; color: var(--text-1); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.history-meta { display: flex; gap: 8px; font-size: 0.78rem; color: var(--text-3); }
.history-date { display: flex; align-items: center; gap: 3px; }
.history-difficulty { background: var(--accent-dim); color: var(--accent); padding: 2px 8px; border-radius: var(--r-full); font-weight: 700; font-family: var(--font-body); font-size: 0.7rem; border: 1px solid var(--accent-border); }

.delete-history-btn {
    background: transparent; color: var(--text-3); width: 30px; height: 30px; padding: 0;
    border-radius: var(--r-full); font-size: 0.9rem; display: flex; align-items: center; justify-content: center;
    border: none; cursor: pointer; transition: background 0.15s, color 0.15s; box-shadow: none;
}

.delete-history-btn:hover { background: var(--red-dim); color: var(--red); }

/* ─── AI 공시 (Toss Apps in Toss 정책) ──────────────────────────────── */

/* ─── AI 고지 바텀시트 ────────────────────────────────────────────────── */
.ai-notice-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 3000;
    display: flex;
    align-items: flex-end;
    animation: fadeIn 0.2s ease-out;
}

.ai-notice-sheet {
    width: 100%;
    background: var(--surface);
    border-radius: 20px 20px 0 0;
    padding: 28px 24px calc(var(--sab) + 28px);
    animation: slideInUp 0.25s ease-out;
}

.ai-notice-sheet-icon {
    font-size: 2.2rem;
    margin-bottom: 12px;
}

.ai-notice-sheet h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-1);
    margin: 0 0 10px;
}

.ai-notice-sheet p {
    font-size: 0.88rem;
    color: var(--text-2);
    line-height: 1.6;
    margin: 0 0 24px;
}

.ai-notice-sheet-btn {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--r-full);
    font-size: 1rem;
    font-weight: 700;
    font-family: var(--font-body);
    cursor: pointer;
}

/* AI 생성 콘텐츠 뱃지 */
.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-dim);
    border: 1px solid var(--accent-border);
    border-radius: var(--r-full);
    padding: 2px 7px;
    letter-spacing: 0.02em;
    white-space: nowrap;
    flex-shrink: 0;
}

/* 학습 카드 AI 라벨 */
.ai-content-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-3);
    margin-bottom: 1rem;
}
.ai-content-label::before {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    background: var(--accent);
    border-radius: 50%;
    flex-shrink: 0;
}

.history-loading, .history-empty { padding: 40px; text-align: center; color: var(--text-3); font-size: 0.88rem; }
.history-empty { background: var(--surface); border-radius: var(--r-lg); border: 1.5px dashed var(--border); }

.home-btn {
    background: transparent; color: var(--text-3); padding: 8px 16px; margin-bottom: 14px;
    font-size: 0.85rem; border: 1.5px solid var(--border); border-radius: var(--r-full);
    cursor: pointer; transition: all 0.15s; font-family: var(--font-body);
    box-shadow: none;
}

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

/* ─── Old Trend Card ─────────────────────────────────────────────────── */
.trend-card { background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-md); padding: 12px; cursor: pointer; transition: all 0.15s; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-sm); }
.trend-card:hover { background: var(--surface-2); box-shadow: var(--shadow-md); }
.trend-card.active { border-color: var(--accent); background: var(--accent-dim); border-left: 3px solid var(--accent); }
.card-top { display: flex; justify-content: space-between; align-items: center; }
.card-category { font-size: 0.63rem; font-weight: 700; font-family: var(--font-body); padding: 3px 8px; border-radius: var(--r-full); letter-spacing: 0.04em; text-transform: uppercase; background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); }
.card-title { font-size: 0.85rem; color: var(--text-1); line-height: 1.45; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.trends-header { margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border-2); display: flex; align-items: center; gap: 6px; }
.trends-header span { font-family: var(--font-body); font-weight: 700; font-size: 0.85rem; color: var(--text-2); }
.trends-vertical-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; flex: 1; }

/* ─── Chat Modal ─────────────────────────────────────────────────────── */
body.chat-active { overflow: hidden; }
body.chat-active .container, body.chat-active .header-section { display: none !important; }

.chat-modal {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100dvh;
    z-index: 2000; display: flex; align-items: stretch; background: var(--bg);
}
.chat-modal-overlay { display: none; }

.chat-modal-container {
    background: var(--bg); width: 100%; height: 100%;
    display: flex; flex-direction: column;
    animation: slideInUp 0.22s ease-out;
    pointer-events: auto; position: relative; z-index: 2005;
}

@keyframes slideInUp { from { transform: translateY(6%) scale(0.99); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }

@media (max-width: 768px) {
    .chat-modal-container { height: 100dvh; position: fixed; top: 0; left: 0; right: 0; bottom: 0; }
}

/* ── Header ── */
.chat-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-2);
    box-shadow: 0 1px 6px rgba(91,91,214,0.07);
    z-index: 10; flex-shrink: 0;
}

.chat-header-left {
    display: flex; align-items: center; gap: 11px;
}

.chat-header-avatar {
    width: 34px; height: 34px; border-radius: var(--r-full);
    background: var(--surface-2); border: 1px solid var(--border-2);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; flex-shrink: 0;
}

.chat-header-info { display: flex; flex-direction: column; gap: 2px; }
.chat-header-left h2 {
    margin: 0; font-family: var(--font-body); font-size: 0.95rem;
    color: var(--text-1); font-weight: 800; line-height: 1.2;
}

.chat-header-actions { display: flex; gap: 4px; align-items: center; }

.chat-header-btn, .chat-close-btn {
    background: none; border: none; color: var(--text-3);
    width: 34px; height: 34px; border-radius: var(--r-full);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, color 0.15s; font-size: 0.95rem;
}

.chat-header-btn:hover, .chat-close-btn:hover {
    background: var(--surface-hover); color: var(--text-1);
}

/* ── Status ── */
.chat-status-indicator { display: flex; align-items: center; gap: 5px; }
.status-dot {
    width: 6px; height: 6px; background: var(--green); border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(26,143,96,0.2);
}
.status-text { font-size: 0.7rem; color: var(--text-3); font-weight: 500; }

/* ── Messages Area ── */
.chat-messages {
    flex: 1; overflow-y: auto; padding: 20px 16px;
    background: var(--bg-2);
    display: flex; flex-direction: column; gap: 4px;
}

.chat-welcome-message {
    background: var(--surface);
    border: 1px solid var(--border-2);
    padding: 18px 20px;
    border-radius: var(--r-xl);
    margin-bottom: 8px;
    color: var(--text-2);
    line-height: 1.7;
    text-align: center;
    font-size: 0.9rem;
    box-shadow: var(--shadow-sm);
}

.chat-welcome-message strong { color: var(--accent); font-weight: 700; }

/* ── Message Bubbles ── */
.chat-message { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 6px; }
.chat-message-user { justify-content: flex-end; }
.chat-message-ai  { justify-content: flex-start; }

.chat-ai-avatar {
    width: 30px; height: 30px; border-radius: var(--r-full); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; margin-bottom: 2px;
    background: var(--surface); border: 1px solid var(--border-2);
    box-shadow: var(--shadow-sm);
}

.chat-message-bubble {
    display: flex; flex-direction: column; max-width: 78%;
}
.chat-message-user .chat-message-bubble { align-items: flex-end; }
.chat-message-ai  .chat-message-bubble { align-items: flex-start; }

.chat-message-text {
    padding: 11px 16px;
    border-radius: var(--r-lg);
    word-wrap: break-word; line-height: 1.7;
    white-space: pre-wrap; font-size: 0.93rem;
}

.chat-message-user .chat-message-text {
    background: var(--accent); color: #fff;
    border-bottom-right-radius: 5px;
    box-shadow: 0 2px 10px rgba(91,91,214,0.28);
}

.chat-message-ai .chat-message-text {
    background: var(--surface); color: var(--text-1);
    border: 1px solid var(--border-2);
    border-bottom-left-radius: 5px;
    box-shadow: var(--shadow-sm);
}

.message-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.chat-message-user .message-actions { justify-content: flex-end; }

.translate-btn {
    display: flex; align-items: center; gap: 3px; margin-top: 4px;
    background: var(--surface) !important; color: var(--text-3) !important;
    border: 1px solid var(--border) !important; padding: 4px 10px !important;
    font-size: 0.7rem !important; font-weight: 600 !important;
    border-radius: var(--r-full) !important; cursor: pointer; transition: all 0.15s !important;
    min-width: unset !important; box-shadow: none !important; transform: none !important;
    font-family: var(--font-body) !important;
}

.translate-btn:hover { background: var(--accent-dim) !important; color: var(--accent) !important; border-color: var(--accent-border) !important; }
.translate-btn.active { background: var(--accent-dim) !important; color: var(--accent) !important; border-color: var(--accent-border) !important; }

.translation-text, .corrections-text {
    margin-top: 5px; padding: 8px 13px;
    background: var(--surface-2); border-left: 2.5px solid var(--border);
    color: var(--text-2); font-size: 0.84rem; line-height: 1.65;
    border-radius: 4px 12px 12px 4px; animation: fadeIn 0.2s ease-out;
}

.corrections-text {
    background: rgba(26,143,96,0.06);
    border-left-color: rgba(26,143,96,0.4);
    color: var(--green);
}

.chat-message-user .translation-text, .chat-message-user .corrections-text {
    text-align: right; border-left: none; border-right: 2.5px solid var(--border);
    border-radius: 12px 4px 4px 12px;
}

/* ── Input Area ── */
.chat-input-area {
    padding: 14px 16px;
    background: var(--surface);
    border-top: 1px solid var(--border-2);
    flex-shrink: 0;
}

.chat-input-wrapper { display: flex; gap: 8px; align-items: center; }

.chat-input {
    flex: 1; padding: 12px 18px;
    border: 1.5px solid var(--border); border-radius: var(--r-full);
    font-size: 0.93rem; outline: none;
    transition: border-color 0.18s, box-shadow 0.18s;
    background: var(--bg); color: var(--text-1); font-family: var(--font-body);
}

.chat-input::placeholder { color: var(--text-3); }
.chat-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
    background: var(--surface);
}

.chat-mic-btn, .chat-send-btn {
    width: 44px; height: 44px; border: none; border-radius: var(--r-full);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.15s; flex-shrink: 0;
}

.chat-mic-btn {
    background: var(--bg); color: var(--text-3);
    border: 1.5px solid var(--border);
    box-shadow: none;
}
.chat-mic-btn:hover { background: var(--surface-hover); color: var(--text-2); }
.chat-mic-btn.recording { background: var(--red-dim); color: var(--red); border-color: var(--red); animation: pulse 1.5s infinite; }

.chat-send-btn {
    background: var(--accent); color: #fff;
    box-shadow: 0 2px 10px rgba(91,91,214,0.35);
}
.chat-send-btn:hover { background: var(--accent-hover); box-shadow: 0 4px 16px rgba(91,91,214,0.48); }

/* Chat button overrides */
.chat-modal-container button,
.chat-modal-container .chat-mic-btn,
.chat-modal-container .chat-send-btn,
.chat-modal-container .chat-header-btn,
.chat-modal-container .chat-close-btn {
    min-width: unset !important; padding: 0 !important;
    transform: none !important; margin: 0 !important;
    display: flex !important; align-items: center !important; justify-content: center !important;
}

.chat-mic-btn, .chat-send-btn { width: 44px !important; height: 44px !important; flex-shrink: 0 !important; }
.chat-send-btn { box-shadow: 0 2px 10px rgba(91,91,214,0.35) !important; }
.chat-mic-btn svg, .chat-send-btn svg { width: 18px !important; height: 18px !important; }
.chat-header-btn, .chat-close-btn { width: 34px !important; height: 34px !important; background: transparent !important; box-shadow: none !important; }
.ai-chat-btn { min-width: unset !important; padding: 0 !important; }

/* ── Typing Indicator ── */
.typing-indicator {
    display: flex; align-items: center; gap: 4px;
    padding: 10px 15px;
    background: var(--surface); border: 1px solid var(--border-2);
    border-radius: var(--r-lg); border-bottom-left-radius: 5px;
    width: fit-content; margin-bottom: 4px;
    box-shadow: var(--shadow-sm);
}
.typing-indicator span {
    width: 5px; height: 5px; background: var(--text-3);
    border-radius: 50%; animation: typing 1.4s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.35; } 30% { transform: translateY(-5px); opacity: 1; } }

@keyframes pulse { 0% { transform: scale(0.95); } 70% { transform: scale(1); } 100% { transform: scale(0.95); } }

/* ── Examples ── */
.examples-container { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; animation: fadeIn 0.2s ease-out; }
.example-chip {
    background: var(--surface); border: 1px solid var(--border-2);
    padding: 10px 15px; border-radius: var(--r-md);
    font-size: 0.86rem; color: var(--text-2); cursor: pointer;
    transition: all 0.15s; line-height: 1.4;
    box-shadow: var(--shadow-sm);
}
.example-chip:hover { background: var(--accent-dim); color: var(--accent); border-color: var(--accent-border); box-shadow: none; }

/* ── Teacher Selection ── */
.teacher-selection {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg); z-index: 10;
    display: flex; align-items: center; justify-content: center;
    padding: 24px 20px;
    overflow-y: auto;
}

.ts-inner {
    width: 100%; max-width: 500px;
    text-align: center;
}

.ts-title {
    font-family: var(--font-body);
    font-size: 1.3rem; font-weight: 800;
    color: var(--text-1); margin: 0 0 6px;
    letter-spacing: -0.02em;
}

.ts-subtitle {
    font-size: 0.84rem; color: var(--text-3);
    font-weight: 500; margin: 0 0 24px;
}

/* ── Cards ── */
.teacher-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    text-align: left;
}

.teacher-card {
    background: var(--surface);
    border: 1.5px solid var(--border-2);
    border-radius: var(--r-xl);
    padding: 20px 18px 18px;
    display: flex; flex-direction: column; gap: 0;
    cursor: pointer;
    transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
    box-shadow: var(--shadow-sm);
    -webkit-tap-highlight-color: transparent;
}

.teacher-card:hover  { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.teacher-card:active { transform: scale(0.98); }
.teacher-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.teacher-card[data-teacher="native"].selected { border-color: #f97316; box-shadow: 0 0 0 3px rgba(249,115,22,0.12); }

/* 국기 */
.tc-flag {
    font-size: 2rem; margin-bottom: 14px; line-height: 1;
}

.tc-name {
    font-family: var(--font-body);
    font-size: 1.05rem; font-weight: 800;
    color: var(--text-1); margin: 0 0 4px;
}

.tc-desc {
    font-size: 0.78rem; color: var(--text-3);
    line-height: 1.5; margin: 0 0 14px;
}

.tc-list {
    list-style: none; padding: 0; margin: 0 0 18px;
    display: flex; flex-direction: column; gap: 7px;
    flex: 1;
}

.tc-list li {
    font-size: 0.76rem; color: var(--text-2);
    font-weight: 500; line-height: 1.4;
    display: flex; align-items: center; gap: 8px;
}

.tc-list li::before {
    content: '';
    width: 4px; height: 4px;
    border-radius: 50%; flex-shrink: 0;
    margin-top: 1px;
}

.teacher-card[data-teacher="korean"] .tc-list li::before { background: var(--accent); }
.teacher-card[data-teacher="native"]  .tc-list li::before { background: #f97316; }

/* ── 버튼 ── */
.teacher-select-btn {
    width: 100%; padding: 11px; border: none;
    border-radius: var(--r-full); font-weight: 700;
    font-size: 0.84rem; font-family: var(--font-body);
    cursor: pointer; transition: all 0.15s; color: #fff;
}

.ts-btn-kor { background: var(--accent); box-shadow: 0 2px 10px rgba(91,91,214,0.25); }
.ts-btn-kor:hover { background: var(--accent-hover); box-shadow: 0 4px 14px rgba(91,91,214,0.38); }

.ts-btn-nat { background: #f97316; box-shadow: 0 2px 10px rgba(249,115,22,0.25); }
.ts-btn-nat:hover { background: #ea6c0a; box-shadow: 0 4px 14px rgba(249,115,22,0.38); }

/* ── Responsive ── */
@media (max-width: 400px) {
    .teacher-selection { padding: 20px 14px; }
    .ts-subtitle { margin-bottom: 18px; }
    .teacher-cards { gap: 10px; }
    .teacher-card { padding: 16px 14px 14px; }
    .tc-flag { font-size: 1.75rem; margin-bottom: 10px; }
    .tc-name { font-size: 0.95rem; }
    .tc-list li { font-size: 0.72rem; }
    .teacher-select-btn { padding: 10px; font-size: 0.8rem; }
}

@media (max-height: 650px) {
    .ts-subtitle { display: none; margin: 0 0 14px; }
    .teacher-card { padding: 14px 14px 12px; }
    .tc-flag { font-size: 1.6rem; margin-bottom: 8px; }
    .tc-desc { display: none; }
    .tc-list { gap: 5px; margin-bottom: 14px; }
    .tc-list li { font-size: 0.72rem; }
    .teacher-select-btn { padding: 10px; }
}

@media (max-height: 520px) {
    .ts-title { font-size: 1rem; margin-bottom: 12px; }
    .tc-flag { font-size: 1.4rem; margin-bottom: 6px; }
    .tc-list { display: none; }
    .teacher-select-btn { padding: 9px; }
}

/* ─── Video Chat ─────────────────────────────────────────────────────── */
.video-chat-container { background: var(--bg); padding: 10px; border-bottom: 1px solid var(--border-2); }
.video-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.video-wrapper { position: relative; aspect-ratio: 4/3; background: var(--surface); border-radius: var(--r-md); overflow: hidden; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border-2); }
#local-video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.video-label { position: absolute; bottom: 6px; left: 6px; background: rgba(0,0,0,0.6); color: #fff; padding: 2px 8px; border-radius: var(--r-full); font-size: 0.65rem; z-index: 2; }
.ai-avatar-visual { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ai-emoji { font-size: 2.25rem; margin-top: 8px; }
.ai-voice-waves { display: flex; align-items: flex-end; gap: 2px; height: 20px; }
.ai-voice-waves span { width: 2px; background: var(--accent); border-radius: 2px; height: 3px; }
.ai-voice-waves.active span { animation: waveAnim 0.5s ease-in-out infinite alternate; }
@keyframes waveAnim { 0% { height: 3px; } 100% { height: 16px; } }

/* ─── Mobile Chat ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .chat-mic-btn, .chat-send-btn { width: 40px !important; height: 40px !important; }
    .chat-input { font-size: 16px; }
    .chat-header-btn, .chat-close-btn { width: 32px !important; height: 32px !important; }
    .chat-modal-header h2 { font-size: 0.95rem; }
    .card { padding: 1.25rem; }
    .english-sentence { font-size: 1.25rem; }
}

/* ─── Chat Page (/chat 전용 페이지 레이아웃) ─────────────────────────── */
.ts-page { padding-top: 1rem; }

.chat-page-interface {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    background: var(--surface);
    border-radius: var(--r-xl);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.chat-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}
.chat-page-header-left, .chat-page-header-right { width: 120px; }
.chat-page-header-center {
    display: flex;
    align-items: center;
    gap: 10px;
}
.chat-page-teacher-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-1);
}
.change-teacher-btn {
    background: none;
    border: 1px solid var(--border-2);
    border-radius: var(--r-full);
    padding: 5px 12px;
    font-size: 0.78rem;
    color: var(--text-2);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.change-teacher-btn:hover { background: var(--bg-2); color: var(--text-1); }

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

.chat-page-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .chat-page-interface { height: calc(100vh - 100px); }
    .change-teacher-btn { font-size: 0.72rem; padding: 4px 8px; }
    .chat-page-header-left, .chat-page-header-right { width: 80px; }
}
