/* ============================================================
   破防急救站 · 便签墙情绪记录器
   Direction: X 式单色克制 × bonjour 编辑排版
   双主色系：暖黑灰阶 + 朱红单强调（#E5484D）
   ============================================================ */

@font-face {
  font-family: "IBM Plex Mono";
  src: url("../_shared/fonts/IBMPlexMono-Regular.ttf") format("truetype");
  font-display: swap;
  font-weight: 400;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../_shared/fonts/IBMPlexMono-Bold.ttf") format("truetype");
  font-display: swap;
  font-weight: 700;
}

:root {
  --bg: #141210;
  --bg2: #1d1a17;
  --ink: #ede8df;
  --muted: #8a8378;
  --rule: rgba(237, 232, 223, 0.12);
  --accent: #e5484d;
  --accent-soft: rgba(229, 72, 77, 0.14);

  --paper: #f2eee6;        /* 便签纸 */
  --paper-ink: #1c1917;    /* 纸上墨色 */
  --paper-muted: #6e675e;  /* 纸上次级文字 */
  --paper-rule: rgba(28, 25, 23, 0.16);

  --f-serif: "Songti SC", "STSong", "NSimSun", "SimSun", "Georgia", serif;
  --f-mono: "IBM Plex Mono", ui-monospace, monospace;
  --f-ui: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;

  --ease-spring: cubic-bezier(0.2, 0.9, 0.3, 1.25);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html, body { height: 100%; }

body {
  font-family: var(--f-ui);
  color: var(--ink);
  background:
    radial-gradient(1100px 700px at 80% -10%, rgba(229, 72, 77, 0.06), transparent 60%),
    radial-gradient(closest-side at 50% 40%, #1b1815, #141210 75%);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* 胶片颗粒 */
body::after {
  content: "";
  position: fixed; inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.045;
  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='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* WebGL 氛围层 */
#gl {
  position: fixed; inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* 暗角 */
.vignette {
  position: fixed; inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(8, 6, 5, 0.5) 100%);
}

/* 爆发闪光 */
.flash {
  position: fixed; inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at var(--fx, 50%) var(--fy, 50%),
    rgba(229, 72, 77, 0.22), rgba(229, 72, 77, 0.08) 30%, transparent 55%);
}
.flash.on { animation: flashFade 0.9s var(--ease-out) forwards; }
@keyframes flashFade {
  0% { opacity: 0; }
  12% { opacity: 1; }
  100% { opacity: 0; }
}

::selection { background: rgba(229, 72, 77, 0.35); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(237, 232, 223, 0.12); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------
   顶栏（X 式：薄、冷静、mono 元数据）
   ------------------------------------------------------------ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 32px 18px;
  background: linear-gradient(180deg, rgba(20, 18, 16, 0.94), rgba(20, 18, 16, 0.72) 70%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(237, 232, 223, 0.06);
}

.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }

.brand-mark {
  flex: none;
  width: 38px; height: 38px;
  border-radius: 8px;
  box-shadow: 0 4px 14px -4px rgba(229, 72, 77, 0.5);
}
.brand-mark svg { display: block; }

.brand-sub .b1024 {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px 2px;
  border: 1px solid rgba(229, 72, 77, 0.55);
  border-radius: 999px;
  color: var(--accent);
  font-family: var(--f-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  vertical-align: 1px;
}

.brand-title {
  font-family: var(--f-serif);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.2;
  white-space: nowrap;
}

.brand-sub {
  font-family: var(--f-mono);
  font-size: 9px;
  letter-spacing: 0.3em;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 4px;
  white-space: nowrap;
}

.top-stats {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-left: 8px;
  margin-right: auto;
  min-width: 0;
}

.stat { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.stat .k {
  font-family: var(--f-mono);
  font-size: 9px;
  letter-spacing: 0.24em;
  color: var(--muted);
  text-transform: uppercase;
  white-space: nowrap;
}

.stat .v {
  font-family: var(--f-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}
.stat .v em { font-style: normal; color: var(--accent); }

.spark { display: block; }

.top-actions { display: flex; align-items: center; gap: 10px; flex: none; }

.btn {
  appearance: none;
  border: none;
  font-family: var(--f-ui);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  padding: 10px 18px;
  border-radius: 999px;
  transition: transform 0.25s var(--ease-spring), box-shadow 0.25s, background 0.25s, border-color 0.25s, color 0.25s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.96); }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule);
}
.btn-ghost:hover { border-color: rgba(229, 72, 77, 0.55); color: var(--accent); }

.btn-primary {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 6px 18px -6px rgba(229, 72, 77, 0.55);
}
.btn-primary:hover {
  transform: translateY(-1px);
  background: #f2555a;
  box-shadow: 0 10px 24px -6px rgba(229, 72, 77, 0.65);
}
.btn-primary:active { transform: scale(0.96); }

.btn-danger {
  background: transparent;
  border: 1px solid rgba(229, 72, 77, 0.45);
  color: var(--accent);
}
.btn-danger:hover { background: var(--accent-soft); }

/* ------------------------------------------------------------
   便签墙（bonjour 编辑式纸卡）
   ------------------------------------------------------------ */
#wall {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  padding: 112px 32px 90px;
}

.note {
  position: absolute;
  width: 244px;
  padding: 26px 20px 14px;
  border-radius: 2px;
  background: var(--paper);
  color: var(--paper-ink);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.3),
    0 18px 32px -14px rgba(0, 0, 0, 0.6);
  transform: rotate(var(--rot, 0deg));
  transform-origin: 50% 0;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.35s var(--ease-spring), box-shadow 0.35s;
  will-change: transform;
}

.note::before {
  /* 顶部编辑细线 */
  content: "";
  position: absolute;
  left: 20px; right: 20px; top: 0;
  height: 3px;
  background: var(--paper-ink);
  opacity: 0.9;
}

.note:hover {
  transform: rotate(calc(var(--rot, 0deg) * 0.3)) translateY(-5px) scale(1.015);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.3),
    0 30px 50px -14px rgba(0, 0, 0, 0.7);
  z-index: 15 !important;
}

.note.dragging {
  transition: none;
  transform: rotate(0deg) scale(1.06);
  box-shadow: 0 44px 72px -18px rgba(0, 0, 0, 0.8);
  cursor: grabbing;
  z-index: 40 !important;
}

.note.just-pinned { animation: pinDrop 0.55s var(--ease-spring) backwards; }
@keyframes pinDrop {
  0% { transform: rotate(calc(var(--rot, 0deg) + 6deg)) translateY(-56px) scale(1.1); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: rotate(var(--rot, 0deg)) translateY(0) scale(1); opacity: 1; }
}

/* 朱红图钉（唯一强调色出现点之一） */
.note .pin {
  position: absolute;
  top: -5px; left: 20px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8a8d, var(--accent) 55%, #a93237 120%);
  box-shadow: 0 3px 5px -1px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.note .eyebrow {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--paper-muted);
  text-transform: uppercase;
}
.note .eyebrow .no { font-weight: 700; color: var(--paper-ink); }
.note .eyebrow .mn { color: var(--accent); }
.note .eyebrow .scene-tag {
  margin-left: auto;
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--paper-muted);
  border: 1px solid var(--paper-rule);
  border-radius: 999px;
  padding: 1px 7px;
}

.note .txt {
  font-family: var(--f-serif);
  font-size: 15px;
  line-height: 1.9;
  margin-top: 12px;
  word-break: break-word;
}

.note .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--paper-rule);
}

.note .date {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--paper-muted);
}

.note .lv { display: flex; gap: 3px; align-items: flex-end; }
.note .lv i {
  width: 10px; height: 3px;
  border-radius: 1px;
  background: rgba(28, 25, 23, 0.14);
}
.note .lv i.on { background: var(--accent); height: 5px; }
.note .lv i.on:nth-child(2) { height: 7px; }
.note .lv i.on:nth-child(3) { height: 9px; }
.note .lv i.on:nth-child(4) { height: 11px; }
.note .lv i.on:nth-child(5) { height: 13px; }

/* 空墙 */
.wall-empty {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 320px;
  padding: 40px 30px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  text-align: center;
  color: var(--muted);
}
.wall-empty .big {
  font-family: var(--f-serif);
  font-size: 19px;
  letter-spacing: 0.08em;
  color: var(--ink);
  margin-bottom: 12px;
}
.wall-empty .sub { font-size: 13px; line-height: 1.9; }
.wall-empty .hand {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 18px;
}

/* ------------------------------------------------------------
   弹窗
   ------------------------------------------------------------ */
.sheet {
  position: fixed; inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}
.sheet[hidden] { display: none; }

.sheet .backdrop {
  position: absolute; inset: 0;
  background: rgba(12, 10, 8, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 0.3s var(--ease-out);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.panel {
  position: relative;
  width: min(580px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: rgba(26, 23, 20, 0.92);
  backdrop-filter: blur(22px) saturate(1.2);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 26px 26px 22px;
  box-shadow: 0 40px 90px -24px rgba(0, 0, 0, 0.8);
  animation: panelIn 0.4s var(--ease-spring);
}
@keyframes panelIn {
  from { transform: translateY(14px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.panel-head h2 {
  font-family: var(--f-serif);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.1em;
}
.panel-head .hint {
  font-family: var(--f-mono);
  font-size: 9px;
  letter-spacing: 0.28em;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 5px;
}

.x {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, transform 0.2s;
}
.x:hover { color: var(--ink); border-color: rgba(237, 232, 223, 0.4); transform: rotate(90deg); }

/* 场景盲盒 */
.blindbox { perspective: 900px; margin-bottom: 24px; }
.bb-inner {
  position: relative;
  width: 100%;
  min-height: 118px;
  transform-style: preserve-3d;
  transition: transform 0.65s var(--ease-spring);
}
.blindbox.flipped .bb-inner { transform: rotateY(180deg); }

.bb-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  border: 1px dashed rgba(237, 232, 223, 0.22);
  background: rgba(237, 232, 223, 0.03);
}
.bb-face.back {
  transform: rotateY(180deg);
  border-style: solid;
  border-color: rgba(229, 72, 77, 0.45);
  background: var(--accent-soft);
}

.bb-label {
  font-family: var(--f-mono);
  font-size: 9px;
  letter-spacing: 0.3em;
  color: var(--muted);
  text-transform: uppercase;
}
.bb-face.back .bb-label { color: var(--accent); }

.bb-front { align-items: flex-start; }
.bb-front p { font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.bb-front .btn { align-self: flex-end; margin-top: 2px; }

.bb-scene {
  font-family: var(--f-serif);
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink);
}
.bb-acts { display: flex; gap: 8px; justify-content: flex-end; }
.bb-acts .btn { padding: 7px 14px; font-size: 12px; }

/* 情绪 chips（极简下划线） */
.field-label {
  font-family: var(--f-mono);
  font-size: 9px;
  letter-spacing: 0.28em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.chips {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px 12px;
  margin-bottom: 24px;
}
.chip {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: var(--f-ui);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 2px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, transform 0.2s;
}
.chip:hover { color: var(--ink); }
.chip.on {
  color: var(--accent);
  border-bottom-color: var(--accent);
  transform: translateY(-1px);
}

/* 破防等级（灰阶 + 朱红单色阶） */
.lv-wrap { margin-bottom: 24px; }
.lv-segs { display: flex; gap: 6px; margin-bottom: 8px; }
.lv-seg {
  flex: 1;
  height: 10px;
  border-radius: 2px;
  border: none;
  cursor: pointer;
  background: rgba(237, 232, 223, 0.1);
  transition: background 0.25s, transform 0.25s var(--ease-spring), box-shadow 0.25s;
}
.lv-seg.on {
  background: var(--seg, var(--accent));
  box-shadow: 0 0 10px -3px var(--seg, var(--accent));
}
.lv-seg:hover { transform: scaleY(1.5); }
.lv-caption { display: flex; justify-content: space-between; align-items: baseline; }
.lv-caption .desc { font-family: var(--f-serif); font-size: 14px; letter-spacing: 0.08em; color: var(--ink); }
.lv-caption .num { font-family: var(--f-mono); font-size: 11px; color: var(--muted); }

/* 输入 */
textarea {
  width: 100%;
  min-height: 104px;
  resize: vertical;
  border-radius: 10px;
  border: 1px solid var(--rule);
  background: rgba(0, 0, 0, 0.26);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 14px;
  line-height: 1.8;
  padding: 14px 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
textarea::placeholder { color: rgba(138, 131, 120, 0.75); }
textarea:focus {
  outline: none;
  border-color: rgba(229, 72, 77, 0.55);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}
.panel-foot .tiny {
  font-family: var(--f-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--muted);
}
.panel-foot .acts { display: flex; gap: 10px; }

/* 详情弹窗 */
#detailPanel { width: min(460px, 100%); }
.dt-mood { margin-bottom: 14px; }
.dt-tag {
  display: inline-block;
  font-family: var(--f-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
}
.dt-scene {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 14px;
  padding-left: 10px;
  border-left: 2px solid var(--accent);
}
.dt-text {
  font-family: var(--f-serif);
  font-size: 17px;
  line-height: 1.9;
  margin-bottom: 18px;
}
.dt-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* ------------------------------------------------------------
   浮动按钮 / toast
   ------------------------------------------------------------ */
.fab {
  position: fixed;
  right: 26px; bottom: 26px;
  z-index: 30;
  display: none;
  width: 56px; height: 56px;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  font-weight: 300;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 14px 30px -8px rgba(229, 72, 77, 0.65);
  cursor: pointer;
  transition: transform 0.25s var(--ease-spring), background 0.25s;
}
.fab:active { transform: scale(0.92); }

.toast {
  position: fixed;
  left: 50%; bottom: 34px;
  transform: translateX(-50%) translateY(20px);
  z-index: 60;
  padding: 11px 22px;
  border-radius: 999px;
  background: rgba(26, 23, 20, 0.94);
  border: 1px solid var(--rule);
  color: var(--ink);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.35s var(--ease-spring);
  backdrop-filter: blur(10px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.foot-tip {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 0 20px 34px;
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: rgba(138, 131, 120, 0.55);
}

/* ------------------------------------------------------------
   响应式
   ------------------------------------------------------------ */
@media (max-width: 900px) {
  .top-stats .spark { display: none; }
}

@media (max-width: 720px) {
  .topbar { padding: 12px 16px; gap: 12px; flex-wrap: wrap; }
  .top-stats { display: none; }
  .top-actions .btn-ghost { display: none; }
  #wall { padding: 96px 20px 110px; }

  .note {
    position: static;
    width: 100%;
    margin-bottom: 20px;
    transform: rotate(var(--rot, 0deg));
  }
  #wall { display: block; }
  .fab { display: block; }
}

@media (min-width: 721px) { .fab { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
