/* ========== 布局系统 ========== */

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    position: relative;
    overflow: hidden;
}

/* 顶部栏 */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    padding-top: max(var(--space-md), env(safe-area-inset-top));
    background: var(--cream);
    border-bottom: 3px solid var(--stroke);
    flex-shrink: 0;
    z-index: 10;
}

.header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.app-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--stroke);
    letter-spacing: 0.5px;
}

.current-model {
    font-size: 0.7rem;
    color: var(--text-light);
    background: var(--white);
    padding: 2px 10px;
    border-radius: var(--radius-full);
    border: 2px solid var(--stroke);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 聊天主区域 */
.chat-main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    padding: var(--space-md);
    padding-bottom: var(--space-lg);
    display: flex;
    flex-direction: column;
}

/* 欢迎页 */
.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: var(--space-xl);
}

.welcome-bubble {
    background: var(--white);
    border: 3px solid var(--stroke);
    border-radius: var(--radius-xl);
    padding: var(--space-xxl);
    text-align: center;
    box-shadow: var(--shadow);
    max-width: 320px;
    width: 100%;
}

.welcome-icon {
    margin-bottom: var(--space-lg);
    animation: float 3s ease-in-out infinite;
}

.welcome-bubble h1 {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--stroke);
    margin-bottom: var(--space-sm);
}

.welcome-bubble p {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: var(--space-xl);
}

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

/* 聊天消息容器 */
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    flex: 1;
}

/* 底部输入区 */
.chat-footer {
    flex-shrink: 0;
    background: var(--white);
    border-top: 3px solid var(--stroke);
    padding: var(--space-md) var(--space-lg);
    padding-bottom: max(var(--space-md), env(safe-area-inset-bottom));
    z-index: 10;
}

.input-toolbar {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.input-box {
    display: flex;
    align-items: flex-end;
    gap: var(--space-sm);
    background: var(--bg);
    border: 2px solid var(--stroke);
    border-radius: var(--radius-lg);
    padding: var(--space-sm) var(--space-md);
    box-shadow: var(--shadow-soft);
}

.input-box textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text);
    line-height: 1.5;
    max-height: 120px;
    min-height: 24px;
    outline: none;
}

.input-box textarea::placeholder {
    color: var(--text-light);
}

/* 面板通用 */
.panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 420px;
    height: 100vh;
    height: 100dvh;
    background: var(--bg);
    border-left: 3px solid var(--stroke);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: translateX(0);
}

.panel.hidden {
    transform: translateX(100%);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    padding-top: max(var(--space-md), env(safe-area-inset-top));
    background: var(--cream);
    border-bottom: 3px solid var(--stroke);
    flex-shrink: 0;
}

.panel-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--stroke);
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
}

/* 遮罩层 */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(93, 64, 55, 0.3);
    z-index: 90;
    backdrop-filter: blur(2px);
    transition: opacity 0.3s;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* 弹窗 */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(93, 64, 55, 0.4);
    backdrop-filter: blur(3px);
}

.modal-content {
    position: relative;
    background: var(--white);
    border: 3px solid var(--stroke);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    background: var(--mint);
    border-bottom: 2px solid var(--stroke);
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 800;
    color: var(--stroke);
}

.modal-body {
    padding: var(--space-lg);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    gap: var(--space-md);
    justify-content: flex-end;
    padding: var(--space-md) var(--space-lg);
    border-top: 2px solid var(--stroke-light);
    background: var(--bg);
}
