/* ============================================
   Design System - CSS Custom Properties
   ============================================ */
:root {
    --bg-primary: #0d0d0d;
    --bg-secondary: #1a1a1a;
    --bg-sidebar: #1a1a2e;
    --bg-input: #1e1e1e;
    --bg-hover: #2a2a2a;
    --bg-message-assistant: #1a1a24;
    --bg-thinking: #12122a;
    --bg-code: #161622;
    --bg-modal: #1e1e2e;

    --text-primary: #e8e8e8;
    --text-secondary: #a0a0a0;
    --text-muted: #666;
    --text-thinking: #b8b0e0;

    --accent: #4a9eff;
    --accent-hover: #3a8eef;
    --accent-thinking: #7c6fe0;
    --border: #2a2a3a;
    --border-light: #333;

    --sidebar-width: 260px;
    --header-height: 56px;
    --input-max-height: 200px;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --transition: 0.2s ease;
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

html {
    height: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    flex-direction: row;
    overflow: hidden;
    /* 모바일 브라우저 주소창을 제외한 실제 보이는 영역에 맞춤 */
    height: 100vh;         /* fallback */
    height: 100dvh;        /* dynamic viewport height — 주소창 표시 여부에 따라 동적 조정 */
    /* 노치/홈 인디케이터 기기 대응 */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    font-size: 15px;
    line-height: 1.6;
}

/* Overlay elements must not participate in flex layout */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;         /* fallback */
    height: 100dvh;
    overflow: hidden;
    width: var(--sidebar-width);
    transition:
        width 0.3s ease,
        transform 0.3s ease;
    flex-shrink: 0;
}

body.sidebar-collapsed .sidebar {
    width: 0;
    border-right: none;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 18px;
    color: var(--accent);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
    color: var(--text-secondary);
    font-size: 14px;
    gap: 8px;
}

.chat-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.chat-item.active {
    background: rgba(74, 158, 255, 0.1);
    color: var(--text-primary);
}

.chat-item-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-item-delete {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    transition: all var(--transition);
    display: flex;
    align-items: center;
}

.chat-item:hover .chat-item-delete {
    opacity: 1;
}

.chat-item-delete:hover {
    color: #ff6b6b;
}

.sidebar-footer {
    padding: 8px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.btn-sidebar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font);
    transition: all var(--transition);
    width: 100%;
    text-align: left;
}

.btn-sidebar:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

/* ============================================
   Main Area
   ============================================ */
.main {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}

.chat-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    flex-shrink: 0;
}

.chat-title {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: all var(--transition);
    outline: none;
    cursor: text;
}

.chat-title:hover {
    background: rgba(255, 255, 255, 0.05);
}

.chat-title:focus {
    background: var(--bg-input);
    border-color: var(--accent);
}

.model-select {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 12px;
    outline: none;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}

.model-select:hover,
.model-select:focus {
    border-color: var(--accent);
    color: var(--text-primary);
}

.model-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.toggle-sidebar-btn {
    flex-shrink: 0;
}

/* Chat Config Panel */
.chat-config {
    padding: 14px 20px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-config-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-config-row label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.chat-config-row textarea {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    min-height: 36px;
    outline: none;
    transition: border-color var(--transition);
}

.chat-config-row textarea:focus {
    border-color: var(--accent);
}

.chat-config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
    align-items: center;
}

.chat-config-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-config-item label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.chat-config-item input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
}

.chat-config-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

.chat-config-item input[type="number"] {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    outline: none;
    width: 100%;
}

.chat-config-item input[type="number"]:focus {
    border-color: var(--accent);
}

.chat-config-item.toggle-group {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

/* ============================================
   Messages
   ============================================ */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
}

.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    opacity: 0.6;
}

.welcome h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.welcome p {
    color: var(--text-secondary);
    font-size: 14px;
}

.message {
    padding: 16px 24px;
    max-width: 960px;
    margin: 0 auto;
    width: 100%;
}

.message.user {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.message-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
    justify-content: flex-end;
}

.message-image {
    max-width: 300px;
    max-height: 300px;
    border-radius: var(--radius-sm);
    object-fit: contain;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
}

.message.user .message-bubble {
    background: var(--accent);
    color: #fff;
    padding: 10px 16px;
    border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
    max-width: 75%;
    word-break: break-word;
}

.user-message-details {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.user-message-summary {
    background: var(--accent);
    color: #fff;
    padding: 10px 16px;
    border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
    cursor: pointer;
    font-size: 14px;
    opacity: 0.9;
    list-style: none;
    user-select: none;
    word-break: break-word;
}

.user-message-summary::-webkit-details-marker {
    display: none;
}

.user-message-summary:hover {
    opacity: 1;
}

.user-message-details[open] .user-message-summary {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin-bottom: 2px;
}

.user-message-details[open] .message-bubble {
    border-radius: 4px 0 4px var(--radius-lg);
    width: 100%;
}

.user-message-details .message-bubble.message-content {
    background: rgba(74, 158, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--accent);
    padding: 14px;
}

.btn-retry {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    opacity: 0;
    transition: all var(--transition);
}

.message.user:hover .btn-retry {
    opacity: 1;
}

.btn-retry:hover {
    color: var(--accent);
    background: rgba(255, 255, 255, 0.05);
}

.message.assistant {
    background: var(--bg-message-assistant);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    max-width: 100%;
}

.message.assistant .message-inner {
    max-width: 960px;
    margin: 0 auto;
}

.message-role {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.message-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
    text-align: right;
}

.message.assistant .message-role {
    color: var(--accent);
}

/* ============================================
   Thinking Block
   ============================================ */
.thinking-block {
    background: var(--bg-thinking);
    border: 1px solid rgba(124, 111, 224, 0.2);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    overflow: hidden;
}

.thinking-block summary {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    color: var(--accent-thinking);
    font-weight: 500;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.thinking-block summary::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-right: 2px solid var(--accent-thinking);
    border-bottom: 2px solid var(--accent-thinking);
    transform: rotate(-45deg);
    transition: transform var(--transition);
}

.thinking-block[open] summary::before {
    transform: rotate(45deg);
}

.thinking-block summary::-webkit-details-marker {
    display: none;
}

.thinking-content {
    padding: 0 30px 12px;
    color: var(--text-thinking);
    font-size: 13px;
    line-height: 1.7;
    border-top: 1px solid rgba(124, 111, 224, 0.1);
}

.thinking-content p {
    margin-bottom: 8px;
}

/* Streaming indicator */
.thinking-block.streaming summary::after {
    content: "";
    width: 8px;
    height: 8px;
    background: var(--accent-thinking);
    border-radius: 50%;
    animation: pulse 1s infinite;
    margin-left: auto;
}

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

/* ============================================
   Markdown Content
   ============================================ */
.message-content {
    line-height: 1.7;
}

.message-content p {
    margin-bottom: 12px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul,
.message-content ol {
    margin: 8px 0 12px 20px;
}

.message-content li {
    margin-bottom: 4px;
}

.message-content strong {
    font-weight: 600;
}

.message-content h1,
.message-content h2,
.message-content h3 {
    margin: 16px 0 8px;
}

.message-content h1 {
    font-size: 1.4em;
}
.message-content h2 {
    font-size: 1.2em;
}
.message-content h3 {
    font-size: 1.1em;
}

.message-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 12px;
    color: var(--text-secondary);
    margin: 8px 0;
}

.message-content table {
    border-collapse: collapse;
    margin: 12px 0;
    width: 100%;
}

.message-content th,
.message-content td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
}

.message-content th {
    background: var(--bg-hover);
    font-weight: 600;
}

/* Inline code */
.message-content code:not(pre code) {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: "Cascadia Code", "Fira Code", monospace;
}

/* Code blocks (collapsible) */
.code-block {
    position: relative;
    margin: 12px 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-code);
    border: 1px solid var(--border);
    word-break: normal;
    overflow-wrap: normal;
    min-width: 0;
}

.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
    user-select: none;
    flex-wrap: wrap;
    gap: 8px;
}

.code-filename {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-family: "Cascadia Code", "Fira Code", monospace;
    flex: 1 1 auto;
    min-width: 0;
}

.code-body {
    position: relative;
}

.code-body.code-collapsed {
    max-height: 76px;
    overflow: hidden;
}

.code-fade {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(transparent, var(--bg-code));
    pointer-events: none;
}

.btn-expand {
    display: block;
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: none;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 14px;
    font-size: 12px;
    font-family: var(--font);
    text-align: center;
    transition: background var(--transition), color var(--transition);
}

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

.code-actions {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.btn-copy {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-family: var(--font);
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-copy:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.btn-copy.copied {
    color: #4ade80;
    border-color: #4ade80;
}

.code-block pre {
    margin: 0;
    padding: 14px;
    overflow-x: auto;
}

.code-block pre code {
    font-family: "Cascadia Code", "Fira Code", monospace;
    font-size: 13px;
    line-height: 1.5;
}

/* ============================================
   Input Area
   ============================================ */
.input-area {
    padding: 16px 24px 24px;
    flex-shrink: 0;
}

.input-container {
    max-width: 960px;
    margin: 0 auto;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition);
    overflow: hidden;
}

.input-container:focus-within {
    border-color: var(--accent);
}

.image-preview-container {
    display: flex;
    gap: 8px;
    padding: 12px 16px 0;
    flex-wrap: wrap;
}

.image-preview-item {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
}

.file-preview-item {
    width: 120px;
    flex-direction: column;
    padding: 8px;
    gap: 4px;
}

.file-icon {
    font-size: 24px;
    line-height: 1;
}

.file-name {
    font-size: 10px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: center;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
}

.image-preview-remove:hover {
    background: #ff4757;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: flex-end;
    padding: 4px 4px 4px 16px;
}

#btnAttach {
    align-self: center;
}

#userInput {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    padding: 10px 0;
    max-height: var(--input-max-height);
    outline: none;
}

#userInput::placeholder {
    color: var(--text-muted);
}

.btn-send,
.btn-stop {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
}

.btn-send {
    background: var(--accent);
    color: white;
}

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

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

.btn-stop {
    background: #ff4757;
    color: white;
}

.btn-stop:hover {
    background: #ff6b6b;
}

/* ============================================
   Buttons
   ============================================ */
.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

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

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-modal);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.setting-group input[type="password"],
.setting-group input[type="text"],
.setting-group input[type="number"] {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}

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

.setting-group input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
}

.setting-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

.setting-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.toggle-group {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border);
    border-radius: 12px;
    transition: var(--transition);
}

.toggle-slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
}

.toggle input:checked + .toggle-slider {
    background: var(--accent);
}

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

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

/* Streaming cursor */
.streaming-cursor::after {
    content: "";
    display: inline-block;
    width: 7px;
    height: 18px;
    background: var(--accent);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 0.8s infinite;
}

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

/* ============================================
   Responsive - Mobile
   ============================================ */
@media (max-width: 768px) {
    /* Sidebar: slide-over panel */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: var(--sidebar-width) !important;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease !important;
        border-right: 1px solid var(--border) !important;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Header */
    .chat-header {
        height: auto;
        min-height: var(--header-height);
        padding: 8px 12px;
        gap: 8px;
        flex-wrap: wrap;
    }

    .chat-title {
        font-size: 14px;
        order: 2;
        flex: 1 1 0;
        min-width: 0;
    }

    .model-select {
        order: 3;
        font-size: 11px;
        padding: 4px 6px;
        max-width: 130px;
    }

    #btnChatConfig {
        order: 4;
    }

    /* Chat config panel */
    .chat-config {
        padding: 12px 16px;
    }

    .chat-config-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* Messages */
    .messages {
        padding: 12px 0;
    }

    .message {
        padding: 10px 16px;
    }

    .message.assistant .message-inner {
        padding: 0;
    }

    .message.user .message-bubble,
    .user-message-details {
        max-width: 90%;
    }

    .message-image {
        max-width: 220px;
        max-height: 220px;
    }

    /* Welcome screen */
    .welcome h2 {
        font-size: 20px;
    }

    .welcome p {
        font-size: 13px;
    }

    /* Code blocks */
    .code-block pre {
        padding: 10px;
    }

    .code-block pre code {
        font-size: 12px;
    }

    .code-header {
        padding: 8px 12px;
    }

    .code-body.code-collapsed {
        max-height: 64px;
    }

    /* Input area — 홈 인디케이터 겹침 방지 */
    .input-area {
        padding: 8px 12px calc(16px + env(safe-area-inset-bottom));
    }

    .input-wrapper {
        padding: 4px 4px 4px 12px;
    }

    #userInput {
        font-size: 14px;
    }

    /* Modals */
    .modal {
        width: 95%;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-header {
        padding: 16px;
    }
}
