/* ============================================================
   线下舞台 · 万能底座 v3（Stage Kit）
   ------------------------------------------------------------
   外部皮肤只需要覆盖本文件顶部的 --vn-* 变量，或者按类名重写
   区块，不必碰 JS。类名契约见 offline-stage.js 顶部注释。

   目录
     0. 变量（颜色 / 字体 / 尺寸 / 贴图 URL / 特效）
     1. 硬重置（按钮、输入框、列表、图片一律归零）
     2. 舞台容器与层级
     3. L0 背景四层
     4. L4 HUD
     5. 信息流 .vn-feed / .vn-row
     6. 头像 .vn-avatar（绝对定位，可越界）
     7. 气泡 .vn-bubble
     8. 卡片 .vn-card（绝对定位，可越界 / 可互相压盖）
     9. 空状态与底部提示
    10. 与 App 原生界面的让位规则
   ============================================================ */

/* ---------- 0. 变量 ---------- */
:root {
  /* 底色与贴图：换皮时最常改的就是这几条 URL */
  --vn-bg: #0b0b0e;
  --vn-bg-url: none;                       /* 主背景图 */
  --vn-tint: rgba(8, 8, 12, .55);          /* 背景图上压的色层 */
  --vn-grain-url: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='4'/></filter><rect width='140' height='140' filter='url(%23n)' opacity='.5'/></svg>");
  --vn-grain-opacity: .10;
  --vn-vignette: radial-gradient(90% 70% at 50% 46%, transparent 34%, rgba(0, 0, 0, .62) 100%);

  /* 文字 */
  --vn-text: #f2f2f4;
  --vn-text-soft: rgba(242, 242, 244, .72);
  --vn-text-dim: rgba(242, 242, 244, .42);
  --vn-accent: #d8a7ae;
  --vn-line: rgba(255, 255, 255, .14);

  /* 字体 */
  --vn-font-ui: "Helvetica Neue", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --vn-font-text: Georgia, "Songti SC", "Noto Serif SC", serif;
  --vn-size-text: 15px;
  --vn-lh-text: 1.95;
  --vn-size-name: 11px;
  --vn-size-time: 10px;

  /* 布局 */
  --vn-hud-h: 52px;
  --vn-feed-pad: 14px 16px 18px;
  --vn-gap-row: 18px;

  /* 头像：绝对定位，允许跑出边界 */
  --vn-avatar-url: none;                   /* 头像贴图（没有就落回文字首字） */
  --vn-avatar-size: 34px;
  --vn-avatar-radius: 50%;
  --vn-avatar-x: 0px;
  --vn-avatar-y: -2px;
  --vn-avatar-rotate: 0deg;
  --vn-avatar-shadow: 0 4px 14px rgba(0, 0, 0, .5);
  --vn-avatar-space: 46px;                 /* 气泡左侧让出的宽度 */

  /* 气泡：整层贴图也可以换 */
  --vn-bubble-bg: rgba(32, 33, 39, .62);
  --vn-bubble-bg-url: none;
  --vn-bubble-border: rgba(255, 255, 255, .16);
  --vn-bubble-radius: 14px;
  --vn-bubble-pad: 12px 14px 13px;
  --vn-bubble-max: 84%;
  --vn-bubble-blur: 12px;
  --vn-bubble-shadow: 0 18px 40px -26px rgba(0, 0, 0, .9);

  /* 卡片：绝对定位 + 错位，天然可以破形 */
  --vn-card-w: calc(100% - 6px);
  --vn-card-h: 118px;
  --vn-card-bg: rgba(26, 27, 33, .82);
  --vn-card-bg-url: none;
  --vn-card-border: rgba(255, 255, 255, .18);
  --vn-card-radius: 10px;
  --vn-card-blur: 10px;
  --vn-card-shadow: 0 22px 44px -26px rgba(0, 0, 0, .95);
  --vn-card-pad: 12px 14px 13px;
  --vn-card-x0: 0px;                       /* 起点偏移 */
  --vn-card-y0: 6px;
  --vn-card-step: 94px;                    /* 卡片之间的垂直步进 */
  --vn-card-shift: 6px;                    /* 每张卡的水平错位 */
  --vn-card-rot: -0.8deg;
  --vn-card-rot-step: 0.6deg;

  /* 主题与兜底（v2） */
  --vn-theme: dark;
  --vn-line-soft: rgba(255, 255, 255, .06);      /* 卡片内细分割线 */
  --vn-scroll-thumb: rgba(255, 255, 255, .22);   /* 信息流滚动条 */
  --vn-photo-fallback: linear-gradient(135deg, rgba(255, 255, 255, .10), rgba(255, 255, 255, .03));
  --vn-avatar-fallback: linear-gradient(135deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, .05));
  --vn-card-lines: 3;                            /* 卡片正文最多几行 */
  --vn-note-lines: 4;                            /* 便签正文最多几行 */
  --vn-fact-max: 5;                              /* 卡片属性最多几行（靠 nth-child 截断） */
}

/* ---------- 0b. 浅色主题 ----------
   在 .vn-layer 上加 data-vn-theme="light" 即可整体换明色。
   它只改令牌，不改任何布局规则，所以和皮肤是正交的：
   data-vn-skin 决定"长什么样"，data-vn-theme 决定"明还是暗"。 */
.vn-layer[data-vn-theme="light"] {
  --vn-theme: light;
  --vn-bg: #f3efe6;
  --vn-tint: rgba(255, 255, 255, .30);
  --vn-grain-opacity: .055;
  --vn-vignette: radial-gradient(96% 76% at 50% 44%, transparent 40%, rgba(96, 84, 64, .18) 100%);
  --vn-text: #1b1813;
  --vn-text-soft: rgba(27, 24, 19, .72);
  --vn-text-dim: rgba(27, 24, 19, .45);
  --vn-accent: #8a4a33;
  --vn-line: rgba(27, 24, 19, .16);
  --vn-line-soft: rgba(27, 24, 19, .08);
  --vn-bubble-bg: rgba(255, 253, 248, .88);
  --vn-bubble-border: rgba(27, 24, 19, .13);
  --vn-bubble-shadow: 0 16px 34px -24px rgba(74, 60, 40, .55);
  --vn-card-bg: rgba(255, 253, 248, .95);
  --vn-card-border: rgba(27, 24, 19, .17);
  --vn-card-shadow: 4px 6px 0 rgba(27, 24, 19, .05), 0 16px 32px -22px rgba(74, 60, 40, .5);
  --vn-avatar-shadow: 0 4px 12px rgba(74, 60, 40, .26);
  --vn-scroll-thumb: rgba(27, 24, 19, .20);
  --vn-photo-fallback: linear-gradient(135deg, rgba(27, 24, 19, .09), rgba(27, 24, 19, .02));
  --vn-avatar-fallback: linear-gradient(135deg, rgba(27, 24, 19, .13), rgba(27, 24, 19, .04));
}

/* ---------- 1. 硬重置 ---------- */
.vn-stage,
.vn-stage *,
.vn-stage *::before,
.vn-stage *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  font: inherit;
  color: inherit;
  line-height: inherit;
  letter-spacing: normal;
  text-decoration: none;
  text-shadow: none;
  list-style: none;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}
.vn-stage button,
.vn-stage input,
.vn-stage textarea,
.vn-stage select { background: transparent; border: none; box-shadow: none; color: inherit; font: inherit; }
.vn-stage img,
.vn-stage svg { display: block; max-width: none; }
.vn-stage svg { fill: currentColor; }

/* 破形：所有容器一律允许溢出 */
.vn-stage,
.vn-stage .vn-row,
.vn-stage .vn-bubble,
.vn-stage .vn-bubble-body,
.vn-stage .vn-cards,
.vn-stage .vn-card-slot { overflow: visible; }

/* ---------- 2. 舞台容器 ---------- */
.vn-stage {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  isolation: isolate;
  color: var(--vn-text);
  font-family: var(--vn-font-ui);
  background: var(--vn-bg);
  -webkit-font-smoothing: antialiased;
}
.vn-stage.is-open { opacity: 1; }

/* ---------- 3. 背景四层 ---------- */
.vn-stage-bg { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.vn-bg-image,
.vn-bg-tint,
.vn-bg-grain,
.vn-bg-vignette { position: absolute; inset: 0; }

.vn-bg-image {
  background-image: var(--vn-bg-url);
  background-size: cover;
  background-position: center;
  filter: var(--vn-bg-filter, none);
}
.vn-bg-tint { background: var(--vn-tint); }
.vn-bg-grain {
  background-image: var(--vn-grain-url);
  opacity: var(--vn-grain-opacity);
  mix-blend-mode: overlay;
}
.vn-bg-vignette { background: var(--vn-vignette); }

/* ---------- 4. HUD ---------- */
.vn-hud {
  position: relative;
  z-index: 4;
  flex: 0 0 var(--vn-hud-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
}
.vn-hud-back,
.vn-hud-menu {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--vn-text-soft);
  cursor: pointer;
  transition: background .18s ease, color .18s ease;
}
.vn-hud-back:hover,
.vn-hud-menu:hover { background: rgba(255, 255, 255, .08); color: var(--vn-text); }
.vn-hud-back svg,
.vn-hud-menu svg { width: 17px; height: 17px; }

.vn-hud-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.vn-hud-title {
  font-family: var(--vn-font-text);
  font-size: 13px;
  letter-spacing: .14em;
  color: var(--vn-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vn-hud-meta {
  font-size: 9px;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--vn-text-dim);
}
.vn-hud-actions { flex: 0 0 auto; display: flex; gap: 6px; }

/* ---------- 5. 信息流 ---------- */
.vn-feed {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  min-height: 0;
  padding: var(--vn-feed-pad);
  display: flex;
  flex-direction: column;
  gap: var(--vn-gap-row);
  overflow-y: auto;
  overflow-x: visible;
  scrollbar-width: thin;
  scrollbar-color: var(--vn-scroll-thumb) transparent;
}
/* 全局 css/main.css 里有 *::-webkit-scrollbar{display:block!important}，
   这里用"更具体的选择器 + !important"把它按住，只在信息流里留 3px 细条。 */
.vn-stage .vn-feed::-webkit-scrollbar { width: 3px; height: 3px; display: block !important; background: transparent !important; }
.vn-stage .vn-feed::-webkit-scrollbar-track { background: transparent !important; }
.vn-stage .vn-feed::-webkit-scrollbar-thumb { background: var(--vn-scroll-thumb) !important; border-radius: 2px; }

.vn-row {
  position: relative;
  display: block;
  padding-left: var(--vn-avatar-space);
  min-height: 24px;
}
.vn-row--user { padding-left: var(--vn-avatar-space); }
.vn-bubble-wrap { display: block; }

/* ---------- 6. 头像（绝对定位） ---------- */
.vn-avatar {
  position: absolute;
  left: var(--vn-avatar-x);
  top: var(--vn-avatar-y);
  width: var(--vn-avatar-size);
  height: var(--vn-avatar-size);
  border-radius: var(--vn-avatar-radius);
  overflow: visible;
  background-color: transparent;
  background-image: var(--vn-avatar-url, none), var(--vn-avatar-fallback);
  background-size: cover, cover;
  background-position: center, center;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(var(--vn-avatar-rotate));
  box-shadow: var(--vn-avatar-shadow);
  z-index: 3;
}
/* 头像加载失败/没配图时，露出底下的首字 */
.vn-avatar-txt {
  position: relative;
  z-index: 0;
  font-size: calc(var(--vn-avatar-size) * .42);
  line-height: 1;
  color: var(--vn-text-soft);
  letter-spacing: 0;
}
.vn-avatar-img {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}
.vn-avatar-img[src=""],
.vn-avatar-img:not([src]) { visibility: hidden; }
.vn-row--user .vn-avatar { filter: var(--vn-avatar-user-filter, none); }

/* ---------- 7. 气泡 ---------- */
.vn-bubble {
  position: relative;
  display: block;
  max-width: var(--vn-bubble-max);
  padding: var(--vn-bubble-pad);
  padding-bottom: calc(var(--vn-bubble-pad-bottom, 13px) + var(--vn-cards-n, 0) * var(--vn-card-step) * 0);
  background-color: var(--vn-bubble-bg);
  background-image: var(--vn-bubble-bg-url);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  border: 1px solid var(--vn-bubble-border);
  border-radius: var(--vn-bubble-radius);
  -webkit-backdrop-filter: blur(var(--vn-bubble-blur));
  backdrop-filter: blur(var(--vn-bubble-blur));
  box-shadow: var(--vn-bubble-shadow);
  color: var(--vn-text);
}
.vn-row--user .vn-bubble { margin-left: auto; }

.vn-bubble-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}
.vn-name {
  font-size: var(--vn-size-name);
  letter-spacing: .18em;
  color: var(--vn-accent);
  white-space: nowrap;
}
.vn-time {
  font-size: var(--vn-size-time);
  letter-spacing: .08em;
  color: var(--vn-text-dim);
  margin-left: auto;
}

.vn-bubble-body { display: block; }
.vn-text {
  font-family: var(--vn-font-text);
  font-size: var(--vn-size-text);
  line-height: var(--vn-lh-text);
  color: var(--vn-text);
  white-space: pre-wrap;
  word-break: break-word;
}
.vn-para + .vn-para { margin-top: .35em; }

/* ---------- 8. 卡片（绝对定位 + 错位） ---------- */
.vn-cards {
  position: relative;
  display: block;
  height: calc(var(--vn-cards-n, 0) * var(--vn-card-step));
  margin-top: 8px;
}
.vn-card-slot {
  position: absolute;
  left: calc(var(--vn-card-x0) + var(--i, 0) * var(--vn-card-shift));
  top: calc(var(--vn-card-y0) + var(--i, 0) * var(--vn-card-step));
  width: var(--vn-card-w);
  height: var(--vn-card-h);
  transform: rotate(calc(var(--vn-card-rot) + var(--i, 0) * var(--vn-card-rot-step)));
  transform-origin: 0 0;
  z-index: calc(10 + var(--i, 0));
}
.vn-card {
  position: absolute;
  inset: 0;
  display: block;
  padding: var(--vn-card-pad);
  background-color: var(--vn-card-bg);
  background-image: var(--vn-card-bg-url);
  background-size: 100% 100%;
  border: 1px solid var(--vn-card-border);
  border-radius: var(--vn-card-radius);
  -webkit-backdrop-filter: blur(var(--vn-card-blur));
  backdrop-filter: blur(var(--vn-card-blur));
  box-shadow: var(--vn-card-shadow);
  color: var(--vn-text);
}

.vn-card-head { display: block; padding-bottom: 8px; border-bottom: 1px solid var(--vn-line); }

/* 防溢出：卡片外框照旧允许越界（破形），但文字不许跑出卡片。
   profile / note 是最容易被长文本撑开的两类，直接裁切；
   ticket 的缺口装饰在框外，所以不能裁，只对文字做行数限制。 */
.vn-card--profile,
.vn-card--note { overflow: hidden; }
.vn-card-kicker {
  display: block;
  font-size: 8px;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--vn-accent);
  margin-bottom: 3px;
}
.vn-card-title {
  display: block;
  font-family: var(--vn-font-text);
  font-size: 15px;
  letter-spacing: .04em;
  color: var(--vn-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vn-card-sub {
  display: block;
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--vn-text-dim);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vn-card-facts { display: block; margin-top: 6px; }
.vn-fact { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 3px 0; }
.vn-fact + .vn-fact { border-top: 1px solid var(--vn-line-soft); }
/* 属性超过 5 条就截断，防止把卡片撑高（AI 偶尔会塞很多条） */
.vn-fact:nth-child(n+6) { display: none; }
.vn-fact-key {
  font-size: 9px;
  letter-spacing: .18em;
  color: var(--vn-text-dim);
  white-space: nowrap;
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vn-fact-val {
  font-size: 11.5px;
  color: var(--vn-text-soft);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vn-card-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--vn-card-lines, 3);
  overflow: hidden;
  font-family: var(--vn-font-text);
  font-size: 12px;
  line-height: 1.7;
  color: var(--vn-text-soft);
  white-space: pre-wrap;
}

/* 便签 */
.vn-card--note { padding: 14px 14px 12px; }
.vn-note { display: block; }
.vn-note-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--vn-note-lines, 4);
  overflow: hidden;
  font-family: var(--vn-font-text);
  font-size: 13px;
  line-height: 1.8;
  color: var(--vn-text);
  white-space: pre-wrap;
}

/* 票据 */
.vn-card--ticket { padding: 12px 16px; border-style: dashed; }
.vn-ticket-notch {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--vn-bg);
  box-shadow: inset 0 0 0 1px var(--vn-card-border);
}
.vn-ticket-notch--left { left: -7px; }
.vn-ticket-notch--right { right: -7px; }
.vn-ticket-kicker { display: block; font-size: 8px; letter-spacing: .32em; color: var(--vn-accent); }
.vn-ticket-title { display: block; font-family: var(--vn-font-text); font-size: 14px; margin-top: 3px; }
.vn-ticket-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 10.5px;
  color: var(--vn-text-dim);
  margin-top: 4px;
}
.vn-ticket-code {
  display: block;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 9px;
  letter-spacing: .22em;
  color: var(--vn-text-dim);
  margin-top: 6px;
}

/* 相片 */
.vn-card--photo { padding: 8px 8px 26px; }
.vn-photo-frame { position: relative; inset: 0; height: calc(100% - 18px); background: rgba(255, 255, 255, .06); border-radius: 2px; overflow: visible; }
.vn-photo-tape {
  position: absolute;
  left: 50%;
  top: -8px;
  width: 42px;
  height: 14px;
  margin-left: -21px;
  background: rgba(255, 255, 255, .22);
  transform: rotate(-2deg);
  z-index: 2;
}
.vn-photo-img {
  position: absolute;
  inset: 0;
  background-image: var(--vn-photo-url, none), var(--vn-photo-fallback);
  background-size: cover, cover;
  background-position: center, center;
}
.vn-photo-caption {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 7px;
  font-family: var(--vn-font-text);
  font-size: 10px;
  letter-spacing: .08em;
  color: var(--vn-text-dim);
}

/* ---------- 9. 空状态 / 底部提示 ---------- */
.vn-empty { margin: auto; text-align: center; }
.vn-empty-title { font-family: var(--vn-font-text); font-size: 15px; color: var(--vn-text-soft); }
.vn-empty-tip { font-size: 11px; color: var(--vn-text-dim); margin-top: 6px; }
.vn-tools {
  position: relative;
  z-index: 4;
  flex: 0 0 auto;
  padding: 6px 0 10px;
  display: flex;
  justify-content: center;
}
.vn-tools-hint { font-size: 9px; letter-spacing: .2em; color: var(--vn-text-dim); }

/* ---------- 10. 与 App 原生界面 ---------- */
.chatroom.vn-on .chatroom-messages,
.chatroom.vn-on .encounter-actions,
.chatroom.vn-on .chatroom-header { visibility: hidden; }
.chatroom.vn-on .extend-panel,
.chatroom.vn-on .input-drawer,
.chatroom.vn-on .sticker-panel,
.chatroom.vn-on .invite-panel { display: none !important; }

/* 舞台贴底时给输入框让出位置 */
.chatroom.vn-on .chatroom-input {
  position: relative;
  z-index: 70;
  background: rgba(0, 0, 0, .42);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
