/*
 * Home carousel polish.
 * The phone keeps native scrolling everywhere, but browser scrollbars stay visual-noise free.
 */
.phone,
.phone * {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

.phone::-webkit-scrollbar,
.phone *::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

#menuDrawer .drawer {
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

.interface-layer .task-zone {
  left: 34px;
  right: 34px;
  top: 126px;
  height: 206px;
  display: flex;
  gap: 10px;
  padding: 0 5px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-padding-inline: 6px;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  cursor: grab;
  -webkit-overflow-scrolling: touch;
}

.interface-layer .task-zone.dragging {
  cursor: grabbing;
  scroll-behavior: auto;
  scroll-snap-type: none;
  user-select: none;
}

.interface-layer .task-card,
.interface-layer .task-card.active {
  position: relative !important;
  inset: auto !important;
  width: auto !important;
  min-width: 0;
  height: 100%;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 14px 16px 12px !important;
  border-radius: 22px;
  flex: 0 0 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  opacity: 0.72 !important;
  pointer-events: auto !important;
  transform: scale(0.975) !important;
  transform-origin: center;
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    box-shadow 180ms ease;
}

.interface-layer .task-card.active {
  opacity: 1 !important;
  transform: none !important;
}

.interface-layer .task-card > span {
  max-width: calc(100% - 58px);
  margin-right: auto !important;
  margin-left: auto !important;
  overflow: visible;
  font-size: 11px !important;
  line-height: 1.25;
  letter-spacing: 0.18em !important;
  overflow-wrap: anywhere;
  text-overflow: clip;
  text-wrap: balance;
  white-space: normal;
}

.interface-layer .task-card h1 {
  width: 100%;
  max-width: 300px !important;
  min-width: 0;
  min-height: 0;
  max-height: none;
  display: flex;
  flex: 1 0 auto;
  align-items: center;
  justify-content: center;
  overflow: visible;
  font-size: clamp(16px, 4.8vw, 20px) !important;
  line-height: 1.24 !important;
  hyphens: auto;
  overflow-wrap: anywhere;
  text-wrap: balance;
  word-break: normal;
  -webkit-box-orient: initial;
  -webkit-line-clamp: unset;
}

.interface-layer .task-card:first-child h1 {
  font-size: clamp(16px, 4.8vw, 20px) !important;
}

.interface-layer .task-card:nth-child(2) h1,
.interface-layer .task-card.task-tarot h1,
.interface-layer .task-card.task-dream h1,
.interface-layer .task-card.task-astrology h1,
.interface-layer .task-card.task-oracle h1,
.interface-layer .task-card.task-quote h1 {
  font-size: clamp(16px, 4.8vw, 20px) !important;
  line-height: 1.24 !important;
}

.interface-layer .task-card.has-home-continuity h1 {
  min-height: 0;
  max-height: none;
  flex: 0 0 auto;
  font-size: clamp(15px, 4.2vw, 16px) !important;
  line-height: 1.25 !important;
}

.interface-layer .task-card.task-astrology h1,
.interface-layer .task-card.task-oracle h1 {
  min-height: 0 !important;
  max-height: none;
  font-size: clamp(16px, 4.5vw, 18px) !important;
  line-height: 1.24 !important;
}

.interface-layer .task-card.task-tarot-single h1 {
  width: calc(100% - 62px);
  max-width: 238px !important;
  margin-right: 0 !important;
}

.interface-layer .task-card .line {
  width: 30px;
  height: 3px;
  margin-top: 7px !important;
  margin-bottom: 9px !important;
}

.interface-layer .task-card .play,
.interface-layer .task-card:nth-child(1) .play,
.interface-layer .task-card:nth-child(2) .play,
.interface-layer .task-card.task-astrology .play,
.interface-layer .task-card.task-oracle .play {
  width: auto !important;
  min-width: 124px;
  max-width: calc(100% - 32px);
  height: auto !important;
  min-height: 44px;
  margin-top: 8px !important;
  padding: 10px 22px;
  border-radius: 999px !important;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.15;
  overflow-wrap: anywhere;
  text-wrap: balance;
  white-space: normal;
}

.interface-layer .task-card.has-home-continuity {
  padding-top: 13px !important;
  padding-bottom: 11px !important;
}

.interface-layer .task-card.has-home-continuity > span {
  max-width: calc(100% - 58px);
  min-height: 0;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.interface-layer .task-card.has-home-continuity .home-card-meta {
  width: min(100%, 276px);
  max-height: none;
  margin: 4px auto 0;
  display: block;
  flex: 0 0 auto;
  overflow: visible;
  line-height: 1.3;
  overflow-wrap: anywhere;
  text-overflow: clip;
  text-wrap: balance;
  white-space: normal;
  -webkit-line-clamp: unset;
}

.interface-layer .task-card.has-home-continuity .home-card-meta[hidden] {
  display: none !important;
}

.interface-layer .task-card.has-home-continuity .play {
  margin-top: auto !important;
}

.interface-layer .task-card .play svg {
  display: none;
}

.interface-layer .task-card .play::after {
  font-size: inherit;
  font-weight: inherit;
}

.interface-layer .task-card .play[data-route="affirmation"]::after {
  content: "Reveal";
}

.interface-layer .task-card .play[data-route="quick-question"]::after {
  content: "Answer now";
}

.interface-layer .task-card .play[data-route="chat"]::after {
  content: "Continue";
}

.interface-layer .task-card .play[data-route="tarot-single"]::after {
  content: "Draw one card";
}

.interface-layer .task-card .play[data-route="tarot-three"]::after {
  content: "Draw three cards";
}

.interface-layer .task-card .play[data-route="dream"]::after {
  content: "Reflect on a dream";
}

.interface-layer .task-card .play[data-route="astrology"]::after {
  content: "Read the sky";
}

.interface-layer .task-card .play[data-route="oracle"]::after {
  content: "Open my reading";
}

.interface-layer .task-card .play[data-route="quote"]::after {
  content: "Read today's thought";
}

html[lang^="zh"] .interface-layer .task-card .play[data-route="affirmation"]::after {
  content: "揭晓";
}

html[lang^="zh"] .interface-layer .task-card .play[data-route="quick-question"]::after {
  content: "现在回答";
}

html[lang^="zh"] .interface-layer .task-card .play[data-route="chat"]::after {
  content: "继续聊天";
}

html[lang^="zh"] .interface-layer .task-card .play[data-route="tarot-single"]::after {
  content: "抽一张牌";
}

html[lang^="zh"] .interface-layer .task-card .play[data-route="tarot-three"]::after {
  content: "抽三张牌";
}

html[lang^="zh"] .interface-layer .task-card .play[data-route="dream"]::after {
  content: "聊聊梦境";
}

html[lang^="zh"] .interface-layer .task-card .play[data-route="astrology"]::after {
  content: "查看星象";
}

html[lang^="zh"] .interface-layer .task-card .play[data-route="oracle"]::after {
  content: "查看指引";
}

html[lang^="zh"] .interface-layer .task-card .play[data-route="quote"]::after {
  content: "读今日灵感";
}

.interface-layer .task-card .task-close {
  top: 0;
  right: 0;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0 !important;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 0;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}

.interface-layer .task-card .task-close::after {
  content: "×";
  font-family: Arial, sans-serif;
  font-size: 23px;
  font-weight: 600;
  line-height: 1;
}

.interface-layer .card-toggle {
  width: 44px;
  height: 44px;
  top: 73px;
  box-shadow: 0 6px 16px rgba(7, 20, 53, 0.16);
}

.interface-layer .card-toggle svg {
  width: 20px;
  height: 20px;
}

.quick-response {
  max-width: 320px;
  margin: 16px auto 0;
  padding: 13px 15px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  color: #2b3350;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

.guidance-loading {
  flex: 0 0 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-align: center;
}

.guidance-done {
  min-height: 44px;
  margin: 12px auto 0;
  padding: 0 22px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.guidance-done:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

.interface-layer .task-card .task-close:hover,
.interface-layer .task-card .task-close:active {
  border: 0 !important;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none !important;
  opacity: 0.72;
}

.interface-layer .task-card .task-close:focus:not(:focus-visible) {
  outline: 0;
}

.interface-layer .task-card .task-close:focus-visible {
  border-radius: 0;
  outline: 2px solid currentColor;
  outline-offset: -12px;
  background: transparent !important;
  box-shadow: none !important;
}

.task-badge {
  top: -3px !important;
  right: -9px !important;
  min-width: 24px;
  height: 18px !important;
  padding: 0 7px;
  border: 0 !important;
  border-radius: 8px 8px 8px 3px;
  background:
    radial-gradient(circle at 28% 18%, rgba(255, 255, 255, .38), transparent 24%),
    linear-gradient(145deg, rgba(111, 102, 195, .98), rgba(66, 145, 174, .98));
  color: rgba(255, 255, 255, .98);
  box-shadow:
    0 0 0 1px rgba(210, 228, 255, .5),
    0 5px 12px rgba(5, 19, 58, .24),
    inset 0 1px 0 rgba(255, 255, 255, .28);
  font-size: 10px !important;
  font-weight: 750;
  letter-spacing: .03em;
  text-shadow: 0 1px 3px rgba(18, 21, 73, .35);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.task-badge::before {
  content: none !important;
  display: none !important;
}

.interface-layer .pages {
  top: 334px;
  left: 50%;
  width: min(320px, calc(100% - 40px));
  height: 44px;
  display: grid;
  grid-template-columns: repeat(var(--guidance-count, 9), minmax(0, 1fr));
  align-items: center;
  gap: 0;
  padding: 0;
  overflow: visible;
  transform: translateX(-50%);
}

.interface-layer .task-card[hidden],
.interface-layer .pages button[hidden],
.interface-layer .pages[hidden] {
  display: none !important;
}

.interface-layer .task-card.daily-removing,
.interface-layer .task-card.daily-removing.active {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translateY(-7px) scale(.95) !important;
}

.guidance-empty {
  width: 100%;
  min-width: 100%;
  height: 100%;
  padding: 28px 32px;
  display: flex;
  flex: 0 0 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(255, 255, 255, .12), rgba(255, 255, 255, .055));
  color: #fff;
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14);
}

.guidance-empty[hidden] {
  display: none;
}

.guidance-empty strong,
.guidance-empty span {
  display: block;
}

.guidance-empty strong {
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.25;
}

.guidance-empty span {
  max-width: 250px;
  margin-top: 8px;
  color: rgba(255, 255, 255, .7);
  font-size: 12px;
  line-height: 1.45;
}

.guidance-empty .guidance-reset {
  min-height: 40px;
  margin-top: 16px;
  padding: 8px 16px;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 999px;
  background: rgba(255, 255, 255, .92);
  color: #28334b;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.guidance-empty .guidance-reset:disabled {
  cursor: wait;
  opacity: .7;
}

.guidance-empty .guidance-reset:focus-visible {
  outline: 3px solid rgba(174, 222, 255, .82);
  outline-offset: 3px;
}

.guidance-memory-toast {
  position: absolute;
  z-index: 95;
  left: 18px;
  right: 18px;
  bottom: max(92px, calc(env(safe-area-inset-bottom) + 82px));
  min-height: 48px;
  padding: 8px 8px 8px 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 18px;
  background: rgba(23, 29, 62, .94);
  color: #fff;
  box-shadow: 0 16px 38px rgba(8, 15, 45, .32);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 220ms cubic-bezier(.2, .8, .2, 1);
  backdrop-filter: blur(14px);
}

.guidance-memory-toast.visible {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.guidance-memory-toast span {
  flex: 1;
  font-size: 11px;
  line-height: 1.35;
}

.guidance-memory-toast button {
  min-width: 54px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.guidance-memory-toast button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .interface-layer .task-card.daily-removing,
  .guidance-memory-toast {
    transition: none !important;
  }
}

.interface-layer .pages button,
.interface-layer .pages button.active {
  position: relative;
  width: 100% !important;
  min-width: 0;
  height: 44px !important;
  margin: 0 !important;
  padding: 0;
  border: 0 !important;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none !important;
}

.interface-layer .pages button::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  border: 0;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.46);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
  transform: translate(-50%, -50%);
  transition:
    width 180ms ease,
    background-color 180ms ease,
    box-shadow 180ms ease;
}

.interface-layer .pages button.active::after {
  width: 20px;
  background: #fff;
  box-shadow: 0 3px 10px rgba(7, 20, 53, 0.2);
}

.interface-layer .pages button:focus-visible {
  outline: none;
}

.interface-layer .pages button:focus-visible::after {
  box-shadow:
    0 0 0 2px rgba(7, 20, 53, 0.42),
    0 0 0 4px rgba(255, 255, 255, 0.94);
}

@media (hover: hover) {
  .interface-layer .task-card.active:hover {
    box-shadow:
      0 24px 52px rgba(5, 24, 58, 0.28),
      inset 0 1px 0 rgba(255, 255, 255, 0.72);
  }
}

@media (max-width: 600px) and (orientation: portrait) {
  .interface-layer .card-toggle {
    top: max(15px, calc(env(safe-area-inset-top) + 9px));
  }

  .interface-layer .task-zone {
    left: max(32px, env(safe-area-inset-left));
    right: max(32px, env(safe-area-inset-right));
    top: max(78px, calc(env(safe-area-inset-top) + 72px));
    height: 200px;
  }

  .interface-layer .task-card,
  .interface-layer .task-card:nth-child(1),
  .interface-layer .task-card:nth-child(2) {
    padding: 14px 15px 12px !important;
    border-radius: 22px;
  }

  .interface-layer .task-card > span {
    margin-top: 1px !important;
    font-size: 10px !important;
    letter-spacing: 0.16em !important;
  }

  .interface-layer .task-card h1 {
    font-size: clamp(16px, 4.8vw, 19px) !important;
  }

  .interface-layer .pages {
    top: max(280px, calc(env(safe-area-inset-top) + 274px));
    width: calc(100% - 28px);
  }
}

@media (max-width: 350px) and (orientation: portrait) {
  .interface-layer .task-zone {
    top: max(72px, calc(env(safe-area-inset-top) + 66px));
    height: 214px;
  }

  .interface-layer .task-card,
  .interface-layer .task-card:nth-child(1),
  .interface-layer .task-card:nth-child(2) {
    padding: 12px 13px 10px !important;
  }

  .interface-layer .task-card .line {
    margin-top: 6px !important;
    margin-bottom: 7px !important;
  }

  .interface-layer .task-card h1 {
    min-height: 0;
    max-height: none;
    font-size: clamp(15px, 5vw, 17px) !important;
    line-height: 1.24 !important;
  }

  .interface-layer .task-card .play,
  .interface-layer .task-card:nth-child(1) .play,
  .interface-layer .task-card:nth-child(2) .play,
  .interface-layer .task-card.task-astrology .play,
  .interface-layer .task-card.task-oracle .play {
    height: auto !important;
    min-height: 44px;
    min-width: 110px;
    margin-top: 5px !important;
    padding: 8px 18px;
    font-size: 13px;
  }

  .interface-layer .pages {
    top: max(288px, calc(env(safe-area-inset-top) + 282px));
  }
}

@media (max-height: 620px) and (orientation: landscape) {
  .interface-layer .card-toggle {
    top: max(12px, calc(env(safe-area-inset-top) + 6px));
  }

  .interface-layer .task-zone {
    left: max(58px, calc(env(safe-area-inset-left) + 52px));
    right: auto;
    top: max(68px, calc(env(safe-area-inset-top) + 58px));
    width: min(42vw, 340px);
    height: min(200px, calc(100dvh - 132px));
  }

  .interface-layer .task-card,
  .interface-layer .task-card:nth-child(1),
  .interface-layer .task-card:nth-child(2) {
    padding: 14px 15px 11px !important;
  }

  .interface-layer .task-card > span {
    font-size: 9px !important;
    line-height: 12px;
    letter-spacing: .12em !important;
  }

  .interface-layer .task-card.task-astrology > span,
  .interface-layer .task-card.task-oracle > span {
    margin-top: 18px !important;
  }

  .interface-layer .task-card h1,
  .interface-layer .task-card:first-child h1,
  .interface-layer .task-card:nth-child(2) h1,
  .interface-layer .task-card.task-tarot h1,
  .interface-layer .task-card.task-dream h1,
  .interface-layer .task-card.task-astrology h1,
  .interface-layer .task-card.task-oracle h1,
  .interface-layer .task-card.task-quote h1 {
    min-height: 0;
    max-height: none;
    font-size: clamp(14px, 3vw, 17px) !important;
    line-height: 1.22 !important;
  }

  .interface-layer .task-card.has-home-continuity {
    padding: 8px 12px 7px !important;
  }

  .interface-layer .task-card.has-home-continuity .line {
    margin-top: 3px !important;
    margin-bottom: 4px !important;
  }

  .interface-layer .task-card.has-home-continuity h1 {
    font-size: 14px !important;
    line-height: 1.18 !important;
  }

  .interface-layer .task-card.has-home-continuity .home-card-meta {
    margin-top: 2px;
    font-size: 8px;
    line-height: 10px;
  }

  .interface-layer .task-card .play,
  .interface-layer .task-card:nth-child(1) .play,
  .interface-layer .task-card:nth-child(2) .play,
  .interface-layer .task-card.task-astrology .play,
  .interface-layer .task-card.task-oracle .play {
    min-width: 112px;
    height: auto !important;
    min-height: 44px;
    padding: 8px 18px;
    font-size: 13px;
  }

  .interface-layer .task-card.has-home-continuity .play {
    min-height: 44px;
  }

  .interface-layer .pages {
    left: max(58px, calc(env(safe-area-inset-left) + 52px));
    top: calc(
      max(68px, calc(env(safe-area-inset-top) + 58px)) +
      min(200px, calc(100dvh - 132px)) +
      8px
    );
    width: min(42vw, 340px);
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .interface-layer .task-zone {
    scroll-behavior: auto;
  }

  .interface-layer .task-card,
  .interface-layer .pages button::after {
    transition: none;
  }
}
