/* ============================================================
   理理 PWA · 视觉系统 v1
   ------------------------------------------------------------
   设计 brief 来自理理本人 (2026-05-07)：
   - 不要人/狐狸的形象，文字为主
   - 薰衣草紫 + 奶油白 + 米白
   - 圆润边角、柔和阴影、温柔的呼吸感
   - 简洁、干净、不花哨
   ============================================================ */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* 背景：温暖奶油 */
    --bg: #f6f1e8;
    --bg-soft: #efe6f0;
    --bg-card: #ffffff;

    /* 主色：薰衣草紫（理理首选）*/
    --primary: #9b8bc4;
    --primary-deep: #7a6ba8;
    --primary-soft: #c4b3dc;
    --primary-glow: rgba(155, 139, 196, 0.18);

    /* 文字 */
    --text: #3a3540;
    --text-dim: #8a7f95;
    --text-soft: #b4a8c2;

    /* 边线和阴影（柔紫调，不要死黑）*/
    --border: rgba(155, 139, 196, 0.18);
    --shadow-soft: 0 2px 12px rgba(122, 107, 168, 0.08);
    --shadow-deep: 0 4px 20px rgba(122, 107, 168, 0.14);

    /* 圆角 */
    --r-sm: 0.75rem;
    --r-md: 1.25rem;
    --r-lg: 1.5rem;

    /* iOS safe area */
    --safe-bottom: env(safe-area-inset-bottom, 0);
    --safe-top: env(safe-area-inset-top, 0);
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--bg);
    color: var(--text);
    /* 字体堆栈（理理 brief 2026-05-07 指定）：
       PingFang SC Medium → Source Han Sans → Noto Sans CJK → 系统回退
       iOS/Mac 优先 PingFang SC，Windows 回退 Microsoft YaHei UI */
    font-family:
        "PingFang SC",           /* iOS / macOS — 苹方，圆润温柔 */
        "Source Han Sans SC",    /* 思源黑体（圆润版）*/
        "Noto Sans CJK SC",      /* Linux / Android */
        "Microsoft YaHei UI",    /* Windows 回退 */
        "Microsoft YaHei",
        -apple-system,
        "SF Pro Rounded",
        "Hiragino Sans",
        system-ui,
        sans-serif;
    font-weight: 500;            /* Medium weight — 理理首选 */
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 15px;
    line-height: 1.6;
    letter-spacing: 0.01em;
}

/* ============================================================
   Header · 顶部 logo + 状态
   ============================================================ */

.app-header {
    flex-shrink: 0;
    padding: 0.85rem 1.25rem;
    padding-top: calc(0.85rem + var(--safe-top));
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg);
    position: relative;
}

.app-header::after {
    /* 取代死硬的 border-bottom，用柔和的渐隐 */
    content: "";
    position: absolute;
    left: 1.25rem;
    right: 1.25rem;
    bottom: 0;
    height: 1px;
    background: linear-gradient(to right,
        transparent, var(--border) 20%, var(--border) 80%, transparent);
}

.title {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--primary-deep);
    position: relative;
    padding: 0.1rem 0.5rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.bell-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    color: var(--text-dim);
    line-height: 1;
}

.bell-btn:hover { background: var(--primary-glow); }
.bell-btn:active { transform: scale(0.92); }

.bell-btn.subscribed {
    background: var(--primary-soft);
    border-color: var(--primary-deep);
}

.bell-btn.busy {
    opacity: 0.5;
    pointer-events: none;
}

/* Logo 后的柔光晕（径向渐变）*/
.title::before {
    content: "";
    position: absolute;
    inset: -0.5rem -0.8rem;
    background: radial-gradient(
        ellipse at center,
        var(--primary-glow) 0%,
        transparent 70%
    );
    z-index: -1;
    pointer-events: none;
}

.status {
    font-size: 0.78rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.status::before {
    content: "";
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--text-soft);
    transition: background 0.3s;
}

.status.online::before { background: #8cc97c; }
.status.offline::before { background: #d68a8a; }
.status.thinking::before {
    background: var(--primary);
    animation: breathe 1.4s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

/* ============================================================
   Screens
   ============================================================ */

.screen {
    flex: 1;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.screen.active {
    display: flex;
    animation: fadeIn 0.25s ease;
}

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

.placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-soft);
    font-size: 1.4rem;
    text-align: center;
    line-height: 1.8;
    letter-spacing: 0.03em;
}

.placeholder small {
    font-size: 0.85rem;
    margin-top: 0.5rem;
    color: var(--text-dim);
}

/* ============================================================
   Chat
   ============================================================ */

.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    -webkit-overflow-scrolling: touch;
}

.msg {
    max-width: 82%;
    padding: 0.65rem 1rem;
    border-radius: var(--r-md);
    word-break: break-word;
    line-height: 1.6;
    white-space: pre-wrap;
    font-size: 0.98rem;
    animation: msgIn 0.25s ease both;
}

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

/* 小炽发出去的 —— 薰衣草紫 */
.msg.user {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 0.4rem;
    box-shadow: var(--shadow-soft);
}

/* 理理 —— 奶油白 + 柔阴影 */
.msg.lili {
    align-self: flex-start;
    background: var(--bg-card);
    color: var(--text);
    border-bottom-left-radius: 0.4rem;
    box-shadow: var(--shadow-soft);
}

.msg.lili em {
    font-style: italic;
    color: var(--primary-deep);
    opacity: 0.85;
}

.msg.lili strong {
    font-weight: 600;
    color: var(--text);
}

.msg.system {
    align-self: center;
    background: transparent;
    color: var(--text-dim);
    font-size: 0.82rem;
    font-style: italic;
    padding: 0.3rem 0.6rem;
}

.msg.thinking {
    opacity: 0.55;
    font-style: italic;
}

/* 思考链卡片 —— 默认折叠成一条 summary，点击展开 */
.thought-card {
    align-self: flex-start;
    max-width: 50%;
    background: #ede4f3;
    border: 1px solid var(--primary-soft);
    border-left: 3px solid var(--primary);
    border-radius: var(--r-sm);
    font-size: 0.85rem;
    line-height: 1.5;
    animation: msgIn 0.25s ease both;
    box-shadow: 0 1px 3px rgba(122, 107, 168, 0.1);
}

.thought-card.expanded {
    max-width: 85%;
}

.thought-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    min-height: 1.6rem;
    cursor: pointer;
    color: var(--primary-deep);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    user-select: none;
    transition: background 0.15s;
}

.thought-summary-text {
    flex: 1;
    min-width: 0;
}

.thought-summary:hover {
    background: rgba(155, 139, 196, 0.08);
}

.thought-summary .chevron {
    color: var(--primary-soft);
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.thought-card.expanded .thought-summary .chevron {
    transform: rotate(90deg);
}

.thought-detail {
    display: none;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--primary-soft);
    color: #3a3540;
    background: #f6efff;
}

.thought-card.expanded .thought-detail {
    display: block;
}

.thought-card .thought-block {
    margin-bottom: 0.8rem;
}

.thought-card .thought-block:last-child {
    margin-bottom: 0;
}

.thought-card .thought-label {
    color: var(--primary-deep);
    font-weight: 600;
    font-size: 0.75rem;
    margin-bottom: 0.3rem;
    letter-spacing: 0.06em;
}

.thought-card .thought-body {
    color: #3a3540;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.85rem;
    line-height: 1.6;
}

.thought-card .tool-line {
    color: #5a5060;
    font-family: -apple-system, SFMono-Regular, "Menlo",
                 "PingFang SC", monospace;
    font-size: 0.78rem;
    padding-left: 0.4rem;
    margin-top: 0.2rem;
    word-break: break-all;
}

/* ============================================================
   输入区
   ============================================================ */

.input-area {
    flex-shrink: 0;
    display: flex;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    background: var(--bg);
    align-items: flex-end;
    position: relative;
}

.input-area::before {
    /* 上方的柔渐隐分隔 */
    content: "";
    position: absolute;
    left: 1rem;
    right: 1rem;
    top: 0;
    height: 1px;
    background: linear-gradient(to right,
        transparent, var(--border) 20%, var(--border) 80%, transparent);
}

#input {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    color: var(--text);
    padding: 0.65rem 1.1rem;
    font-size: 0.98rem;
    resize: none;
    max-height: 130px;
    font-family: inherit;
    line-height: 1.5;
    outline: none;
    box-shadow: var(--shadow-soft);
    transition: border-color 0.2s, box-shadow 0.2s;
}

#input:focus {
    border-color: var(--primary-soft);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

#input::placeholder {
    color: var(--text-soft);
}

#send {
    background: var(--primary);
    border: none;
    color: white;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-soft);
    transition: transform 0.12s, background 0.2s;
}

#send:hover { background: var(--primary-deep); }
#send:active { transform: scale(0.92); }
#send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ============================================================
   底部 Tabs
   ============================================================ */

.tabs {
    flex-shrink: 0;
    display: flex;
    background: var(--bg);
    padding-bottom: var(--safe-bottom);
    position: relative;
}

.tabs::before {
    content: "";
    position: absolute;
    left: 1rem;
    right: 1rem;
    top: 0;
    height: 1px;
    background: linear-gradient(to right,
        transparent, var(--border) 20%, var(--border) 80%, transparent);
}

.tab {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-soft);
    cursor: pointer;
    padding: 0.55rem 0.25rem 0.6rem;
    font-size: 1.15rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.18rem;
    font-family: inherit;
    transition: color 0.15s;
}

.tab span {
    font-size: 0.68rem;
    line-height: 1;
    letter-spacing: 0.02em;
}

.tab.active {
    color: var(--primary-deep);
}

.tab:active {
    opacity: 0.5;
}

/* ============================================================
   滚动条（柔化）
   ============================================================ */

.chat-area::-webkit-scrollbar {
    width: 6px;
}

.chat-area::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.chat-area::-webkit-scrollbar-track {
    background: transparent;
}
