/* RedInk Studio R0.4 - Oriental Frosted Glaze Design System & 4-Scene Adaptive Skeleton
 * Baseline: Android 8.1 Chrome / WebView 61 + @supports Backdrop-Filter Glaze Layer
 * Themes: vermilion-arena | bamboo-academy | gilded-omamori | ink-editorial
 * Scene Modes (auto-detected): full | half | poster | thumb
 */

:root {
  --xhs-top-offset: 56px;
  --app-height: 100vh;

  /* Harmonious Paired Font Stacks: Songti/Serif Display + Kaiti Calligraphic Exemplar + Clean Sans UI */
  --font-display: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "Kaiti SC", "STKaiti", "SimSun", serif;
  --font-kaiti: "Kaiti SC", "STKaiti", "KaiTi", "DFKai-SB", "BiauKai", "Songti SC", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", sans-serif;

  /* Mobile Typography Scale (>=13px floor) */
  --fs-hero: 20px;
  --fs-title: 17px;
  --fs-subtitle: 15px;
  --fs-body: 14px;
  --fs-control: 14px;
  --fs-caption: 13px;

  /* Ergonomic Touch & Radius Tokens */
  --touch-min-h: 44px;
  --radius-card: 22px;
  --radius-panel: 16px;
  --radius-pill: 999px;
  --radius-chip: 12px;

  /* Theme 1 (Default): vermilion-arena (朱砂琉璃 · 暖宣云母 + 半透朱印) */
  --ui-bg: #faf4ec;
  --ui-aura-1: rgba(200, 30, 50, 0.08);
  --ui-aura-2: rgba(217, 119, 6, 0.07);
  --ui-surface: rgba(255, 253, 249, 0.88);
  --ui-surface-soft: rgba(247, 239, 229, 0.78);
  --ui-surface-elevated: #fffdf9;
  --ui-glass-fallback: rgba(255, 252, 247, 0.9);
  --ui-glass-bg: rgba(255, 252, 247, 0.66);
  --ui-glass-border: rgba(255, 255, 255, 0.76);
  --ui-glass-rim: rgba(200, 30, 50, 0.14);
  --ui-glass-shadow: 0 8px 28px rgba(42, 24, 18, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.88);

  --ui-text: #261b18;
  --ui-text-secondary: #5e5047;
  --ui-text-muted: #85756b;
  --ui-primary: #be1e30;
  --ui-primary-cta: #e0243c;
  --ui-primary-ink: #ffffff;
  --ui-primary-soft: rgba(200, 30, 50, 0.09);
  --ui-primary-halo: rgba(200, 30, 50, 0.18);
  --ui-border: rgba(140, 108, 88, 0.16);
  --ui-border-strong: rgba(140, 108, 88, 0.28);

  --ui-success-bg: rgba(22, 163, 74, 0.09);
  --ui-success-text: #15803d;
  --ui-success-border: rgba(22, 163, 74, 0.22);
  --ui-danger-bg: rgba(220, 38, 38, 0.09);
  --ui-danger-text: #b91c1c;
  --ui-danger-border: rgba(220, 38, 38, 0.22);
  --ui-warn-bg: rgba(217, 119, 6, 0.1);
  --ui-warn-text: #92400e;

  /* Oriental Translucent Glaze Seal Tokens */
  --ui-seal-glass-bg: rgba(200, 30, 50, 0.13);
  --ui-seal-rim: rgba(190, 30, 48, 0.42);
  --ui-seal-ink: rgba(176, 22, 40, 0.86);
  --ui-seal-glow: rgba(200, 30, 50, 0.14);

  --ui-stage-bg: #fffdf9;
  --ui-stage-grid: rgba(198, 92, 102, 0.46);
  --ui-stage-subgrid: rgba(198, 92, 102, 0.2);
  --ui-stage-outline: #ebe2d8;
  --ui-stage-ink: #241916;
  --ui-stage-radical: #be1e30;
  --ui-stage-highlight: #e0243c;
}

/* Theme 2: bamboo-academy (晴山青玉 · 温润青瓷琉璃 + 宋刻竹韵) */
[data-theme="bamboo-academy"] {
  --ui-bg: #f1f7f3;
  --ui-aura-1: rgba(21, 128, 61, 0.08);
  --ui-aura-2: rgba(14, 116, 144, 0.06);
  --ui-surface: rgba(252, 255, 253, 0.88);
  --ui-surface-soft: rgba(234, 245, 238, 0.78);
  --ui-surface-elevated: #fcfffd;
  --ui-glass-fallback: rgba(250, 255, 252, 0.9);
  --ui-glass-bg: rgba(250, 255, 252, 0.66);
  --ui-glass-border: rgba(255, 255, 255, 0.8);
  --ui-glass-rim: rgba(21, 128, 61, 0.15);
  --ui-glass-shadow: 0 8px 28px rgba(20, 64, 38, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.9);

  --ui-text: #18271f;
  --ui-text-secondary: #465b4e;
  --ui-text-muted: #6b8073;
  --ui-primary: #167940;
  --ui-primary-cta: #15803d;
  --ui-primary-ink: #ffffff;
  --ui-primary-soft: rgba(22, 121, 64, 0.1);
  --ui-primary-halo: rgba(22, 121, 64, 0.18);
  --ui-border: rgba(68, 112, 84, 0.15);
  --ui-border-strong: rgba(68, 112, 84, 0.28);

  --ui-seal-glass-bg: rgba(22, 121, 64, 0.13);
  --ui-seal-rim: rgba(22, 121, 64, 0.42);
  --ui-seal-ink: rgba(18, 105, 54, 0.88);
  --ui-seal-glow: rgba(22, 121, 64, 0.14);

  --ui-stage-bg: #fcfffd;
  --ui-stage-grid: rgba(72, 152, 103, 0.45);
  --ui-stage-subgrid: rgba(72, 152, 103, 0.2);
  --ui-stage-outline: #ddebe1;
  --ui-stage-ink: #1a2a21;
  --ui-stage-radical: #167940;
  --ui-stage-highlight: #d97706;
}

/* Theme 3: gilded-omamori (洒金琥珀 · 绛纱琉璃 + 泥金透印) */
[data-theme="gilded-omamori"] {
  --ui-bg: #3e0a11;
  --ui-aura-1: rgba(234, 179, 8, 0.12);
  --ui-aura-2: rgba(225, 29, 72, 0.16);
  --ui-surface: rgba(98, 18, 28, 0.82);
  --ui-surface-soft: rgba(78, 13, 22, 0.76);
  --ui-surface-elevated: #691420;
  --ui-glass-fallback: rgba(96, 17, 27, 0.88);
  --ui-glass-bg: rgba(96, 17, 27, 0.58);
  --ui-glass-border: rgba(253, 230, 138, 0.28);
  --ui-glass-rim: rgba(250, 204, 21, 0.22);
  --ui-glass-shadow: 0 10px 30px rgba(15, 2, 5, 0.36), inset 0 1px 0 rgba(254, 240, 138, 0.22);

  --ui-text: #fef3c7;
  --ui-text-secondary: #f6dc99;
  --ui-text-muted: #cfa968;
  --ui-primary: #eab308;
  --ui-primary-cta: #facc15;
  --ui-primary-ink: #420a0d;
  --ui-primary-soft: rgba(250, 204, 21, 0.14);
  --ui-primary-halo: rgba(250, 204, 21, 0.24);
  --ui-border: rgba(245, 211, 138, 0.24);
  --ui-border-strong: rgba(250, 204, 21, 0.46);

  --ui-success-bg: rgba(34, 197, 94, 0.16);
  --ui-success-text: #bbf7d0;
  --ui-success-border: rgba(134, 239, 172, 0.34);
  --ui-danger-bg: rgba(248, 113, 113, 0.18);
  --ui-danger-text: #fecaca;
  --ui-danger-border: rgba(252, 165, 165, 0.38);

  --ui-seal-glass-bg: rgba(250, 204, 21, 0.15);
  --ui-seal-rim: rgba(253, 224, 71, 0.52);
  --ui-seal-ink: rgba(254, 240, 138, 0.92);
  --ui-seal-glow: rgba(250, 204, 21, 0.2);

  --ui-stage-bg: #841723;
  --ui-stage-grid: rgba(245, 211, 138, 0.45);
  --ui-stage-subgrid: rgba(245, 211, 138, 0.2);
  --ui-stage-outline: rgba(255, 235, 195, 0.2);
  --ui-stage-ink: #f8dc8c;
  --ui-stage-radical: #fde047;
  --ui-stage-highlight: #fff3b0;
}

/* Theme 4: ink-editorial (松烟冰珀 · 水墨雾玻璃 + 朱砂微印) */
[data-theme="ink-editorial"] {
  --ui-bg: #f4f4f2;
  --ui-aura-1: rgba(24, 24, 27, 0.05);
  --ui-aura-2: rgba(220, 38, 38, 0.05);
  --ui-surface: rgba(255, 255, 255, 0.86);
  --ui-surface-soft: rgba(238, 238, 235, 0.76);
  --ui-surface-elevated: #ffffff;
  --ui-glass-fallback: rgba(255, 255, 255, 0.9);
  --ui-glass-bg: rgba(255, 255, 255, 0.66);
  --ui-glass-border: rgba(255, 255, 255, 0.85);
  --ui-glass-rim: rgba(24, 24, 27, 0.1);
  --ui-glass-shadow: 0 8px 28px rgba(24, 24, 27, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.92);

  --ui-text: #18181b;
  --ui-text-secondary: #46464d;
  --ui-text-muted: #767680;
  --ui-primary: #27272a;
  --ui-primary-cta: #c81e32;
  --ui-primary-ink: #ffffff;
  --ui-primary-soft: rgba(24, 24, 27, 0.07);
  --ui-primary-halo: rgba(200, 30, 50, 0.16);
  --ui-border: rgba(39, 39, 42, 0.1);
  --ui-border-strong: rgba(39, 39, 42, 0.2);

  --ui-seal-glass-bg: rgba(200, 30, 50, 0.12);
  --ui-seal-rim: rgba(200, 30, 50, 0.4);
  --ui-seal-ink: rgba(185, 24, 42, 0.86);
  --ui-seal-glow: rgba(200, 30, 50, 0.12);

  --ui-stage-bg: #fcfcfb;
  --ui-stage-grid: rgba(82, 82, 91, 0.36);
  --ui-stage-subgrid: rgba(82, 82, 91, 0.16);
  --ui-stage-outline: #e5e5e8;
  --ui-stage-ink: #18181b;
  --ui-stage-radical: #c81e32;
  --ui-stage-highlight: #c81e32;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

/* Hide ugly desktop native scrollbars in Note/Card preview while preserving touch scroll */
html {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  scrollbar-width: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--ui-bg);
  background-image:
    radial-gradient(circle at 16% 12%, var(--ui-aura-1) 0%, transparent 52%),
    radial-gradient(circle at 86% 78%, var(--ui-aura-2) 0%, transparent 56%);
  color: var(--ui-text);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.48;
  -webkit-touch-callout: none;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

/* Adaptive Page Container across 4 Host Scenes */
.ui-page {
  width: 100%;
  max-width: 460px;
  min-height: 100vh;
  min-height: var(--app-height, 100vh);
  margin: 0 auto;
  padding-top: calc(var(--xhs-top-offset, 56px) + 4px);
  padding-right: 14px;
  padding-left: 14px;
  padding-bottom: 12px;
  padding-bottom: calc(12px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
  display: flex;
  flex-direction: column;
}

.ui-page.is-stage-locked {
  height: 100vh;
  height: var(--app-height, 100vh);
  overflow: hidden;
}

/* Scene-Specific Top Offset & Padding Refinements */
[data-scene-mode="pad"] .ui-page {
  max-width: 560px;
  padding-top: calc(var(--xhs-top-offset, 56px) + 12px);
  padding-right: 22px;
  padding-left: 22px;
  padding-bottom: 20px;
}

[data-scene-mode="pad"] .ui-sheet {
  max-width: 560px;
}

[data-scene-mode="half"] .ui-page {
  padding-top: 44px;
  padding-bottom: 10px;
}

[data-scene-mode="poster"] .ui-page {
  padding-top: 16px;
  padding-bottom: 52px; /* Reserves clean space for XHS host "点击使用小工具" pill */
}

[data-scene-mode="thumb"] .ui-page {
  padding-top: 12px;
  padding-right: 10px;
  padding-left: 10px;
  padding-bottom: 12px;
}

/* Oriental Frosted Glaze Surface & Header Plaque */
.ui-glass-bar {
  background: var(--ui-glass-fallback);
  border: 1px solid var(--ui-glass-border);
  box-shadow: var(--ui-glass-shadow);
  border-radius: 18px;
  padding: 8px 12px;
  position: relative;
}

.ui-glass-panel {
  background: var(--ui-surface);
  border: 1px solid var(--ui-glass-border);
  box-shadow: var(--ui-glass-shadow);
  border-radius: var(--radius-card);
}

@supports ((-webkit-backdrop-filter: blur(16px)) or (backdrop-filter: blur(16px))) {
  .ui-glass-bar,
  .ui-glass-panel {
    background: var(--ui-glass-bg);
    -webkit-backdrop-filter: blur(16px) saturate(1.28);
    backdrop-filter: blur(16px) saturate(1.28);
  }
}

/* Poised Songti/Serif Brand Title + Translucent Emblem */
.ui-brand-row {
  display: flex;
  align-items: center;
  min-width: 0;
}

.ui-brand-emblem {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--ui-primary-soft);
  border: 1px solid var(--ui-glass-rim);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
  color: var(--ui-primary);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  flex-shrink: 0;
}

.ui-serif-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-hero);
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.25;
  color: var(--ui-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Oriental Glaze Header Sound / Mute Pill (Auto-mounted across all matrix headers) */
.ui-sound-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--ui-glass-rim);
  background: var(--ui-primary-soft);
  color: var(--ui-primary);
  font-size: var(--fs-caption);
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.14s ease, opacity 0.18s ease, background-color 0.18s ease;
}

.ui-sound-pill:active {
  transform: scale(0.95);
}

.ui-sound-pill.is-muted {
  background: var(--ui-surface-soft);
  border-color: var(--ui-border);
  color: var(--ui-text-muted);
  opacity: 0.82;
}

/* Jade-Bead Stroke Progress Dots (Replaces flat harsh circles) */
.ui-jade-dots {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  min-width: 0;
}

.ui-jade-dot {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--ui-surface-soft);
  border: 1px solid var(--ui-border-strong);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.6);
  color: var(--ui-text-muted);
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 5px;
  transition: transform 0.22s ease, background-color 0.22s ease, box-shadow 0.22s ease;
}

.ui-jade-dot.is-current {
  border-color: var(--ui-primary);
  color: var(--ui-primary);
  background: var(--ui-primary-soft);
  box-shadow: 0 0 0 3px var(--ui-primary-halo), inset 0 1px 1px rgba(255, 255, 255, 0.7);
  transform: scale(1.08);
}

.ui-jade-dot.is-done {
  background: var(--ui-primary);
  border-color: var(--ui-primary);
  color: var(--ui-primary-ink);
  opacity: 0.84;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.5);
}

/* Oriental Translucent Jade/Cinnabar Glaze Seal (通关琉璃半透玉印) */
@keyframes uiGlazeSealCondense {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-12deg) scale(1.32);
  }
  65% {
    opacity: 0.94;
    transform: translate(-50%, -50%) rotate(-6deg) scale(0.97);
  }
  100% {
    opacity: 0.9;
    transform: translate(-50%, -50%) rotate(-7deg) scale(1);
  }
}

.ui-glaze-seal {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 88px;
  height: 88px;
  padding: 6px;
  border-radius: 18px;
  background: var(--ui-seal-glass-bg);
  border: 1.5px solid var(--ui-seal-rim);
  box-shadow:
    0 12px 28px var(--ui-seal-glow),
    inset 0 1px 2px rgba(255, 255, 255, 0.68),
    inset 0 -1px 2px rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 30;
  transform: translate(-50%, -50%) rotate(-7deg);
  animation: uiGlazeSealCondense 0.52s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@supports ((-webkit-backdrop-filter: blur(10px)) or (backdrop-filter: blur(10px))) {
  .ui-glaze-seal {
    -webkit-backdrop-filter: blur(10px) saturate(1.35);
    backdrop-filter: blur(10px) saturate(1.35);
  }
}

.ui-glaze-seal-inner {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  align-items: center;
  justify-items: center;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--ui-seal-ink);
  line-height: 1;
}

/* Standard Touch-Safe Frosted Buttons (>=44px in full, >=38px in compact half) */
.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-min-h);
  padding: 9px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-size: var(--fs-control);
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.14s ease, opacity 0.14s ease, background-color 0.18s ease;
}

[data-scene-mode="half"] .ui-btn {
  min-height: 38px;
  padding: 7px 12px;
  font-size: var(--fs-caption);
}

.ui-btn:active {
  transform: scale(0.96);
  opacity: 0.88;
}

.ui-btn:focus {
  outline: 2px solid var(--ui-primary);
  outline-offset: 2px;
}

.ui-btn-primary {
  background: var(--ui-primary-cta);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 6px 18px var(--ui-seal-glow);
}

[data-theme="gilded-omamori"] .ui-btn-primary {
  color: var(--ui-primary-ink);
}

.ui-btn-tonal {
  background: var(--ui-primary-soft);
  color: var(--ui-primary);
  border-color: var(--ui-glass-rim);
}

.ui-btn-secondary {
  background: var(--ui-glass-fallback);
  color: var(--ui-text);
  border-color: var(--ui-border);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.ui-btn-ghost {
  background: transparent;
  color: var(--ui-text-secondary);
  border-color: var(--ui-border);
}

.ui-btn.is-locked {
  background: var(--ui-surface-soft);
  color: var(--ui-text-muted);
  border-color: var(--ui-border);
  box-shadow: none;
  opacity: 0.78;
}

.ui-btn.is-hint-ready {
  background: var(--ui-primary-soft);
  color: var(--ui-primary);
  border-color: var(--ui-glass-rim);
  box-shadow: 0 2px 10px var(--ui-seal-glow);
}

/* Chrome 61 Flex Row & Stack Baseline */
.ui-row {
  display: flex;
  align-items: center;
}

.ui-row > * + * {
  margin-left: 8px;
}

.supports-flex-gap .ui-row {
  column-gap: 8px;
}

.supports-flex-gap .ui-row > * + * {
  margin-left: 0;
}

.ui-stack {
  display: flex;
  flex-direction: column;
}

.ui-stack > * + * {
  margin-top: 10px;
}

.supports-flex-gap .ui-stack {
  row-gap: 10px;
}

.supports-flex-gap .ui-stack > * + * {
  margin-top: 0;
}

/* 关注条：一句理由 + 一个按钮，放在成果下面。显示与否由各工具按关注状态决定（默认加 hidden） */
.ui-follow-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding: 5px 5px 5px 14px;
  border-radius: var(--radius-pill);
  background: var(--ui-surface-soft);
  border: 1px solid var(--ui-border);
}

.ui-follow-bar-text {
  min-width: 0;
  font-size: var(--fs-caption);
  color: var(--ui-text-secondary);
}

.ui-follow-bar .ui-follow-bar-btn {
  flex: 0 0 auto;
  min-height: 32px;
  margin-left: 10px;
  padding: 4px 18px;
  font-size: var(--fs-caption);
}

/* Surface Card (Borderless Glassy Xuan Feel) */
.ui-card {
  background: var(--ui-surface);
  border: 1px solid var(--ui-glass-border);
  border-radius: var(--radius-card);
  padding: 14px;
  box-shadow: var(--ui-glass-shadow);
}

/* Frosted Segmented Mode Bar */
.ui-segmented {
  display: flex;
  align-items: center;
  background: var(--ui-surface-soft);
  border: 1px solid var(--ui-glass-border);
  border-radius: var(--radius-pill);
  padding: 3px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

.ui-segmented-btn {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  padding: 5px 10px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ui-text-secondary);
  font-size: var(--fs-caption);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.ui-segmented-btn.is-active {
  background: var(--ui-surface-elevated);
  color: var(--ui-primary);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
}

[data-theme="gilded-omamori"] .ui-segmented-btn.is-active {
  background: var(--ui-primary);
  color: var(--ui-primary-ink);
}

/* Slide-Up Frosted Bottom Sheet */
.ui-sheet-backdrop {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 9950;
  background: rgba(18, 14, 12, 0.46);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.ui-sheet-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.ui-sheet {
  width: 100%;
  max-width: 460px;
  max-height: 78vh;
  background: var(--ui-surface-elevated);
  color: var(--ui-text);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  border-top: 1px solid var(--ui-glass-border);
  display: flex;
  flex-direction: column;
  transform: translateY(102%);
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.16);
}

.ui-sheet-backdrop.is-open .ui-sheet {
  transform: translateY(0);
}

.ui-sheet-grabber {
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: var(--ui-border-strong);
  margin: 10px auto 4px;
  flex-shrink: 0;
}

.ui-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 18px 12px;
  border-bottom: 1px solid var(--ui-border);
  flex-shrink: 0;
}

.ui-sheet-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-title);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.ui-sheet-close {
  min-width: 44px;
  min-height: 36px;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--ui-border);
  background: var(--ui-surface-soft);
  color: var(--ui-text-secondary);
  font-size: var(--fs-caption);
  font-weight: 600;
  cursor: pointer;
}

.ui-sheet-body {
  position: relative;
  padding: 14px 18px;
  padding-bottom: calc(20px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  min-height: 0;
  flex: 1;
}

.ui-sheet.has-more-below::after {
  content: "↓ 下滑查看更多";
  display: block;
  text-align: center;
  padding: 6px 0 10px;
  font-size: var(--fs-caption);
  font-weight: 600;
  color: var(--ui-primary);
  background: var(--ui-surface-elevated);
  border-top: 1px dashed var(--ui-border);
  flex-shrink: 0;
}

/* Scroll Hint Frosted Floating Pill */
.ui-scroll-cue {
  position: fixed;
  right: 16px;
  bottom: 18px;
  bottom: calc(18px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
  z-index: 9900;
  padding: 8px 15px;
  border-radius: var(--radius-pill);
  background: var(--ui-glass-fallback);
  border: 1px solid var(--ui-glass-rim);
  color: var(--ui-primary);
  font-size: var(--fs-caption);
  font-weight: 600;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
  cursor: pointer;
}

@supports ((-webkit-backdrop-filter: blur(12px)) or (backdrop-filter: blur(12px))) {
  .ui-scroll-cue {
    background: var(--ui-glass-bg);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }
}

/* Gentle Spring Entrance & Mistake Damped Shake */
@keyframes uiCardEnter {
  0% {
    opacity: 0;
    transform: translateY(6px) scale(0.985);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.is-entering {
  animation: uiCardEnter 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes uiShakeHorizontal {
  0%, 100% { transform: translateX(0); }
  22% { transform: translateX(-5px); }
  48% { transform: translateX(5px); }
  74% { transform: translateX(-3px); }
}

.is-shaking {
  animation: uiShakeHorizontal 0.3s ease;
}

@media (prefers-reduced-motion: reduce) {
  .is-entering,
  .is-shaking,
  .ui-glaze-seal {
    animation: none !important;
  }
}
