:root {
  /* Affirm × Tolan-soft: own palette, airy glass UI */
  --bg: #FFF7FB;
  --bg-deep: #F3E8F2;
  --surface: rgba(255, 255, 255, 0.55);
  --ink: #1C1524;
  --ink-soft: #3A3144;
  --muted: #6B6174;
  --line: rgba(28, 21, 36, 0.08);
  --accent: #FF4FB8;
  --accent-deep: #E6369E;
  --accent-soft: rgba(255, 208, 235, 0.72);
  --accent-soft-hover: #FFB8E0;
  --accent-glow: rgba(255, 79, 184, 0.18);
  --lime: #D4FF3A;
  --violet: #C9B6FF;
  --violet-soft: #E4DCFF;
  --sky: #7AA7FF;
  --mist: #FFF7FB;
  --grad-main: linear-gradient(160deg, #FFF7FB 0%, #FFE8F6 42%, #EDE4FF 100%);
  --grad-hero: radial-gradient(70% 80% at 50% 0%, rgba(201, 182, 255, 0.45) 0%, transparent 70%);
  --grad-soft: linear-gradient(180deg, #FFF7FB 0%, #FFFFFF 100%);
  --blue: #7AA7FF;
  --success: #0acf83;
  --cta: #1C1524;
  --pink-shell: #FFE8F4;
  --pink-deep: #FFC2E3;
  --pink-shadow: rgba(28, 21, 36, 0.12);
  --pink-border: rgba(255, 255, 255, 0.55);
  --pink-highlight: #FFF7FB;
  --shell: var(--pink-shell);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --touch: 44px;
  --icon-nav: 22px;
  --chat-sheet-peek: 20px;
  --rail-bottom: max(14px, var(--safe-bottom));
  --rail-height: 72px;
  --rail-side: 14px;
  --rail-reserve: calc(var(--rail-bottom) + var(--rail-height) + 10px);
  --rail-ink: rgba(255, 255, 255, 0.92);
  --rail-ink-muted: rgba(255, 255, 255, 0.78);
  --rail-pill-bg: rgba(16, 20, 44, 0.48);
  --rail-pill-border: rgba(255, 255, 255, 0.16);
  --rail-pill-shadow: 0 12px 32px rgba(6, 10, 28, 0.22);
  --shell-deep: var(--pink-deep);
  --shell-shadow: rgba(28, 21, 36, 0.1);
  --screen-edge: transparent;
  --navy: #FFF7FB;
  --sea: #FF4FB8;
  --sea-deep: #E6369E;
  --ice: #FFFFFF;
  --ice-blue: #C9B6FF;
  --hud: rgba(255, 255, 255, 0.42);
  --hud-border: rgba(255, 255, 255, 0.55);
  --yellow: #D4FF3A;
  --orange: #FF4FB8;
  --mint: #FF4FB8;
  --mint-deep: #E6369E;
  --card-radius: 28px;
  --card-radius-sm: 20px;
  --soft-shadow: 0 20px 48px rgba(8, 12, 40, 0.18);
  --soft-shadow-sm: 0 10px 28px rgba(8, 12, 40, 0.1);
  --glass: rgba(255, 255, 255, 0.1);
  --glass-strong: rgba(255, 255, 255, 0.16);
  --glass-border: rgba(255, 255, 255, 0.18);
  --glass-blur: blur(28px) saturate(1.2);
  --float-btn: rgba(255, 255, 255, 0.12);
  --brutal-shadow: var(--soft-shadow);
  --brutal-shadow-lg: var(--soft-shadow);
  --pixel: "Figtree", "Noto Sans SC", system-ui, sans-serif;
  --display: "Unbounded", "Figtree", "Noto Sans SC", system-ui, sans-serif;
  --cute: "Figtree", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --home-bg-color: #1A2348;
  --chat-bg-color: #CFE8F8;
  --sky-deep: #0E1530;
  --sky-mid: #1A2348;
  --sky-soft: #2E3A72;
  --sky-glow: rgba(140, 160, 230, 0.28);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  height: 100%;
}

body {
  font-family: var(--cute);
  color: var(--ink);
  background: #1A2348;
  display: block;
  padding: 0;
  margin: 0;
  image-rendering: auto;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

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

/* Keep taps visually clean in Android WebView/mobile browsers. */
button,
a,
summary,
label,
[role="button"],
[role="tab"],
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button:focus,
a:focus,
summary:focus,
[role="button"]:focus,
[role="tab"]:focus,
input[type="checkbox"]:focus,
input[type="radio"]:focus {
  outline: none;
}

kbd {
  font-family: var(--cute);
  font-size: 11px;
  font-weight: 600;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  box-shadow: 0 1px 0 rgba(17, 26, 37, 0.04);
}

/* —— Full-bleed app screen —— */
.screen {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  background: linear-gradient(180deg, #0E1530 0%, #1A2348 42%, #2A3568 100%);
  border: none;
  border-radius: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  isolation: isolate;
  color: var(--ink);
  box-shadow: none;
}

.screen.drawer-open {
  grid-template-columns: 1fr;
}

/* —— Scene background: celestial indigo sky —— */
.scene-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: linear-gradient(180deg, #0E1530 0%, #1A2348 42%, #2A3568 100%);
  pointer-events: none;
}

.bg-photo {
  position: absolute;
  inset: 0;
  image-rendering: auto;
  background-color: var(--home-bg-color, #1A2348);
}

/* Soft fill so letterboxing doesn't look empty */
.bg-photo::before {
  content: "";
  position: absolute;
  inset: -12%;
  background-color: var(--home-bg-color, #1A2348);
  background-image: var(--home-bg-image, none);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  filter: blur(28px) saturate(1.05) brightness(0.82);
  opacity: 0.7;
  transform: scale(1.05);
}

.bg-photo.bg-mode-color::before,
.bg-photo.bg-mode-gradient::before {
  display: none;
}

/* Keep natural aspect — fill screen without horizontal stretch */
.bg-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background-color: transparent;
  background-image: var(--home-bg-image, none);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

.bg-photo.bg-mode-color::after,
.bg-photo.bg-mode-gradient::after {
  display: none;
}

.bg-aurora {
  display: none;
  position: absolute;
  inset: -8%;
  overflow: hidden;
  background:
    radial-gradient(ellipse 75% 50% at 50% 40%, rgba(120, 145, 220, 0.28) 0%, transparent 62%),
    radial-gradient(ellipse 50% 36% at 80% 18%, rgba(90, 110, 190, 0.2) 0%, transparent 58%),
    radial-gradient(ellipse 48% 34% at 16% 78%, rgba(60, 50, 140, 0.26) 0%, transparent 55%),
    linear-gradient(180deg, #0E1530 0%, #1A2348 45%, #2E3A72 100%);
  animation: aurora-base-breathe 18s ease-in-out infinite alternate;
  will-change: transform;
}

.bg-photo.bg-mode-gradient .bg-aurora {
  display: block;
}

.bg-stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.bg-stars-a {
  background-image:
    radial-gradient(1.2px 1.2px at 8% 12%, rgba(255, 255, 255, 0.95), transparent),
    radial-gradient(1px 1px at 18% 28%, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1.4px 1.4px at 27% 8%, rgba(255, 255, 255, 0.85), transparent),
    radial-gradient(1px 1px at 36% 22%, rgba(255, 255, 255, 0.55), transparent),
    radial-gradient(1.6px 1.6px at 48% 14%, rgba(255, 255, 255, 0.9), transparent),
    radial-gradient(1px 1px at 62% 9%, rgba(255, 255, 255, 0.65), transparent),
    radial-gradient(1.3px 1.3px at 74% 18%, rgba(255, 255, 255, 0.8), transparent),
    radial-gradient(1px 1px at 86% 11%, rgba(255, 255, 255, 0.6), transparent),
    radial-gradient(1.5px 1.5px at 92% 26%, rgba(255, 255, 255, 0.88), transparent),
    radial-gradient(1px 1px at 12% 48%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1.2px 1.2px at 22% 62%, rgba(255, 255, 255, 0.75), transparent),
    radial-gradient(1px 1px at 33% 54%, rgba(255, 255, 255, 0.45), transparent),
    radial-gradient(1.4px 1.4px at 55% 58%, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1px 1px at 68% 46%, rgba(255, 255, 255, 0.55), transparent),
    radial-gradient(1.3px 1.3px at 81% 52%, rgba(255, 255, 255, 0.8), transparent),
    radial-gradient(1px 1px at 94% 44%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1.5px 1.5px at 6% 76%, rgba(255, 255, 255, 0.65), transparent),
    radial-gradient(1px 1px at 19% 88%, rgba(255, 255, 255, 0.55), transparent),
    radial-gradient(1.2px 1.2px at 42% 82%, rgba(255, 255, 255, 0.72), transparent),
    radial-gradient(1px 1px at 58% 90%, rgba(255, 255, 255, 0.48), transparent),
    radial-gradient(1.4px 1.4px at 72% 78%, rgba(255, 255, 255, 0.78), transparent),
    radial-gradient(1px 1px at 88% 86%, rgba(255, 255, 255, 0.6), transparent);
  animation: star-twinkle-a 6s ease-in-out infinite alternate;
}

.bg-stars-b {
  opacity: 0.85;
  background-image:
    radial-gradient(1px 1px at 14% 18%, rgba(255, 255, 255, 0.55), transparent),
    radial-gradient(1.8px 1.8px at 41% 6%, rgba(255, 255, 255, 0.95), transparent),
    radial-gradient(1px 1px at 53% 31%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1.3px 1.3px at 69% 24%, rgba(255, 255, 255, 0.75), transparent),
    radial-gradient(1px 1px at 83% 38%, rgba(255, 255, 255, 0.45), transparent),
    radial-gradient(1.6px 1.6px at 4% 42%, rgba(255, 255, 255, 0.8), transparent),
    radial-gradient(1px 1px at 29% 39%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1.2px 1.2px at 46% 48%, rgba(255, 255, 255, 0.65), transparent),
    radial-gradient(1px 1px at 77% 61%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1.5px 1.5px at 96% 58%, rgba(255, 255, 255, 0.85), transparent),
    radial-gradient(1px 1px at 11% 68%, rgba(255, 255, 255, 0.42), transparent),
    radial-gradient(1.3px 1.3px at 35% 72%, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1px 1px at 51% 76%, rgba(255, 255, 255, 0.48), transparent),
    radial-gradient(1.4px 1.4px at 64% 68%, rgba(255, 255, 255, 0.72), transparent),
    radial-gradient(1px 1px at 90% 72%, rgba(255, 255, 255, 0.55), transparent),
    radial-gradient(1.2px 1.2px at 26% 92%, rgba(255, 255, 255, 0.6), transparent),
    radial-gradient(1px 1px at 79% 94%, rgba(255, 255, 255, 0.45), transparent);
  animation: star-twinkle-b 8s ease-in-out infinite alternate;
}

.aurora-glow {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(28px);
}

.aurora-glow-core {
  width: 46%;
  height: 32%;
  left: 27%;
  top: 32%;
  background: radial-gradient(circle, rgba(170, 190, 255, 0.28) 0%, rgba(110, 130, 210, 0.12) 45%, transparent 72%);
  animation: aurora-glow-breathe 14s ease-in-out infinite alternate;
}

.aurora-glow-soft {
  width: 72%;
  height: 50%;
  left: 14%;
  top: 26%;
  background: radial-gradient(circle, rgba(110, 130, 210, 0.18) 0%, transparent 70%);
  filter: blur(56px);
  animation: aurora-glow-breathe 16s ease-in-out infinite alternate-reverse;
}

.aurora-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(56px);
  opacity: 0.55;
  will-change: transform, opacity;
  mix-blend-mode: screen;
}

.aurora-blob.aurora-a {
  width: 48%;
  height: 38%;
  left: -8%;
  top: 8%;
  background: radial-gradient(circle, rgba(150, 165, 255, 0.7) 0%, transparent 70%);
  animation: aurora-drift-a 11s ease-in-out infinite;
}

.aurora-blob.aurora-b {
  width: 46%;
  height: 36%;
  right: -10%;
  top: 22%;
  background: radial-gradient(circle, rgba(180, 170, 255, 0.55) 0%, transparent 72%);
  opacity: 0.45;
  animation: aurora-drift-b 13s ease-in-out infinite;
}

.aurora-blob.aurora-c {
  width: 58%;
  height: 42%;
  left: 22%;
  bottom: -18%;
  background: radial-gradient(circle, rgba(120, 130, 230, 0.65) 0%, transparent 72%);
  opacity: 0.5;
  animation: aurora-drift-c 12s ease-in-out infinite;
}

@keyframes aurora-base-breathe {
  0% {
    transform: scale(1) translate(0, 0);
  }
  100% {
    transform: scale(1.04) translate(-1.2%, 0.8%);
  }
}

@keyframes aurora-glow-breathe {
  0% {
    opacity: 0.75;
    transform: scale(1);
  }
  100% {
    opacity: 1;
    transform: scale(1.08);
  }
}

@keyframes star-twinkle-a {
  0% {
    opacity: 0.72;
  }
  100% {
    opacity: 1;
  }
}

@keyframes star-twinkle-b {
  0% {
    opacity: 0.55;
  }
  100% {
    opacity: 0.95;
  }
}

@keyframes aurora-drift-a {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
    opacity: 0.45;
  }
  50% {
    transform: translate(10%, 8%) scale(1.12);
    opacity: 0.65;
  }
}

@keyframes aurora-drift-b {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
    opacity: 0.4;
  }
  50% {
    transform: translate(-12%, 6%) scale(1.1);
    opacity: 0.6;
  }
}

@keyframes aurora-drift-c {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
    opacity: 0.42;
  }
  50% {
    transform: translate(-6%, -10%) scale(1.14);
    opacity: 0.62;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bg-aurora,
  .aurora-blob,
  .aurora-glow,
  .bg-stars {
    animation: none !important;
  }
}

.scene-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 62% at 50% 38%, rgba(150, 170, 230, 0.1) 0%, transparent 60%),
    radial-gradient(ellipse 100% 70% at 50% 110%, rgba(6, 10, 28, 0.35) 0%, transparent 55%),
    linear-gradient(180deg, rgba(6, 10, 28, 0.22) 0%, transparent 30%, transparent 72%, rgba(8, 12, 36, 0.18) 100%);
  pointer-events: none;
}

/* Legacy bottom-dock styles removed — V2 dock lives in v2.css (.dock-v2) */

/* —— Drawers (calendar / stats / resources / faq) — normal full pages —— */
.calendar-drawer,
.stats-drawer,
.resources-drawer,
.faq-drawer,
.favorites-drawer {
  position: absolute;
  inset: 0;
  z-index: 15;
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: auto;
  max-width: none;
  height: auto;
  max-height: none;
  border-radius: 0;
  overflow: hidden;
  box-sizing: border-box;
  padding-bottom: var(--rail-reserve);
  background: #f4f5f8;
  color: #1c1524;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transform: none;
  opacity: 1;
  pointer-events: auto;
}

.calendar-drawer[hidden],
.stats-drawer[hidden],
.resources-drawer[hidden],
.faq-drawer[hidden],
.favorites-drawer[hidden] {
  display: none !important;
}

.screen.drawer-open .calendar-drawer:not([hidden]),
.screen.drawer-open .stats-drawer:not([hidden]),
.screen.drawer-open .resources-drawer:not([hidden]),
.screen.drawer-open .faq-drawer:not([hidden]),
.screen.drawer-open .favorites-drawer:not([hidden]) {
  display: flex;
  animation: drawer-fade 0.22s ease;
}

@keyframes drawer-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.stats-body {
  padding: 12px;
  gap: 14px;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.stats-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 22px;
  background: #fff;
  border: 1px solid rgba(28, 21, 36, 0.06);
  box-shadow: 0 10px 28px rgba(28, 21, 36, 0.06);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.stats-heading {
  margin: 0 0 2px;
  font-family: var(--cute);
  font-size: 14px;
  font-weight: 500;
  color: #6b6174;
}

.stats-today-block {
  align-items: flex-start;
  gap: 4px;
}

.stats-today-value {
  font-family: var(--pixel);
  font-size: 36px;
  line-height: 1.1;
  color: #1c1524;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.stats-chart-block {
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.stats-range-tabs {
  margin: 0;
}

.stats-chart {
  position: relative;
  height: 200px;
  padding: 10px 4px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.stats-chart.is-line {
  display: block;
}

.stats-line-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  touch-action: none;
  cursor: crosshair;
}

.stats-line-plot {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0 2px;
}

.stats-line-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.stats-line-area {
  fill: url(#stats-line-fill);
}

.stats-line-path {
  fill: none;
  stroke: #e93abb;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.stats-line-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #e93abb;
  box-shadow: 0 1px 4px rgba(233, 58, 187, 0.25);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.12s, transform 0.12s;
  pointer-events: none;
  z-index: 2;
}

.stats-line-dot.is-active,
.stats-line-dot.is-today {
  opacity: 1;
  transform: scale(1);
}

.stats-line-dot.is-today:not(.is-active) {
  opacity: 0.85;
}

.stats-line-cursor {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(26, 26, 26, 0.18);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 1;
}

.stats-line-cursor.is-on {
  opacity: 1;
}

.stats-line-xlabels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 14px;
  padding: 0 2px;
}

.stats-line-xlabel {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 11px;
  line-height: 1;
  color: #8b8b8b;
  font-family: var(--cute);
  white-space: nowrap;
}

.stats-line-xlabel.is-today {
  color: #1a1a1a;
  font-weight: 700;
}

.stats-chart.is-month .stats-line-xlabel {
  font-size: 9px;
}

.stats-tip {
  position: absolute;
  z-index: 5;
  min-width: 132px;
  max-width: 200px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #1a1a1a;
  color: #fff;
  box-shadow: 0 10px 28px rgba(26, 26, 26, 0.22);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, calc(-100% - 10px)) scale(0.96);
  transition: opacity 0.12s, transform 0.12s;
  font-family: var(--cute);
}

.stats-tip.is-on {
  opacity: 1;
  transform: translate(-50%, calc(-100% - 10px)) scale(1);
}

.stats-tip-date {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #fff;
}

.stats-tip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.78);
}

.stats-tip-row strong {
  color: #ff9fd4;
  font-family: var(--pixel);
  font-size: 10px;
  font-weight: 600;
}

.stats-tip-row strong.is-yes {
  color: #7dffb3;
}

.stats-tip-row strong.is-no {
  color: rgba(255, 255, 255, 0.45);
}

.stats-chart-foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 4px;
  font-size: 14px;
  color: #1a1a1a;
  font-family: var(--cute);
}

.stats-chart-foot strong {
  font-family: var(--pixel);
  font-size: 12px;
  color: #e93abb;
  font-weight: 600;
}

.resources-body {
  padding: 12px;
  gap: 12px;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.res-view[hidden] {
  display: none !important;
}

.res-lead {
  margin: 0 0 4px;
  font-size: 13px;
  line-height: 1.45;
  color: #8b8b8b;
  font-family: var(--cute);
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.faq-item {
  border-radius: var(--card-radius-sm);
  background: #fff;
  border: 1.5px solid var(--pink-border);
  box-shadow: 0 6px 18px rgba(245, 184, 206, 0.1);
  overflow: hidden;
}

.faq-item summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  font-family: var(--cute);
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.4;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-top: 6px;
  border-radius: 50%;
  background: #e93abb;
  flex-shrink: 0;
}

.faq-item summary::after {
  content: "+";
  margin-left: auto;
  color: #8b8b8b;
  font-weight: 500;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}

.faq-item[open] summary::after {
  content: "–";
}

.faq-item p {
  margin: 0;
  padding: 0 14px 14px 30px;
  font-size: 13px;
  line-height: 1.55;
  color: #4a3a44;
  font-family: var(--cute);
}

.resource-add {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 14px;
  padding: 12px;
  border-radius: 20px;
  background: #fff;
  border: 1px dashed rgba(28, 21, 36, 0.12);
}

.resource-add-url,
.resource-add-title {
  width: 100%;
  border: 1px solid rgba(28, 21, 36, 0.1);
  border-radius: 14px;
  background: #fff;
  color: #1c1524;
  font-family: var(--cute);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
}

.resource-add-url:focus,
.resource-add-title:focus {
  border-color: rgba(255, 79, 184, 0.45);
}

.resource-add-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.resource-add-title {
  flex: 1;
  min-width: 0;
}

.resource-add-btn {
  flex-shrink: 0;
  border: 1px solid #1c1524;
  border-radius: 14px;
  background: #1c1524;
  color: #fff;
  font-family: var(--cute);
  font-size: 14px;
  font-weight: 600;
  padding: 0 16px;
  cursor: pointer;
  white-space: nowrap;
}

.resource-add-btn:active {
  transform: scale(0.98);
}

.resource-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.resource-card-wrap {
  position: relative;
}

.resource-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 22px;
  background: #fff;
  border: 1px solid rgba(28, 21, 36, 0.06);
  box-shadow: 0 10px 28px rgba(28, 21, 36, 0.06);
  text-decoration: none;
  color: #1c1524;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s, background 0.15s;
}

.resource-card-wrap.is-custom .resource-card {
  padding-right: 40px;
}

.resource-card:hover {
  transform: translateY(-1px);
  border-color: rgba(28, 21, 36, 0.1);
  background: #fff;
  box-shadow: 0 14px 32px rgba(28, 21, 36, 0.1);
}

.resource-card:active {
  transform: translateY(0);
}

.resource-card-remove {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: #f3f4f7;
  color: #6b6174;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.resource-card-remove:hover {
  background: #eceef3;
  color: #1c1524;
}

.resource-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.resource-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f3f4f7;
  color: #5c5566;
  font-size: 11px;
  font-family: var(--cute);
  font-weight: 600;
}

.resource-card-title {
  margin: 0;
  font-family: var(--cute);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  color: #1c1524;
}

.resource-card-meta {
  font-size: 12px;
  color: #8a8294;
  font-family: var(--cute);
}

.resource-card-cta {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #c2187a;
  font-family: var(--cute);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) max(16px, var(--safe-right)) 12px max(16px, var(--safe-left));
  border-bottom: 1px solid rgba(28, 21, 36, 0.06);
  font-family: var(--cute);
  font-size: 17px;
  font-weight: 600;
  color: #1c1524;
  background: #f4f5f8;
}

.icon-close {
  width: var(--touch);
  height: var(--touch);
  border: 1px solid rgba(28, 21, 36, 0.08);
  border-radius: 50%;
  background: #eceef3;
  color: #1c1524;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.icon-close:hover {
  background: #e2e5ec;
  border-color: rgba(28, 21, 36, 0.12);
  color: #1c1524;
}

/* —— HUD boxes —— */
.hud-box {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--soft-shadow);
  border-radius: var(--card-radius);
  color: rgba(245, 248, 255, 0.94);
}

.calendar-drawer.hud-box,
.stats-drawer.hud-box,
.resources-drawer.hud-box,
.faq-drawer.hud-box,
.favorites-drawer.hud-box {
  background: #f4f5f8;
  border: none;
  box-shadow: none;
  border-radius: 0;
  color: #1c1524;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* —— Side panel pieces (used by calendar drawer) —— */
.panel-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 10px 12px 0;
  padding: 4px;
  border-bottom: none;
  border-radius: 999px;
  background: #eceef3;
  border: 1px solid rgba(28, 21, 36, 0.06);
}

.tab {
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 9px 4px;
  color: #6b6174;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.2s ease, color 0.2s ease;
}

.tab.active {
  background: #1c1524;
  border-color: transparent;
  color: #fff;
  box-shadow: none;
}

.tab:hover {
  background: rgba(28, 21, 36, 0.08);
  color: #1c1524;
}

.tab.active:hover {
  background: #1c1524;
  color: #fff;
}

.panel-body {
  flex: 1;
  overflow: auto;
  padding: 10px 10px 12px;
  min-height: 0;
  scrollbar-width: none;
}

.panel-body::-webkit-scrollbar {
  display: none;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(28, 21, 36, 0.06);
}

.cal-title {
  font-family: var(--cute);
  font-size: 14px;
  font-weight: 600;
  color: #1c1524;
  letter-spacing: 0.02em;
}

.nav-btn {
  background: #f3f4f7;
  color: #1c1524;
  border: 1px solid rgba(28, 21, 36, 0.06);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: none;
  font-size: 11px;
  display: grid;
  place-items: center;
  padding: 0;
}

.nav-btn:hover {
  background: #eceef3;
}

.nav-btn:active {
  transform: scale(0.96);
  box-shadow: none;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin-bottom: 6px;
  text-align: center;
  font-size: 11px;
  color: #8a8294;
  font-family: var(--cute);
}

.cal-weekdays span:first-child,
.cal-weekdays span:last-child {
  color: #c2187a;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.cal-cell {
  aspect-ratio: 1;
  border: 1px solid rgba(28, 21, 36, 0.06);
  background: #fff;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  position: relative;
  color: #1c1524;
  transition: transform 0.12s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.cal-cell:not(.empty):hover {
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 6px 16px rgba(28, 21, 36, 0.1);
  background: #f8f9fb;
}

.cal-cell.empty {
  background: transparent;
  border-color: transparent;
  pointer-events: none;
}

/* Soft glass heat levels */
.cal-cell.heat-0 {
  background: #fff;
  border-color: rgba(28, 21, 36, 0.06);
}

.cal-cell.heat-1 {
  background: rgba(255, 180, 220, 0.22);
  border-color: rgba(255, 150, 210, 0.2);
}

.cal-cell.heat-2 {
  background: rgba(255, 150, 210, 0.35);
  border-color: rgba(255, 120, 190, 0.28);
}

.cal-cell.heat-3 {
  background: rgba(255, 120, 190, 0.5);
  border-color: rgba(255, 100, 180, 0.35);
}

.cal-cell.heat-4 {
  background: rgba(255, 90, 180, 0.68);
  border-color: rgba(255, 80, 170, 0.4);
}

.cal-cell.today {
  box-shadow: inset 0 0 0 1.5px rgba(28, 21, 36, 0.35);
  border-color: rgba(28, 21, 36, 0.28);
}

.cal-cell.today.heat-3,
.cal-cell.today.heat-4 {
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.7);
}

.cal-cell .day-num {
  font-family: var(--cute);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  color: #1c1524;
  pointer-events: none;
}

.cal-cell.heat-2 .day-num {
  color: #1c1524;
}

.cal-cell.heat-3 .day-num,
.cal-cell.heat-4 .day-num {
  color: #fff;
  text-shadow: none;
}

.cal-cell.today .day-num {
  font-weight: 700;
}

.cal-cell .day-count,
.cal-cell .pingu-face {
  display: none !important;
}

.cal-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 12px;
  font-size: 11px;
  color: #8b8b8b;
  font-family: var(--cute);
}

.cal-legend .heat-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  border: 1px solid transparent;
}

.cal-legend .heat-swatch.heat-0 {
  background: #f3eef1;
  border-color: rgba(26, 26, 26, 0.06);
}

.cal-legend .heat-swatch.heat-1 {
  background: #ffd6ec;
}

.cal-legend .heat-swatch.heat-2 {
  background: #ff9fd4;
}

.cal-legend .heat-swatch.heat-3 {
  background: #e93abb;
}

.cal-legend .heat-swatch.heat-4 {
  background: #9b0b66;
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.history-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  border: 1px solid rgba(28, 21, 36, 0.06);
  border-radius: 12px;
  padding: 9px 11px;
  font-size: 14px;
  color: #1c1524;
  transition: background 0.15s, border-color 0.15s;
}

.history-list li:hover {
  background: #fff5fa;
  border-color: rgba(233, 58, 187, 0.28);
}

.history-list li .date {
  opacity: 0.9;
  color: #1c1524;
}

.history-list li .count {
  font-family: var(--pixel);
  font-size: 8px;
  color: #c2187a;
  background: rgba(233, 58, 187, 0.1);
  border: 1px solid rgba(233, 58, 187, 0.28);
  border-radius: 999px;
  padding: 4px 7px;
}

.history-list .empty-msg {
  text-align: center;
  opacity: 0.7;
  font-size: 14px;
  padding: 28px 8px;
  border: 1px dashed rgba(28, 21, 36, 0.12);
  background: #fff;
  border-radius: 12px;
  color: #6b6174;
}

.panel-footer {
  border-top: 1px solid rgba(28, 21, 36, 0.06);
  padding: 10px;
  background: #fff;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-chip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #f4f5f8;
  border: 1px solid rgba(28, 21, 36, 0.06);
}

.stat-chip-label {
  font-size: 12px;
  color: #6b6174;
  opacity: 1;
}

.stat-chip-value {
  font-family: var(--pixel);
  font-size: 11px;
  color: #e93abb;
  font-weight: 600;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  margin-bottom: 2px;
  padding: 4px 0;
  color: #1a1a1a;
}

.stat-row strong {
  font-family: var(--pixel);
  font-size: 10px;
  color: #e93abb;
  font-weight: 600;
}

.power-bars {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.power-bars .bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.power-bars .bar i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--mint);
  box-shadow: none;
  flex-shrink: 0;
}

.power-bars .bar span {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
}

.power-bars .bar span::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--w);
  background: linear-gradient(90deg, #4fb3ff, var(--mint));
}

.power-bars .bar:nth-child(2) span::after {
  background: linear-gradient(90deg, #bf73eb, #4e65ff);
}

.power-bars .bar:nth-child(3) span::after {
  background: linear-gradient(90deg, #ff7d33, var(--mint));
}

/* —— Stage —— */
.stage {
  grid-column: 1;
  grid-row: 1;
  z-index: 4;
  position: relative;
  min-width: 0;
  padding:
    max(12px, var(--safe-top))
    max(14px, var(--safe-right))
    var(--rail-reserve)
    max(14px, var(--safe-left));
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: visible;
}

.screen.drawer-open .stage {
  grid-column: 1;
}

.hud-top {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 12px;
  z-index: 3;
  position: relative;
  flex-shrink: 0;
  margin-bottom: 4px;
}

.title-block {
  text-shadow: 3px 3px 0 #c44520;
}

.game-title {
  font-family: var(--cute);
  font-size: clamp(16px, 3vw, 24px);
  color: var(--yellow);
  letter-spacing: 2px;
  line-height: 1.2;
}

.game-sub {
  font-family: var(--cute);
  font-size: 9px;
  color: var(--orange);
  margin-top: 6px;
  letter-spacing: 2px;
}

.score-box {
  padding: 8px 12px;
  text-align: right;
  min-width: 140px;
}

.count-label {
  font-size: 13px;
  color: #b8e8ff;
  margin-bottom: 4px;
}

.count-num {
  font-family: var(--cute);
  font-size: clamp(24px, 5vw, 36px);
  color: #fff;
  line-height: 1;
  text-shadow: 0 6px 18px rgba(20, 16, 24, 0.18);
}

.count-num.pop {
  animation: count-pop 0.28s steps(3);
}

@keyframes count-pop {
  40% {
    transform: scale(1.2);
  }
}

.hint {
  margin-top: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.9);
}

.hint-mobile {
  display: none;
}

/* —— Daily ritual (soft frosted glass card) —— */
.ritual-bar {
  position: relative;
  z-index: 5;
  margin: 64px 12px 14px;
  padding: 12px;
  flex-shrink: 0;
  color: #fff;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.09);
  box-shadow:
    0 18px 44px rgba(6, 10, 28, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(30px) saturate(1.15);
  -webkit-backdrop-filter: blur(30px) saturate(1.15);
  overflow: visible;
}

.ritual-bar::before {
  display: none;
}

.ritual-title-row {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
  padding-right: 36px;
}

.ritual-kicker-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.ritual-kicker {
  font-family: var(--cute);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(210, 220, 255, 0.62);
}

.ritual-kicker::after {
  content: "";
  display: block;
  width: 22px;
  height: 1px;
  margin-top: 6px;
  background: rgba(255, 255, 255, 0.22);
}

.ritual-title {
  font-family: var(--display);
  font-size: clamp(22px, 5.4vw, 30px);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.96);
  letter-spacing: -0.03em;
  line-height: 1.1;
  text-shadow: none;
}

.ritual-done-mark {
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  flex-shrink: 0;
}

.ritual-collapse-btn {
  position: absolute;
  top: -48px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 16;
  width: 52px;
  height: 52px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 24px rgba(6, 10, 28, 0.16);
  color: rgba(255, 255, 255, 0.92);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  backdrop-filter: blur(22px) saturate(1.15);
  -webkit-backdrop-filter: blur(22px) saturate(1.15);
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.ritual-collapse-btn::before {
  content: "";
  position: absolute;
  inset: -14px -28px;
  border-radius: 999px;
}

.ritual-collapse-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  box-shadow: 0 12px 28px rgba(6, 10, 28, 0.2);
}

.ritual-collapse-btn:active {
  transform: translateX(-50%) scale(0.94);
}

.ritual-collapse-btn i {
  font-size: 18px;
  line-height: 1;
  color: inherit;
  pointer-events: none;
}

.ritual-expand-btn {
  position: absolute;
  top: max(12px, var(--safe-top));
  left: auto;
  right: max(12px, var(--safe-right));
  transform: none;
  z-index: 15;
  width: auto;
  min-width: 0;
  height: auto;
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  color: inherit;
  display: none;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.ritual-expand-btn::before {
  content: "";
  position: absolute;
  inset: -12px -10px;
  border-radius: 999px;
}

.ritual-expand-logo {
  display: block;
  height: 30px;
  width: auto;
  max-width: min(156px, 46vw);
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 10px 22px rgba(48, 255, 100, 0.28)) drop-shadow(0 6px 16px rgba(6, 10, 28, 0.35));
  transition: transform 0.22s ease, filter 0.22s ease;
}

.ritual-expand-btn:hover .ritual-expand-logo {
  transform: translateY(-1px) scale(1.03);
  filter: drop-shadow(0 12px 26px rgba(48, 255, 100, 0.38)) drop-shadow(0 8px 18px rgba(6, 10, 28, 0.32));
}

.ritual-expand-btn:active .ritual-expand-logo {
  transform: scale(0.97);
}

.ritual-expand-btn[hidden] {
  display: none !important;
}

.stage.ritual-collapsed .ritual-bar {
  display: none;
}

.stage.ritual-collapsed .ritual-expand-btn {
  display: inline-flex;
}

.stage.ritual-on .ritual-expand-btn,
.stage.ritual-on .ritual-collapse-btn {
  display: none !important;
}

.stage.ritual-collapsed .pingu-stage {
  margin-top: 0;
}

.stage.ritual-collapsed .bubble-anchor {
  top: 72px;
  bottom: max(160px, min(240px, calc(34vh + 20px)));
}

.stage.ritual-collapsed .pingu-wrap {
  width: min(420px, 72vw);
  max-height: min(420px, 54vh);
}

.stage.ritual-collapsed .pingu-sprite {
  max-height: min(420px, 54vh);
  filter: drop-shadow(0 22px 36px rgba(28, 21, 36, 0.18));
}

.ritual-tabs {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 12px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.ritual-tab {
  border: none;
  background: transparent;
  color: rgba(210, 220, 255, 0.7);
  font-family: var(--cute);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.ritual-tab:hover {
  color: #fff;
}

.ritual-tab.is-active {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  box-shadow: none;
}

.ritual-tab.is-done:not(.is-active)::after {
  content: " ✓";
  opacity: 0.85;
}

.ritual-tab.is-active.is-done::after {
  content: " ✓";
}

.ritual-panels {
  min-height: 88px;
}

.ritual-panel {
  position: relative;
  display: none;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
  padding: 14px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.ritual-panel.is-active {
  display: flex;
}

.ritual-panel-copy {
  margin: 0;
  font-family: var(--cute);
  font-size: 14px;
  line-height: 1.55;
  color: rgba(220, 228, 255, 0.86);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 4.6em;
  overflow: hidden;
}

.ritual-btn {
  align-self: stretch;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border-radius: 999px;
  font-family: var(--cute);
  font-size: 15px;
  font-weight: 600;
  padding: 13px 16px;
  cursor: pointer;
  box-shadow: none;
  transition: transform 0.15s ease, background 0.2s ease, opacity 0.15s ease;
  white-space: nowrap;
  text-align: center;
}

.ritual-btn:hover {
  filter: none;
  background: rgba(255, 255, 255, 0.24);
}

.ritual-btn:active {
  transform: scale(0.98);
  opacity: 0.92;
}

.ritual-btn-ghost {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.88);
}

.stage.ritual-on .ritual-bar {
  display: none;
}

.stage.ritual-on .bubble-motion {
  display: none !important;
}

.ritual-session {
  pointer-events: auto;
  position: relative;
  width: min(700px, 100%);
  height: auto;
  max-height: 100%;
  margin: 0 0 36px;
  display: flex;
  flex-direction: column;
  text-align: center;
  animation: ritual-fade-in 0.22s ease-out;
  z-index: 12;
  transform: translateY(-18px);
  overflow: auto;
}

.ritual-session[hidden] {
  display: none !important;
}

.ritual-session-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  border-radius: var(--card-radius);
  background: #fff;
  border: 1.5px solid var(--pink-border);
  box-shadow: 0 12px 40px rgba(245, 184, 206, 0.22);
  overflow: hidden;
  color: #1a1a1a;
}

.ritual-session.kind-visual .ritual-session-panel {
  border-color: #f5b8d4;
}

.ritual-session.kind-visual .ritual-ring-progress {
  stroke: #c41e96;
}

.ritual-session.kind-visual .ritual-session-mode {
  background: #ffe4f2;
  color: #c41e96;
}

.ritual-session-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.ritual-session-mode {
  font-family: var(--cute);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: var(--accent-soft);
  border: none;
  border-radius: 999px;
  padding: 5px 12px;
  box-shadow: none;
}

.ritual-session-kicker {
  color: #8b8b8b;
  font-size: 13px;
  font-family: var(--cute);
  margin: 0;
}

.ritual-timer-ring {
  position: relative;
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.ritual-ring-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ritual-ring-track {
  fill: none;
  stroke: #ffe4f2;
  stroke-width: 8;
}

.ritual-ring-progress {
  fill: none;
  stroke: #e93abb;
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.9s linear;
  filter: drop-shadow(0 2px 6px rgba(233, 58, 187, 0.28));
}

.ritual-session-timer {
  position: relative;
  z-index: 1;
  font-family: "Press Start 2P", var(--pixel), monospace;
  font-size: 14px;
  color: #1a1a1a;
  margin: 0;
  text-shadow: none;
  letter-spacing: 0.02em;
}

.ritual-session-body-card {
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 14px;
  border-radius: var(--card-radius-sm);
  background: #f7f7f7;
  border: none;
  box-shadow: none;
  text-align: left;
  scrollbar-width: thin;
}

.ritual-session-body {
  font-family: var(--cute);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  color: #3d3d3d;
  margin: 0;
}

.ritual-session-actions {
  display: flex;
  gap: 8px;
  width: 100%;
  flex-shrink: 0;
}

.ritual-session-actions .ritual-btn {
  flex: 1;
  width: auto;
  padding: 12px 10px;
  font-size: 14px;
}

.ritual-session-actions .ritual-btn:not(.ritual-btn-ghost) {
  background: #1a1a1a;
  color: #fff;
}

.ritual-session-actions .ritual-btn:not(.ritual-btn-ghost):hover {
  background: #333;
  filter: none;
}

.ritual-toast {
  position: absolute;
  left: 50%;
  bottom: 18%;
  transform: translateX(-50%);
  z-index: 20;
  padding: 10px 16px;
  border-radius: 14px;
  background: #fff;
  border: 1.5px solid var(--pink-border);
  color: #1a1a1a;
  font-family: var(--cute);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 12px 28px rgba(245, 184, 206, 0.28);
  pointer-events: none;
  animation: ritual-toast-in 0.2s ease-out;
}

.ritual-toast[hidden] {
  display: none !important;
}

@keyframes ritual-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes ritual-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.bubble-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  margin: 0 0 10px;
  padding: 0 2px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.bubble-switch {
  position: static;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.9);
  display: grid;
  place-items: center;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.bubble-switch.is-robotic {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
}

@media (hover: hover) {
  .bubble-switch:hover {
    transform: none;
    background: rgba(255, 255, 255, 0.2);
  }

  .bubble-switch:not(.is-robotic):hover {
    background: rgba(255, 255, 255, 0.18);
  }

  .bubble-switch.is-robotic:hover {
    background: rgba(255, 255, 255, 0.28);
    border-color: rgba(255, 255, 255, 0.32);
    color: #fff;
  }
}

.bubble-mode-label {
  position: static;
  margin: 0;
  font-size: 12px;
  color: rgba(210, 220, 255, 0.62);
  font-family: var(--cute);
  pointer-events: none;
  line-height: 1;
}

/* —— Speech bubble + Pingu —— */
.pingu-stage {
  position: absolute;
  inset: 0;
  z-index: 8;
  overflow: visible;
  pointer-events: none;
}

.pingu-stage .pingu-wrap {
  overflow: visible;
  pointer-events: auto;
}

.bubble-anchor {
  position: absolute;
  top: 8px;
  left: 10px;
  right: 10px;
  /* Expanded task card: sit a bit lower, only lightly tuck behind character */
  bottom: max(118px, min(168px, calc(20vh + 30px)));
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding: 0;
  z-index: 7;
  pointer-events: none;
  perspective: 900px;
}

.bubble-motion {
  width: min(700px, 100%);
  max-height: 100%;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  animation: bubble-float 3.6s ease-in-out infinite;
  transform: translateZ(0);
  will-change: transform;
}

.bubble-motion.is-paused {
  animation-play-state: paused;
}

.speech-bubble {
  pointer-events: auto;
  position: relative;
  width: 100%;
  height: auto;
  max-height: 100%;
  margin: 0;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 28px;
  box-shadow:
    0 18px 44px rgba(6, 10, 28, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(28px) saturate(1.15);
  -webkit-backdrop-filter: blur(28px) saturate(1.15);
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 79, 184, 0.4) transparent;
  -ms-overflow-style: auto;
  transform-origin: center center;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  color: var(--ink);
  transform: translateZ(0);
}

.speech-bubble.is-flipping {
  pointer-events: none;
  will-change: transform, opacity;
}

@keyframes bubble-float {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, -6px, 0);
  }
}

.speech-bubble::-webkit-scrollbar {
  width: 4px;
}

.speech-bubble::-webkit-scrollbar-thumb {
  background: rgba(233, 58, 187, 0.35);
  border-radius: 999px;
}

.speech-bubble::-webkit-scrollbar-track {
  background: transparent;
}

.speech-bubble::before,
.speech-bubble::after {
  display: none !important;
  content: none !important;
}

.speech-text {
  flex: 0 0 auto;
  overflow: visible;
  font-family: var(--cute);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.7;
  letter-spacing: -0.01em;
  color: rgba(245, 248, 255, 0.94);
  word-break: break-word;
  -webkit-font-smoothing: antialiased;
  text-rendering: auto;
  padding-right: 0;
  white-space: normal;
}

.speech-text:empty::before {
  content: "肯定语会出现在这里…";
  color: rgba(210, 220, 255, 0.45);
  font-family: var(--cute);
}

.wobble-line {
  display: block;
  margin: 0.2em 0;
  transform-origin: left center;
}

.wobble-line:nth-child(odd) {
  transform: rotate(-1.2deg) translateX(2px);
}

.wobble-line:nth-child(even) {
  transform: rotate(1.4deg) translateX(-3px);
}

.wobble-line:nth-child(3n) {
  transform: rotate(-0.8deg) translateX(5px);
}

.wobble-line:nth-child(4n) {
  transform: rotate(1.8deg) translateX(-1px);
}

.pingu-wrap {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  width: min(280px, 46vw);
  max-height: min(200px, 28vh);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  cursor: pointer;
  z-index: 10;
  overflow: visible;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.pingu-sprite {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(220px, 32vh);
  object-fit: contain;
  object-position: bottom center;
  image-rendering: auto;
  transform-origin: 50% 100%;
  position: relative;
  z-index: 2;
  user-select: none;
  filter: drop-shadow(0 12px 24px rgba(6, 10, 28, 0.28));
}

.pingu-sprite.jump {
  animation: pingu-pop 0.55s cubic-bezier(0.18, 1.35, 0.35, 1);
}

@keyframes pingu-pop {
  0% {
    transform: translateY(110%) scale(0.55);
    opacity: 0.15;
  }
  40% {
    transform: translateY(-52px) scale(1.14);
    opacity: 1;
  }
  62% {
    transform: translateY(6px) scale(0.95);
  }
  80% {
    transform: translateY(-18px) scale(1.05);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

.jump-fx {
  position: absolute;
  left: 50%;
  top: 4%;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transform: translateX(-50%);
}

.jump-fx.show {
  opacity: 1;
}

.jump-plus {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  font-family: "Press Start 2P", var(--pixel), monospace;
  font-size: 14px;
  line-height: 1;
  color: #ff7ad1;
  text-shadow:
    2px 0 0 #1a1a1a,
    -2px 0 0 #1a1a1a,
    0 2px 0 #1a1a1a,
    0 -2px 0 #1a1a1a,
    2px 2px 0 #1a1a1a;
  white-space: nowrap;
  image-rendering: pixelated;
}

.jump-fx.show .jump-plus {
  animation: jump-plus-float 0.85s ease-out forwards;
}

.jump-heart {
  position: absolute;
  color: #e93abb;
  filter: drop-shadow(1px 1px 0 #1a1a1a);
  image-rendering: pixelated;
  overflow: visible;
}

.jump-heart.heart-l {
  left: -28px;
  top: 8px;
}

.jump-heart.heart-r {
  left: 18px;
  top: 2px;
}

.jump-fx.show .jump-heart.heart-l {
  animation: jump-heart-float-l 0.9s ease-out forwards;
}

.jump-fx.show .jump-heart.heart-r {
  animation: jump-heart-float-r 0.95s ease-out 0.05s forwards;
}

@keyframes jump-plus-float {
  0% {
    opacity: 0;
    transform: translate(-50%, 10px) scale(0.7);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1.08);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -48px) scale(1);
  }
}

@keyframes jump-heart-float-l {
  0% {
    opacity: 0;
    transform: translate(0, 8px) scale(0.5);
  }
  20% {
    opacity: 1;
    transform: translate(-4px, 0) scale(1.1);
  }
  100% {
    opacity: 0;
    transform: translate(-18px, -42px) scale(0.9) rotate(-12deg);
  }
}

@keyframes jump-heart-float-r {
  0% {
    opacity: 0;
    transform: translate(0, 10px) scale(0.45);
  }
  22% {
    opacity: 1;
    transform: translate(4px, 0) scale(1.05);
  }
  100% {
    opacity: 0;
    transform: translate(16px, -46px) scale(0.85) rotate(14deg);
  }
}

/* —— Full pages (affirm history / edit / appearance) —— */
.app-page {
  position: absolute;
  inset: 0;
  z-index: 16;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--rail-reserve);
  background: #f4f5f8;
  color: #1c1524;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.app-page[hidden] {
  display: none !important;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(var(--safe-top) + 12px) max(16px, var(--safe-right)) 12px max(16px, var(--safe-left));
  border-bottom: 1px solid rgba(28, 21, 36, 0.06);
  flex-shrink: 0;
  background: #f4f5f8;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.page-header h1 {
  flex: 1;
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  color: #1c1524;
  letter-spacing: -0.02em;
}

.page-back,
.page-action {
  border: 1px solid rgba(28, 21, 36, 0.08);
  background: #eceef3;
  color: #1c1524;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--cute);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 14px;
  min-width: var(--touch);
  min-height: var(--touch);
  display: inline-grid;
  place-items: center;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.page-action {
  background: #1c1524;
  border-color: #1c1524;
  color: #fff;
}

.page-spacer {
  width: 40px;
}

.page-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px;
  scrollbar-width: none;
}

.page-body::-webkit-scrollbar {
  display: none;
}

.current-card {
  background: #fff;
  border: 1px solid rgba(28, 21, 36, 0.06);
  border-radius: 24px;
  padding: 16px 18px;
  margin-bottom: 18px;
  box-shadow: 0 10px 28px rgba(28, 21, 36, 0.06);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.card-label {
  font-size: 13px;
  font-weight: 600;
  color: #6b6174;
  margin-bottom: 8px;
}

.current-text {
  font-family: var(--cute);
  font-size: 16px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  color: #1c1524;
}

.history-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.history-title {
  font-size: 15px;
  font-weight: 600;
  color: #3a3144;
  margin: 0;
}

.history-tag-bar {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin: 0 -4px 14px;
  padding: 2px 4px 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.history-tag-bar::-webkit-scrollbar {
  display: none;
}

.history-tag-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1.5px dashed transparent;
  background: transparent;
  border-radius: 999px;
  padding: 7px 13px;
  font-family: var(--cute);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.12s;
}

.history-tag-chip i {
  font-size: 12px;
  line-height: 1;
  opacity: 0.9;
}

.history-tag-chip.tone-all {
  color: #5b7cff;
  border-color: rgba(91, 124, 255, 0.55);
  background: rgba(91, 124, 255, 0.1);
}

.history-tag-chip.tone-lime {
  color: #5f8f1a;
  border-color: rgba(95, 143, 26, 0.5);
  background: rgba(190, 230, 120, 0.28);
}

.history-tag-chip.tone-pink {
  color: #e04aa0;
  border-color: rgba(224, 74, 160, 0.5);
  background: rgba(255, 150, 210, 0.18);
}

.history-tag-chip.tone-ink {
  color: #8a7040;
  border-color: rgba(180, 150, 80, 0.55);
  background: rgba(245, 220, 150, 0.28);
}

.history-tag-chip.tone-violet {
  color: #7a5fd4;
  border-color: rgba(122, 95, 212, 0.5);
  background: rgba(200, 180, 255, 0.22);
}

.history-tag-chip.tone-custom {
  color: #7a6a40;
  border-color: rgba(180, 150, 80, 0.5);
  background: rgba(245, 220, 150, 0.22);
}

.history-tag-chip.tone-add,
.history-tag-chip.is-add {
  color: #c24a90;
  border-color: rgba(255, 79, 184, 0.45);
  background: rgba(255, 79, 184, 0.08);
}

.history-tag-chip.is-active {
  border-style: dashed;
  opacity: 1;
}

.history-tag-chip.tone-all.is-active {
  background: rgba(91, 124, 255, 0.2);
  border-color: rgba(91, 124, 255, 0.85);
}

.history-tag-chip.tone-lime.is-active {
  background: rgba(190, 230, 120, 0.48);
  border-color: rgba(95, 143, 26, 0.8);
}

.history-tag-chip.tone-pink.is-active {
  background: rgba(255, 150, 210, 0.32);
  border-color: rgba(224, 74, 160, 0.8);
}

.history-tag-chip.tone-ink.is-active {
  background: rgba(245, 220, 150, 0.48);
  border-color: rgba(180, 150, 80, 0.85);
  color: #8a7040;
}

.history-tag-chip.tone-violet.is-active {
  background: rgba(200, 180, 255, 0.4);
  border-color: rgba(122, 95, 212, 0.8);
}

.history-tag-chip.tone-custom.is-active {
  background: rgba(245, 220, 150, 0.42);
  border-color: rgba(180, 150, 80, 0.85);
}

.history-tag-chip:active {
  opacity: 0.85;
}

.history-tag-add {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
  align-items: center;
}

.history-tag-add[hidden] {
  display: none !important;
}

.history-tag-input {
  flex: 1 1 140px;
  min-width: 0;
  border: 1px solid rgba(20, 16, 24, 0.1);
  border-radius: 12px;
  padding: 8px 12px;
  font-family: var(--cute);
  font-size: 14px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
}

.history-tag-add-btn,
.history-tag-add-cancel {
  border: none;
  border-radius: 999px;
  padding: 8px 12px;
  font-family: var(--cute);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.history-tag-add-btn {
  background: var(--accent);
  color: #fff;
}

.history-tag-add-cancel {
  background: rgba(20, 16, 24, 0.06);
  color: var(--muted);
}

.history-item-tags {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin-top: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.history-item-tags::-webkit-scrollbar {
  display: none;
}

.history-item-tag.history-tag-chip {
  padding: 5px 10px;
  font-size: 11px;
  opacity: 0.5;
}

.history-item-tag.history-tag-chip i {
  font-size: 10px;
}

.history-item-tag.history-tag-chip.is-on,
.history-item-tag.history-tag-chip.is-active {
  opacity: 1;
  border-style: dashed;
}

.affirm-history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.affirm-history-list li {
  background: #fff;
  border: 1px solid rgba(28, 21, 36, 0.06);
  border-radius: 20px;
  padding: 14px 16px;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(28, 21, 36, 0.06);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.affirm-history-list li:hover {
  border-color: rgba(28, 21, 36, 0.1);
  background: #fff;
  box-shadow: 0 12px 28px rgba(28, 21, 36, 0.1);
}

.affirm-history-list .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: #8a8294;
  margin-bottom: 6px;
}

.affirm-history-list .meta-time {
  min-width: 0;
}

.history-delete {
  flex-shrink: 0;
  border: 1px solid rgba(180, 40, 90, 0.35);
  background: rgba(255, 90, 120, 0.14);
  color: #9a1848;
  border-radius: 999px;
  font-family: var(--cute);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 5px 10px;
  cursor: pointer;
}

.history-delete:hover {
  background: rgba(233, 58, 187, 0.16);
  color: #7a1038;
  border-color: rgba(154, 24, 72, 0.5);
}

.history-delete:active {
  transform: scale(0.96);
}

.affirm-history-list .snippet {
  font-family: var(--cute);
  font-size: 15px;
  line-height: 1.55;
  color: #1c1524;
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.affirm-history-list .empty-msg {
  text-align: center;
  opacity: 0.65;
  padding: 28px 10px;
  border: none;
  background: transparent;
  cursor: default;
}

.edit-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.edit-kind-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  flex-shrink: 0;
  padding: 4px;
  border-radius: 999px;
  background: #f6f6f6;
}

.edit-kind-tab {
  border: none;
  background: transparent;
  color: #8b8b8b;
  font-family: var(--cute);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.edit-kind-tab:hover {
  color: #1a1a1a;
}

.edit-kind-tab.is-active {
  background: #fff;
  color: #1a1a1a;
  box-shadow: 0 1px 4px rgba(26, 26, 26, 0.08);
}

#affirm-input {
  font-family: var(--cute);
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  display: block;
  width: 100%;
  flex: 1;
  min-height: 280px;
  resize: none;
  border: 3px solid rgba(255, 255, 255, 0.75);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.95);
  padding: 16px;
  font-size: 18px;
  color: #2a2438;
  outline: none;
}

#affirm-input::placeholder {
  color: rgba(42, 36, 56, 0.4);
}

#affirm-input:focus {
  border-color: var(--yellow);
}

.edit-actions {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

.btn-discard,
.btn-save {
  flex: 1;
  border: 1px solid rgba(20, 16, 24, 0.08);
  border-radius: 999px;
  padding: 12px 16px;
  font-family: var(--cute);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--soft-shadow-sm);
}

.btn-discard {
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
}

.btn-save {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.btn-discard:active,
.btn-save:active {
  transform: scale(0.98);
  opacity: 0.92;
}

/* —— Crystal-ball chat sheet: only this pops from bottom —— */
.chat-page.chat-sheet {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--safe-top) + var(--chat-sheet-peek));
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: auto;
  height: auto;
  max-height: none;
  margin: 0;
  padding: 0 max(0px, var(--safe-right)) max(10px, var(--safe-bottom)) max(0px, var(--safe-left));
  border-radius: 28px 28px 0 0;
  overflow: hidden;
  background: #fff;
  background-image: none !important;
  color: #1c1524;
  border: none;
  border-top: 1px solid rgba(28, 21, 36, 0.04);
  box-shadow: 0 -12px 48px rgba(6, 10, 28, 0.22);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transform: translateY(108%);
  opacity: 1;
  pointer-events: none;
  transition: transform 0.52s cubic-bezier(0.22, 1.2, 0.36, 1);
  will-change: transform;
}

.chat-page.chat-sheet[hidden] {
  display: none !important;
}

body:not(.theme-v2) .screen.chat-open .chat-page.chat-sheet:not([hidden]) {
  display: flex;
  transform: translateY(0);
  pointer-events: auto;
}

body.theme-v2 .screen.chat-open .chat-page.chat-sheet:not([hidden]) {
  display: flex;
}

.chat-page.chat-bg-mode-color {
  background-image: none !important;
}

.chat-top {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 5;
  isolation: isolate;
  pointer-events: none;
}

.chat-top-blur {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: -14px;
  pointer-events: none;
  z-index: 0;
  background: linear-gradient(
    180deg,
    #fff 0%,
    #fff calc(100% - 14px),
    rgba(255, 255, 255, 0.7) calc(100% - 7px),
    rgba(255, 255, 255, 0.28) calc(100% - 3px),
    rgba(255, 255, 255, 0) 100%
  );
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  -webkit-mask-image: linear-gradient(
    180deg,
    #000 0%,
    #000 calc(100% - 14px),
    rgba(0, 0, 0, 0.65) calc(100% - 7px),
    rgba(0, 0, 0, 0.22) calc(100% - 2px),
    transparent 100%
  );
  mask-image: linear-gradient(
    180deg,
    #000 0%,
    #000 calc(100% - 14px),
    rgba(0, 0, 0, 0.65) calc(100% - 7px),
    rgba(0, 0, 0, 0.22) calc(100% - 2px),
    transparent 100%
  );
}

.chat-hero {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--touch) 1fr var(--touch);
  align-items: center;
  gap: 10px;
  padding: 10px 14px 4px;
  background: transparent;
  border: none;
  pointer-events: none;
}

.chat-hero .chat-round-btn {
  pointer-events: auto;
}

.chat-hero-center {
  display: flex;
  justify-content: center;
  min-width: 0;
}

.chat-crystal {
  width: 44px;
  height: 44px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 0 10px rgba(255, 79, 184, 0.4)) drop-shadow(0 6px 14px rgba(255, 79, 184, 0.2));
  -webkit-mask-image: radial-gradient(circle at 50% 46%, #000 48%, rgba(0, 0, 0, 0.7) 58%, rgba(0, 0, 0, 0.35) 70%, transparent 86%);
  mask-image: radial-gradient(circle at 50% 46%, #000 48%, rgba(0, 0, 0, 0.7) 58%, rgba(0, 0, 0, 0.35) 70%, transparent 86%);
  user-select: none;
  pointer-events: none;
}

.chat-hero-spacer {
  width: var(--touch);
  height: var(--touch);
}

.chat-chips {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 2px 16px 10px;
  pointer-events: none;
}

.chat-chips .chat-chip {
  pointer-events: auto;
}

.chat-chip {
  appearance: none;
  border: 1px solid rgba(28, 21, 36, 0.08);
  border-radius: 999px;
  background: #f3f4f7;
  color: #1c1524;
  font-family: var(--cute);
  font-size: 13px;
  font-weight: 650;
  padding: 8px 14px;
  cursor: pointer;
  box-shadow: none;
  transition: transform 0.15s ease, background 0.15s ease;
}

.chat-chip-accent {
  background: #ffe6f3;
  border-color: rgba(255, 79, 184, 0.2);
  color: #b01570;
}

.chat-chip:active {
  transform: scale(0.96);
}

.chat-chip:disabled {
  opacity: 0.5;
  cursor: default;
}

.chat-round-btn {
  width: var(--touch);
  height: var(--touch);
  min-width: var(--touch);
  min-height: var(--touch);
  border: 1px solid rgba(28, 21, 36, 0.06);
  border-radius: 50%;
  background: #eceef3;
  color: #2a2433;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transition: transform 0.15s, background 0.15s, color 0.15s;
}

.chat-round-btn .rail-icon {
  width: 20px;
  height: 20px;
}

.chat-round-btn i {
  font-size: 16px;
}

.chat-round-btn:hover {
  background: #e2e5ec;
  color: #1c1524;
}

.chat-round-btn:active {
  transform: scale(0.94);
}

.chat-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--cute);
  font-size: 14px;
  color: #6b6174;
}

.chat-field input,
.chat-field select {
  border: 1px solid rgba(28, 21, 36, 0.1);
  border-radius: 14px;
  background: #fff;
  color: #1c1524;
  font-family: var(--cute);
  font-size: 15px;
  padding: 10px 12px;
  outline: none;
}

.chat-field input:focus,
.chat-field select:focus {
  border-color: rgba(255, 79, 184, 0.45);
}

.chat-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--cute);
  font-size: 14px;
  color: #3a3144;
}

#chat-input::placeholder {
  color: #9a93a3;
}

.chat-settings-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  font-family: var(--cute);
  color: #8a8294;
}

.page-action-ghost {
  visibility: hidden;
  pointer-events: none;
  min-width: 44px;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 112px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: none;
  color: #1c1524;
}

.chat-messages::-webkit-scrollbar {
  display: none;
}

.chat-jump-bottom {
  position: absolute;
  right: max(18px, var(--safe-right));
  bottom: calc(78px + var(--safe-bottom));
  z-index: 6;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(28, 21, 36, 0.08);
  border-radius: 50%;
  background: #fff;
  color: #1c1524;
  box-shadow: 0 10px 24px rgba(28, 21, 36, 0.12);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s, background 0.15s;
}

.chat-jump-bottom[hidden] {
  display: none !important;
}

.chat-jump-bottom i {
  font-size: 16px;
  line-height: 1;
}

@media (hover: hover) {
  .chat-jump-bottom:hover {
    background: #fff;
    color: var(--accent);
    transform: translateY(-2px);
  }
}

.chat-jump-bottom:active {
  transform: scale(0.94);
}

.chat-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 100%;
  align-self: flex-start;
}

.chat-row.assistant {
  width: 100%;
}

.chat-msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  margin-top: 2px;
  background: #111318;
  border: 1px solid rgba(28, 21, 36, 0.06);
  box-shadow: 0 4px 12px rgba(28, 21, 36, 0.08);
}

.chat-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 14%;
  transform: scale(1.85);
  transform-origin: 50% 18%;
  display: block;
}

.chat-bubble {
  max-width: 92%;
  border-radius: 22px;
  padding: 12px 14px;
  font-family: var(--cute);
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: none;
}

.chat-bubble.md {
  white-space: normal;
}

.chat-bubble.md .md-p {
  margin: 0 0 0.55em;
}

.chat-bubble.md .md-p:last-child {
  margin-bottom: 0;
}

.chat-bubble.md .md-h {
  margin: 0.35em 0 0.45em;
  font-size: 1.05em;
  font-weight: 700;
  color: #1c1524;
}

.chat-bubble.md .md-gap {
  height: 0.45em;
}

.chat-bubble.md .md-list {
  margin: 0.2em 0 0.55em;
  padding-left: 1.2em;
}

.chat-bubble.md .md-list li {
  margin: 0.15em 0;
}

.chat-bubble.md strong {
  font-weight: 700;
  color: #1c1524;
}

.chat-bubble.user.md strong {
  color: #1c1524;
}

.chat-bubble.md em {
  font-style: italic;
  opacity: 0.95;
}

.chat-bubble.md .md-code,
.chat-bubble.md .md-pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em;
}

.chat-bubble.md .md-code {
  background: rgba(28, 21, 36, 0.06);
  border-radius: 6px;
  padding: 0.1em 0.35em;
}

.chat-bubble.md .md-pre {
  margin: 0.4em 0 0.55em;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(28, 21, 36, 0.05);
  overflow: auto;
  white-space: pre-wrap;
}

.chat-bubble.md .md-link {
  color: #c2187a;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-bubble.user {
  align-self: flex-end;
  max-width: 86%;
  background: #eef0f4;
  border: none;
  color: #1c1524;
  border-radius: 22px 22px 8px 22px;
}

.chat-row .chat-bubble.assistant {
  flex: 1;
  min-width: 0;
  max-width: calc(100% - 44px);
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: #f3f4f7;
  border: none;
  color: #1c1524;
  border-radius: 8px 22px 22px 22px;
}

.chat-bubble.system,
.chat-bubble.error {
  align-self: center;
  max-width: 100%;
  background: #f3f4f7;
  border: none;
  color: #5c5566;
  font-size: 13px;
  text-align: center;
  padding: 8px 14px;
  box-shadow: none;
}

.chat-bubble.error {
  color: #b4235a;
  background: #ffe0ef;
}

.chat-bubble.pending {
  opacity: 0.75;
}

.chat-composer {
  position: relative;
  z-index: 6;
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 8px 14px 12px;
  border-top: none;
  background: #fff;
}

.chat-input-shell {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 8px 8px 16px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(28, 21, 36, 0.06);
  box-shadow: 0 12px 32px rgba(28, 21, 36, 0.1);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

#chat-input {
  resize: none;
  flex: 1;
  min-width: 0;
  min-height: 36px;
  max-height: 120px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: #1c1524;
  font-family: var(--cute);
  font-size: 15px;
  line-height: 1.45;
  padding: 8px 0;
  outline: none;
  box-shadow: none;
}

#chat-input:focus {
  border: none;
  outline: none;
}

.chat-send {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: #1c1524;
  color: #fff;
  font-family: var(--cute);
  font-size: 14px;
  font-weight: 700;
  padding: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.chat-send .rail-icon {
  width: 18px;
  height: 18px;
}

.chat-send i {
  font-size: 14px;
}

.chat-send:disabled {
  opacity: 0.45;
  cursor: default;
}

/* —— Coach profile —— */
.profile-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.profile-intro {
  margin: 0;
  font-family: var(--cute);
  font-size: 14px;
  line-height: 1.5;
  color: #6b6174;
}

.profile-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--cute);
  font-size: 14px;
  color: #3a3144;
}

.profile-field textarea {
  width: 100%;
  resize: vertical;
  min-height: 72px;
  border: 1px solid rgba(28, 21, 36, 0.1);
  border-radius: 14px;
  background: #fff;
  color: #1c1524;
  font-family: var(--cute);
  font-size: 15px;
  line-height: 1.55;
  padding: 10px 12px;
  outline: none;
}

.profile-field textarea:focus {
  border-color: rgba(255, 79, 184, 0.45);
}

/* —— Appearance settings —— */
.appearance-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.appearance-block {
  padding: 16px;
  border-radius: 24px;
  background: #fff;
  border: 1px solid rgba(28, 21, 36, 0.06);
  box-shadow: 0 10px 28px rgba(28, 21, 36, 0.06);
  display: flex;
  flex-direction: column;
  gap: 12px;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.appearance-heading {
  margin: 0;
  font-family: var(--display);
  font-size: 14px;
  font-weight: 700;
  color: #1c1524;
  letter-spacing: -0.01em;
}

.appearance-mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: #f4f5f8;
  border: 1px solid rgba(28, 21, 36, 0.06);
}

.appearance-mode-row-3 {
  grid-template-columns: repeat(3, 1fr);
}

.appearance-mode-btn {
  border: none;
  background: transparent;
  color: #6b6174;
  font-family: var(--cute);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.appearance-mode-btn.is-active {
  background: #1c1524;
  color: #fff;
  box-shadow: none;
}

.appearance-pick {
  position: relative;
  display: block;
  width: 100%;
  height: 96px;
  padding: 0;
  border-radius: 18px;
  border: 1px dashed rgba(28, 21, 36, 0.16);
  background-color: #f4f5f8;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s, filter 0.15s, box-shadow 0.15s;
}

.appearance-pick:hover {
  border-style: solid;
  border-color: rgba(255, 79, 184, 0.35);
  filter: brightness(1.02);
  box-shadow: var(--soft-shadow-sm);
}

.appearance-pick:active {
  transform: scale(0.99);
}

.appearance-pick.is-gradient-mode {
  border-style: solid;
  background-image:
    radial-gradient(circle at 18% 22%, #FF4FB8 0%, transparent 42%),
    radial-gradient(circle at 82% 28%, #C9B6FF 0%, transparent 44%),
    radial-gradient(circle at 48% 88%, #D4FF3A 0%, transparent 48%),
    linear-gradient(160deg, #FFF9F2, #FFE8F6 40%, #EDE4FF 70%, #FFF9F2);
  background-size: cover;
}

.appearance-pick-hint {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(14, 21, 48, 0.72);
  color: rgba(255, 255, 255, 0.92);
  font-family: var(--cute);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.pingu-preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 12px;
}

.pingu-preset-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(210, 220, 255, 0.7);
  font-family: var(--cute);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
}

.pingu-preset-btn img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  image-rendering: auto;
}

.pingu-preset-plus {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  font-size: 28px;
  line-height: 1;
  color: var(--ink);
  background: rgba(201, 182, 255, 0.55);
  border: none;
  border-radius: 14px;
}

.pingu-preset-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  box-shadow: none;
}

.pingu-preset-btn.is-active {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  box-shadow: none;
}

.appearance-preview-pingu {
  height: 132px;
  background-color: #C9B6FF;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  pointer-events: none;
  cursor: default;
  border-style: solid;
}

.appearance-preview-pingu .appearance-pick-hint {
  background: var(--ink);
  color: #FFF9F2;
}

.appearance-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: rgba(210, 220, 255, 0.55);
  font-family: var(--cute);
}

/* —— Drawer / folder backdrop —— */
.drawer-backdrop {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 14;
  border: none;
  background: rgba(6, 14, 36, 0.34);
  backdrop-filter: blur(10px) saturate(1.15);
  -webkit-backdrop-filter: blur(10px) saturate(1.15);
  cursor: pointer;
}

.drawer-backdrop[hidden] {
  display: none !important;
}

.screen.drawer-open .stage {
  transition: filter 0.2s ease, transform 0.2s ease;
}

/* —— Responsive —— */
@media (max-width: 780px) {
  :root {
    --rail-bottom: 10px;
    --rail-height: 74px;
    --rail-side: 10px;
    --rail-reserve: calc(var(--rail-bottom) + var(--rail-height) + 14px);
  }

  html,
  body {
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  body {
    display: block;
    padding: 0;
    background: #1A2348;
  }

  .screen,
  .screen.drawer-open {
    width: 100%;
    height: 100%;
    min-height: 100dvh;
    max-height: none;
    border-radius: 0;
  }

  .screen.drawer-open {
    grid-template-columns: 1fr;
  }

  .ritual-expand-btn {
    right: max(12px, var(--safe-right));
  }

  .ritual-expand-logo {
    height: 28px;
    max-width: min(140px, 48vw);
  }

  .ritual-collapse-btn i {
    font-size: 17px;
  }

  .ritual-bar {
    margin-top: 60px;
    margin-left: 12px;
    margin-right: 12px;
    border-radius: 28px;
    padding: 12px;
  }

  .ritual-title {
    font-size: 24px;
  }

  .calendar-drawer,
  .stats-drawer,
  .resources-drawer,
  .faq-drawer {
    inset: 0;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    height: auto;
    max-height: none;
    z-index: 15;
    margin: 0;
    max-width: none;
    border-radius: 0;
    box-sizing: border-box;
    padding-bottom: var(--rail-reserve);
    background: #f4f5f8;
    color: #1c1524;
    box-shadow: none;
  }

  .chat-page.chat-sheet {
    left: 0;
    right: 0;
    top: calc(var(--safe-top) + var(--chat-sheet-peek));
    bottom: 0;
    height: auto;
    max-height: none;
    border-radius: 28px 28px 0 0;
    z-index: 20;
  }

  .screen.drawer-open .stage {
    grid-column: 1;
    filter: none;
  }

  .stage,
  .screen.drawer-open .stage {
    grid-column: 1;
    padding: 8px 8px 56px;
  }

  .hud-top {
    flex-direction: row;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 2px;
  }

  .game-title {
    font-size: 13px;
  }

  .game-sub {
    font-size: 7px;
    margin-top: 4px;
  }

  .score-box {
    min-width: 0;
    padding: 6px 8px;
    text-align: right;
  }

  .count-label {
    font-size: 10px;
  }

  .count-num {
    font-size: 20px;
  }

  .hint {
    font-size: 10px;
    margin-top: 4px;
  }

  .stage.ritual-collapsed .bubble-anchor {
    top: 6px;
    bottom: max(180px, min(250px, calc(36vh + 20px)));
  }

  .stage.ritual-collapsed .pingu-wrap {
    width: min(300px, 72vw);
    max-height: min(260px, 40vh);
  }

  .stage.ritual-collapsed .pingu-sprite {
    max-height: min(260px, 40vh);
  }

  .ritual-bar {
    padding: 12px;
    margin-bottom: 8px;
    margin-left: 12px;
    margin-right: 12px;
  }

  .ritual-title {
    font-size: 14px;
  }

  .ritual-tab {
    font-size: 12px;
    padding: 7px 8px;
  }

  .ritual-panel-copy {
    font-size: 12px;
  }

  .ritual-btn {
    font-size: 12px;
    padding: 7px 12px;
  }

  .ritual-timer-ring {
    width: 96px;
    height: 96px;
  }

  .ritual-session-timer {
    font-size: 14px;
  }

  .ritual-session-body {
    font-size: 12px;
  }

  .ritual-session-panel {
    padding: 10px 10px 8px;
    gap: 6px;
    border-radius: 22px;
  }

  .ritual-session {
    margin-bottom: 24px;
    transform: translateY(-12px);
  }

  .bubble-toolbar {
    margin-bottom: 8px;
    padding-bottom: 6px;
  }

  .bubble-switch {
    width: 26px;
    height: 26px;
  }

  .bubble-mode-label {
    font-size: 11px;
  }

  .hint-desktop {
    display: none;
  }

  .hint-mobile {
    display: block;
  }

  .hint kbd {
    font-size: 6px;
  }

  .bubble-anchor {
    top: 6px;
    left: 8px;
    right: 8px;
    bottom: max(100px, min(145px, calc(18vh + 26px)));
    padding: 0;
    align-items: flex-end;
  }

  .bubble-motion {
    width: 100%;
  }

  .speech-bubble {
    width: 100%;
    height: auto;
    max-height: 100%;
    border-radius: 20px;
    border-width: 1px;
    padding: 10px 12px 12px;
    box-shadow: var(--soft-shadow);
  }

  .speech-text {
    font-size: clamp(13px, 3.6vw, 15px);
    line-height: 1.6;
  }

  .wobble-line {
    margin: 0.1em 0;
  }

  .pingu-wrap {
    width: clamp(140px, 40vw, 200px);
    max-height: min(160px, 26vh);
    bottom: 4px;
  }

  .pingu-sprite {
    max-width: 100%;
    max-height: min(160px, 26vh);
  }

  .drawer-head {
    font-size: 15px;
    padding: 10px;
  }

  .tab {
    font-size: 13px;
    padding: 7px 4px;
  }

  .cal-title {
    font-size: 9px;
  }

  .cal-weekdays {
    font-size: 10px;
  }

  .stat-chip-value {
    font-size: 10px;
  }

  .stat-row {
    font-size: 14px;
  }

  .stat-row strong {
    font-size: 9px;
  }

  .page-header {
    padding: calc(var(--safe-top) + 10px) max(12px, var(--safe-right)) 10px max(12px, var(--safe-left));
  }

  .page-header h1 {
    font-size: 18px;
  }

  .page-body {
    padding: 12px;
  }

  .current-text {
    font-size: 15px;
  }

  #affirm-input {
    min-height: 220px;
    font-size: 16px;
    padding: 12px;
  }

  .btn-discard,
  .btn-save {
    font-size: 16px;
    padding: 12px 10px;
  }

  .chat-bubble {
    font-size: 14px;
  }

  #chat-input {
    font-size: 16px;
  }

  .chat-send {
    font-size: 15px;
  }
}

@media (max-width: 780px) and (max-height: 640px) {
  .stage.ritual-collapsed .bubble-anchor {
    bottom: max(150px, min(200px, calc(30vh + 16px)));
  }

  .stage.ritual-collapsed .pingu-wrap {
    width: min(240px, 68vw);
    max-height: min(210px, 36vh);
  }

  .stage.ritual-collapsed .pingu-sprite {
    max-height: min(210px, 36vh);
  }

  .bubble-anchor {
    bottom: max(88px, min(128px, calc(16vh + 22px)));
  }

  .pingu-wrap {
    width: clamp(120px, 36vw, 160px);
    max-height: min(140px, 24vh);
  }

  .pingu-sprite {
    max-height: min(140px, 24vh);
  }

  .speech-text {
    font-size: 13px;
    line-height: 1.55;
  }

  .game-title {
    font-size: 12px;
  }

  .count-num {
    font-size: 18px;
  }

  .ritual-bar {
    padding: 12px;
    margin-left: 12px;
    margin-right: 12px;
  }
}
