/* 微信「笔记」页面 1:1 复刻 */

:root {
  --fg: #000;
  --bg: #fff;
  --hl: #fcecb0;
  --rule: #d2d2d2;
  --pad: 20px;
  --lh: 30px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: var(--lh);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body { overflow-x: hidden; }

/* ---------- 顶部导航栏 ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  height: 44px;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: 4px;
  padding-right: 6px;
  background: var(--bg);
  box-sizing: content-box;
}

.nav-back {
  flex: 0 0 40px;
  width: 40px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg);
  text-decoration: none;
}

.nav-back svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-title {
  position: absolute;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-size: 17px;
  font-weight: 400;
  line-height: 44px;
  color: var(--fg);
  pointer-events: none;
}

.nav-acts {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-ic {
  width: 34px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
}

.nav-ic.is-off { color: #c8c8c8; }

.nav-ic svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-ic svg.dots { fill: currentColor; stroke: none; }

/* ---------- 正文 ---------- */

.note {
  padding: 20px var(--pad) calc(60px + env(safe-area-inset-bottom, 0px));
}

.body {
  outline: 0;
  min-height: 30px;
}

.body div,
.body p {
  margin: 0;
  line-height: var(--lh);
  min-height: var(--lh);
  word-break: break-word;
}

.body mark {
  color: inherit;
  background: linear-gradient(var(--hl), var(--hl)) no-repeat 0 50% / 100% 23px;
  padding: 0 1px;
}

.body hr {
  height: 0;
  margin: 22px 0 25px;
  border: 0;
  border-top: 1px solid var(--rule);
}

/* ---------- 九宫格(视频 + 图片混排) ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px 4px;
  margin-top: 8px;
}

.grid:empty { display: none; }

.tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 0;
  margin: 0;
  background: #f2f2f2;
  border-radius: 2px;
  overflow: hidden;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile .play {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 21%;
  height: auto;
  transform: translate(-50%, -50%);
  pointer-events: none;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.4));
}

.tile .del {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 3;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 15px;
  line-height: 22px;
  text-align: center;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

/* ---------- 全屏查看 ---------- */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  -webkit-user-select: none;
  user-select: none;
}

.viewer[hidden] { display: none; }

.viewer video {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #000;
  outline: 0;
}

.viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* 关闭:圆形半透明底 + 白叉,同微信 */
.vclose {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  left: 14px;
  z-index: 3;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.17);
  color: #fff;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.vclose svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* 底部控制条 */
.vctl {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  height: calc(52px + env(safe-area-inset-bottom, 0px));
  padding: 0 14px env(safe-area-inset-bottom, 0px) 10px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0));
  color: #fff;
  transition: opacity 0.22s ease;
}

.vctl[hidden] { display: none; }
.vctl.is-hidden { opacity: 0; pointer-events: none; }

.vplay {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.vplay svg { width: 22px; height: 22px; fill: currentColor; }
.vplay .ic-pause { display: none; }
.vplay.is-playing .ic-play { display: none; }
.vplay.is-playing .ic-pause { display: block; }

.vtime {
  flex: 0 0 auto;
  font-size: 12px;
  line-height: 1;
  color: #fff;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  opacity: 0.95;
}

.vbar {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  height: 30px;
  margin: 0 2px;
  touch-action: none;
  cursor: pointer;
}

.vtrack {
  position: relative;
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.34);
}

.vbuf {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.5);
}

.vfill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  border-radius: 2px;
  background: #fff;
}

.vthumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: 11px;
  height: 11px;
  margin: -5.5px 0 0 -5.5px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  transition: transform 0.12s ease;
}

.vbar:active .vthumb { transform: scale(1.35); }

.vrate {
  flex: 0 0 auto;
  padding: 6px 2px;
  border: 0;
  background: none;
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  -webkit-appearance: none;
  appearance: none;
}

/* 倍速菜单 */
.vmenu {
  position: absolute;
  right: 12px;
  bottom: calc(58px + env(safe-area-inset-bottom, 0px));
  z-index: 4;
  min-width: 108px;
  padding: 5px 0;
  border-radius: 10px;
  background: rgba(32, 32, 34, 0.96);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
}

.vmenu[hidden] { display: none; }

.vmenu button {
  display: block;
  width: 100%;
  padding: 9px 16px;
  border: 0;
  background: none;
  color: #fff;
  font-size: 14px;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.vmenu button.is-on { color: #07c160; }
.vmenu button:active { background: rgba(255, 255, 255, 0.08); }

/* ---------- 桌面端:居中窄栏,像微信窗口 ---------- */

@media (min-width: 720px) {
  body {
    max-width: 560px;
    margin: 0 auto;
  }
  .nav { position: static; }
}
