/* 私訊機 — 殼照抄家裡訊息 App（工坊 msg_viewer.js）的對話頁；預設配色＝msg_viewer 的中性預設 */
:root { color-scheme: light dark;
  --bg:#f7f6f4; --fg:#26282c; --accent:#3d5a80;
  --him:#e9e6e1; --himfg:#26282c; --her:#3d5a80; --herfg:#fff;
  --line:rgba(0,0,0,.08); --bar:rgba(250,250,249,.92); --card:#fff; --muted:rgba(0,0,0,.5); }
@media (prefers-color-scheme: dark) { :root:not(.dressed) {
  --bg:#15171c; --fg:#e6e6e6; --accent:#5c7fa8;
  --him:#2a2d34; --himfg:#e6e6e6; --her:#41608a; --herfg:#fff;
  --line:rgba(255,255,255,.1); --bar:rgba(24,26,31,.92); --card:#1f2228; --muted:rgba(255,255,255,.5); } }
* { box-sizing:border-box; }
html, body { height:100%; }
body { margin:0; background:var(--bg); color:var(--fg);
  font-family:-apple-system,"PingFang TC","Microsoft JhengHei",sans-serif; -webkit-text-size-adjust:100%; }
button { font-family:inherit; }
[hidden] { display:none !important; }

/* ---- 頂列（三頁共用） ---- */
.top { position:fixed; top:0; left:0; right:0; z-index:5; background:var(--bar);
  -webkit-backdrop-filter:blur(12px); backdrop-filter:blur(12px);
  padding:calc(env(safe-area-inset-top) + 8px) 14px 8px; display:flex; align-items:center; gap:10px;
  border-bottom:1px solid var(--line); color:var(--barfg, var(--fg)); }
.top .av { width:34px; height:34px; border-radius:50%; object-fit:cover; background:var(--him); flex:none;
  -webkit-touch-callout:none; -webkit-user-select:none; user-select:none; }
.top .name { font-weight:600; font-size:1.05rem; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.top .sub { font-size:.72rem; opacity:.5; }
.top .icon { margin-left:auto; background:none; border:none; color:var(--accent); padding:4px 6px;
  display:flex; align-items:center; cursor:pointer; }
.top .icon + .icon { margin-left:0; }
.top .icon { position:relative; }
.top .dot { position:absolute; top:3px; right:3px; width:9px; height:9px; border-radius:50%; background:#e0245e; border:2px solid var(--bg); }
textarea.memo { width:100%; min-width:0; min-height:110px; border:1px solid var(--line); background:var(--bg); color:var(--fg);
  border-radius:10px; padding:10px 12px; font-size:.95rem; line-height:1.7; font-family:inherit; resize:vertical; }
/* 記事本｜日記 切換：照家裡「現頁粗體｜另一頁」的文字導覽 */
.tabs { display:flex; align-items:center; gap:6px; font-size:1.02rem; }
.tabs button { border:none; background:none; color:inherit; font:inherit; padding:2px 2px; cursor:pointer; opacity:.55; position:relative; }
.tabs button.on { opacity:1; font-weight:600; }
.tabs span { opacity:.35; }
.tabs .tdot { position:absolute; top:0; right:-8px; width:7px; height:7px; border-radius:50%; background:#e0245e; }
/* 日記條目 */
.dentry { background:var(--card); border:1px solid var(--line); border-radius:14px; padding:12px 14px; margin-bottom:12px; }
.dentry .dh { display:flex; align-items:baseline; gap:8px; margin-bottom:6px; }
.dentry .dw { font-size:.78rem; font-weight:600; color:var(--accent); }
.dentry .dd { font-size:.72rem; opacity:.5; margin-left:auto; flex:none; }
.dentry .dt { white-space:pre-wrap; line-height:1.8; font-size:.95rem; overflow-wrap:anywhere; }
.dentry.me { border-left:3px solid var(--her); }
.dentry.reply { margin-left:14px; }
.dentry.wait .dt { opacity:.5; font-size:.85rem; }
.top .back {background:none; border:none; color:var(--accent); padding:4px 2px; display:flex; align-items:center; cursor:pointer; }

/* ---- 背景圖（衣櫃） ---- */
#bgimg { position:fixed; inset:0; z-index:0; background-size:cover; background-position:center; }
#veil { position:fixed; inset:0; z-index:0; }

/* ---- 對話流 ----
   column-reverse＝捲動原點在底（原生釘底）。三坑照訊息線：勿加 -webkit-overflow-scrolling:touch；
   上下 padding 放 #flowin 不放 #flow；高度用 100dvh。 */
#flow { position:relative; z-index:1; overflow-y:auto; height:100vh; height:100dvh;
  display:flex; flex-direction:column-reverse; }
#flowin { width:100%; padding:calc(env(safe-area-inset-top) + 66px) 12px calc(env(safe-area-inset-bottom) + 66px); }
body.kb #flowin { padding-bottom:66px; }
.day { text-align:center; font-size:.72rem; opacity:.45; margin:16px 0 6px; }
.row { display:flex; margin:15px 0 0; }
.row.same { margin-top:4px; }   /* 同一人兩分鐘內連發＝收緊（只用上邊距，免得上下邊距疊在一起收不掉） */
#typing { margin-bottom:2px; }
.row.her { justify-content:flex-end; }
.bub { max-width:76%; padding:9px 13px; border-radius:18px; font-size:.98rem; line-height:1.45;
  white-space:pre-wrap; word-break:break-word; min-width:0; }
.bub.imgbub { padding:4px; }
.bub.imgbub img { display:block; max-width:min(220px, 60vw); max-height:300px; border-radius:14px; }
.bub.imgbub .cap { padding:7px 9px 5px; }
/* 預設泡泡＝訊息 App 的毛玻璃（08-27 業主點的那套）；衣櫃換裝時由 #wardrobe-live 蓋掉 */
.row.him .bub { background:color-mix(in srgb, var(--him) 45%, transparent); color:var(--himfg); border-bottom-left-radius:5px;
  -webkit-backdrop-filter:blur(14px) saturate(150%); backdrop-filter:blur(14px) saturate(150%);
  border:1px solid color-mix(in srgb, var(--himfg) 12%, transparent); }
.row.her .bub { background:color-mix(in srgb, var(--her) 55%, transparent); color:var(--herfg); border-bottom-right-radius:5px;
  -webkit-backdrop-filter:blur(14px) saturate(150%); backdrop-filter:blur(14px) saturate(150%);
  border:1px solid color-mix(in srgb, var(--herfg) 18%, transparent); }
.tm { font-size:.66rem; opacity:.4; align-self:flex-end; margin:0 6px 2px; flex:none; }
#typing { display:none; }
#typing.on { display:flex; }
#typing .bub { display:flex; gap:4px; align-items:center; padding:13px 15px; }
#typing i { width:7px; height:7px; border-radius:50%; background:var(--himfg); opacity:.35; animation:tp 1.2s infinite; }
#typing i:nth-child(2) { animation-delay:.2s; } #typing i:nth-child(3) { animation-delay:.4s; }
@keyframes tp { 0%,60%,100% { transform:translateY(0); opacity:.3; } 30% { transform:translateY(-4px); opacity:.85; } }
.nudge { display:flex; justify-content:center; margin:10px 0; }
.nudge button { border:1px solid var(--line); background:var(--card); color:var(--accent); border-radius:14px;
  padding:6px 14px; font-size:.8rem; cursor:pointer; }
.empty { text-align:center; opacity:.5; font-size:.85rem; margin-top:30vh; line-height:1.7; }

/* ---- 輸入列 ---- */
#bar { position:fixed; bottom:0; left:0; right:0; z-index:5; background:var(--bar);
  -webkit-backdrop-filter:blur(12px); backdrop-filter:blur(12px); border-top:1px solid var(--line);
  padding:8px 10px calc(env(safe-area-inset-bottom) + 8px); display:flex; flex-wrap:wrap; gap:8px; align-items:flex-end; }
body.kb #bar { padding-bottom:8px; }
#stage { display:none; flex-basis:100%; }
#stage.on { display:flex; }
#stage .thumbwrap { position:relative; }
#stage img { height:64px; border-radius:10px; display:block; }
.unstage { position:absolute; top:-7px; right:-7px; width:22px; height:22px; border-radius:50%;
  border:none; background:rgba(0,0,0,.65); color:#fff; font-size:.8rem; line-height:1; padding:0; cursor:pointer; }
#inp { flex:1; min-width:0; border:1px solid var(--line); background:var(--bg); color:var(--fg); border-radius:18px;
  padding:9px 14px; font-size:1rem; font-family:inherit; resize:none; max-height:110px; line-height:1.35; overflow-y:hidden; }
#sendbtn { border:none; background:var(--accent); color:#fff; width:38px; height:38px; border-radius:50%; flex:0 0 auto;
  display:flex; align-items:center; justify-content:center; cursor:pointer; }
#plusbtn { border:none; background:none; color:var(--accent); width:32px; height:38px; padding:0; flex:0 0 auto;
  display:flex; align-items:center; justify-content:center; cursor:pointer; }

/* ---- 設定頁、衣櫃頁 ---- */
.page { min-height:100dvh; padding:calc(env(safe-area-inset-top) + 66px) 14px calc(env(safe-area-inset-bottom) + 30px);
  max-width:640px; margin:0 auto; position:relative; z-index:1; }
.card { background:var(--card); border:1px solid var(--line); border-radius:14px; padding:12px 14px; margin-bottom:14px; }
.card h2 { font-size:.8rem; margin:0 0 10px; opacity:.6; font-weight:600; letter-spacing:.05em; }
.card p.hint, .hint { font-size:.78rem; opacity:.6; margin:4px 0 10px; line-height:1.55; }
.field { display:grid; grid-template-columns:minmax(0,1fr); gap:5px; margin:10px 0; }
.field > span { font-size:.82rem; opacity:.8; }
.field input[type=text], .field input[type=password], .field textarea, .field select {
  width:100%; min-width:0; border:1px solid var(--line); background:var(--bg); color:var(--fg); border-radius:10px;
  padding:9px 11px; font-size:1rem; font-family:inherit; }
.field textarea { resize:vertical; min-height:96px; line-height:1.5; }
.inline { display:flex; gap:8px; align-items:center; }
.inline > * { min-width:0; }
.inline input { flex:1; }
.btn { border:1px solid var(--line); background:var(--bg); color:var(--fg); border-radius:10px; padding:9px 13px;
  font-size:.88rem; cursor:pointer; flex:none; }
.btn.pri { background:var(--accent); border-color:var(--accent); color:#fff; }
.btn.warn { color:#c0392b; }
.btn.arm { background:#c0392b; border-color:#c0392b; color:#fff; }
.btnrow { display:flex; gap:8px; flex-wrap:wrap; }
.btnrow .btn { flex:1; }
.avedit { display:flex; align-items:center; gap:12px; }
.avedit img { width:64px; height:64px; border-radius:50%; object-fit:cover; background:var(--him); }
.welcome { border-color:color-mix(in srgb, var(--accent) 40%, transparent); background:color-mix(in srgb, var(--accent) 8%, var(--card)); }
.welcome p { margin:4px 0; font-size:.9rem; line-height:1.6; }
.saved { font-size:.72rem; opacity:.5; margin-left:auto; }
a { color:var(--accent); }

/* ---- 衣櫃 ---- */
#wstagewrap { position:relative; border-radius:16px; overflow:hidden; border:1px solid var(--line); margin-bottom:14px; }
#wbg { position:absolute; inset:0; background-size:cover; background-position:center; }
#wveil { position:absolute; inset:0; }
#wstage { position:relative; padding:4px 14px 14px; color:var(--fg); }
/* 衣櫃預覽的迷你頂列與輸入列（吃 #wstagewrap 上的草稿色） */
.pvtop, .pvbar { position:relative; display:flex; align-items:center; gap:8px; padding:9px 12px; color:var(--barfg, var(--fg));
  background:var(--bar); -webkit-backdrop-filter:blur(12px); backdrop-filter:blur(12px); }
.pvtop { border-bottom:1px solid var(--line); font-size:.9rem; }
.pvtop svg { margin-left:auto; color:var(--accent); }
.pvav { width:24px; height:24px; border-radius:50%; background:var(--him); flex:none; }
.pvbar { border-top:1px solid var(--line); }
.pvinp { flex:1; min-width:0; border:1px solid var(--line); background:var(--bg); color:var(--fg); border-radius:16px; padding:6px 12px; font-size:.85rem; opacity:.7; }
.pvsend { width:30px; height:30px; border-radius:50%; background:var(--accent); flex:none; }
.btn.auto { padding:4px 10px; font-size:.75rem; }
.btn.auto.on { border-color:var(--accent); color:var(--accent); font-weight:600; }
#wstyles { display:grid; grid-template-columns:repeat(3, minmax(0,1fr)); gap:8px; }
.stybtn { border:1px solid var(--line); background:var(--bg); color:var(--fg); border-radius:10px;
  padding:9px 4px; font-size:.85rem; cursor:pointer; min-width:0; }
.stybtn.on { border-color:var(--accent); background:color-mix(in srgb, var(--accent) 14%, var(--bg)); color:var(--accent); font-weight:600; }
.crow { display:flex; align-items:center; gap:8px; margin:8px 0; font-size:.85rem; }
.crow label { flex:1; opacity:.8; }
.crow input[type=color] { width:44px; height:30px; padding:0; cursor:pointer; border:1px solid var(--line);
  border-radius:6px; background:none; -webkit-appearance:none; appearance:none; }
.crow input[type=color]::-webkit-color-swatch-wrapper { padding:0; }
.crow input[type=color]::-webkit-color-swatch { border:none; border-radius:5px; }
.krow { display:flex; align-items:center; gap:10px; margin:9px 0; font-size:.85rem; }
.krow label { width:78px; flex:none; opacity:.8; }
.krow input[type=range] { flex:1; min-width:0; }
.krow output { width:44px; text-align:right; font-variant-numeric:tabular-nums; opacity:.7; flex:none; }
@media (min-width:760px) { #wstyles { grid-template-columns:repeat(4, minmax(0,1fr)); } }

/* ---- 行事曆 ---- */
.calhead { display:flex; align-items:center; gap:10px; margin-bottom:8px; }
.calhead #k-month { flex:1; text-align:center; font-weight:600; }
.calhead .btn { padding:4px 14px; font-size:1.1rem; }
.calgrid { display:grid; grid-template-columns:repeat(7, minmax(0,1fr)); gap:3px; }
#k-wd div { text-align:center; font-size:.72rem; opacity:.5; padding:4px 0; }
.cday { position:relative; border:none; background:none; color:var(--fg); aspect-ratio:1 / 1; border-radius:10px;
  font-size:.92rem; cursor:pointer; padding:0; min-width:0; font-family:inherit; }
.cday.out { opacity:.3; }
.cday.per { background:color-mix(in srgb, #e0245e 22%, transparent); }
.cday.pred { background:color-mix(in srgb, #e0245e 9%, transparent); }
.cday.today { font-weight:700; color:var(--accent); }
.cday.sel { outline:2px solid var(--accent); outline-offset:-2px; }
.cday .ev { position:absolute; left:50%; bottom:5px; width:5px; height:5px; margin-left:-2.5px; border-radius:50%; background:var(--accent); }
.calleg { font-size:.72rem; opacity:.6; margin-top:8px; display:flex; align-items:center; gap:5px; }
.calleg .lg { width:12px; height:12px; border-radius:4px; display:inline-block; margin-left:6px; }
.calleg .lg.per { background:color-mix(in srgb, #e0245e 22%, transparent); }
.calleg .lg.pred { background:color-mix(in srgb, #e0245e 9%, transparent); }
.evrow { display:flex; align-items:center; gap:8px; padding:8px 0; border-bottom:1px solid var(--line); font-size:.95rem; }
.evrow .t { opacity:.55; font-variant-numeric:tabular-nums; flex:none; }
.evrow .x { margin-left:auto; border:none; background:none; color:var(--muted); font-size:1rem; cursor:pointer; flex:none; }
.evrow > span { min-width:0; overflow-wrap:anywhere; }
.evadd { margin-top:10px; }
.evadd input[type=text], .evadd input[type=time] { border:1px solid var(--line); background:var(--bg); color:var(--fg); border-radius:10px; padding:8px 10px; font-size:1rem; font-family:inherit; min-width:0; }
.evadd input[type=time] { flex:0 0 auto; width:7.2em; }
.crow input[type=checkbox] { width:20px; height:20px; accent-color:var(--accent); }

#toast {position:fixed; left:50%; bottom:calc(env(safe-area-inset-bottom) + 80px); transform:translateX(-50%);
  z-index:50; background:rgba(30,30,34,.92); color:#fff; padding:9px 16px; border-radius:12px; font-size:.85rem;
  max-width:calc(100vw - 32px); opacity:0; pointer-events:none; transition:opacity .2s; }
#toast.on { opacity:1; }

/* ---- 動態 ---- */
.top .avbtn { border:none; background:none; padding:0; position:relative; display:flex; cursor:pointer; flex:none; }
.top .avbtn .dot { top:-1px; right:-1px; }
#f-stage { margin-top:8px; }
#f-stage .thumbwrap { position:relative; display:inline-block; }
#f-stage img { height:72px; border-radius:10px; display:block; }
.post { background:var(--card); border:1px solid var(--line); border-radius:14px; padding:12px 14px; margin-bottom:12px; }
.post .ph { display:flex; align-items:center; gap:9px; margin-bottom:8px; }
.post .ph img { width:34px; height:34px; border-radius:50%; object-fit:cover; background:var(--him); flex:none; }
.post .pn { font-weight:600; font-size:.92rem; }
.post .pt { font-size:.72rem; opacity:.5; margin-left:auto; flex:none; }
.post .pb { white-space:pre-wrap; line-height:1.65; font-size:.97rem; overflow-wrap:anywhere; }
.post .pimg { display:block; max-width:100%; max-height:420px; border-radius:12px; margin-top:8px; }
.post .pa { display:flex; align-items:center; gap:16px; margin-top:10px; font-size:.82rem; color:var(--muted); }
.post .pa button { border:none; background:none; color:inherit; font:inherit; padding:0; display:flex; align-items:center; gap:4px; cursor:pointer; }
.post .pa .liked { color:#e0245e; }
.post .cm { margin-top:10px; border-top:1px solid var(--line); padding-top:8px; }
.post .cmi { display:flex; gap:8px; padding:5px 0; font-size:.9rem; line-height:1.5; }
.post .cmi b { flex:none; font-weight:600; }
.post .cmi span { min-width:0; overflow-wrap:anywhere; }
.post .cmi .ct { margin-left:auto; flex:none; font-size:.7rem; opacity:.45; padding-left:6px; }
.post .cmin { display:flex; gap:8px; margin-top:6px; }
.post .cmin input { flex:1; min-width:0; border:1px solid var(--line); background:var(--bg); color:var(--fg); border-radius:16px; padding:7px 12px; font-size:.92rem; font-family:inherit; }
.post .cmin button { flex:none; }
