/* =============================================================
   识字小课堂 · 双人同写房间 — 界面层
   -------------------------------------------------------------
   车道 C（界面）专属文件。只做样式，不含任何业务逻辑。

   设计基调继承 hanzi.css：
     奶油纸底 #fff6ec + 家族橙 #ff8a3d + 白卡 + 圆角 20 + 柔光斑。
   本文件新增的全部变量以 --hzr- 前缀，避免污染兄弟页。

   前缀约定：hzr- = hanzi room
   组件清单：
     .hzr-btn        房间按钮（未建房 / 等对方 / 已连接）
     .hzr-bar        在线成员条
     .hzr-member    成员 chip（含 --writing / --offline / --waiting）
     .hzr-net       断线提示条（含 --back / --ok）
     .hzr-sheet     邀请面板（移动端 bottom sheet / 宽屏居中 dialog）
     .hzr-err       进房失败提示卡（含 --full / --used / --expired）
   ============================================================= */

/* ============================================================
   1. 本文件的设计令牌（--hzr- 前缀）
   ============================================================ */
:root {
  /* ---------- 房间专用色 ---------- */
  --hzr-blue: #3b82f6;
  --hzr-blue-ink: #1d4ed8;
  --hzr-blue-soft: #e8f0fe;
  --hzr-blue-line: #bfd4fb;

  --hzr-purple: #8b5cf6;
  --hzr-purple-ink: #6d28d9;
  --hzr-purple-soft: #f0eaff;
  --hzr-purple-line: #d6c4fb;

  --hzr-teal: #14b8a6;
  --hzr-teal-ink: #0f766e;
  --hzr-teal-soft: #e2f7f4;
  --hzr-teal-line: #a7e4dd;

  --hzr-amber: #f59e0b;
  --hzr-amber-ink: #b45309;
  --hzr-amber-soft: #fff4dc;
  --hzr-amber-line: #ffd88a;

  /* ---------- 尺寸 ---------- */
  --hzr-tap: 44px; /* 最小点按边长 */
  --hzr-sheet-max: 420px; /* 宽屏 dialog 宽度 */
  --hzr-z-net: 45; /* 断线条：在顶栏(50)之下，避免盖住顶栏 */
  --hzr-z-sheet: 120; /* 邀请面板 */
  --hzr-z-err: 140; /* 失败卡 */

  /* ---------- 对比度专用文字色 ----------
     hanzi.css 的 --muted(#A2908A) 在奶油纸底上只有 2.85:1，
     达不到正文 4.5:1。房间文案（提示语、成员状态）改用下面这组
     专门调过对比度的颜色，不动兄弟页的 --muted。 */
  --hzr-text: #6b5a52; /* 5.3:1 / 纸底 */
  --hzr-text-soft: #7d6b61; /* 4.6:1 / 纸底 */
  --hzr-text-accent: #9a4f12; /* 5.0:1 / accent-soft */
  --hzr-text-green: #14663a; /* 5.9:1 / green-soft */
  --hzr-text-red: #a52a2a; /* 6.1:1 / 红底 */

  /* 顶栏实际高度。窄屏顶栏会折行（品牌 + 标签两行），
     高度随文字换行变化，静态值不可靠 —— 由 JS 用
     ResizeObserver 量出 .topbar 的 offsetHeight 后写入。
     拿不到时退回 0（此时断线条贴顶滚动，会被顶栏盖住，
     但仍不遮挡顶栏自身，因为 z-index 低于顶栏）。 */
  --hzr-topbar-h: 0px;

  /* ---------- 动效 ---------- */
  --hzr-t-fast: 180ms;
  --hzr-t: 220ms;
  --hzr-t-slow: 240ms;
  --hzr-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --hzr-ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================================
   2. 房间按钮
   -------------------------------------------------------------
   放在字卡顶部工具栏（.hz-actions 或 .hz-write-actions 那一行）
   或紧随其后。视觉：与 .act 同一语言（浅橙底 + 橙边 + 橙字）。
   三态：
     默认        未建房
     .hzr-btn--waiting  自己在线、对方没来（呼吸）
     .hzr-btn--live     2/2 已连接（绿色在线点）
   ============================================================ */
.hzr-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--hzr-tap);
  padding: 9px 16px;
  border-radius: 14px;
  background: #fdf1e5;
  color: var(--accent-ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  border: 1.5px solid var(--accent-line);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.13s ease, background 0.16s ease,
    border-color 0.16s ease, box-shadow 0.16s ease, color 0.16s ease;
}
.hzr-btn:hover {
  background: var(--accent-soft);
}
.hzr-btn:active {
  transform: scale(0.96);
}
.hzr-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* 图标（emoji） */
.hzr-btn__icon {
  font-size: 16px;
  line-height: 1;
  flex: none;
}

/* 计数（2/2） */
.hzr-btn__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 22px;
  padding: 0 7px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.9);
  font-family: var(--font-num);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.3px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  flex: none;
}

/* 在线点：绿点 */
.hzr-btn__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.22);
  flex: none;
}

/* --- 状态：等对方（自己在线，对方还没进） --- */
.hzr-btn--waiting {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.hzr-btn--waiting .hzr-btn__icon {
  animation: hzr-breathe 1.9s ease-in-out infinite;
}
/* 呼吸只作用在图标上，避免整块按钮晃动导致点击漂移 */
@keyframes hzr-breathe {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.18);
    opacity: 0.72;
  }
}

/* --- 状态：已连接（2/2） --- */
.hzr-btn--live {
  background: var(--green-soft);
  border-color: #a8e6bf;
  color: var(--green-ink);
}
.hzr-btn--live:hover {
  background: #ddf6e6;
}
.hzr-btn--live .hzr-btn__count {
  background: #fff;
  color: var(--green-ink);
}
.hzr-btn--live .hzr-btn__dot {
  animation: hzr-dot 1.6s ease-in-out infinite;
}
@keyframes hzr-dot {
  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.22);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.06);
  }
}

/* --- 状态：房间满 / 不能再加人了 --- */
.hzr-btn--full {
  background: #f6efe9;
  border-color: var(--line-2);
  color: var(--hzr-text-soft);
}

/* --- 状态：连接中（刚建房、还没握手） --- */
.hzr-btn--connecting {
  background: var(--paper-tint);
  border-color: var(--line-2);
  color: var(--hzr-text-soft);
}
.hzr-btn--connecting .hzr-btn__icon {
  animation: hzr-breathe 1.2s ease-in-out infinite;
}

/* 变体：占满一行（窄屏工具栏放不下时） */
.hzr-btn--block {
  width: 100%;
}

/* 变体：小号（在线成员条里的「邀请」入口） */
.hzr-btn--sm {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius-pill);
}

/* 变体：退出房间（描边式，比「邀请」弱一档；不做危险红） */
.hzr-btn--quit {
  min-height: 40px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 700;
  background: var(--card);
  border: 1.5px solid var(--line-2);
  color: var(--hzr-text);
  box-shadow: none;
  border-radius: var(--radius-pill);
}
.hzr-btn--quit:hover {
  background: var(--paper-tint);
  border-color: var(--hzr-text-soft);
  color: var(--ink);
}
.hzr-btn--quit .hzr-btn__icon {
  font-size: 13px;
  opacity: 0.75;
}
/* 第一段已点：等第二次确认 */
.hzr-btn--quit.hzr-btn--armed {
  background: var(--hzr-amber-soft);
  border-color: var(--hzr-amber);
  color: var(--hzr-amber-ink);
}
.hzr-btn--quit.hzr-btn--armed:hover {
  background: var(--hzr-amber-soft);
  border-color: var(--hzr-amber-ink);
  color: var(--hzr-amber-ink);
}

/* ============================================================
   3. 在线成员条
   -------------------------------------------------------------
   两枚成员 chip：彩色圆点 + 昵称 + 状态。
   状态修饰符：
     .hzr-member--online   在线
     .hzr-member--waiting  等对方（对方还没进 / 没轮到你）
     .hzr-member--writing  正在写…（圆点脉冲）
     .hzr-member--offline 已断开
   ============================================================ */
.hzr-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 9px 11px;
  margin: 10px 0 12px;
  background: var(--card);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  box-shadow: var(--shadow-soft);
  min-width: 0;
}
.hzr-bar__title {
  font-size: 12px;
  font-weight: 800;
  color: var(--hzr-text);
  flex: none;
  letter-spacing: 0.4px;
}

/* 单个成员 chip */
.hzr-member {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 5px 12px 5px 8px;
  border-radius: var(--radius-pill);
  background: var(--paper-tint);
  border: 1.5px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  min-width: 0;
  max-width: 100%;
  transition: background 0.18s ease, border-color 0.18s ease,
    box-shadow 0.18s ease, opacity 0.18s ease;
}

/* 彩色圆点 */
.hzr-member__dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex: none;
  background: var(--muted);
  box-shadow: 0 0 0 3px rgba(162, 144, 138, 0.16);
}
/* 颜色按角色分配（由 --hzr-color 传入） */
.hzr-member[style*='--hzr-color'] .hzr-member__dot {
  background: var(--hzr-color, var(--muted));
}
/* 光晕用 color-mix 派生；不支持 color-mix 的老浏览器退化为无光晕 */
@supports (color: color-mix(in srgb, red 50%, transparent)) {
  .hzr-member[style*='--hzr-color'] .hzr-member__dot {
    box-shadow: 0 0 0 3px
      color-mix(in srgb, var(--hzr-color, #a2908a) 22%, transparent);
  }
}
/* 兜底：没有内联变量时用 nth-child 上色 */
.hzr-member:nth-child(2) .hzr-member__dot {
  background: var(--hzr-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
.hzr-member:nth-child(3) .hzr-member__dot {
  background: var(--hzr-purple);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.hzr-member__name {
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 11ch; /* 长昵称省略，不撑破布局 */
}
.hzr-member__state {
  font-size: 12px;
  font-weight: 700;
  color: var(--hzr-text);
  white-space: nowrap;
}

/* --- 状态：在线 --- */
.hzr-member--online {
  background: #f6fbf7;
  border-color: #cdebd9;
}
.hzr-member--online .hzr-member__state {
  color: var(--hzr-text-green);
}

/* --- 状态：等对方 --- */
.hzr-member--waiting {
  background: var(--paper-tint);
}
.hzr-member--waiting .hzr-member__state {
  color: var(--hzr-text);
}

/* --- 状态：正在写…（圆点脉冲） --- */
.hzr-member--writing {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px rgba(255, 138, 61, 0.12);
}
.hzr-member--writing .hzr-member__state {
  color: var(--hzr-text-accent);
}
.hzr-member--writing .hzr-member__dot {
  animation: hzr-pulse 1.25s ease-in-out infinite;
}
@keyframes hzr-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(255, 138, 61, 0.28);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(255, 138, 61, 0.02);
  }
}

/* --- 状态：已断开 --- */
.hzr-member--offline {
  background: #faf4f1;
  border-color: var(--line);
  color: var(--hzr-text-soft);
  opacity: 0.9;
}
.hzr-member--offline .hzr-member__dot {
  background: #b9a49a !important;
  box-shadow: none !important;
}
.hzr-member--offline .hzr-member__name {
  color: var(--hzr-text-soft);
}
.hzr-member--offline .hzr-member__state {
  color: var(--hzr-text-red);
}

/* 「我」标记 */
.hzr-member__self {
  font-size: 11px;
  font-weight: 800;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-radius: var(--radius-pill);
  padding: 1px 6px;
  flex: none;
}

/* 成员条右侧的「邀请」小按钮容器 */
.hzr-bar__spacer {
  flex: 1 1 auto;
  min-width: 0;
}

/* 面板里的成员条是副本：不放操作按钮（退出/邀请只在房间栏里） */
.hzr-sheet__members .hzr-btn {
  display: none;
}
.hzr-sheet__members .hzr-bar__spacer {
  display: none;
}

/* 窄屏：成员 chip 只留「圆点 + 名字」，按钮换到第二行并平分宽度；
   在线状态是冗余信息，已离开 / 正在写 仍然显示 */
@media (max-width: 430px) {
  .hzr-bar {
    gap: 6px;
    padding: 8px 9px;
  }
  .hzr-bar__title {
    display: none;
  }
  .hzr-bar .hzr-member {
    padding: 4px 10px 4px 7px;
    gap: 6px;
  }
  .hzr-bar .hzr-member--online .hzr-member__state {
    display: none;
  }
  /* 占位撑满一行 → 两个按钮另起一行 */
  .hzr-bar__spacer {
    flex: 1 0 100%;
    height: 0;
  }
  .hzr-bar .hzr-btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: 40px;
  }
}

/* ============================================================
   4. 断线提示条
   -------------------------------------------------------------
   页面顶部窄条。紧贴顶栏（position: sticky; top: 0），
   不遮挡顶栏内容 —— 顶栏 sticky 在上，窄条排在其下。
   两态：
     默认（.hzr-net）      「网络断了，正在重连…」
     .hzr-net--ok          「已重新连上 ✓」2 秒后自动收起（加 .is-hide）
   ============================================================ */
.hzr-net {
  position: sticky;
  top: var(--hzr-topbar-h, 0px);
  z-index: var(--hzr-z-net);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 14px;
  background: var(--hzr-amber-soft);
  border-bottom: 1.5px solid var(--hzr-amber-line);
  color: var(--hzr-amber-ink);
  font-size: 13.5px;
  font-weight: 800;
  text-align: center;
  line-height: 1.4;
  overflow-wrap: anywhere;
  /* 出现/收起：位移 + 透明度，220ms */
  transform: translateY(-100%);
  opacity: 0;
  visibility: hidden;
  transition: transform var(--hzr-t) var(--hzr-ease), opacity var(--hzr-t) ease,
    visibility 0s linear var(--hzr-t);
}
.hzr-net.is-show {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
  transition: transform var(--hzr-t) var(--hzr-ease), opacity var(--hzr-t) ease,
    visibility 0s;
}
/* 收起（重连成功后 2 秒） */
.hzr-net.is-hide {
  transform: translateY(-100%);
  opacity: 0;
  visibility: hidden;
}

/* 断线中的小转轮 */
.hzr-net__icon {
  font-size: 15px;
  line-height: 1;
  flex: none;
  display: inline-block;
}
.hzr-net.is-show:not(.hzr-net--ok) .hzr-net__icon {
  animation: hzr-spin 1.15s linear infinite;
}
@keyframes hzr-spin {
  to {
    transform: rotate(360deg);
  }
}

/* 重连成功 */
.hzr-net--ok,
.hzr-net--ok.is-show {
  background: var(--green-soft);
  border-bottom-color: #b8e8c9;
  color: var(--green-ink);
}
.hzr-net--ok .hzr-net__icon {
  animation: none;
}

/* ============================================================
   5. 邀请面板（邀请链接）
   -------------------------------------------------------------
   <720px  ：底部抽屉 bottom sheet（拖拽把手、圆角上沿、safe-area）
   >=720px ：居中 dialog + 半透明遮罩
   遮罩：.hzr-sheet__scrim
   面板：.hzr-sheet
   ============================================================ */

/* ---------- 遮罩 ---------- */
.hzr-sheet__scrim {
  position: fixed;
  inset: 0;
  z-index: calc(var(--hzr-z-sheet) - 1);
  background: rgba(61, 47, 40, 0.44);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--hzr-t) ease, visibility 0s linear var(--hzr-t);
}
.hzr-sheet__scrim.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--hzr-t) ease, visibility 0s;
}

/* ---------- 面板本体 ---------- */
.hzr-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--hzr-z-sheet);
  display: flex;
  flex-direction: column;
  max-height: min(86vh, 620px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-top: 3px solid var(--accent-line);
  box-shadow: 0 -12px 40px rgba(120, 78, 40, 0.22);
  padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  visibility: hidden;
  transition: transform var(--hzr-t-slow) var(--hzr-ease), visibility 0s linear var(--hzr-t-slow);
}
.hzr-sheet.is-open {
  transform: translateY(0);
  visibility: visible;
  transition: transform var(--hzr-t-slow) var(--hzr-ease), visibility 0s;
}

/* 拖拽把手（仅窄屏显示，纯视觉） */
.hzr-sheet__grip {
  width: 46px;
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--line-2);
  margin: 2px auto 10px;
  flex: none;
}

/* 头部 */
.hzr-sheet__head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: none;
}
.hzr-sheet__title {
  font-size: 19px;
  font-weight: 900;
  color: var(--ink);
  letter-spacing: 0.5px;
  line-height: 1.35;
  margin: 0;
  flex: 1;
  min-width: 0;
}
.hzr-sheet__sub {
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.6;
  margin: 4px 0 0;
}

/* 关闭按钮 */
.hzr-sheet__close {
  flex: none;
  width: var(--hzr-tap);
  height: var(--hzr-tap);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--paper-tint);
  border: 1.5px solid var(--line);
  color: var(--ink-2);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, transform 0.15s ease;
}
.hzr-sheet__close:hover {
  background: var(--accent-soft);
}
.hzr-sheet__close:active {
  transform: scale(0.92);
}
.hzr-sheet__close:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 链接区 ---------- */
.hzr-sheet__body {
  margin-top: 14px;
  min-width: 0;
}

/* 只读链接框 */
.hzr-sheet__link {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper-tint);
  border: 2px dashed var(--accent-line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-width: 0;
}
.hzr-sheet__link-text {
  flex: 1;
  min-width: 0;
  font-family: var(--font-num);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-2);
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: all;
  -webkit-user-select: all;
}
/* 链接框：超长时允许两行，避免把按钮挤出屏幕 */
.hzr-sheet__link--wrap .hzr-sheet__link-text {
  white-space: normal;
  word-break: break-all;
  text-overflow: clip;
  max-height: 4.9em;
  overflow-y: auto;
}
.hzr-sheet__link-tag {
  flex: none;
  font-size: 11px;
  font-weight: 800;
  color: var(--hzr-text-accent);
  background: var(--accent-soft);
  border-radius: var(--radius-pill);
  padding: 3px 9px;
}

/* ---------- 复制按钮 ---------- */
.hzr-sheet__copy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 54px;
  margin-top: 12px;
  padding: 14px 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, #ff9d4d, #ff7a2f);
  color: #fff;
  font-family: inherit;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(255, 122, 47, 0.32);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s var(--hzr-ease-back), box-shadow 0.15s ease,
    background 0.18s ease, color 0.18s ease;
}
.hzr-sheet__copy:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(255, 122, 47, 0.38);
}
.hzr-sheet__copy:active {
  transform: scale(0.97);
}
.hzr-sheet__copy:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
.hzr-sheet__copy__icon {
  font-size: 19px;
  line-height: 1;
  flex: none;
}

/* 复制成功：绿底 + 文字变「已复制 ✓」+ 回弹 */
.hzr-sheet__copy--copied {
  background: linear-gradient(135deg, #4ade80, #22c55e);
  box-shadow: 0 10px 24px rgba(34, 197, 94, 0.32);
  animation: hzr-pop 0.4s var(--hzr-ease-back);
}
@keyframes hzr-pop {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}

/* 复制失败 */
.hzr-sheet__copy--error {
  background: linear-gradient(135deg, #f87171, #ef4444);
  box-shadow: 0 10px 24px rgba(239, 68, 68, 0.3);
}

/* 底部小提示 */
.hzr-sheet__hint {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  line-height: 1.55;
}
.hzr-sheet__hint b {
  color: var(--accent-ink);
}

/* 面板内的成员条（谁在线一目了然） */
.hzr-sheet__members {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

/* ============================================================
   6. 进房失败提示卡
   -------------------------------------------------------------
   居中卡片：大图标 + 一句话 + 「自己开一个房间」按钮位。
   状态修饰符：
     .hzr-err--full    房间满了
     .hzr-err--used    链接被用掉
     .hzr-err--expired 链接过期
   ============================================================ */
.hzr-err {
  position: fixed;
  inset: 0;
  z-index: var(--hzr-z-err);
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(61, 47, 40, 0.46);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--hzr-t) ease, visibility 0s linear var(--hzr-t);
}
.hzr-err.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--hzr-t) ease, visibility 0s;
}

.hzr-err__card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 2px solid var(--line);
  box-shadow: var(--shadow-lift);
  padding: 26px 22px 22px;
  text-align: center;
  transform: translateY(14px) scale(0.96);
  opacity: 0;
  transition: transform var(--hzr-t-slow) var(--hzr-ease-back),
    opacity var(--hzr-t) ease;
}
.hzr-err.is-open .hzr-err__card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.hzr-err__icon {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 10px;
  display: block;
}
.hzr-err__title {
  font-size: 20px;
  font-weight: 900;
  color: var(--ink);
  margin: 0 0 6px;
  letter-spacing: 0.6px;
}
.hzr-err__text {
  font-size: 15px;
  color: var(--ink-2);
  line-height: 1.7;
  margin: 0 0 18px;
}
/* 状态配色 */
.hzr-err--full .hzr-err__icon {
  filter: drop-shadow(0 4px 8px rgba(245, 158, 11, 0.28));
}
.hzr-err--used .hzr-err__icon {
  filter: drop-shadow(0 4px 8px rgba(239, 68, 68, 0.24));
}
.hzr-err--expired .hzr-err__icon {
  filter: drop-shadow(0 4px 8px rgba(162, 144, 138, 0.3));
}

/* 「自己开一个房间」按钮位 */
.hzr-err__cta {
  display: flex;
  width: 100%;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, #ff9d4d, #ff7a2f);
  color: #fff;
  font-family: inherit;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 1.5px;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(255, 122, 47, 0.32);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.hzr-err__cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(255, 122, 47, 0.38);
}
.hzr-err__cta:active {
  transform: scale(0.97);
}
.hzr-err__cta:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* 次要按钮：回首页自己练 */
.hzr-err__alt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--hzr-tap);
  margin-top: 10px;
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  background: var(--paper-tint);
  border: 1.5px solid var(--line);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.hzr-err__alt:hover {
  background: var(--accent-soft);
}
.hzr-err__alt:active {
  transform: scale(0.96);
}
.hzr-err__alt:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   7. 宽屏：≥720px 邀请面板改为居中 dialog
   ============================================================ */
@media (min-width: 720px) {
  .hzr-sheet {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    width: var(--hzr-sheet-max);
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 80px);
    border-radius: var(--radius-lg);
    border: 2px solid var(--accent-line);
    border-top-width: 2px;
    box-shadow: var(--shadow-lift);
    padding: 22px 22px 22px;
    transform: translate(-50%, -50%) scale(0.95);
    opacity: 0;
    transition: transform var(--hzr-t-slow) var(--hzr-ease-back),
      opacity var(--hzr-t) ease, visibility 0s linear var(--hzr-t-slow);
  }
  .hzr-sheet.is-open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    visibility: visible;
    transition: transform var(--hzr-t-slow) var(--hzr-ease-back),
      opacity var(--hzr-t) ease, visibility 0s;
  }
  /* 宽屏不需要拖拽把手 */
  .hzr-sheet__grip {
    display: none;
  }
  .hzr-sheet__copy {
    min-height: 56px;
  }
}

/* ============================================================
   8. 窄屏微调
   ============================================================ */
@media (max-width: 719px) {
  /* 链接框在窄屏换行显示，避免横向滚动 */
  .hzr-sheet__link-text {
    font-size: 13.5px;
  }
  /* 失败卡在小屏收紧内边距 */
  .hzr-err__card {
    padding: 22px 18px 18px;
  }
  .hzr-err__icon {
    font-size: 48px;
  }
  .hzr-err__title {
    font-size: 19px;
  }
  .hzr-err__text {
    font-size: 14.5px;
  }
}

/* 极窄屏（≤360px） */
@media (max-width: 360px) {
  .hzr-btn {
    padding: 9px 12px;
    font-size: 13.5px;
  }
  .hzr-sheet {
    padding-left: 14px;
    padding-right: 14px;
  }
  .hzr-member__name {
    max-width: 8ch;
  }
}

/* 房间按钮在工具栏里独占一行时（窄屏） */
@media (max-width: 480px) {
  .hzr-btn--responsive {
    flex: 1 1 100%;
  }
}

/* ============================================================
   9. 无障碍 / 降低动效
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .hzr-btn--waiting .hzr-btn__icon,
  .hzr-btn--connecting .hzr-btn__icon,
  .hzr-btn--live .hzr-btn__dot,
  .hzr-member--writing .hzr-member__dot,
  .hzr-net.is-show:not(.hzr-net--ok) .hzr-net__icon {
    animation: none !important;
  }
  .hzr-sheet,
  .hzr-sheet__scrim,
  .hzr-err,
  .hzr-err__card,
  .hzr-net,
  .hzr-sheet__copy--copied {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
  /* 降低动效时，断线条仍然要能被看见（用不透明度区分） */
  .hzr-net.is-show {
    opacity: 1;
  }
}

/* 高对比 / 强制颜色模式 */
@media (forced-colors: active) {
  .hzr-btn,
  .hzr-member,
  .hzr-sheet,
  .hzr-err__card,
  .hzr-net {
    border: 1.5px solid CanvasText;
  }
  .hzr-btn__dot,
  .hzr-member__dot {
    forced-color-adjust: none;
  }
}

/* ============================================================
   10. 打印 & 杂项
   ============================================================ */
@media print {
  .hzr-sheet,
  .hzr-sheet__scrim,
  .hzr-err,
  .hzr-net {
    display: none !important;
  }
}

/* 视觉隐藏但屏幕阅读器可读 */
.hzr-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
