/* =========================================================
   Formicarium · 主體 app 樣式
   配色：桃絨 #FFCDB2 / 粉狀腮紅 #FFB4A2 / 棉花糖 #E5989B / Dusty Rose #B5838D / 暗灰色 #6D6875
   ========================================================= */
:root {
  --peach: #FFCDB2; --blush: #FFB4A2; --candy: #E5989B; --dusty: #B5838D; --ash: #6D6875;
  --paper: #FFF6F1; --line: rgba(181, 131, 141, .22); --ink: #5d5865;
  --serif: "Noto Serif TC", serif; --latin: "Cormorant Garamond", serif;
}
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--dusty); } .small { font-size: 12px; } .center { text-align: center; }

/* ---------------- 主畫面 ---------------- */
#home {
  position: fixed; inset: 0; opacity: 0; pointer-events: none; transition: opacity 1.2s ease .35s;
  color: var(--ash); font-family: var(--serif); overflow: hidden; z-index: 10;
  background:
    radial-gradient(70% 45% at 15% 8%, rgba(255, 205, 178, .95), rgba(255, 205, 178, 0) 70%),
    radial-gradient(60% 40% at 92% 35%, rgba(255, 180, 162, .7), rgba(255, 180, 162, 0) 70%),
    radial-gradient(80% 50% at 25% 88%, rgba(229, 152, 155, .5), rgba(229, 152, 155, 0) 70%),
    radial-gradient(60% 40% at 95% 98%, rgba(181, 131, 141, .5), rgba(181, 131, 141, 0) 70%), #FBE3D6;
  display: flex; flex-direction: column;
}
#home::before { content: ""; position: absolute; inset: 0; opacity: .2; mix-blend-mode: multiply; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .43 0 0 0 0 .41 0 0 0 0 .46 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
#home.show { opacity: 1; pointer-events: auto; }
.pager { flex: 1; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: none; position: relative; -webkit-overflow-scrolling: touch; }
.pager::-webkit-scrollbar { display: none; }
.hpage { flex: 0 0 100%; scroll-snap-align: start; scroll-snap-stop: always; overflow: hidden; display: flex;
  padding: calc(env(safe-area-inset-top) + 30px) 20px 4px; box-sizing: border-box; }
.pgrid { position: relative; flex: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(6, minmax(0, 1fr));
  gap: 12px 10px; max-width: 470px; margin: 0 auto; width: 100%; max-height: 720px; align-self: center; height: 100%; }
.cell { border-radius: 18px; pointer-events: none; transition: background .2s; }
#home.editing .cell { background: rgba(255, 255, 255, .16); outline: 1px dashed rgba(181, 131, 141, .28); outline-offset: -2px; }
.drop { border-radius: 20px; border: 2px dashed var(--candy); background: rgba(229, 152, 155, .14); pointer-events: none; z-index: 1; }
.drop.bad { border-color: #b85f63; background: rgba(184, 95, 99, .1); }
.item { z-index: 2; min-width: 0; min-height: 0; }
#home.has-wall { background-size: cover !important; background-position: center !important; }
#home.has-wall::before { display: none; }
.item { position: relative; touch-action: pan-x; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.app { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--ash);
  font-family: var(--serif); font-size: 12px; letter-spacing: .1em; cursor: pointer; }
.ico { width: 60px; height: 60px; border-radius: 19px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 7px 16px rgba(109, 104, 117, .15), inset 0 1px 0 rgba(255, 255, 255, .55); transition: transform .15s; }
.app:active .ico { transform: scale(.9); }
.ico svg, .iconbtn svg, .back svg, .send svg { width: 27px; height: 27px; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.c0 { background: linear-gradient(150deg, #FFE0CC, #FFCDB2); } .c0 svg { stroke: #B5838D; }
.c1 { background: linear-gradient(150deg, #FFC9BA, #FFB4A2); } .c1 svg { stroke: #8f6b78; }
.c2 { background: linear-gradient(150deg, #EDAAAC, #E5989B); } .c2 svg { stroke: #fff6f0; }
.c3 { background: linear-gradient(150deg, #C2949D, #B5838D); } .c3 svg { stroke: #FFE6D8; }
.c4 { background: linear-gradient(150deg, #7c7784, #6D6875); } .c4 svg { stroke: #FFCDB2; }
.dots { display: flex; justify-content: center; gap: 8px; padding: 6px 0 12px; }
.dots i { width: 6px; height: 6px; border-radius: 3px; background: rgba(109, 104, 117, .25); transition: all .3s; }
.dots i.on { width: 18px; background: var(--dusty); }
.dock { display: flex; justify-content: space-around; align-items: center; min-height: 64px; margin: 0 18px calc(env(safe-area-inset-bottom) + 16px); padding: 13px 10px;
  border-radius: 30px; background: rgba(255, 255, 255, .32); border: 1px solid rgba(255, 255, 255, .6);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); max-width: 480px; align-self: center; width: calc(100% - 36px); box-sizing: border-box; }
.dock .app span { display: none; } .dock .item { flex: 0 0 auto; } .dockgap { width: 60px; height: 60px; border-radius: 19px; border: 2px dashed var(--candy); box-sizing: border-box; }

/* 小組件 */
.widget { border-radius: 24px; overflow: hidden; cursor: pointer; color: var(--ash); font-family: var(--serif);
  background: linear-gradient(135deg, rgba(255, 255, 255, .46), rgba(255, 255, 255, .18)); border: 1px solid rgba(255, 255, 255, .62);
  box-shadow: 0 12px 30px rgba(109, 104, 117, .11), inset 0 1px 0 rgba(255, 255, 255, .7); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.widget > div { height: 100%; box-sizing: border-box; }
.w-clock.widget { background: none; border: none; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
.w-clock { display: flex; flex-direction: column; justify-content: center; padding: 0 4px; }
.clock { font-family: var(--latin); font-weight: 300; font-size: 72px; line-height: 1; letter-spacing: .02em; }
.date { font-size: 12px; letter-spacing: .32em; color: var(--dusty); margin-top: 8px; }
.widget[data-sw="2"] .clock, .widget[data-sh="1"] .clock { font-size: 44px; } .widget[data-sw="2"] .date { letter-spacing: .1em; }
.widget[data-sw="2"][data-sh="1"] .clock { font-size: 34px; } .widget[data-sh="1"] .date { margin-top: 2px; font-size: 11px; }
.widget[data-sw="3"][data-sh="1"] .clock { font-size: 40px; }
.w-glass { padding: 16px 18px 12px; }
.w-glass .t { font-family: var(--latin); font-size: 13px; letter-spacing: .28em; color: var(--dusty); display: flex; justify-content: space-between; margin-bottom: 8px; }
.w-glass .t span { font-family: var(--serif); letter-spacing: .1em; font-size: 11px; }
.w-glass .m { font-size: 14px; letter-spacing: .06em; line-height: 1.7; }
.w-glass .m small { display: block; font-size: 11.5px; color: var(--dusty); }
.w-glass .gl { display: grid; grid-template-columns: 28px auto 1fr auto; align-items: center; gap: 10px; padding: 4px 0; font-size: 13px; }
.w-glass .gl span { color: var(--dusty); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-glass .more { font-size: 11px; color: var(--dusty); }
.w-char { display: flex; align-items: center; gap: 14px; padding: 14px 18px; }
.widget[data-sh="2"][data-sw="2"] .w-char, .widget[data-sw="1"]:not([data-sh="1"]) .w-char, .widget[data-sh="3"] .w-char, .widget[data-sh="4"] .w-char { flex-direction: column; justify-content: center; gap: 8px; text-align: center; padding: 10px; }
.w-char b { font-weight: 400; font-size: 15px; display: block; letter-spacing: .08em; }
.w-char small { display: block; font-size: 12px; color: var(--dusty); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.w-char > div { min-width: 0; }
.w-note { padding: 16px; font-size: 14px; line-height: 1.7; overflow: hidden; background: linear-gradient(160deg, rgba(255, 236, 224, .9), rgba(255, 205, 178, .75)); }
.w-photo { background-size: cover; background-position: center; }
.w-days { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.w-days b { font-family: var(--latin); font-weight: 300; font-size: 48px; line-height: 1.1; color: var(--candy); }
.w-days small { font-size: 12px; color: var(--dusty); letter-spacing: .12em; }
.widget[data-sh="1"] .w-days { flex-direction: row; gap: 8px; } .widget[data-sh="1"] .w-days b { font-size: 30px; }
.widget[data-sw="1"][data-sh="1"] .w-days small:first-child { display: none; } .widget[data-sw="1"] .w-days b { font-size: 30px; }
.widget[data-sw="1"][data-sh="1"] .w-char { padding: 0; justify-content: center; } .widget[data-sw="1"][data-sh="1"] .w-char > div { display: none; }
.widget[data-sw="1"] .w-char small { display: none; }
.widget[data-sh="1"] .w-char { padding: 8px 14px; } .widget[data-sh="1"] .w-char small + small { display: none; }
.widget[data-sh="1"] .w-glass .gl:nth-child(n+3), .widget[data-sh="1"] .w-glass .more { display: none; }
.widget[data-sw="1"] .w-note { padding: 10px; font-size: 12px; } .widget[data-sw="1"] .empty-w { font-size: 11px; }
.widget[data-sh="1"] .w-feed .t { display: none; } .widget[data-sh="1"] .w-feed p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.w-feed { padding: 14px 16px; } .w-feed .t { font-size: 12px; letter-spacing: .2em; color: var(--dusty); margin-bottom: 8px; }
.w-feed .fp { display: flex; gap: 10px; } .w-feed p { margin: 0; font-size: 13px; line-height: 1.6; } .w-feed p b { font-weight: 400; color: var(--candy); margin-right: 6px; }
.empty-w { display: flex; align-items: center; justify-content: center; text-align: center; font-size: 12.5px; color: var(--dusty); padding: 10px; }

/* 編輯桌面 */
.item .x, .item .cfg { display: none; }
#home.editing .item .x { display: flex; position: absolute; top: -6px; left: -2px; width: 22px; height: 22px; border-radius: 50%; background: var(--ash); color: #fff;
  font-style: normal; font-size: 15px; align-items: center; justify-content: center; z-index: 3; box-shadow: 0 2px 6px rgba(0, 0, 0, .2); }
#home.editing .app .x { left: 6px; top: 2px; }
#home.editing .widget .cfg { display: block; position: absolute; right: 8px; bottom: 8px; font-style: normal; font-size: 11px; background: rgba(109, 104, 117, .85); color: #fff; padding: 3px 10px; border-radius: 999px; z-index: 3; }
#home.editing .widget { overflow: visible; }
.item .rs { display: none; }
#home.editing .widget .rs { display: block; position: absolute; right: -4px; bottom: -4px; width: 26px; height: 26px; z-index: 4; touch-action: none; cursor: nwse-resize; }
#home.editing .widget .rs::after { content: ""; position: absolute; right: 5px; bottom: 5px; width: 12px; height: 12px; border-right: 3px solid var(--ash); border-bottom: 3px solid var(--ash); border-radius: 0 0 6px 0; }
#home.editing .widget .cfg { right: 30px; }
#home.editing .item { animation: jiggle .32s ease-in-out infinite alternate; touch-action: none; }
#home.editing .item:nth-child(2n) { animation-delay: -.16s; }
@keyframes jiggle { from { transform: rotate(-1.1deg); } to { transform: rotate(1.1deg); } }
.item.placeholder { opacity: .25; animation: none !important; }
.dragghost { position: fixed !important; z-index: 80; pointer-events: none; transform: scale(1.06); opacity: .92; filter: drop-shadow(0 12px 20px rgba(109, 104, 117, .3)); animation: none !important; }
.dragghost .x, .dragghost .cfg { display: none !important; }
.edbar { display: none; position: absolute; top: calc(env(safe-area-inset-top) + 6px); left: 0; right: 0; z-index: 5; justify-content: center; gap: 6px; flex-wrap: wrap; padding: 0 10px; }
#home.editing .edbar { display: flex; }
.edbar button { border: none; border-radius: 999px; padding: 7px 13px; font-family: var(--serif); font-size: 12.5px; background: rgba(255, 255, 255, .8); color: var(--ash); box-shadow: 0 3px 10px rgba(109, 104, 117, .15); }
.edbar .done { background: var(--candy); color: #fff; }
#home.editing .hpage { padding-top: calc(env(safe-area-inset-top) + 52px); }
.wpick { display: flex; flex-direction: column; gap: 8px; }
.wp { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; background: #fff; border: 1px solid var(--line); border-radius: 14px; font-family: var(--serif); color: var(--ink); text-align: left; cursor: pointer; } .wp small { color: var(--dusty); font-size: 11.5px; }
.wp b { font-weight: 400; font-size: 14px; } .wp div { display: flex; gap: 6px; }
.wp button, .segs button { border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 5px 11px; font-family: var(--serif); font-size: 12px; color: var(--ash); }
.segs { display: flex; gap: 8px; } .segs button.on { background: var(--candy); color: #fff; border-color: var(--candy); }

/* ---------------- 頭貼 ---------------- */
.av { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; overflow: hidden; flex: none;
  color: #fff; font-family: var(--serif); background: var(--candy); box-shadow: 0 0 0 2px #fff, 0 3px 8px rgba(109, 104, 117, .2); }
.av img { width: 100%; height: 100%; object-fit: cover; }
.av0 { background: #E5989B; } .av1 { background: #B5838D; } .av2 { background: #F2A88F; } .av3 { background: #6D6875; } .av4 { background: #D69C8C; }

/* ---------------- App 視窗 ---------------- */
#panels { position: fixed; inset: 0; pointer-events: none; z-index: 15; }
.panel { position: absolute; inset: 0; background: var(--paper); color: var(--ink); font-family: var(--serif); pointer-events: auto;
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .38s cubic-bezier(.2, .8, .2, 1); box-shadow: -10px 0 30px rgba(109, 104, 117, .12); }
.panel.in { transform: translateX(0); }
.phead { display: flex; align-items: center; gap: 6px; padding: calc(env(safe-area-inset-top) + 10px) 10px 10px; border-bottom: 1px solid var(--line); background: rgba(255, 246, 241, .92); backdrop-filter: blur(8px); }
.back, .iconbtn { width: 40px; height: 40px; border: none; background: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--ash); cursor: pointer; flex: none; }
.back svg, .iconbtn svg { width: 22px; height: 22px; stroke: currentColor; }
.back:active, .iconbtn:active { background: rgba(229, 152, 155, .15); }
.ptitle { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ptitle b { font-weight: 400; font-size: 17px; letter-spacing: .12em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ptitle small { font-family: var(--latin); font-size: 11px; letter-spacing: .25em; color: var(--dusty); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pact { display: flex; }
.pbody { flex: 1; overflow-y: auto; padding: 18px 18px calc(env(safe-area-inset-bottom) + 30px); -webkit-overflow-scrolling: touch; }

/* ---------------- 表單 ---------------- */
.in, .ta { width: 100%; box-sizing: border-box; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 12px;
  font-family: var(--serif); font-size: 14px; color: var(--ink); outline: none; transition: border-color .2s; }
.ta { resize: vertical; line-height: 1.6; }
.in:focus, .ta:focus { border-color: var(--candy); }
select.in { appearance: none; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23B5838D' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 12px center; padding-right: 32px; }
.fld { display: block; margin: 12px 0; }
.fld > span { display: block; font-size: 12px; color: var(--dusty); letter-spacing: .08em; margin-bottom: 6px; }
.row { display: flex; align-items: center; } .gap { gap: 10px; } .row .in { flex: 1; }
.btn { border: none; border-radius: 999px; padding: 11px 20px; background: var(--candy); color: #fff; font-family: var(--serif); font-size: 13.5px; letter-spacing: .12em; cursor: pointer; }
.btn:active { transform: scale(.97); } .btn:disabled { opacity: .4; }
.btn.ghost { background: transparent; color: var(--ash); border: 1px solid var(--line); }
.btn.danger { background: #c97a7d; } .btn.danger.ghost { background: none; color: #b85f63; border-color: rgba(184, 95, 99, .35); }
.btn.sm { padding: 8px 14px; font-size: 12.5px; } .btn.full { width: 100%; margin-top: 12px; }
.row .btn { flex: 1; } .row .btn.sm { flex: none; }
.card { background: #fff; border-radius: 20px; padding: 6px 16px 14px; margin-bottom: 16px; border: 1px solid var(--line); }
.card h3 { font-weight: 400; font-size: 15px; letter-spacing: .14em; margin: 12px 0 4px; color: var(--ash); }
.switch { display: flex; gap: 12px; align-items: flex-start; margin: 14px 0; cursor: pointer; }
.switch input { display: none; }
.switch > span { flex: none; width: 42px; height: 24px; border-radius: 12px; background: #e6d9d4; position: relative; transition: background .2s; margin-top: 2px; }
.switch > span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.switch input:checked + span { background: var(--candy); } .switch input:checked + span::after { left: 21px; }
.switch b { font-weight: 400; font-size: 14px; display: block; } .switch small { font-size: 12px; color: var(--dusty); line-height: 1.6; display: block; }
input[type=range] { width: 100%; accent-color: var(--candy); }

/* ---------------- 角色列表／編輯 ---------------- */
.cgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.ccard { background: #fff; border: 1px solid var(--line); border-radius: 22px; padding: 18px 12px 14px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-family: var(--serif); color: var(--ink); cursor: pointer; }
.ccard b { font-weight: 400; font-size: 15px; letter-spacing: .08em; margin-top: 6px; }
.ccard small { font-size: 11.5px; color: var(--dusty); }
.bar { display: block; width: 100%; height: 4px; border-radius: 2px; background: #f3e4de; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--blush), var(--candy)); transition: width .4s; }
.ccard .bar { width: 70%; margin-top: 4px; }
.empty { text-align: center; padding: 60px 20px; color: var(--dusty); } .empty p { font-size: 15px; color: var(--ash); margin-bottom: 6px; }
.empty .btn { margin-top: 18px; } .empty.small { padding: 40px 10px; }
.ehead { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 16px; }
.avpick { border: none; background: none; display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--dusty); font-family: var(--serif); cursor: pointer; }
.avpick small { font-size: 11px; }
.in.name { text-align: center; font-size: 20px; letter-spacing: .12em; border: none; border-bottom: 1px solid var(--line); border-radius: 0; background: none; }
.prog { width: 80%; text-align: center; } .prog small { font-size: 11.5px; color: var(--dusty); display: block; margin-top: 6px; }
.sec { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 0 16px; margin-bottom: 12px; }
.sec summary { list-style: none; padding: 14px 0; font-size: 15px; letter-spacing: .14em; display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.sec summary::-webkit-details-marker { display: none; }
.sec summary small { font-size: 11px; color: var(--dusty); letter-spacing: .05em; }
.sec summary::after { content: "›"; color: var(--candy); transition: transform .2s; margin-left: 8px; }
.sec[open] summary::after { transform: rotate(90deg); }
.sec[open] { padding-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 6px 5px 12px; border-radius: 999px; background: #FFE6D9; font-size: 13px; }
.chip.grown { background: #EDE6DA; }
.chip button { border: none; background: none; color: var(--dusty); font-size: 15px; cursor: pointer; padding: 0 4px; }
.ebtns { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }

/* ---------------- 聊天 ---------------- */
.clist { display: flex; flex-direction: column; }
.crow, .rrow { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 4px; border: none; border-bottom: 1px solid var(--line);
  background: none; text-align: left; font-family: var(--serif); color: var(--ink); cursor: pointer; }
.crow b, .rrow b { font-weight: 400; font-size: 15px; letter-spacing: .06em; }
.crow small, .rrow small { display: block; font-size: 12.5px; color: var(--dusty); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crow > div, .rrow > div { min-width: 0; }
.crow time, .rrow time { font-size: 11px; color: var(--dusty); }
.chatpanel .pbody { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.msgs { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 8px; }
.day { align-self: center; font-size: 11px; color: var(--dusty); margin: 8px 0; letter-spacing: .1em; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 82%; animation: pop .25s ease; }
.msg p { margin: 0; padding: 9px 14px; border-radius: 18px; font-size: 14.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.msg.char p { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.user { align-self: flex-end; }
.msg.user p { background: linear-gradient(140deg, var(--blush), var(--candy)); color: #fff; border-bottom-right-radius: 6px; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }
.typing { display: none; gap: 4px; padding: 0 22px 8px; } .typing.show { display: flex; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--dusty); opacity: .4; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: 1; transform: translateY(-2px); } }
.composer { display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px calc(env(safe-area-inset-bottom) + 10px); border-top: 1px solid var(--line); background: #fff; }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 20px; padding: 10px 14px; font-family: var(--serif); font-size: 14.5px; max-height: 120px; outline: none; color: var(--ink); background: var(--paper); }
.send { width: 42px; height: 42px; border-radius: 50%; border: none; background: var(--candy); display: flex; align-items: center; justify-content: center; flex: none; cursor: pointer; }
.send svg { stroke: #fff; width: 20px; height: 20px; }
.quote { background: var(--paper); border-left: 3px solid var(--blush); padding: 10px 12px; border-radius: 8px; font-size: 14px; white-space: pre-wrap; }

/* ---------------- 家園 ---------------- */
.homepanel .pbody { padding: 12px 14px 30px; }
.htabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; }
.htabs button { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 14px; font-family: var(--serif); font-size: 13px; color: var(--ash); cursor: pointer; }
.htabs button small { margin-left: 6px; color: var(--dusty); font-size: 11px; }
.htabs button.on { background: var(--candy); color: #fff; border-color: var(--candy); } .htabs button.on small { color: #fff; }
.htabs .add { border-style: dashed; color: var(--dusty); }
.away { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #FFE6D9; border-radius: 14px; padding: 10px 14px; font-size: 13px; margin-bottom: 10px; }
.away button { border: none; background: var(--candy); color: #fff; border-radius: 999px; padding: 5px 12px; font-family: var(--serif); font-size: 12px; flex: none; }
.scene { position: relative; width: 100%; aspect-ratio: 100 / 125; max-height: 62vh; margin: 0 auto; border-radius: 26px; overflow: hidden;
  box-shadow: 0 14px 34px rgba(109, 104, 117, .18), inset 0 0 0 1px rgba(255, 255, 255, .7); background: #F7E4D8; }
@supports not (aspect-ratio: 1) { .scene { height: 125vw; } }
.scene .room { position: absolute; inset: 0; width: 100%; height: 100%; }
.actors { position: absolute; inset: 0; }
.actor { position: absolute; transform: translate(-50%, -62%); border: none; background: none; padding: 0; display: flex; flex-direction: column; align-items: center; cursor: pointer;
  transition: left 2.6s cubic-bezier(.45, .05, .35, 1), top 2.6s cubic-bezier(.45, .05, .35, 1), opacity .8s; font-family: var(--serif); }
.actor .av { animation: bob 3.2s ease-in-out infinite; box-shadow: 0 0 0 2.5px #fff, 0 6px 12px rgba(109, 104, 117, .3); }
.actor.hop .av { animation: walk .45s ease-in-out 6, bob 3.2s ease-in-out 2.7s infinite; }
.actor .nm { font-size: 10.5px; margin-top: 4px; padding: 1px 7px; border-radius: 999px; background: rgba(255, 255, 255, .85); color: var(--ash); white-space: nowrap; }
.actor .bubble { position: relative; background: #fff; border-radius: 14px; padding: 2px 7px; margin-bottom: 6px; font-size: 17px; line-height: 1.3; box-shadow: 0 3px 8px rgba(109, 104, 117, .2); }
.actor .bubble::after { content: ""; position: absolute; left: 50%; bottom: -4px; width: 8px; height: 8px; background: #fff; transform: translateX(-50%) rotate(45deg); }
.actor .be { display: inline-block; transition: transform .18s, opacity .18s; position: relative; z-index: 1; }
.actor .be.swap { transform: scale(.4); opacity: 0; }
.actor.sleep .av { animation: none; filter: saturate(.7) brightness(.95); }
.actor.out { opacity: .45; }
@keyframes bob { 50% { transform: translateY(-3px); } }
@keyframes walk { 0%, 100% { transform: translateY(0) rotate(0); } 25% { transform: translateY(-4px) rotate(-5deg); } 75% { transform: translateY(-4px) rotate(5deg); } }
.noone { position: absolute; left: 50%; top: 48%; transform: translate(-50%, -50%); text-align: center; background: rgba(255, 255, 255, .8); padding: 14px 20px; border-radius: 16px; font-size: 14px; color: var(--ash); }
.noone small { color: var(--dusty); font-size: 12px; }
.clockchip { position: absolute; right: 10px; top: 10px; font-family: var(--latin); font-size: 14px; letter-spacing: .1em; color: #fff; background: rgba(109, 104, 117, .45); padding: 2px 10px; border-radius: 999px; }
.residents { margin-top: 14px; display: flex; flex-direction: column; }
.dhead { display: flex; gap: 14px; align-items: center; } .dhead h2 { margin: 0; }
.dhead small { color: var(--dusty); font-size: 13px; }
.narr { font-size: 14.5px; line-height: 1.9; background: var(--paper); padding: 14px 16px; border-radius: 16px; margin: 14px 0 10px; white-space: pre-wrap; }
h3.sub { font-weight: 400; font-size: 13px; letter-spacing: .2em; color: var(--dusty); margin: 18px 0 6px; }
.tline { list-style: none; padding: 0; margin: 0 0 16px; font-size: 13.5px; }
.tline li { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.tline time { font-family: var(--latin); color: var(--dusty); width: 40px; flex: none; }
.tline em { margin-left: auto; font-style: normal; }
.tline b { font-weight: 400; color: var(--candy); }
.pick { display: flex; flex-direction: column; gap: 4px; max-height: 40vh; overflow: auto; margin: 10px 0 14px; }
.pk { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.pk span { flex: 1; } .pk b { font-weight: 400; display: block; font-size: 14px; } .pk small { font-size: 11.5px; color: var(--dusty); }
.pk input { width: 20px; height: 20px; accent-color: var(--candy); }

/* ---------------- 底部面板／提示 ---------------- */
#sheetBg { position: fixed; inset: 0; background: rgba(109, 104, 117, .35); opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 40; }
#sheetBg.show { opacity: 1; pointer-events: auto; }
#sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 82vh; overflow: auto; z-index: 41; background: var(--paper); border-radius: 26px 26px 0 0;
  padding: 14px 22px calc(env(safe-area-inset-bottom) + 24px); transform: translateY(105%); transition: transform .38s cubic-bezier(.2, .8, .2, 1);
  color: var(--ink); font-family: var(--serif); max-width: 560px; margin: 0 auto; box-shadow: 0 -10px 40px rgba(109, 104, 117, .18); }
#sheet.show { transform: translateY(0); }
#sheet .grab { width: 38px; height: 4px; border-radius: 2px; background: var(--candy); opacity: .5; margin: 0 auto 16px; }
#sheet h2 { font-weight: 400; font-size: 19px; letter-spacing: .14em; margin: 0 0 10px; }
#sheet .tag { display: inline-block; font-size: 11px; letter-spacing: .2em; padding: 4px 10px; border-radius: 999px; background: var(--peach); color: var(--ash); }
.flist { margin-top: 14px; padding-left: 1.1em; font-size: 13.5px; line-height: 1.85; } .flist li::marker { color: var(--candy); }
.choice { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.choice button { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 14px 16px; font-family: var(--serif); color: var(--ink); cursor: pointer; }
.choice b { font-weight: 400; font-size: 15px; display: block; } .choice small { font-size: 12px; color: var(--dusty); }
.confirm-msg { font-size: 15px; line-height: 1.7; margin: 6px 0 18px; }
#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 90px); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: rgba(109, 104, 117, .94); color: #fff; padding: 10px 18px; border-radius: 14px; font-family: var(--serif); font-size: 13px; line-height: 1.6;
  max-width: 84vw; transition: all .3s; z-index: 60; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 群組 ---------------- */
.stack { display: flex; width: 50px; flex-wrap: wrap; gap: 0; position: relative; height: 50px; }
.stack .av { position: absolute; } .stack .av:nth-child(1) { left: 0; top: 0; } .stack .av:nth-child(2) { right: 0; top: 6px; } .stack .av:nth-child(3) { left: 8px; bottom: 0; }
.cnt { font-style: normal; font-size: 11px; color: var(--dusty); }
.msg > div { display: flex; flex-direction: column; min-width: 0; }
.msg .who { font-size: 11px; color: var(--dusty); margin: 0 0 3px 4px; }
.msg.cont { margin-top: -4px; } .avsp { width: 30px; flex: none; }
.typing em { font-style: normal; font-size: 11px; color: var(--dusty); margin-left: 6px; }
.composer .iconbtn { width: 36px; height: 42px; }

/* ---------------- 記憶 ---------------- */
.hintcard { background: #FFE6D9; border-radius: 14px; padding: 10px 14px; font-size: 13px; line-height: 1.6; margin-bottom: 12px; }
.mlist { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.mem { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.mem p { margin: 0 0 8px; font-size: 14px; line-height: 1.7; white-space: pre-wrap; max-height: 9em; overflow: hidden; }
.mmeta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11px; color: var(--dusty); }
.mmeta time { margin-right: auto; }
.mmeta button { border: none; background: var(--paper); border-radius: 999px; padding: 3px 9px; font-family: var(--serif); font-size: 11px; color: var(--ash); }
.srctag { background: #F6E5DE; border-radius: 6px; padding: 1px 6px; } .srctag.v { background: #E9E2EE; }

/* ---------------- 動態 ---------------- */
.compose-post { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 14px; } .compose-post .ta { flex: 1; }
.post { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 14px 16px 10px; margin-bottom: 12px; }
.post header { display: flex; gap: 10px; align-items: center; }
.post header div { flex: 1; } .post header b { font-weight: 400; font-size: 15px; display: block; } .post header small { font-size: 11.5px; color: var(--dusty); }
.post .pm { border: none; background: none; color: var(--dusty); font-size: 18px; }
.ptext { font-size: 14.5px; line-height: 1.75; margin: 10px 0 8px; white-space: pre-wrap; }
.pphoto { background: linear-gradient(135deg, #FFE3D3, #F1D4D2); border-radius: 14px; padding: 22px 16px; font-size: 13px; color: var(--ash); line-height: 1.6; display: flex; gap: 8px; margin-bottom: 8px; }
.pacts { display: flex; gap: 6px; border-top: 1px solid var(--line); padding-top: 6px; }
.pacts button { border: none; background: none; font-family: var(--serif); color: var(--ash); font-size: 13.5px; padding: 6px 10px; border-radius: 10px; }
.pacts button.on { color: var(--candy); }
.plikes { font-size: 12px; color: var(--candy); padding: 4px 2px; }
.pcmts { background: var(--paper); border-radius: 12px; padding: 8px 12px; margin-top: 4px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; line-height: 1.6; }
.pcmts b { font-weight: 400; color: var(--dusty); margin-right: 8px; }
.iconbtn.spin svg { animation: spin 1.2s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 觀察窗 ---------------- */
.peekpanel .phead { background: rgba(109, 104, 117, .96); color: #FFE6D8; } .peekpanel .phead small { color: #E5989B; } .peekpanel .back { color: #FFE6D8; }
.peekc { background: linear-gradient(160deg, #fff, #F5E8E4); }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; background: #F3E4DE; padding: 4px; border-radius: 999px; }
.tabs button { flex: 1; border: none; background: none; padding: 8px 0; border-radius: 999px; font-family: var(--serif); font-size: 13px; color: var(--ash); }
.tabs button.on { background: #fff; box-shadow: 0 2px 6px rgba(109, 104, 117, .12); }
.mind { background: #6D6875; color: #FFE6D8; border-radius: 20px; padding: 20px; text-align: center; }
.mind p { font-size: 15px; line-height: 1.95; text-align: left; white-space: pre-wrap; margin: 0 0 10px; }
.mind small { display: block; font-size: 11px; color: #E5989B; margin-bottom: 12px; text-align: left; }
.mind .muted { color: #FFCDB2; text-align: center; }
.mind .btn.ghost { color: #FFE6D8; border-color: rgba(255, 230, 216, .35); }
.oldmind { border-left: 2px solid var(--blush); padding: 4px 0 4px 12px; margin: 10px 0; }
.oldmind p { font-size: 13.5px; line-height: 1.8; margin: 0; white-space: pre-wrap; } .oldmind small { font-size: 11px; color: var(--dusty); }
.linkback { border: none; background: none; color: var(--dusty); font-family: var(--serif); font-size: 13px; padding: 0 0 8px; }
.pmhead { display: flex; align-items: center; gap: 6px; justify-content: center; font-size: 13px; margin-bottom: 8px; } .pmhead em { color: var(--candy); font-style: normal; margin: 0 6px; }
.pmthread { max-height: 52vh; background: #fff; border-radius: 18px; border: 1px solid var(--line); margin-bottom: 4px; }
.pmthread .msg.user p { background: linear-gradient(140deg, #8a8492, #6D6875); }
.tline .dsep { color: var(--candy); font-size: 12px; letter-spacing: .2em; border: none; padding-top: 12px; }
.cssref { font-size: 12.5px; color: var(--ash); margin-bottom: 8px; } .cssref summary { color: var(--dusty); cursor: pointer; }
.cssref ul { padding-left: 1.1em; line-height: 1.9; } .cssref code { background: var(--paper); padding: 0 4px; border-radius: 4px; font-size: 11.5px; }

.steps { display: flex; gap: 18px; } .steps label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ash); }
.steps button { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: #fff; font-size: 16px; color: var(--ash); }
.steps b { font-weight: 400; min-width: 14px; text-align: center; font-size: 16px; }

/* ---------------- 共用：選項晶片 ---------------- */
.chipsel { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 6px; }
.chipsel button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-family: var(--serif); font-size: 12.5px; color: var(--ash); display: inline-flex; align-items: center; gap: 6px; }
.chipsel button.on { background: var(--candy); border-color: var(--candy); color: #fff; }
.chipsel button i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.chipsel.filt { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-bottom: 12px; padding-bottom: 2px; }
.chipsel.filt button { flex: none; }

/* ---------------- 見面 ---------------- */
.meetpanel .pbody { background: #FFF9F5; }
.story { flex: 1; overflow-y: auto; padding: 18px 20px 10px; }
.sit { font-size: 12.5px; color: var(--dusty); background: #FFEDE4; border-radius: 12px; padding: 8px 12px; margin-bottom: 16px; line-height: 1.6; }
.beat { margin: 0 0 18px; font-size: 15px; line-height: 2; color: var(--ink); cursor: pointer; }
.beat p { margin: 0 0 .7em; text-indent: 0; }
.beat.user { background: linear-gradient(140deg, rgba(255, 180, 162, .22), rgba(229, 152, 155, .18)); border-radius: 16px; padding: 10px 14px; font-size: 14.5px; line-height: 1.8; }
.beat.user small { display: block; font-size: 11px; color: var(--candy); letter-spacing: .15em; }
.beat i { color: var(--dusty); }
.meetc { flex-direction: column; align-items: stretch; }
.meetc textarea { border-radius: 16px; min-height: 52px; }
.mbtns { display: flex; justify-content: flex-end; gap: 8px; }
.mbtns .btn { flex: none; }

/* ---------------- 寫文 ---------------- */
.slist { display: flex; flex-direction: column; gap: 12px; }
.scard { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; font-family: var(--serif); color: var(--ink); cursor: pointer; }
.scard b { font-weight: 400; font-size: 16px; letter-spacing: .06em; display: block; }
.scard small { font-size: 11.5px; color: var(--dusty); }
.scard p { margin: 8px 0 0; font-size: 13px; color: var(--ash); line-height: 1.7; }
.readpanel .pbody { background: #FFFAF6; }
.reader { max-width: 620px; margin: 0 auto; padding: 6px 4px 10px; }
.reader h1 { font-weight: 400; font-size: 22px; letter-spacing: .12em; text-align: center; margin: 10px 0 8px; }
.byline { display: flex; justify-content: center; align-items: center; gap: 4px; font-size: 12px; color: var(--dusty); margin-bottom: 22px; }
.byline span { margin-left: 8px; }
.reader p { font-size: 15.5px; line-height: 2.05; margin: 0 0 1em; text-indent: 2em; }
.rx { display: flex; gap: 10px; margin: 10px 0; } .rx p { text-indent: 0; font-size: 14px; line-height: 1.7; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; margin: 0; }
.rx b { font-weight: 400; color: var(--candy); display: block; font-size: 12px; }

/* ---------------- 筆記 ---------------- */
.nlist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.ncard { text-align: left; border: none; border-radius: 6px 18px 18px 18px; padding: 12px 14px; font-family: var(--serif); color: var(--ink); cursor: pointer;
  background: repeating-linear-gradient(#FFF8F2 0 25px, #F3DED5 25px 26px); box-shadow: 0 4px 12px rgba(109, 104, 117, .1); min-height: 140px; display: flex; flex-direction: column; }
.ncard header { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--dusty); margin-bottom: 6px; }
.ncard header em { font-style: normal; background: var(--peach); color: var(--ash); border-radius: 6px; padding: 0 6px; margin-left: auto; }
.ncard b { font-weight: 400; font-size: 15px; margin-bottom: 4px; } .ncard p { margin: 0 0 auto; font-size: 12.5px; line-height: 1.6; color: var(--ash); }
.ncard small { font-size: 11px; color: var(--dusty); margin-top: 6px; }
.paper { background: repeating-linear-gradient(#FFF8F2 0 31px, #F0D9CF 31px 32px); border-radius: 6px 22px 22px 22px; padding: 18px 20px 20px; box-shadow: 0 8px 22px rgba(109, 104, 117, .12); }
.paper header b { font-weight: 400; font-size: 19px; display: block; letter-spacing: .08em; } .paper header small { font-size: 11.5px; color: var(--dusty); }
.pbody2 { font-size: 15px; line-height: 32px; margin-top: 10px; }
.anns { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.ann { background: rgba(255, 205, 178, .55); border-radius: 10px; padding: 6px 10px; font-size: 13px; line-height: 1.6; transform: rotate(-.6deg); }
.ann:nth-child(2n) { transform: rotate(.5deg); background: rgba(229, 152, 155, .25); }
.ann b { font-weight: 400; color: var(--candy); margin-right: 8px; font-size: 12px; }
.ann img { display: block; max-width: 70%; margin-top: 4px; }
.doodle { width: 100%; aspect-ratio: 600 / 420; background: #FFF8F2; border-radius: 16px; border: 1px solid var(--line); touch-action: none; }
.swatches { display: flex; gap: 8px; flex: 1; } .swatches button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.swatches button.on { box-shadow: 0 0 0 2px var(--ash); }

/* ---------------- 行事曆 ---------------- */
.calhead { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 10px; }
.calhead b { font-weight: 400; font-size: 16px; letter-spacing: .12em; }
.calhead button { border: none; background: #fff; width: 34px; height: 34px; border-radius: 50%; font-size: 18px; color: var(--ash); border: 1px solid var(--line); }
.calgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 10px; }
.calgrid small { text-align: center; font-size: 11px; color: var(--dusty); padding-bottom: 4px; }
.calgrid button { border: none; background: none; aspect-ratio: 1; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-family: var(--latin); font-size: 15px; color: var(--ink); }
.calgrid button.today span { color: var(--candy); font-weight: 600; }
.calgrid button.sel { background: var(--peach); }
.calgrid em { display: flex; gap: 2px; height: 5px; } .calgrid em b { width: 5px; height: 5px; border-radius: 50%; }
.evlist { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.ev { display: flex; gap: 12px; align-items: center; text-align: left; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--candy); border-radius: 12px; padding: 10px 12px; font-family: var(--serif); color: var(--ink); }
.ev time { font-family: var(--latin); font-size: 14px; color: var(--dusty); min-width: 44px; }
.ev b { font-weight: 400; font-size: 14px; display: block; } .ev small { font-size: 11.5px; color: var(--dusty); }
