/* =========================================================
   Chat K plus - Complete CSS (2026-06-19 v3.6 배타2)
   v3.6 배타1 기반 + 스크롤 겹침 수정
   ========================================================= */

/* ==========================================
 * 0. CSS 변수 정의 (라이트 테마)
 * ========================================== */
:root {
    /* 라이트 컬러 */
    --bg-primary: #ffffff;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f8f8f8;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-input: #ffffff;
    --bg-hover: rgba(0, 0, 0, 0.04);
    
    /* 텍스트 컬러 */
    --text-primary: #000000;
    --text-secondary: rgba(0, 0, 0, 0.65);
    --text-muted: rgba(0, 0, 0, 0.45);
    --text-disabled: rgba(0, 0, 0, 0.3);
    
    /* 악센트 - 블랙 미니멀 */
    --accent-primary: #000000;
    --accent-secondary: #333333;
    --accent-tertiary: #666666;
    --accent-gradient: linear-gradient(135deg, #000000 0%, #222222 100%);
    --accent-accent: rgba(0, 0, 0, 0.1);
    --accent-glow: rgba(0, 0, 0, 0.08);
    
    /* 기능 컬러 */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    
    /* 보더 */
    --border-subtle: rgba(0, 0, 0, 0.06);
    --border-medium: rgba(0, 0, 0, 0.12);
    --border-strong: rgba(0, 0, 0, 0.18);
    --border-accent: rgba(0, 0, 0, 0.2);
    
    /* 그림자 - 매우 은은하게 */
    --shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-strong: 0 8px 24px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 0 rgba(0, 0, 0, 0);
    --shadow-inner: inset 0 1px 0 rgba(0, 0, 0, 0.03);
    
    /* 모던한 그림자 */
    --shadow-modern: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-modern-hover: 0 12px 40px rgba(0, 0, 0, 0.15);
    --shadow-3d: 0 12px 40px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-3d-hover: 0 16px 48px rgba(0, 0, 0, 0.18), 0 6px 16px rgba(0, 0, 0, 0.1);
    
    /* 입력바 디테일 그림자 */
    --shadow-input-detail: 0 2px 8px rgba(0, 0, 0, 0.04), 0 1px 4px rgba(0, 0, 0, 0.02);
    --shadow-input-detail-hover: 0 4px 16px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-input-detail-focus: 0 6px 24px rgba(0, 0, 0, 0.08), 0 3px 12px rgba(0, 0, 0, 0.06), 0 0 0 3px rgba(0, 0, 0, 0.05);
    
    /* 버튼 그림자 */
    --shadow-btn: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.04);
    --shadow-btn-hover: 0 4px 16px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-btn-active: 0 1px 4px rgba(0, 0, 0, 0.06), 0 0.5px 2px rgba(0, 0, 0, 0.03);
    
    /* 원형 틀 그림자 */
    --shadow-circle-frame: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.03);
    --shadow-circle-frame-hover: 0 4px 12px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.05);
    
    /* 채팅방/입력바 떠 있는 느낌 */
    --shadow-floating: 0 8px 24px rgba(0,0,0,0.08);
    --shadow-floating-hover: 0 12px 32px rgba(0,0,0,0.12);
    --shadow-floating-focus: 0 12px 32px rgba(0,0,0,0.12);
    
    /* 둥근 모서리 */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* 트랜지션 */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
    
    /* 블러 효과 - 라이트에서는 최소화 */
    --blur-subtle: blur(8px);
    --blur-medium: blur(12px);
    --blur-strong: blur(16px);
    
    /* 모던한 블러 효과 */
    --blur-modern: blur(20px);
    --blur-glass: blur(30px);
}

/* ==========================================
 * 1. 기본 리셋 스타일
 * ========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    font-weight: 400;
    overflow: hidden;
}

html, body {
    height: 100%;
}

/* ==========================================
 * 2. 앱 컨테이너
 * ========================================== */
.app-container {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-primary);
    position: relative;
}

.app-container::before {
    display: none;
}

/* ==========================================
 * 3. 검색 화면
 * ========================================== */
#search-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background: #ffffff;
    position: relative;
    overflow: hidden;
}

#search-view::before {
    display: none;
}

.search-content {
    width: 100%;
    max-width: 680px;
    text-align: center;
    position: relative;
    z-index: 1;
    animation: slideUp 0.8s ease-out;
}

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

.logo {
    font-size: 64px;
    margin-bottom: 24px;
    background: linear-gradient(135deg, #000000 0%, #333333 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.title {
    font-size: 42px;
    font-weight: 800;
    color: #000000;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.beta-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.08);
    color: #000000;
    font-size: 11px;
    font-weight: 700;
    border-radius: 20px;
    margin-left: 8px;
    vertical-align: middle;
    border: 1px solid rgba(0, 0, 0, 0.12);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.search-container {
    width: 100%;
    margin-bottom: 32px;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 24px 28px;
    padding-right: 72px;
    border: 2px solid rgba(0, 0, 0, 0.12);
    border-radius: 32px;
    font-size: 20px;
    background: #ffffff;
    color: #000000;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-input-detail);
    line-height: 1.4;
}

.search-input::placeholder {
    color: rgba(0, 0, 0, 0.5);
    font-weight: 400;
}

.search-input:hover {
    box-shadow: var(--shadow-input-detail-hover);
    border-color: rgba(0, 0, 0, 0.18);
    transform: translateY(-2px);
}

.search-input:focus {
    outline: none;
    border-color: #000000;
    box-shadow: var(--shadow-input-detail-focus);
    transform: translateY(-2px) scale(1.005);
    background: #ffffff;
}

.search-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 24px;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-btn);
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-btn:hover:not(:disabled) {
    transform: translateY(-50%) scale(1.1);
    box-shadow: var(--shadow-btn-hover);
}

.search-btn:active:not(:disabled) {
    transform: translateY(-50%) scale(0.95);
    box-shadow: var(--shadow-btn-active);
}

.search-btn:disabled {
    background: rgba(0, 0, 0, 0.15);
    cursor: not-allowed;
    opacity: 0.5;
}

.examples {
    margin-top: 40px;
}

.examples-title {
    color: rgba(0, 0, 0, 0.7);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.example-btn {
    padding: 14px 24px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-lg);
    font-size: 15px;
    font-weight: 500;
    color: #000000;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-subtle);
}

.example-btn:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.25);
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

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

.app-footer {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(0, 0, 0, 0.5);
    font-size: 13px;
    font-weight: 500;
}

.hidden {
    display: none !important;
}

/* ==========================================
 * 4. 채팅 화면
 * ========================================== */
#chat-view {
    display: none;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-primary);
    position: relative;
    z-index: 1;
}

#chat-view:not(.hidden) {
    display: flex;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 20px;
    background: var(--bg-primary);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: 2px solid var(--text-primary);
    box-shadow: none;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.chat-header-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.back-btn {
    position: absolute;
    left: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-normal);
}

.back-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-primary);
}

/* [수정됨 v3.6 배타2] 채팅 박스 - 스크롤 겹침 수정 */
.chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px 120px 20px; /* 하단 패딩 증가 */
    background: var(--bg-primary);
    scroll-behavior: smooth;
    min-height: 0;
    overscroll-behavior: contain; /* 스크롤 체이닝 방지 */
}

.chat-box::-webkit-scrollbar {
    width: 6px; /* 스크롤바 너비 증가 */
}

.chat-box::-webkit-scrollbar-track {
    background: transparent;
    margin: 4px 0; /* 스크롤바 트랙 여백 */
}

.chat-box::-webkit-scrollbar-thumb {
    background: #e0e0e0;
    border-radius: 3px;
    margin: 4px 0; /* 스크롤바 썸 여백 */
}

.chat-box.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}

.chat-box.empty::before {
    content: '';
    display: none;
}

.chat-box.empty::after {
    content: '';
    display: none;
}

.message {
    margin-bottom: 16px;
    padding: 14px 18px;
    border-radius: 18px;
    max-width: 85%;
    animation: messageAppear 0.25s ease-out;
}

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

.user-msg {
    background: var(--text-primary);
    color: var(--bg-primary);
    margin-left: auto;
    border-bottom-right-radius: 6px;
}

.ai-msg {
    background: #f5f5f5;
    color: var(--text-primary);
    border: 1px solid #eeeeee;
    border-bottom-left-radius: 6px;
}

.thinking {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #f5f5f5;
    border-radius: 18px;
    border: 1px solid #eeeeee;
}

.thinking-icon {
    width: 20px;
    height: 20px;
    border: 2.5px solid var(--text-primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: thinkingSpin 1s linear infinite;
}

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

.thinking-text {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

/* ==========================================
 * 5. 채팅 입력바
 * ========================================== */
.chat-footer {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 12px 20px calc(16px + env(safe-area-inset-bottom));
    background: transparent;
    border-top: none;
    box-shadow: none;
    position: sticky;
    bottom: 0;
    z-index: 200;
    flex-shrink: 0;
}

.input-wrapper-modern {
    width: 100%;
    position: relative;
    background: #ffffff;
    border: 2px solid #e5e5e5;
    border-radius: 48px;
    padding: 18px 22px 16px 24px;
    box-shadow: var(--shadow-floating);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.input-wrapper-modern::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, 
        rgba(0, 0, 0, 0.02) 0%, 
        rgba(0, 0, 0, 0.01) 50%, 
        rgba(0, 0, 0, 0.02) 100%);
    pointer-events: none;
    z-index: 0;
}

.input-wrapper-modern::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    opacity: 0;
    transition: opacity var(--transition-normal);
    pointer-events: none;
    z-index: 1;
}

.input-wrapper-modern:hover::after {
    opacity: 1;
}

.input-wrapper-modern:hover {
    box-shadow: var(--shadow-floating-hover);
    border-color: rgba(0, 0, 0, 0.25);
    transform: translateY(-2px);
}

.input-wrapper-modern:focus-within {
    border-color: #000000;
    box-shadow: var(--shadow-floating-focus), 0 0 0 4px rgba(0, 0, 0, 0.1);
    background: #ffffff;
    transform: translateY(-2px);
}

.input-top {
    width: 100%;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    z-index: 2;
}

.chat-input {
    flex: 1;
    padding: 10px 0 12px 0;
    border: none;
    font-size: 18px;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    line-height: 1.4;
    background: transparent;
    color: #000000;
    font-family: inherit;
    z-index: 2;
}

.chat-input::placeholder {
    color: #757575;
    font-weight: 400;
}

.chat-input:focus {
    outline: none;
    border: none;
    background: transparent;
    box-shadow: none;
}

.circular-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding: 6px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 24px;
    border: 2px solid #000000;
    box-shadow: var(--shadow-circle-frame);
    z-index: 2;
    position: relative;
}

.circular-buttons::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(0, 0, 0, 0.1) 0%, transparent 70%);
    opacity: 0;
    transition: opacity var(--transition-normal);
    pointer-events: none;
    z-index: 0;
}

.circular-buttons:hover::before {
    opacity: 1;
}

.circular-btn {
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid #e5e5e5;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666666;
    transition: all var(--transition-normal);
    flex-shrink: 0;
    box-shadow: var(--shadow-btn);
    z-index: 2;
    position: relative;
}

.circular-btn::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(0, 0, 0, 0.1) 0%, transparent 70%);
    opacity: 0;
    transition: opacity var(--transition-normal);
    pointer-events: none;
    z-index: 0;
}

.circular-btn:hover::before {
    opacity: 1;
}

.circular-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    border-color: #000000;
    transform: scale(1.15);
    color: #000000;
    box-shadow: var(--shadow-btn-hover);
}

.circular-btn:active {
    transform: scale(0.95);
    box-shadow: var(--shadow-btn-active);
}

.input-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-top: 12px;
    z-index: 2;
}

.controls-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.icon-btn {
    width: 40px;
    height: 40px;
    background: transparent;
    border: 2px solid #000000;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666666;
    transition: all var(--transition-normal);
    flex-shrink: 0;
    z-index: 2;
    position: relative;
}

.icon-btn::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(0, 0, 0, 0.1) 0%, transparent 70%);
    opacity: 0;
    transition: opacity var(--transition-normal);
    pointer-events: none;
    z-index: 0;
}

.icon-btn:hover::before {
    opacity: 1;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    transform: scale(1.15);
    color: #000000;
    box-shadow: var(--shadow-btn);
}

.icon-btn:active {
    transform: scale(0.95);
    box-shadow: var(--shadow-btn-active);
}

.difficulty-select {
    padding: 12px 36px 12px 14px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%23666' d='M5 7L2 3h6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    z-index: 2;
}

.send-circle,
.stop-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e5e5e5;
    color: #a9a8af;
    transition: all var(--transition-normal);
    flex-shrink: 0;
    box-shadow: var(--shadow-btn);
    z-index: 2;
    position: relative;
}

.send-circle::before,
.stop-circle::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(0, 0, 0, 0.1) 0%, transparent 70%);
    opacity: 0;
    transition: opacity var(--transition-normal);
    pointer-events: none;
    z-index: 0;
}

.send-circle:hover::before,
.stop-circle:hover::before {
    opacity: 1;
}

.send-circle:not(:disabled) {
    background: #000000;
    color: #ffffff;
    box-shadow: var(--shadow-btn-hover);
}

.send-circle:not(:disabled):hover {
    transform: scale(1.15);
    background: #222222;
    box-shadow: var(--shadow-btn-hover);
}

.send-circle:disabled {
    cursor: not-allowed;
    opacity: 1;
    transform: none;
}

.stop-circle {
    border-color: #ef4444;
    color: #ef4444;
}

.stop-circle:hover {
    background: #ef4444;
    color: white;
    box-shadow: var(--shadow-btn-hover);
}

/* 모바일 최적화 */
@supports (-webkit-touch-callout: none) {
    .chat-footer {
        padding: 10px 18px calc(14px + env(safe-area-inset-bottom));
    }
    
    .input-wrapper-modern {
        padding: 16px 20px 14px 22px;
        border-radius: 44px;
    }
    
    .chat-input {
        min-height: 40px;
        font-size: 17px;
    }
    
    .circular-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .icon-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .send-circle,
    .stop-circle {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 768px) {
    .chat-header {
        padding: 16px;
    }

    .chat-header-title {
        font-size: 18px;
    }

    .chat-box {
        padding: 20px 16px 100px 16px; /* 하단 패딩 조정 */
    }

    .message {
        max-width: 90%;
        padding: 12px 16px;
        margin-bottom: 12px;
    }

    .input-wrapper-modern {
        padding: 16px 20px 14px 22px;
        border-radius: 44px;
    }

    .chat-input {
        min-height: 40px;
        font-size: 17px;
    }

    .circular-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .icon-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .send-circle,
    .stop-circle {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    .chat-header {
        padding: 14px 16px;
    }

    .chat-header-title {
        font-size: 16px;
    }

    .back-btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    .chat-box {
        padding: 16px 12px 80px 12px; /* 하단 패딩 조정 */
    }

    .message {
        max-width: 95%;
        padding: 10px 14px;
        margin-bottom: 10px;
    }

    .input-wrapper-modern {
        padding: 14px 18px 12px 20px;
        border-radius: 40px;
    }

    .chat-input {
        min-height: 36px;
        font-size: 16px;
    }

    .circular-btn {
        width: 32px;
        height: 32px;
        font-size: 15px;
    }

    .icon-btn {
        width: 32px;
        height: 32px;
        font-size: 15px;
    }

    .send-circle,
    .stop-circle {
        width: 36px;
        height: 36px;
    }
}

@media (max-width: 360px) {
    .chat-box {
        padding: 14px 10px 70px 10px; /* 하단 패딩 조정 */
    }
    
    .input-wrapper-modern {
        padding: 12px 16px 10px 18px;
        border-radius: 36px;
    }

    .chat-input {
        min-height: 34px;
        font-size: 15px;
    }

    .circular-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .icon-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .send-circle,
    .stop-circle {
        width: 34px;
        height: 34px;
    }
}

.chat-footer.keyboard-open {
    padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
}

@media (max-height: 500px) and (orientation: landscape) {
    .chat-footer {
        padding: 6px 16px calc(8px + env(safe-area-inset-bottom));
    }
    
    .chat-box {
        padding: 8px 8px 60px 8px; /* 하단 패딩 조정 */
    }
    
    .input-wrapper-modern {
        padding: 12px 16px 10px 18px;
        border-radius: 36px;
    }
    
    .chat-input {
        min-height: 34px;
        font-size: 15px;
    }
    
    .circular-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
    
    .icon-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
    
    .send-circle,
    .stop-circle {
        width: 34px;
        height: 34px;
    }
}

/* ==========================================
 * 6. 외부 링크 및 정책 경고
 * ========================================== */
.external-link {
    color: #000000;
    text-decoration: none;
    border-bottom: 1px solid #000000;
    transition: all var(--transition-fast);
    position: relative;
}

.external-link::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 0;
    height: 1px;
    background: #000000;
    transition: width var(--transition-normal);
}

.external-link:hover {
    color: #000000;
}

.external-link:hover::after {
    width: 100%;
}

.policy-warning {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    color: #c53030;
    padding: 18px 22px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    box-shadow: var(--shadow-subtle);
}

/* ==========================================
 * 7. 모달 공통
 * ========================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    background: #fafafa;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid #d0d0d0;
    border-radius: var(--radius-xl);
    padding: 32px;
    max-width: 500px;
    width: 90%;
    z-index: 1001;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    animation: modalAppear 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(0, 0, 0, 0.15) 30%, 
        rgba(0, 0, 0, 0.15) 70%, 
        transparent 100%);
    opacity: 0.5;
}

.close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 10;
}

.close-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
    transform: scale(1.1);
    border-color: rgba(0, 0, 0, 0.15);
}

.close-btn:active {
    transform: scale(0.95);
    background: rgba(0, 0, 0, 0.15);
}

.close-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

/* ==========================================
 * 8. 시간표 모달
 * ========================================== */
.timetable-modal {
    max-width: 560px;
}

.timetable-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    padding-right: 44px;
}

.timetable-header h3 {
    font-size: 26px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.timetable-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 24px;
    background: rgba(0, 0, 0, 0.04);
    padding: 6px;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.tab {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.tab::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.tab:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.06);
}

.tab.active {
    color: white;
    box-shadow: var(--shadow-subtle);
}

.tab.active::before {
    opacity: 1;
}

.tab span {
    position: relative;
    z-index: 1;
}

.timetable-content {
    max-height: 340px;
    overflow-y: auto;
    margin-bottom: 24px;
    padding: 8px;
}

.timetable-content::-webkit-scrollbar {
    width: 4px;
}

.timetable-content::-webkit-scrollbar-track {
    background: transparent;
}

.timetable-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
}

.timetable-empty {
    text-align: center;
    padding: 56px 24px;
    color: var(--text-muted);
    font-size: 15px;
    font-weight: 500;
}

.timetable-item {
    display: flex;
    gap: 16px;
    padding: 18px;
    background: #f5f5f5;
    border: 1px solid #e8e8e8;
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    transition: all var(--transition-normal);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.timetable-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.timetable-item:hover {
    background: #f0f0f0;
    border-color: #d8d8d8;
    transform: translateX(4px);
    box-shadow: var(--shadow-subtle);
}

.timetable-item:hover::before {
    opacity: 1;
}

.timetable-time {
    flex: 0 0 110px;
    font-weight: 700;
    color: var(--accent-primary);
    font-size: 15px;
    display: flex;
    align-items: center;
    letter-spacing: 0.02em;
}

.timetable-subject {
    flex: 1;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 16px;
    display: flex;
    align-items: center;
}

.timetable-room {
    flex: 0 0 90px;
    color: var(--text-primary);
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: var(--radius-md);
    font-weight: 700;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: var(--shadow-subtle);
}

.timetable-footer {
    margin-top: 20px;
}

.timetable-add {
    width: 100%;
    padding: 18px;
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-medium);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.timetable-add::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.2) 0%, 
        transparent 50%);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.timetable-add:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-strong);
}

.timetable-add:hover::before {
    opacity: 1;
}

.timetable-add:active {
    transform: translateY(0);
}

/* ==========================================
 * 9. 수업 추가 모달
 * ========================================== */
.add-class-modal {
    max-width: 460px;
}

.add-class-modal h3 {
    font-size: 26px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 28px;
    padding-right: 44px;
    letter-spacing: -0.02em;
}

.form-group {
    margin-bottom: 22px;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.01em;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 16px 18px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-lg);
    font-size: 15px;
    transition: all var(--transition-normal);
    background: #ffffff;
    color: var(--text-primary);
    font-family: inherit;
    box-shadow: var(--shadow-inner);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.1);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='rgba(0,0,0,0.6)' d='M7 10L2 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 44px;
}

.form-group select option {
    background: #ffffff;
    color: var(--text-primary);
    padding: 12px;
}

.modal-buttons {
    display: flex;
    gap: 14px;
    margin-top: 32px;
}

.modal-btn {
    flex: 1;
    padding: 18px;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.modal-btn.cancel {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.modal-btn.cancel:hover {
    background: rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
    box-shadow: var(--shadow-subtle);
}

.modal-btn.go,
.modal-btn.save {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-medium);
}

.modal-btn.go::before,
.modal-btn.save::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.2) 0%, 
        transparent 50%);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.modal-btn.go:hover,
.modal-btn.save:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-strong);
}

.modal-btn.go:hover::before,
.modal-btn.save:hover::before {
    opacity: 1;
}

/* ==========================================
 * 10. 링크 경고 모달
 * ========================================== */
#linkModal .modal-url {
    word-break: break-all;
    color: #000000;
    margin: 18px 0;
    padding: 18px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 500;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: var(--shadow-subtle);
}
