/* Ask Chikku, page-mascot tiger docked bottom-right */
.chikku {
  --chikku-ink: #0c1f13;
  --chikku-paper: #f6f1e6;
  --chikku-forest: #1f3d2a;
  --chikku-line: rgba(12, 31, 19, 0.14);
  position: fixed;
  z-index: 70;
  right: max(0.7rem, env(safe-area-inset-right));
  bottom: max(0.7rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.55rem;
  width: max-content;
  max-width: min(22.5rem, calc(100vw - 1.4rem));
  pointer-events: none;
  font-family: "Instrument Sans", "Inter", sans-serif;
}

.chikku.is-open {
  width: min(22.5rem, calc(100vw - 1.4rem));
}

.chikku * {
  box-sizing: border-box;
}

.chikku .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chikku-panel {
  pointer-events: auto;
  width: 100%;
  max-height: min(32rem, calc(100svh - 8.5rem));
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--chikku-paper);
  color: var(--chikku-ink);
  border: 1px solid var(--chikku-line);
  border-radius: 1.15rem;
  box-shadow: 0 18px 50px rgba(12, 31, 19, 0.18);
  overflow: hidden;
}

.chikku-panel[hidden] {
  display: none !important;
}

.chikku-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.75rem 0.85rem 0.65rem;
  border-bottom: 1px solid var(--chikku-line);
  flex: 0 0 auto;
}

.chikku-head-copy {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.chikku-head-face {
  position: relative;
  width: 2.35rem;
  height: 2.35rem;
  flex: 0 0 auto;
  filter: drop-shadow(0 4px 8px rgba(12, 31, 19, 0.18));
}

.chikku-head-face .chikku-sheet {
  background-position: 50% 50%;
}

.chikku-head h2 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.chikku-head p {
  margin: 0.12rem 0 0;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #5a6b5e;
}

.chikku-x {
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--chikku-ink);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}

.chikku-x:hover {
  background: rgba(12, 31, 19, 0.06);
}

.chikku-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.85rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.chikku-log::before {
  content: "";
  flex: 1 0 0;
}

.chikku-log > * + * {
  margin-top: 0.65rem;
}

.chikku-msg {
  max-width: 92%;
  padding: 0.65rem 0.8rem;
  border-radius: 0.85rem;
  font-size: 0.92rem;
  line-height: 1.45;
}

.chikku-msg p {
  margin: 0 0 0.45rem;
}

.chikku-msg p:last-child {
  margin-bottom: 0;
}

.chikku-msg a {
  color: var(--chikku-forest);
  font-weight: 600;
}

.chikku-msg.is-bot {
  align-self: flex-start;
  background: #e7eee6;
}

.chikku-msg.is-user {
  align-self: flex-end;
  background: var(--chikku-forest);
  color: #f6f1e6;
}

.chikku-msg.is-refuse {
  background: #efe6d4;
}

.chikku-composer {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-top: 1px solid var(--chikku-line);
  padding-bottom: env(safe-area-inset-bottom);
}

.chikku-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.55rem 0.85rem 0.2rem;
}

.chikku-chip {
  pointer-events: auto;
  border: 1px solid var(--chikku-line);
  background: #fff;
  color: var(--chikku-ink);
  border-radius: 999px;
  padding: 0.32rem 0.7rem;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
}

.chikku-chip:hover {
  border-color: var(--chikku-forest);
}

.chikku-form {
  display: flex;
  gap: 0.4rem;
  padding: 0.45rem 0.7rem 0.7rem;
  background: #fff;
}

.chikku-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--chikku-line);
  border-radius: 999px;
  padding: 0.62rem 0.9rem;
  font: inherit;
  font-size: 16px;
  line-height: 1.25;
  background: var(--chikku-paper);
  color: var(--chikku-ink);
}

.chikku-form button[type="submit"] {
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  background: var(--chikku-forest);
  color: #f6f1e6;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.chikku-dock {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  width: max-content;
  max-width: 100%;
}

.chikku-tag {
  margin: 0;
  padding: 0.42rem 0.95rem 0.5rem;
  border-radius: 999px;
  background: var(--chikku-forest);
  color: #f6f1e6;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  text-align: center;
  min-width: 5.8rem;
  position: relative;
  z-index: 0;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(12, 31, 19, 0.2);
}

.chikku-mascot {
  position: relative;
  z-index: 1;
  width: 108px;
  height: 108px;
  margin: 0 0 -16px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  flex: 0 0 auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(0 10px 18px rgba(12, 31, 19, 0.28));
  animation: chikku-idle 3.2s ease-in-out infinite;
}

.chikku-squash {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: 50% 78%;
  transition: transform 0.45s ease;
}

.chikku-squash.is-tilt-left {
  transform: rotate(-9deg);
}

.chikku-squash.is-tilt-right {
  transform: rotate(9deg);
}

.chikku-sheet {
  position: absolute;
  inset: 0;
  background-size: 300% 300%;
  background-repeat: no-repeat;
  transition: opacity 0.12s linear;
}

.chikku-sheet.is-dir {
  background-image: url("assets/mascots/tiger-directions.webp");
}

.chikku-sheet.is-react {
  background-image: url("assets/mascots/tiger-reactions.webp");
  opacity: 0;
}

.chikku-sheet.is-react.is-on {
  opacity: 1;
}

.chikku-sheet.is-dir.is-off {
  opacity: 0;
}

@keyframes chikku-idle {
  0%,
  100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes chikku-sheet-in {
  from { transform: translateY(24px); }
  to { transform: translateY(0); }
}

@media (max-width: 720px) {
  .chikku-mascot {
    width: 88px;
    height: 88px;
  }
}

@media (max-width: 820px) {
  .chikku.is-open {
    z-index: 90;
    inset: 0;
    right: auto;
    bottom: auto;
    width: 100%;
    max-width: none;
    align-items: stretch;
    justify-content: flex-end;
    gap: 0;
  }

  .chikku.is-open .chikku-scrim {
    position: absolute;
    inset: 0;
    background: rgba(12, 31, 19, 0.42);
    pointer-events: auto;
  }

  .chikku.is-open .chikku-dock {
    display: none;
  }

  .chikku.is-open .chikku-panel {
    position: relative;
    z-index: 1;
    width: 100%;
    height: min(36rem, 100%);
    max-height: 100%;
    min-height: 0;
    border-radius: 1.05rem 1.05rem 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    box-shadow: 0 -12px 40px rgba(12, 31, 19, 0.22);
    animation: chikku-sheet-in 0.28s ease-out;
  }

  .chikku.is-open .chikku-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .chikku.is-open .chikku-chips::-webkit-scrollbar {
    display: none;
  }

  html.chikku-sheet-open,
  html.chikku-sheet-open body {
    overflow: hidden;
    overscroll-behavior: none;
  }
}

.chikku-scrim {
  display: none;
}

.chikku.is-open .chikku-scrim {
  display: block;
}

@media (min-width: 821px) {
  .chikku-scrim {
    display: none !important;
  }

  .chikku-head-face {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chikku-mascot {
    animation: none;
  }

  .chikku.is-open .chikku-panel {
    animation: none;
  }
}

body.is-locked .chikku-panel,
body.is-locked .chikku-form,
body.is-locked .chikku-chip,
body.is-locked .chikku-composer {
  background: #12151a;
  color: #dfe7e0;
  border-color: rgba(223, 231, 224, 0.12);
}

body.is-locked .chikku-form input,
body.is-locked .chikku-msg.is-bot {
  background: #1a1e24;
  color: #dfe7e0;
}

body.is-locked .chikku-head p,
body.is-locked .chikku-msg.is-refuse {
  color: #9aa59c;
}

body.is-locked .chikku-msg.is-refuse {
  background: #241c16;
}

body.is-locked .chikku.is-open .chikku-scrim {
  background: rgba(0, 0, 0, 0.55);
}

/* transitions.dev — Streaming text */
:root {
  --stream-gap: 60ms;
  --stream-fade: 350ms;
  --stream-blur: 1px;
  --stream-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

.t-stream-w {
  opacity: 0;
  filter: blur(var(--stream-blur));
  transition:
    opacity var(--stream-fade) var(--stream-ease),
    filter var(--stream-fade) var(--stream-ease);
}
.t-stream-w.is-in {
  opacity: 1;
  filter: blur(0);
}

.t-stream-w.is-wait {
  display: none;
}

.chikku-msg.t-stream p:not(.is-live) {
  display: none;
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  .t-stream-w { transition: none !important; filter: none !important; opacity: 1 !important; }
}
