/* ============================================================
   网页提词器 /prompt —— 样式
   浅色编辑态 + 深色提词态；移动端参数为底部抽屉，编辑区优先
   ============================================================ */

:root {
  --ink: #101418;
  --sub: #475569;
  --muted: #8b939f;
  --line: #e5e7eb;
  --line-soft: #eceef2;
  --line-strong: #d4d8de;
  --bg: #f5f6f8;
  --card: #ffffff;
  --ctl-bg: #fafbfc;
  --accent: #1c64f2;
  --accent-soft: #eaf1fe;
  --green: #12805c;
  --danger: #d93a3a;

  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 20, 24, .05);
  --shadow-md: 0 6px 24px rgba(16, 20, 24, .08);

  --topbar-h: 56px;

  --stage-bg: #0b0e14;
  --stage-color: #f5f7fa;
  --stage-font: 56px;
  --stage-lh: 1.75;
  --stage-pad: 3.3%;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button { font-family: inherit; cursor: pointer; }
a { color: inherit; }

/* ============================ 编辑视图 ============================ */

.editor-view {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 8px 16px;
  padding-top: calc(8px + env(safe-area-inset-top, 0));
  min-height: calc(var(--topbar-h) + env(safe-area-inset-top, 0));
  background: var(--card);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  flex: none;
}

.brand-text {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .2px;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition: background .16s ease, border-color .16s ease, opacity .16s ease;
}
.btn.ghost { border-color: var(--line-strong); background: var(--card); }
.btn.ghost:hover { background: #f3f4f6; }
.btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(28, 100, 242, .25);
}
.btn.primary:hover { background: #1a58d6; }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.danger-text { color: var(--danger); }

.icon-btn { padding: 0 9px; gap: 6px; }

/* 顶栏文字块按钮：文字 + 背景色块；容器允许换行，宽度不足自动转行 */
.topnav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid #d7e3fb;
  border-radius: 9px;
  background: var(--accent-soft);
  color: #1747b0;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .2px;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.topnav:hover { background: #dce8fd; border-color: #c2d6fa; }
.topnav:active { transform: translateY(.5px); }

.topnav-primary {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(28, 100, 242, .28);
}
.topnav-primary:hover { background: #1a58d6; border-color: transparent; }

.topnav-admin {
  background: transparent;
  border-color: transparent;
  color: #8a94a6;
  font-weight: 500;
}
.topnav-admin:hover { background: #eef2f8; border-color: transparent; color: #5b6472; }

.btn:focus-visible,
.topnav:focus-visible,
.opt:focus-visible,
.step:focus-visible,
.swatch:focus-visible,
.hud-btn:focus-visible,
.chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 工作区 */
.workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
}

/* 台词本侧栏（桌面） */
.library {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--card);
  z-index: 30;
}

.library-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .4px;
  color: var(--muted);
}

.lib-count {
  font-weight: 500;
  color: var(--muted);
  background: #f1f3f5;
  border-radius: 20px;
  padding: 1px 8px;
  font-size: 11px;
}

.lib-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0 8px 12px;
  -webkit-overflow-scrolling: touch;
}

.lib-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .14s ease;
}
.lib-item:hover { background: #f4f5f7; }
.lib-item.active { background: var(--accent-soft); border-color: #cfe0fd; }
.lib-item.active .lib-title { color: #1747b0; }

.lib-title {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lib-sub {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-foot {
  flex: none;
  padding: 12px 16px 8px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
}

.library-link {
  flex: none;
  display: block;
  margin: 0 12px 14px;
  padding: 9px 10px;
  border-radius: 9px;
  background: var(--ctl-bg);
  border: 1px solid var(--line-soft);
  font-size: 12.5px;
  color: var(--accent);
  text-decoration: none;
  text-align: center;
}
.library-link:hover { background: var(--accent-soft); }

/* 编辑区 */
.canvas {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 12px 18px 0;
}

.canvas-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 8px;
}

.title-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  padding: 4px 0;
  outline: none;
}
.title-input::placeholder { color: #b6bcc6; font-weight: 500; }
.title-input[readonly] { color: var(--sub); }

.canvas-meta {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.save-state { transition: color .2s ease; }
.save-state.ok { color: var(--green); }
.save-state.warn { color: #b45309; }
.save-state.err { color: var(--danger); }

.btn-save {
  height: 28px;
  padding: 0 14px;
  font-size: 13px;
  line-height: 1;
  border-radius: 8px;
}
.btn-save:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* 分类条 */
.doc-bar {
  flex: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding-bottom: 10px;
}

.cat-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--sub);
  font-size: 12.5px;
  flex: none;
  max-width: 60%;
}
.cat-pick select {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 500;
  color: var(--ink);
  outline: none;
  max-width: 190px;
  padding: 0;
  margin: 0;
  text-overflow: ellipsis;
}
.cat-pick select:disabled { color: var(--muted); }
.cat-pick .caret { color: var(--muted); flex: none; }

.doc-hint {
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.doc-hint.is-readonly { color: #b45309; font-weight: 500; }

.unlock-bar {
  flex: none;
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid #f3d9a8;
  border-radius: var(--radius);
  background: #fffaf0;
}
.unlock-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.unlock-input {
  flex: 1 1 auto;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .18em;
  text-align: center;
  outline: none;
  max-width: 180px;
}
.unlock-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(28, 100, 242, .12); }
.unlock-msg {
  margin: 8px 0 0;
  font-size: 12px;
  color: #b45309;
  line-height: 1.5;
}
.unlock-msg.is-err { color: #dc2626; }

.content-input {
  flex: 1 1 auto;
  min-height: 200px;
  width: 100%;
  resize: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 16px 18px;
  font-size: 15.5px;
  line-height: 1.9;
  color: var(--ink);
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: border-color .16s ease, box-shadow .16s ease;
  -webkit-overflow-scrolling: touch;
}
.content-input:focus {
  border-color: #b9cef8;
  box-shadow: 0 0 0 3px rgba(28, 100, 242, .09);
}
.content-input::placeholder { color: #aab1bb; line-height: 2.1; }
.content-input[readonly] { background: #fbfbfc; color: var(--sub); }

.canvas-foot {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 2px 10px;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #fff;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--sub);
}

/* ============================ 参数面板 ============================ */

.panel {
  flex: none;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 18px;
}

.panel-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.panel-summary {
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 7px;
  flex: none;
}
.panel-toggle:hover { background: #f3f4f6; color: var(--sub); }
.panel-toggle svg { transition: transform .2s ease; }
.panel.collapsed .panel-toggle svg { transform: rotate(180deg); }

.panel-close {
  display: none;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: #f3f4f6;
  color: var(--sub);
  flex: none;
}
.panel-close:hover { background: #e9ecf1; }

.panel-body {
  padding: 0 18px 14px;
  max-height: 46vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.panel.collapsed .panel-body { display: none; }

.ctl-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.ctl-grid-wide {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

/* 独立控件卡片 */
.ctl {
  background: var(--ctl-bg);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 12px 14px;
  min-width: 0;
}

.ctl-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.ctl-label {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
}

.ctl-value {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
}
.ctl-value b {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.2px;
}
.ctl-value i { font-style: normal; font-size: 11px; }

.ctl-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #475569;
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background .14s ease, border-color .14s ease;
  user-select: none;
  -webkit-user-select: none;
}
.step:hover { background: #f1f3f6; }
.step:active { background: #e6eaf0; border-color: #c3c9d2; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  min-width: 0;
  height: 6px;
  border-radius: 6px;
  background: #e4e8ee;
  outline: none;
  margin: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(16, 20, 24, .2);
  cursor: pointer;
  transition: transform .12s ease;
}
input[type="range"]::-webkit-slider-thumb:active { transform: scale(1.1); }
input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  cursor: pointer;
}

.swatches { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.swatch {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(16, 20, 24, .16);
  background-clip: padding-box;
  position: relative;
  transition: transform .12s ease, box-shadow .12s ease;
}
.swatch:hover { transform: scale(1.08); }
.swatch.active { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }

.swatch.custom {
  display: grid;
  place-items: center;
  background: conic-gradient(#f87171, #fbbf24, #34d399, #60a5fa, #a78bfa, #f87171);
  overflow: hidden;
  cursor: pointer;
}
.swatch.custom::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #fff;
}
.swatch.custom input[type="color"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.opt-row { display: flex; gap: 8px; }

.opt {
  flex: 1;
  min-width: 0;
  height: 34px;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 9px;
  font-size: 12.5px;
  color: var(--sub);
  padding: 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}
.opt:hover { background: #f4f5f7; }
.opt.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* 抽屉遮罩 */
.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(16, 20, 24, .38);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
  z-index: 44;
}
.drawer-mask.show { opacity: 1; pointer-events: auto; }

/* ============================ 通用弹层 ============================ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal[hidden] { display: none; }

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(16, 20, 24, .42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(16, 20, 24, .28);
  animation: modalIn .2s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.modal-title {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.modal-input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 15px;
  color: var(--ink);
  outline: none;
}
.modal-input:focus { border-color: #b9cef8; box-shadow: 0 0 0 3px rgba(28, 100, 242, .09); }

.modal-tip {
  min-height: 18px;
  margin: 8px 0 0;
  font-size: 12.5px;
  color: #b45309;
}

.modal-note {
  margin: 10px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.55;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.modal-tall { max-width: 440px; max-height: 84vh; display: flex; flex-direction: column; }

/* ============================ 提词视图 ============================ */

.stage {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 100;
  background: var(--stage-bg);
  color: var(--stage-color);
  overflow: hidden;
  touch-action: none;
  transition: background-color .2s ease, color .2s ease;
  overscroll-behavior: none;
}

.stage[hidden] { display: none; }

.stage-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.stage-roller {
  will-change: transform;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
}

.stage-mirror { transform-origin: center center; }
.stage-mirror.mh { transform: scaleX(-1); }
.stage-mirror.mv { transform: scaleY(-1); }
.stage-mirror.mh.mv { transform: scale(-1, -1); }

.stage-text {
  padding-top: 52vh;
  padding-bottom: 74vh;
  padding-left: var(--stage-pad);
  padding-right: var(--stage-pad);
  font-size: var(--stage-font);
  line-height: var(--stage-lh);
  font-weight: 700;
  letter-spacing: .01em;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
}
.stage-text.align-left {
  text-align: justify;
  text-justify: inter-ideograph;
  text-align-last: left;
}
.stage-text.weight-normal { font-weight: 500; }

/* 横屏：视口更扁，首行抬高、尾部收紧 */
.stage.is-landscape .stage-text {
  padding-top: 42vh;
  padding-bottom: 60vh;
}

/* 边缘渐隐，与背景同色 */
.edge {
  position: absolute;
  left: 0;
  right: 0;
  height: 14vh;
  pointer-events: none;
}
.edge-top {
  top: 0;
  background: linear-gradient(to bottom, var(--stage-bg) 8%, rgba(0, 0, 0, 0) 100%);
}
.edge-bottom {
  bottom: 0;
  background: linear-gradient(to top, var(--stage-bg) 8%, rgba(0, 0, 0, 0) 100%);
}

.stage-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: rgba(255, 255, 255, .1);
  pointer-events: none;
}
.stage-progress i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--stage-color);
  opacity: .55;
  transition: width .1s linear;
}

.stage-hud {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(28px + env(safe-area-inset-bottom, 0));
  display: flex;
  justify-content: center;
  padding: 0 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
  z-index: 5;
}
.stage-hud.show { opacity: 1; pointer-events: auto; }

/* 快捷菜单栏：图标放不下时横向滑动，隐藏滚动条 */
.hud-scroll {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(20, 24, 32, .62);
  border: 1px solid rgba(255, 255, 255, .1);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  scrollbar-width: none;
  -ms-overflow-style: none;
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
}
.hud-scroll::-webkit-scrollbar { display: none; width: 0; height: 0; }

.hud-left, .hud-right { display: flex; align-items: center; gap: 6px; }
.hud-center { display: flex; align-items: center; flex: none; }

.hud-btn {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, .78);
  font-size: 12.5px;
  font-weight: 600;
  flex: none;
  transition: background .14s ease, color .14s ease;
}
.hud-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.hud-btn svg[hidden] { display: none; }

.hud-play {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 0;
  background: #fff;
  color: #101418;
  flex: none;
  transition: transform .14s ease;
}
.hud-play:active { transform: scale(.94); }
.hud-play svg[hidden] { display: none; }

/* 底部速度加减 */
.hud-speed-btn {
  min-width: 30px;
  height: 30px;
  padding: 0;
  font-size: 15px;
  font-weight: 700;
  background: rgba(255, 255, 255, .08);
}
.hud-speed-btn:hover { background: rgba(255, 255, 255, .18); }
.hud-speed-val {
  min-width: 26px;
  text-align: center;
  color: rgba(255, 255, 255, .85);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  flex: none;
}

.stage-tip {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(20, 24, 32, .7);
  color: rgba(255, 255, 255, .82);
  font-size: 13px;
  letter-spacing: .3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s ease;
  z-index: 6;
  max-width: 82vw;
  text-align: center;
}
.stage-tip.show { opacity: 1; }

.countdown-mask {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 7, 10, .55);
  z-index: 8;
}
.countdown-mask[hidden] { display: none; }
.countdown-mask span {
  font-size: clamp(64px, 18vw, 160px);
  font-weight: 300;
  color: #fff;
  font-variant-numeric: tabular-nums;
  animation: cdPop .9s ease-out;
}
@keyframes cdPop {
  0%   { opacity: 0; transform: scale(.72); }
  35%  { opacity: 1; transform: scale(1); }
  100% { opacity: .92; transform: scale(1.04); }
}

/* 横屏下控制条更紧凑 */
.stage.is-landscape .stage-hud { bottom: calc(12px + env(safe-area-inset-bottom, 0)); }
.stage.is-landscape .hud-scroll { padding: 6px 10px; gap: 8px; }
.stage.is-landscape .hud-play { width: 40px; height: 40px; }
.stage.is-landscape .hud-btn { min-width: 32px; height: 32px; }

/* ============================ 台词详情页 ============================ */

body.view-body {
  background: var(--bg);
  overflow-y: auto;
  overscroll-behavior: auto;
}

.view-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 16px env(safe-area-inset-bottom, 0);
  display: flex;
  flex-direction: column;
}

.view-top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 10px 0;
  padding-top: calc(10px + env(safe-area-inset-top, 0));
  background: rgba(245, 246, 248, .92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(229, 231, 235, .8);
}

.view-main { flex: 1; padding: 18px 0 32px; }

.view-title {
  font-size: 21px;
  font-weight: 700;
  line-height: 1.4;
  margin: 0 0 8px;
  color: var(--ink);
  word-break: break-word;
}

.view-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--muted);
}
.view-meta .dot { opacity: .5; }

.view-content {
  margin-top: 16px;
  padding: 18px 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
  line-height: 1.95;
  color: #334155;
  max-height: 62vh;
  overflow-y: auto;
}

.view-foot {
  margin-top: 14px;
  font-size: 12px;
  color: #a0a7b1;
  text-align: center;
}
.view-foot p { margin: 0; }
.view-back {
  display: inline-block;
  margin-top: 8px;
  font-size: 12.5px;
  color: #6d7787;
  text-decoration: none;
}
.view-back:hover { color: var(--accent); }

.view-center { align-items: center; justify-content: center; padding: 24px; }

.empty-card {
  text-align: center;
  padding: 36px 28px 30px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  max-width: 360px;
  width: 100%;
}
.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: #f1f3f5;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  color: var(--muted);
}
.empty-card h1 { font-size: 17px; margin: 0 0 6px; }
.empty-card p { font-size: 13.5px; color: var(--muted); margin: 0 0 20px; line-height: 1.6; }

/* ============================ 台词本模块 ============================ */

body.lib-body {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
}

.lib-wrap {
  max-width: 860px;
  margin: 0 auto;
  min-height: 100%;
  padding-bottom: calc(28px + env(safe-area-inset-bottom, 0));
}

.lib-top {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top, 0));
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.lib-top-title { flex: 1 1 auto; min-width: 0; }
.lib-top-title h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
}
.lib-top-sub {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lib-top-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  flex: none;
}

.lib-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 16px 10px;
  padding: 0 10px;
  height: 42px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  box-shadow: var(--shadow-sm);
}
.lib-search input[type="search"] {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 14.5px;
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}
.lib-search input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 16px 12px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--sub);
  font-size: 13px;
  text-decoration: none;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}
.chip:hover { background: #f4f5f7; }
.chip i {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.chip.active i { color: rgba(255, 255, 255, .72); }
.chip-add {
  border-style: dashed;
  color: var(--accent);
  background: #fff;
}

.lib-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin: 0 16px 10px;
  font-size: 12px;
  color: var(--muted);
}

/* 批量管理入口（列表计数行右侧） */
.lib-batch-entry {
  flex: none;
  height: 28px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--sub);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, color .16s ease;
}
.lib-batch-entry:hover { background: #f3f6fb; border-color: #c3d3ee; }
.lib-batch-entry[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.lib-cards {
  list-style: none;
  margin: 0;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lib-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.lib-card:hover { border-color: #cfdcf5; box-shadow: var(--shadow-md); }

/* ---- 批量选择 ---- */
.lib-check {
  display: none;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 26px;
  min-height: 44px;
  cursor: pointer;
}
.lib-check input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.lib-cards.batch .lib-check { display: flex; }
.lib-cards.batch .lib-card.is-own { cursor: pointer; }
.lib-cards.batch .lib-card.is-own:hover { border-color: #a9c6f7; }
.lib-card.selected {
  border-color: #9dbdf7;
  background: #f7faff;
  box-shadow: 0 0 0 3px rgba(28, 100, 242, .10);
}

/* ---- 批量操作条 ---- */
.batchbar {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom, 0));
  transform: translateX(-50%);
  z-index: 40;
  width: min(680px, calc(100% - 20px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(16, 20, 24, .95);
  color: #fff;
  box-shadow: 0 12px 34px rgba(16, 20, 24, .32);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: batchUp .2s cubic-bezier(.4, 0, .2, 1);
}
@keyframes batchUp {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.batchbar-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #dfe6ef;
  white-space: nowrap;
}
.batchbar-info b { color: #8ab4ff; font-weight: 700; font-size: 15px; }
.batchbar-link {
  border: 0;
  background: none;
  padding: 2px 2px;
  color: #9fb6d4;
  font-size: 12.5px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.batchbar-link:hover { color: #cfdcec; }

.batchbar-acts { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.batchbar-btn {
  height: 32px;
  padding: 0 13px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(255, 255, 255, .10);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, opacity .16s ease;
}
.batchbar-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .2); }
.batchbar-btn:disabled { opacity: .38; cursor: not-allowed; }
.batchbar-btn.danger { background: #d93a3a; border-color: #d93a3a; }
.batchbar-btn.danger:hover:not(:disabled) { background: #bd3434; }
.batchbar-btn.ghost { background: transparent; border-color: rgba(255, 255, 255, .3); color: #cfd8e3; }
.batchbar-btn.ghost:hover { background: rgba(255, 255, 255, .1); }

/* 批量模式下给底部操作条留出空间，避免遮住最后一张卡片 */
.lib-body.batch-on .lib-wrap { padding-bottom: calc(108px + env(safe-area-inset-bottom, 0)); }

.batchbar-msg {
  flex: 1 0 100%;
  font-size: 12.5px;
  color: #ffb4b4;
  line-height: 1.4;
}

/* 操作结果提示 */
.toast {
  position: fixed;
  left: 50%;
  top: calc(14px + env(safe-area-inset-top, 0));
  transform: translateX(-50%);
  z-index: 60;
  max-width: calc(100% - 28px);
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(16, 20, 24, .94);
  color: #fff;
  font-size: 13.5px;
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(16, 20, 24, .26);
  animation: toastIn .2s ease;
  transition: opacity .35s ease, transform .35s ease;
}
.toast.out { opacity: 0; transform: translate(-50%, -6px); }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.lib-card-main { flex: 1; min-width: 0; }

.lib-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.lib-card-title {
  flex: 1;
  min-width: 0;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lib-card-title:hover { color: var(--accent); }

.lib-card-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--muted);
  flex-wrap: wrap;
}
.lib-card-meta .dot { opacity: .5; }

.lib-card-actions {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 62px;
}
.lib-card-actions .btn { width: 100%; }

.tag {
  display: inline-flex;
  align-items: center;
  flex: none;
  height: 20px;
  padding: 0 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.tag-own { background: #eef2ff; color: #3b47b8; }
.tag-cat { background: var(--accent-soft); color: #1747b0; }
.tag-cat:hover { background: #dbe8fd; }
.tag-none { background: #f3f4f6; color: #98a1ad; }

/* 自己台词上的分类标签可点击归类 */
button.tag {
  border: 0;
  font-family: inherit;
  cursor: pointer;
  transition: filter .14s ease, background .14s ease;
}
button.tag:hover { filter: brightness(.96); }
button.tag::after {
  content: "▾";
  font-size: 9px;
  margin-left: 3px;
  opacity: .7;
}

.cat-picker-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 44vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.cat-picker-item {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fff;
  font-size: 13.5px;
  color: var(--sub);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}
.cat-picker-item:hover { background: #f4f5f7; }
.cat-picker-item.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.cat-picker-new { border-style: dashed; color: var(--accent); }

.lib-empty {
  margin: 24px 16px;
  padding: 40px 24px;
  background: #fff;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}
.lib-empty p { margin: 0 0 16px; }
.lib-empty .empty-icon { margin-bottom: 12px; }

.lib-foot {
  margin-top: 22px;
  text-align: center;
  font-size: 11.5px;
  color: #a8afb9;
}
.lib-foot p { margin: 0; }
.lib-back {
  display: inline-block;
  margin-top: 8px;
  font-size: 12.5px;
  color: #6d7787;
  text-decoration: none;
}
.lib-back:hover { color: var(--accent); }

/* 分类管理 */
.cat-manage-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 60px;
  max-height: 46vh;
  -webkit-overflow-scrolling: touch;
}

.cat-manage-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--line-soft);
}
.cat-manage-item:last-child { border-bottom: 0; }

.cat-manage-name {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cat-manage-name i {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  flex: none;
}

.cat-manage-input {
  width: 100%;
  height: 32px;
  border: 1px solid #b9cef8;
  border-radius: 7px;
  padding: 0 8px;
  font-size: 14px;
  outline: none;
  box-shadow: 0 0 0 3px rgba(28, 100, 242, .09);
}

.cat-manage-empty {
  padding: 18px 2px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.cat-manage-add {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.cat-manage-add input {
  flex: 1;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 0 11px;
  font-size: 14.5px;
  outline: none;
}
.cat-manage-add input:focus { border-color: #b9cef8; box-shadow: 0 0 0 3px rgba(28, 100, 242, .09); }

/* ============================ 响应式 ============================ */

@media (min-width: 901px) {
  .only-mobile { display: none; }
  #btnPanelOpen { display: none; }
}

@media (max-width: 900px) {
  /* 顶栏：文字块按钮，宽度不足由 flex-wrap 自动转行 */
  .topbar {
    padding-left: 12px;
    padding-right: 12px;
  }
  .topbar-actions { gap: 8px; }
  .topnav { height: 34px; padding: 0 12px; font-size: 13px; }
  .topnav-primary { padding: 0 13px; }

  .workspace { grid-template-columns: minmax(0, 1fr); }

  /* 侧栏在移动端不再使用，交由台词本页 */
  .library {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(80vw, 300px);
    padding-top: env(safe-area-inset-top, 0);
    transform: translateX(-102%);
    transition: transform .26s cubic-bezier(.4, 0, .2, 1);
    box-shadow: var(--shadow-md);
  }
  .library.open { transform: translateX(0); }

  .canvas { padding: 8px 12px 0; }
  .title-input { font-size: 16px; }
  .canvas-head { padding-bottom: 6px; }
  .doc-bar { padding-bottom: 8px; gap: 8px; }
  .cat-pick { height: 30px; font-size: 12px; }
  .cat-pick select { max-width: 132px; }

  .content-input {
    padding: 14px;
    font-size: 15px;
    line-height: 1.85;
    border-radius: 10px;
    min-height: 52vh;
  }

  .canvas-foot { padding: 6px 0 6px; }
  .hint { display: none; }
  .canvas-foot .btn { height: 32px; font-size: 13px; }

  /* 参数面板 → 底部抽屉，不再占用编辑区高度 */
  .panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 46;
    display: flex;
    flex-direction: column;
    max-height: 84vh;
    border-radius: 16px 16px 0 0;
    border-top: 0;
    box-shadow: 0 -10px 36px rgba(16, 20, 24, .22);
    transform: translateY(104%);
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    padding-bottom: env(safe-area-inset-bottom, 0);
    visibility: hidden;
  }
  .panel.open { transform: translateY(0); visibility: visible; }

  .panel-head {
    position: relative;
    padding: 14px 16px 8px;
    border-bottom: 1px solid var(--line-soft);
  }
  .panel-head::before {
    content: "";
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 38px;
    height: 4px;
    border-radius: 2px;
    background: #e2e6ec;
  }
  .panel-toggle { display: none; }
  .panel-close { display: grid; }

  .panel .panel-body {
    display: block;
    flex: 1;
    max-height: none;
    padding: 12px 16px 16px;
    overflow-y: auto;
  }

  /* 控件区：两列，触摸目标加大 */
  .ctl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .ctl-grid-wide { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
  .ctl { padding: 11px 12px; border-radius: 11px; }
  .ctl-head { margin-bottom: 9px; }
  .ctl-label { font-size: 12.5px; }
  .ctl-value b { font-size: 15px; }
  .ctl-control { gap: 8px; }
  .step { width: 36px; height: 36px; border-radius: 11px; }
  .opt { height: 38px; font-size: 12.5px; }
  .swatch { width: 24px; height: 24px; }
  .swatches { gap: 7px; }

  .stage-hud { bottom: calc(18px + env(safe-area-inset-bottom, 0)); }
  .hud-scroll { gap: 8px; }
  .hud-play { width: 44px; height: 44px; }

  .view-main { padding: 14px 0 28px; }
  .view-title { font-size: 19px; }
  .view-content { padding: 16px; font-size: 14.5px; max-height: none; }

  /* 台词本模块 */
  .lib-wrap { max-width: 100%; }
  .lib-card { padding: 12px; gap: 10px; border-radius: 12px; }
  .lib-card-title { font-size: 15px; }
  .lib-card-actions { width: 56px; }
  .lib-card-actions .btn { height: 32px; padding: 0 6px; font-size: 12.5px; }
  .chips { padding: 2px 12px 10px; }
  .lib-search { margin: 10px 12px 8px; height: 44px; }
  .lib-cards { padding: 0 12px; gap: 9px; }
  .lib-result { margin: 0 12px 8px; }
  .lib-top { padding-left: 12px; padding-right: 12px; }
  .lib-top-actions { gap: 8px; }

  /* 批量操作条：贴底留边，操作按钮加大触控高度 */
  .batchbar {
    left: 10px;
    right: 10px;
    width: auto;
    transform: none;
    animation: none;
    padding: 10px;
    gap: 8px;
  }
  .batchbar-info { font-size: 12.5px; }
  .batchbar-btn { height: 34px; padding: 0 12px; font-size: 12.5px; }
  .lib-batch-entry { height: 28px; }
  .lib-cards.batch .lib-check { width: 22px; }

  .modal { align-items: flex-end; padding: 0; }
  .modal-card {
    max-width: 100%;
    border-radius: 18px 18px 0 0;
    padding: 20px 18px calc(18px + env(safe-area-inset-bottom, 0));
    animation: sheetIn .24s cubic-bezier(.4, 0, .2, 1);
  }
  @keyframes sheetIn {
    from { transform: translateY(100%); }
    to   { transform: none; }
  }
  .modal-tall { max-height: 88vh; }
}

/* 手机：品牌让位给按钮，按钮占满整行，放不下即换行 */
@media (max-width: 560px) {
  .brand { display: none; }
  .topbar-actions { flex: 1 1 100%; justify-content: flex-start; }
  .lib-top-sub { display: none; }
}

@media (max-width: 380px) {
  .ctl-grid { gap: 8px; }
  .ctl { padding: 10px; }
  .ctl-value b { font-size: 14px; }
  .step { width: 32px; height: 32px; font-size: 16px; }
  .ctl-control { gap: 6px; }
  .swatch { width: 22px; height: 22px; }
  .lib-card-actions { width: 52px; }
  .topnav { padding: 0 10px; font-size: 12.5px; }
}

/* 横屏且矮：压缩纵向占用，保证正文区不被控件挤没 */
@media (max-height: 460px) and (orientation: landscape) {
  .content-input { min-height: 40vh; }
  .canvas-head { padding-bottom: 4px; }
  .doc-bar { padding-bottom: 6px; }
  .panel { max-height: 92vh; }
  .lib-card { padding: 10px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}


/* ============================================================
   访问方式：公开 / 4 位数字口令
   ============================================================ */
.access-pick {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #f3f5f8;
  flex: none;
}

.access-btn {
  height: 26px;
  padding: 0 11px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--sub);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.access-btn:hover:not(:disabled) { color: var(--ink); }
.access-btn.is-on {
  background: #fff;
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 20, 24, .1);
}
.access-btn:disabled { opacity: .5; cursor: not-allowed; }

.code-pick { flex: none; display: inline-flex; }
.code-pick[hidden] { display: none; }
.code-input {
  width: 92px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .18em;
  text-align: center;
  outline: none;
}
.code-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(28, 100, 242, .12); }
.code-input:disabled { background: #f7f8fa; color: var(--muted); }

.tag-lock {
  background: #fff4e5;
  color: #a65a09;
  border: 1px solid #f6dfc0;
}

/* ============================================================
   口令门（v.php）
   ============================================================ */
.gate-card {
  width: 100%;
  max-width: 340px;
  padding: 26px 22px 20px;
  border-radius: 16px;
  background: #12161f;
  border: 1px solid rgba(255, 255, 255, .09);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .45);
  text-align: center;
}
.gate-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(28, 100, 242, .16);
  color: #7ea6ff;
}
.gate-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
  color: #f2f5fa;
  line-height: 1.35;
  word-break: break-word;
}
.gate-sub {
  margin: 0 0 18px;
  font-size: 12.5px;
  line-height: 1.6;
  color: #9aa4b2;
}
.gate-form { display: flex; flex-direction: column; gap: 10px; }
.gate-input {
  width: 100%;
  height: 52px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .05);
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: .5em;
  text-indent: .5em;
  text-align: center;
  outline: none;
}
.gate-input::placeholder { color: rgba(255, 255, 255, .22); letter-spacing: .3em; }
.gate-input:focus { border-color: #4b7df3; box-shadow: 0 0 0 3px rgba(75, 125, 243, .2); }
.gate-submit { height: 44px; font-size: 15px; border-radius: 10px; }
.gate-msg {
  min-height: 18px;
  margin: 10px 0 0;
  font-size: 12.5px;
  color: #ff8a8a;
}
.gate-msg.is-ok { color: #5fd39b; }
.view-foot-note {
  margin: 14px 0 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: #6d7787;
}

@media (max-width: 560px) {
  .doc-bar { gap: 8px; }
  .doc-hint { flex-basis: 100%; white-space: normal; }
}
