/* ============ 遗物 · OS 桌面 ============ */
:root {
  --bg: #0a0c11;
  --panel: rgba(18, 21, 28, 0.92);
  --panel-border: #232936;
  --text: #d6dbe6;
  --text-dim: #8b93a5;
  --accent: #6e86a6;
  --danger: #8f3a3a;
  --win-w: 560px;
  --win-h: 400px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-user-select: none; user-select: none;
}
/* 输入框必须可编辑可选中（body 的 user-select:none 会拦掉部分手机浏览器聚焦） */
input, textarea, [contenteditable] { user-select: text; -webkit-user-select: text; }
button { font-family: inherit; cursor: pointer; }
img { -webkit-user-drag: none; }

/* ============ 开机画面 ============ */
#boot {
  position: fixed; inset: 0; z-index: 1000;
  background: #05060a;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .5s ease;
}
.boot-inner { text-align: center; }
.boot-logo {
  font-size: 54px; letter-spacing: .35em; font-weight: 200;
  color: #e8ecf4; text-shadow: 0 0 30px rgba(120, 140, 180, .35);
}
.boot-sub { margin-top: 14px; font-size: 13px; color: #5c6474; letter-spacing: .2em; }
.boot-bar {
  width: 220px; height: 3px; margin: 34px auto 0;
  background: #1a1f2a; border-radius: 2px; overflow: hidden;
}
.boot-bar-fill {
  height: 100%; width: 0; background: linear-gradient(90deg, #5a708f, #a9bcd8);
  animation: bootfill 1.6s ease forwards;
}
@keyframes bootfill { from { width: 0 } to { width: 100% } }
.boot-hint { margin-top: 20px; font-size: 12px; color: #3d4452; }
.boot-reset {
  position: absolute; bottom: 18px; width: 100%; text-align: center;
  font-size: 11px; color: #3d4452; cursor: pointer; letter-spacing: .1em;
}
.boot-reset:hover { color: #7d8a9e; text-decoration: underline; }
#boot.boot-done { opacity: 0; pointer-events: none; }

/* ============ 桌面 ============ */
.os { position: fixed; inset: 0; display: flex; flex-direction: column; }
#wallpaper {
  position: absolute; inset: 0;
  background:
    radial-gradient(1200px 700px at 70% 20%, #141a26 0%, transparent 60%),
    radial-gradient(900px 600px at 20% 85%, #0d1118 0%, transparent 55%),
    linear-gradient(160deg, #0a0d13 0%, #0c1017 55%, #08090d 100%);
}
/* 噪点质感（内联 SVG，零外部素材） */
#wallpaper::after {
  content: ""; position: absolute; inset: 0; opacity: .05; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.desktop { position: relative; flex: 1; overflow: hidden; }
.icons { position: absolute; inset: 14px; display: flex; flex-direction: column; flex-wrap: wrap; align-content: flex-start; gap: 4px; }

.desk-icon {
  width: 84px; padding: 10px 4px 8px; text-align: center; border-radius: 8px;
  cursor: pointer; border: 1px solid transparent;
  transition: background .15s;
}
.desk-icon:hover { background: rgba(120, 140, 180, .12); }
.desk-icon:active { transform: scale(.96); }
.di-ico { font-size: 34px; line-height: 1; filter: drop-shadow(0 2px 6px rgba(0,0,0,.5)); }
.di-label {
  margin-top: 6px; font-size: 12px; color: #cdd3e0;
  text-shadow: 0 1px 2px #000; word-break: break-all;
}

/* ============ 窗口 ============ */
.windows { position: absolute; inset: 0; pointer-events: none; }
.window {
  position: absolute; left: 120px; top: 70px;
  width: var(--win-w); height: var(--win-h);
  min-width: 320px; min-height: 220px;
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 10px; box-shadow: 0 18px 60px rgba(0,0,0,.6);
  display: flex; flex-direction: column; overflow: hidden;
  pointer-events: auto;
  transition: opacity .18s ease, transform .18s ease;
}
.window:nth-child(2) { left: 180px; top: 110px; }
.window:nth-child(3) { left: 240px; top: 150px; }
.window:nth-child(4) { left: 300px; top: 190px; }
.window:nth-child(5) { left: 360px; top: 230px; }
.window.minimized { display: none; }
.window-touch { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; border-radius: 0; }

.win-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-bottom: 1px solid var(--panel-border);
  background: linear-gradient(#1c2230, #151a25); cursor: default;
  touch-action: none;
}
.win-title { font-size: 13px; color: var(--text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.win-btns { display: flex; gap: 4px; }
.win-btns button {
  width: 26px; height: 22px; border: none; border-radius: 5px;
  background: transparent; color: var(--text-dim); font-size: 12px; line-height: 1;
}
.win-btns button:hover { background: rgba(255,255,255,.08); color: var(--text); }
.win-btns .wb-close:hover { background: #a33; color: #fff; }
.win-body { flex: 1; overflow: auto; position: relative; background: #10141b; }

.app-placeholder, .app-error { padding: 40px; text-align: center; color: var(--text-dim); font-size: 14px; }

/* ============ 任务栏 ============ */
.taskbar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; background: rgba(13, 16, 22, .92);
  border-top: 1px solid var(--panel-border);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.tb-start {
  width: 34px; height: 30px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; border-radius: 6px; border: none; background: transparent; color: var(--text);
}
.tb-start:hover { background: rgba(255,255,255,.08); }
.tb-apps { flex: 1; display: flex; gap: 6px; overflow-x: auto; }
.tb-app {
  padding: 5px 12px; border-radius: 6px; border: none;
  background: rgba(255,255,255,.05); color: var(--text-dim); font-size: 12px;
  white-space: nowrap;
}
.tb-app:hover { background: rgba(255,255,255,.1); color: var(--text); }
.tb-clock { font-size: 12px; color: var(--text-dim); }
.tb-clue {
  height: 28px; padding: 0 10px; border: none; border-radius: 6px;
  background: transparent; font-size: 14px;
}
.tb-clue:hover { background: rgba(255,255,255,.08); }
.clue-body p { margin-bottom: 8px; line-height: 1.7; }
.clue-restart {
  padding: 7px 16px; border: none; border-radius: 7px;
  background: transparent; color: var(--text-dim); font-size: 12px;
}
.clue-restart:hover { color: var(--danger); background: rgba(200,80,80,.08); }
.tb-donate {
  height: 28px; padding: 0 10px; border: none; border-radius: 6px;
  background: transparent; font-size: 15px;
}
.tb-donate:hover { background: rgba(255,255,255,.08); }
.donate-qr { width: 200px; height: 200px; object-fit: contain; border-radius: 10px; background: #fff; padding: 8px; }
.donate-tip { margin-top: 10px; font-size: 11px; color: var(--text-dim); }

/* ============ 系统提示 ============ */
.toast {
  position: absolute; left: 50%; top: 16px; transform: translateX(-50%) translateY(-10px);
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 8px;
  padding: 10px 18px; font-size: 13px; color: var(--text); z-index: 900;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); opacity: 0; transition: opacity .25s, transform .25s;
  pointer-events: none; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.hidden { display: none !important; }

/* ============ 开场邮件 ============ */
.email { position: fixed; inset: 0; z-index: 800; background: rgba(4,5,8,.7); display: flex; align-items: center; justify-content: center; padding: 20px; }
.email-box { width: min(520px, 94vw); background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px; box-shadow: 0 20px 70px rgba(0,0,0,.6); overflow: hidden; }
.email-head { padding: 12px 16px; font-size: 13px; color: var(--text); border-bottom: 1px solid var(--panel-border); background: linear-gradient(#1c2230, #151a25); }
.email-subject { color: var(--text-dim); }
.email-body { padding: 18px 20px; font-size: 14px; line-height: 1.9; color: var(--text); white-space: pre-line; }
.email-body p { margin-bottom: 10px; }
.email-foot { padding: 12px 16px; text-align: right; border-top: 1px solid var(--panel-border); }
.email-ok { padding: 7px 22px; border: none; border-radius: 7px; background: #2c4a5c; color: #e6eef6; font-size: 13px; }

/* ============ 阶段氛围 ============ */
.os[data-stage="act2"] #wallpaper { filter: brightness(.88) saturate(.8); }
.os[data-stage="end"] #wallpaper { filter: brightness(.7) saturate(.6) contrast(1.05); }
.os[data-stage="end"]::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 1; opacity: .06;
  background: repeating-linear-gradient(0deg, transparent 0 3px, #000 3px 4px);
  animation: hz .12s steps(2) infinite;
}
@keyframes hz { 50% { transform: translateY(1px) } }

/* ============ 结局场景 ============ */
.ending { position: fixed; inset: 0; z-index: 980; background: #030406; overflow: hidden; }
.ending-fog {
  position: absolute; inset: 0; opacity: .05; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.ending-box {
  position: relative; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 8vh 12vw;
}
.ending-text {
  max-width: 640px; color: #aab4c4; font-size: 16px; line-height: 2.1;
  letter-spacing: .05em; font-weight: 300;
}
.ending-text p { margin-bottom: 6px; }
.ending-text p::after { content: "▍"; color: #5a6678; animation: caret 1s steps(2) infinite; }
@keyframes caret { 50% { opacity: 0 } }
.ending-fin { text-align: center; margin-top: 36px; }
.ending-theend { font-size: 42px; letter-spacing: .5em; color: #c9d2e0; font-weight: 200; margin-bottom: 26px; }
.ending-ok {
  padding: 9px 26px; border: 1px solid #2c3554; border-radius: 8px;
  background: transparent; color: #8fa2b8; font-size: 13px;
}
.ending-ok:hover { background: rgba(120,150,190,.1); color: #cdd8e6; }

/* ============ 恐怖特效层 ============ */
.scare { position: fixed; inset: 0; z-index: 950; pointer-events: none; }
/* 跳吓瞬间整屏闪白 + 失真 + 屏幕震动 */
body.scared #os { filter: brightness(2.3) saturate(.35) contrast(1.35); }
body.scare-shake #os, body.scare-shake #wallpaper { animation: scareShake .06s linear infinite; }
@keyframes scareShake {
  0% { transform: translate(-5px, 4px) } 25% { transform: translate(5px, -4px) }
  50% { transform: translate(-4px, -5px) } 75% { transform: translate(4px, 5px) }
  100% { transform: translate(0, 0) }
}
.scare-face {
  position: fixed; inset: 0; z-index: 960; pointer-events: none;
}
.scare-face img {
  width: 100vw; height: 100vh; object-fit: cover; display: block;
  filter: grayscale(1) contrast(1.6) brightness(.88);
  animation: scareFlicker .09s linear infinite;
}
@keyframes scareFlicker {
  0% { filter: grayscale(1) contrast(1.6) brightness(.7) }
  50% { filter: grayscale(1) contrast(1.9) brightness(1.15) }
  100% { filter: grayscale(1) contrast(1.4) brightness(.55) }
}

/* 桌面 glitch 抖动 */
.os.glitch { animation: osglitch .22s steps(2) 3; }
@keyframes osglitch {
  0% { transform: translate(-3px, 2px) skewX(2deg); filter: hue-rotate(20deg); }
  50% { transform: translate(3px, -2px); filter: invert(.08); }
  100% { transform: none; }
}
.desk-icon.glitch { animation: iconjitter .18s linear 4; }
@keyframes iconjitter { 0%{transform:translate(0)} 25%{transform:translate(-2px,1px)} 50%{transform:translate(2px,-1px)} 75%{transform:translate(-1px,2px)} 100%{transform:none} }

/* ============ 微信 ============ */
.wx { display: flex; height: 100%; }
.wx-list { width: 200px; flex-shrink: 0; border-right: 1px solid var(--panel-border); overflow-y: auto; }
.wx-item { display: flex; align-items: center; gap: 8px; padding: 10px; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,.03); }
.wx-item:hover { background: rgba(255,255,255,.05); }
.wx-item.active { background: rgba(120,150,190,.14); }
.wx-avatar { width: 34px; height: 34px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 20px; background: #1d2431; border-radius: 6px; }
.wx-meta { min-width: 0; }
.wx-name { font-size: 13px; color: var(--text); }
.wx-last { font-size: 11px; color: var(--text-dim); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.wx-chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.wx-chat-head { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--panel-border); font-size: 13px; color: var(--text); }
.wx-back { display: none; }
.wx-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.wx-input { display: flex; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--panel-border); background: #141924; }
.wx-input input { flex: 1; height: 34px; padding: 0 12px; border-radius: 17px; border: 1px solid var(--panel-border); background: #0e131b; color: var(--text); font-size: 14px; outline: none; }
.wx-input input:focus { border-color: var(--accent); }
.wx-input button { height: 34px; padding: 0 16px; border: none; border-radius: 17px; background: #2c4a5c; color: #e6eef6; font-size: 13px; }
/* 移动端输入栏：更大触控目标 + 刘海屏安全区，保证始终可见 */
body.mode-touch .wx-input { position: sticky; bottom: 0; z-index: 3; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
body.mode-touch .wx-input input { height: 40px; font-size: 15px; }
body.mode-touch .wx-input button { height: 40px; min-width: 68px; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 85%; }
.msg-me { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar { width: 28px; height: 28px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 15px; background: #1d2431; border-radius: 6px; }
.msg-bubble { padding: 9px 12px; border-radius: 10px; background: #1a2029; font-size: 13px; line-height: 1.6; }
.msg-me .msg-bubble { background: #2c4a5c; }
.msg-time { margin-top: 4px; font-size: 10px; color: #5b6372; }
.msg-corrupt { color: #a33; animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: .4 } }
.msg-scare { background: #241a1a; border: 1px solid #4a2222; color: #d8b0b0; }

/* ============ 相册 ============ */
.ph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; padding: 14px; }
.ph-thumb { aspect-ratio: 1; border-radius: 8px; overflow: hidden; cursor: pointer; position: relative; border: 1px solid var(--panel-border); background: #000; }
.ph-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-thumb .ph-file { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 6px; font-size: 10px; color: #c8ceda; background: rgba(0,0,0,.55); }
.ph-lightbox { position: absolute; inset: 0; background: rgba(4,5,8,.92); display: flex; align-items: center; justify-content: center; z-index: 5; }
.ph-lightbox img { max-width: 92%; max-height: 70%; border-radius: 6px; }
.ph-info { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 18px; color: var(--text-dim); font-size: 13px; text-align: center; }
.ph-close { position: absolute; top: 10px; right: 12px; z-index: 6; background: rgba(255,255,255,.06); color: var(--text); border: none; border-radius: 6px; padding: 6px 12px; }

/* ============ 备忘录 ============ */
.nt-list { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.nt-item { background: #f2efe6; color: #2a2a24; border-radius: 8px; padding: 12px 14px; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.nt-title { font-size: 14px; font-weight: 600; }
.nt-date { font-size: 11px; color: #8a8a80; margin-top: 2px; }
.nt-text { display: none; margin-top: 8px; font-size: 13px; line-height: 1.7; white-space: pre-line; }
.nt-item.open .nt-text { display: block; }
.nt-item.open { background: #efe9d8; }

/* ============ 浏览器 ============ */
.br { display: flex; flex-direction: column; height: 100%; }
.br-tabs { display: flex; gap: 6px; padding: 8px 10px 0; border-bottom: 1px solid var(--panel-border); }
.br-tab { padding: 6px 14px; border-radius: 8px 8px 0 0; border: none; background: transparent; color: var(--text-dim); font-size: 12px; }
.br-tab.active { background: #151a25; color: var(--text); }
.br-badge {
  display: inline-block; margin-left: 6px; min-width: 15px; height: 15px; line-height: 15px;
  text-align: center; font-size: 10px; font-weight: 700; color: #fff;
  background: #b34; border-radius: 8px; padding: 0 4px; animation: badgePulse 1.4s ease infinite;
}
@keyframes badgePulse { 50% { opacity: .45 } }
.br-panel { flex: 1; overflow-y: auto; padding: 12px; }
.br-enc { border: 1px dashed transparent; }
.br-enc-hot {
  border: 1px solid rgba(190, 90, 60, .5); background: rgba(190, 90, 60, .08);
  animation: badgePulse 2.4s ease infinite;
}
.br-hint { font-size: 11px; color: #8a98a8; }
.br-ok {
  padding: 7px 26px; border: none; border-radius: 7px;
  background: #2c4a5c; color: #e6eef6; font-size: 13px;
}
.br-item { padding: 9px 10px; border-radius: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.br-item:hover { background: rgba(255,255,255,.05); }
.br-item .br-title { font-size: 13px; color: #9db6d6; }
.br-item .br-url { font-size: 11px; color: var(--text-dim); }
.br-item .br-time { font-size: 10px; color: #4c5464; }
.br-lock { text-align: center; padding: 40px 20px; color: var(--text-dim); }
.br-passcode { display: flex; justify-content: center; gap: 8px; margin: 16px 0; }
.br-passcode input { width: 52px; height: 52px; text-align: center; font-size: 24px; letter-spacing: 4px; background: #151a25; border: 1px solid var(--panel-border); color: var(--text); border-radius: 8px; outline: none; }
.br-passcode input:focus { border-color: var(--accent); }
.br-err { color: var(--danger); font-size: 12px; min-height: 18px; }
.br-content { white-space: pre-line; font-size: 13px; line-height: 1.8; color: var(--text); font-family: "Courier New", monospace; }
.br-note { margin-top: 16px; padding: 12px; border: 1px dashed #4a3030; color: #c0a0a0; border-radius: 8px; font-size: 13px; }

/* ============ 移动端（mode-touch 作用域，独立于视口，便于强制/调试） ============ */
body.mode-touch .icons {
  flex-direction: row; flex-wrap: wrap; gap: 10px; align-content: flex-start;
  padding: 10px;
}
body.mode-touch .desk-icon { width: 72px; }
body.mode-touch .taskbar { padding: 4px 8px; }
body.mode-touch .tb-start { display: none; }

/* 移动端应用布局 */
body.mode-touch .wx-list { width: 100%; }
body.mode-touch .wx-chat { display: none; }
body.mode-touch .wx.in-chat .wx-list { display: none; }
body.mode-touch .wx.in-chat .wx-chat { display: flex; }
body.mode-touch .wx-back { display: inline-block; border: none; background: transparent; color: var(--text); font-size: 20px; padding: 0 6px; }
body.mode-touch .win-head .wb-min { display: none; }
body.mode-touch .win-body { -webkit-overflow-scrolling: touch; }
