:root{
    --bg-0:#fffaf6;
    --bg-1:#fdf6f1;
    --bg-2:#f7ece2;
    --text-1:#2b2420;
    --text-2:#9c8d83;
    --ink:#332b25;
    --line:rgba(140,105,80,.14);
    --radius-xl:30px;
    --radius-lg:30px;
    --radius-md:18px;
    --radius-chat:30px;
    --radius-pill:999px;
    --shadow-soft:0 10px 26px -6px rgba(196,160,150,.22),0 2px 8px rgba(196,160,150,.12);
    --shadow-lift:0 16px 40px -8px rgba(196,160,150,.26),0 4px 12px rgba(196,160,150,.14);
    --accent:#ff5c82;
    --spring:cubic-bezier(.34,1.56,.64,1);
}

*{
    margin:0;
    padding:0;
    box-sizing:border-box;
}

html,body{
    height:100%;
}

body{
    font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","PingFang SC","Microsoft YaHei",sans-serif;
    background:linear-gradient(180deg,var(--bg-1) 0%,var(--bg-2) 100%);
    color:var(--text-1);
    -webkit-font-smoothing:antialiased;
}

img{
    display:block;
    max-width:100%;
}

/* ---------- 通用外壳：桌面端居中卡片，移动端占满屏幕 ---------- */

.app-shell{
    width:100%;
    max-width:620px;
    height:100vh;
    height:100dvh;
    margin:0 auto;
    background:var(--bg-1);
    display:flex;
    flex-direction:column;
    overflow:hidden;
    position:relative;
    animation:page-enter .28s ease both;
}

/* 统一的进页过渡：所有页面共用同一个 .app-shell，这里加一次，全站生效 */
@keyframes page-enter{
    from{opacity:0;transform:translateY(8px);}
    to{opacity:1;transform:translateY(0);}
}

@media (prefers-reduced-motion:reduce){
    .app-shell{
        animation:none;
    }
}

@media (min-width:660px){
    body{
        display:flex;
        align-items:center;
        justify-content:center;
        padding:24px;
    }
    .app-shell{
        height:min(880px,92vh);
        border-radius:var(--radius-xl);
        box-shadow:var(--shadow-lift);
        border:1px solid var(--line);
    }
}

/* ================= 聊天页（唯一入口，不再有联系人列表） ================= */

.chat-topbar{
    position:sticky;
    top:0;
    z-index:2;
    display:flex;
    align-items:center;
    gap:14px;
    padding:16px 18px;
    background:rgba(255,250,244,.78);
    backdrop-filter:blur(20px);
    -webkit-backdrop-filter:blur(20px);
    border-bottom:1px solid var(--line);
}

.chat-back{
    display:flex;
    align-items:center;
    justify-content:center;
    width:34px;
    height:34px;
    border-radius:50%;
    background:var(--bg-2);
    color:var(--text-1);
    font-size:16px;
    text-decoration:none;
    flex-shrink:0;
    transition:background .2s ease,transform .3s var(--spring);
}

.chat-back:hover{
    background:#f3e6dc;
}

.chat-back:active{
    transform:scale(.92);
}

.chat-userinfo{
    display:flex;
    align-items:center;
    gap:12px;
    min-width:0;
}

.chat-avatar{
    width:42px;
    height:42px;
    border-radius:50%;
    object-fit:cover;
    background:var(--bg-2);
    box-shadow:var(--shadow-soft);
    flex-shrink:0;
}

.chat-name{
    font-size:16px;
    font-weight:600;
    color:var(--text-1);
    line-height:1.3;
}

.chat-status{
    font-size:12px;
    color:var(--text-2);
    line-height:1.3;
}

.chat-settings{
    display:flex;
    align-items:center;
    justify-content:center;
    width:34px;
    height:34px;
    margin-left:auto;
    border-radius:50%;
    background:var(--bg-2);
    color:var(--text-1);
    font-size:16px;
    text-decoration:none;
    flex-shrink:0;
    transition:background .2s ease,transform .3s var(--spring);
}

.chat-settings:hover{
    background:#f3e6dc;
}

.chat-settings:active{
    transform:scale(.92);
}

#chat-messages{
    flex:1;
    overflow-y:auto;
    padding:24px 20px 32px;
    display:flex;
    flex-direction:column;
    gap:20px;
    background-color:var(--bg-2);
    background-size:cover;
    background-position:center;
}

/* ---------- 剧情卡片：一次剧情 = 一张白色圆角大卡片，按时间顺序向下堆叠，
   宽度较宽、内边距充足，正文追求小说式的阅读体验，而不是聊天软件的消息条 ---------- */

.story-card{
    background:var(--bg-0);
    border-radius:var(--radius-chat);
    padding:24px 26px;
    box-shadow:var(--shadow-soft);
    transition:transform .35s var(--spring),box-shadow .25s ease;
}

@media (hover:hover){
    .story-card:hover{
        transform:translateY(-2px);
        box-shadow:var(--shadow-lift);
    }
}

.story-card-header{
    display:flex;
    align-items:flex-start;
    gap:14px;
    margin-bottom:18px;
    padding-bottom:16px;
    border-bottom:1px solid var(--line);
}

.story-avatar{
    width:44px;
    height:44px;
    border-radius:50%;
    object-fit:cover;
    background:var(--bg-2);
    flex-shrink:0;
    box-shadow:var(--shadow-soft);
}

.story-meta{
    display:flex;
    flex-direction:column;
    gap:4px;
    min-width:0;
}

.story-name{
    font-size:15px;
    font-weight:600;
    color:var(--text-1);
    line-height:1.3;
}

.story-datetime{
    font-size:12px;
    color:var(--text-2);
    line-height:1.3;
}

.story-content{
    font-size:16px;
    line-height:1.9;
    color:var(--chat-font-color,var(--text-1));
    word-break:break-word;
    letter-spacing:.2px;
}

.story-content p{
    margin:0 0 16px;
    text-indent:2em;
}

.story-content p:last-child{
    margin-bottom:0;
}

.story-content strong{
    font-weight:700;
}

/* 【动作】【环境】【心理】标签：斜体 + 弱化色，用不同色相区分类别 */

.story-tag{
    font-style:italic;
}

.story-tag-action{
    color:#8d8378;
}

.story-tag-scene{
    color:#7a9a8b;
}

.story-tag-mind{
    color:#8a83b0;
}

.story-tag-generic{
    color:var(--text-2);
}

/* 引用文字 */

.story-quote{
    color:var(--accent);
}

.story-blockquote{
    margin:0 0 16px;
    padding-left:14px;
    border-left:3px solid var(--line);
    color:var(--text-2);
    font-style:italic;
}

.story-blockquote:last-child{
    margin-bottom:0;
}

.chat-inputbar{
    display:flex;
    align-items:flex-end;
    gap:10px;
    padding:14px 16px;
    background:rgba(255,250,244,.88);
    backdrop-filter:blur(20px);
    -webkit-backdrop-filter:blur(20px);
    border-top:1px solid var(--line);
}

.chat-input{
    flex:1;
    resize:none;
    border:none;
    outline:none;
    max-height:120px;
    padding:12px 18px;
    font-size:15px;
    font-family:inherit;
    line-height:1.4;
    background:var(--bg-2);
    border-radius:var(--radius-pill);
    color:var(--text-1);
}

.chat-input::placeholder{
    color:var(--text-2);
}

.send-btn{
    flex-shrink:0;
    width:44px;
    height:44px;
    border:none;
    border-radius:50%;
    background:var(--accent);
    color:#ffffff;
    font-size:18px;
    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    box-shadow:0 8px 20px rgba(255,92,130,.32);
    transition:transform .3s var(--spring),opacity .15s ease;
}

.send-btn:active{
    transform:scale(.92);
}

.send-btn:disabled{
    opacity:.4;
    cursor:default;
    transform:none;
}

/* ================= 设置页 ================= */

.settings-topbar{
    position:sticky;
    top:0;
    z-index:2;
    display:flex;
    align-items:center;
    gap:14px;
    padding:16px 18px;
    background:rgba(255,250,244,.78);
    backdrop-filter:blur(20px);
    -webkit-backdrop-filter:blur(20px);
    border-bottom:1px solid var(--line);
}

.settings-back{
    display:flex;
    align-items:center;
    justify-content:center;
    width:34px;
    height:34px;
    border-radius:50%;
    background:var(--bg-2);
    color:var(--text-1);
    font-size:16px;
    text-decoration:none;
    flex-shrink:0;
    transition:background .2s ease,transform .3s var(--spring);
}

.settings-back:hover{
    background:#f3e6dc;
}

.settings-back:active{
    transform:scale(.92);
}

.settings-title{
    font-size:17px;
    font-weight:600;
    color:var(--text-1);
}

.settings-content{
    flex:1;
    overflow-y:auto;
    padding:20px 16px 40px;
    background:var(--bg-2);
    display:flex;
    flex-direction:column;
    gap:24px;
}

.settings-group{
    background:var(--bg-0);
    border-radius:var(--radius-lg);
    box-shadow:var(--shadow-soft);
    overflow:hidden;
    transition:box-shadow .25s ease;
}

.settings-row{
    display:flex;
    align-items:center;
    gap:14px;
    padding:14px 16px;
    min-height:56px;
    border-bottom:1px solid var(--line);
    cursor:pointer;
    transition:background .15s ease;
    color:inherit;
    text-decoration:none;
}

.settings-group .settings-row:last-child{
    border-bottom:none;
}

.settings-row:hover{
    background:var(--bg-1);
}

.settings-row:active{
    background:var(--bg-2);
}

.settings-row-label{
    flex:1;
    font-size:15px;
    color:var(--text-1);
}

.settings-row-arrow{
    flex-shrink:0;
    font-size:18px;
    color:var(--text-2);
}

.settings-row-avatar{
    width:40px;
    height:40px;
    border-radius:50%;
    object-fit:cover;
    background:var(--bg-2);
    box-shadow:var(--shadow-soft);
    flex-shrink:0;
}

.settings-row-input{
    flex-shrink:0;
    width:140px;
    border:none;
    outline:none;
    background:transparent;
    font-size:15px;
    font-family:inherit;
    text-align:right;
    color:var(--text-1);
    cursor:text;
}

.settings-row-input::placeholder{
    color:var(--text-2);
}

.settings-bg-preview{
    width:40px;
    height:40px;
    border-radius:10px;
    background-color:var(--bg-2);
    background-size:cover;
    background-position:center;
    box-shadow:inset 0 0 0 1px var(--line);
    flex-shrink:0;
}

.settings-color-input{
    -webkit-appearance:none;
    appearance:none;
    width:28px;
    height:28px;
    padding:0;
    border:none;
    border-radius:50%;
    background:none;
    cursor:pointer;
    flex-shrink:0;
    box-shadow:inset 0 0 0 1px var(--line);
}

.settings-color-input::-webkit-color-swatch-wrapper{
    padding:0;
    border-radius:50%;
}

.settings-color-input::-webkit-color-swatch{
    border:none;
    border-radius:50%;
}

.settings-color-input::-moz-color-swatch{
    border:none;
    border-radius:50%;
}

/* iOS 风格开关（纯样式，不带任何保存/持久化逻辑） */

.ios-switch{
    position:relative;
    display:inline-block;
    width:51px;
    height:31px;
    flex-shrink:0;
}

.ios-switch input{
    opacity:0;
    width:0;
    height:0;
}

.ios-switch-track{
    position:absolute;
    inset:0;
    background:#f0e4da;
    border-radius:var(--radius-pill);
    cursor:pointer;
    transition:background .2s ease;
}

.ios-switch-track::before{
    content:"";
    position:absolute;
    top:2px;
    left:2px;
    width:27px;
    height:27px;
    background:#ffffff;
    border-radius:50%;
    box-shadow:0 3px 8px rgba(0,0,0,.18);
    transition:transform .2s ease;
}

.ios-switch input:checked + .ios-switch-track{
    background:#34c759;
}

.ios-switch input:checked + .ios-switch-track::before{
    transform:translateX(20px);
}

/* ================= 深色模式 ================= */
/* 通过在 body.dark-mode 上重新定义 :root 里同名的 CSS 变量来整体换肤，
   页面里凡是引用了这些变量的规则会自动跟着变，不需要逐条重写选择器。 */

body.dark-mode{
    --bg-0:#1c1c1e;
    --bg-1:#000000;
    --bg-2:#2c2c2e;
    --text-1:#f2f2f2;
    --text-2:#98989d;
    --line:rgba(255,255,255,.14);
}

body.dark-mode .chat-topbar,
body.dark-mode .chat-inputbar,
body.dark-mode .chat-tabs-bottom,
body.dark-mode .settings-topbar{
    background:rgba(28,28,30,.72);
}

body.dark-mode .chat-back:hover,
body.dark-mode .chat-settings:hover,
body.dark-mode .settings-back:hover{
    background:#3a3a3c;
}

body.dark-mode .ios-switch-track{
    background:#39393d;
}

/* ================= 占位页（Phase 1：外观先行，功能后补） ================= */

.placeholder-topbar{
    position:sticky;
    top:0;
    z-index:2;
    display:flex;
    align-items:center;
    gap:14px;
    padding:16px 18px;
    background:rgba(255,250,244,.78);
    backdrop-filter:blur(20px);
    -webkit-backdrop-filter:blur(20px);
    border-bottom:1px solid var(--line);
}

.placeholder-content{
    flex:1;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:14px;
    padding:32px;
    text-align:center;
    background:var(--bg-1);
}

.placeholder-title{
    font-size:19px;
    font-weight:700;
    color:var(--text-1);
}

.placeholder-desc{
    font-size:14px;
    color:var(--text-2);
    max-width:280px;
    line-height:1.6;
}

.placeholder-badge{
    margin-top:6px;
    padding:8px 18px;
    border-radius:var(--radius-pill);
    background:var(--bg-2);
    color:var(--text-2);
    font-size:13px;
    font-weight:600;
}
