/* Light native chat — Skill Space (mobile + elder-friendly) */
.ss-chat {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 60;
  font-family: var(--font, "Manrope", system-ui, sans-serif);
}

body.ss-chat-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  left: 0;
  right: 0;
  touch-action: none;
}

.ss-chat-backdrop {
  position: fixed;
  inset: 0;
  z-index: 59;
  background: rgba(31, 42, 46, 0.45);
  -webkit-tap-highlight-color: transparent;
}

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

.ss-chat-fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border: none;
  border-radius: 999px;
  padding: 0;
  background: var(--dark, #1f2a2e);
  color: var(--primary, #c1ff72);
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(31, 42, 46, 0.22);
  transition: transform 0.15s ease, background 0.15s ease;
}

.ss-chat-fab:hover {
  transform: translateY(-1px);
}

.ss-chat.is-open .ss-chat-fab {
  display: none;
}

.ss-chat-fab-ico {
  display: block;
}

.ss-chat-panel {
  position: relative;
  right: 0;
  bottom: 0;
  z-index: 61;
  width: min(360px, calc(100vw - 1.5rem));
  max-height: min(520px, calc(100dvh - 2rem));
  height: min(520px, calc(100dvh - 2rem));
  display: flex;
  flex-direction: column;
  background: var(--white, #fff);
  border: 1px solid var(--border, #e0e6eb);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(31, 42, 46, 0.18);
  overflow: hidden;
}

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

.ss-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border, #e0e6eb);
  background: linear-gradient(180deg, rgba(193, 255, 114, 0.22), transparent);
}

.ss-chat-head strong {
  display: block;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.ss-chat-x {
  flex-shrink: 0;
  border: 1px solid var(--border, #e0e6eb);
  background: var(--white, #fff);
  font-size: 1.5rem;
  line-height: 1;
  color: var(--dark, #1f2a2e);
  cursor: pointer;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.ss-chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 0.85rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: var(--surface, #f4f8fa);
}

.ss-chat-row {
  display: flex;
}

.ss-chat-row.is-user {
  justify-content: flex-end;
}

.ss-chat-row.is-bot {
  justify-content: flex-start;
}

.ss-chat-bubble {
  max-width: 92%;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.ss-chat-row.is-user .ss-chat-bubble {
  background: var(--dark, #1f2a2e);
  color: var(--white, #fff);
  border-bottom-right-radius: 5px;
}

.ss-chat-row.is-bot .ss-chat-bubble {
  background: var(--white, #fff);
  color: var(--dark, #1f2a2e);
  border: 1px solid var(--border, #e0e6eb);
  border-bottom-left-radius: 5px;
}

.ss-chat-row.is-wait .ss-chat-bubble {
  color: var(--muted, #6b7a86);
  font-weight: 650;
}

.ss-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  min-height: 1.1em;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.ss-chat-dot {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: var(--muted, #6b7a86);
  opacity: 0.35;
  animation: ss-chat-bounce 1.05s ease-in-out infinite;
}

.ss-chat-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.ss-chat-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes ss-chat-bounce {
  0%,
  70%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  35% {
    transform: translateY(-0.28rem);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ss-chat-dot {
    animation: none;
    opacity: 0.65;
  }
}

.ss-chat-quiet {
  align-self: center;
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--muted, #6b7a86);
  padding: 0.25rem 0.35rem;
  text-align: center;
}

.ss-chat-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  padding: 0.15rem 0 0.35rem;
  flex-shrink: 0;
}

.ss-chat-chip {
  border: 1px solid var(--border, #e0e6eb);
  background: var(--white, #fff);
  color: var(--dark, #1f2a2e);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.35;
  min-height: 2.75rem;
  text-align: left;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}

.ss-chat-chip:active {
  border-color: #b7d48a;
  background: rgba(193, 255, 114, 0.25);
}

.ss-chat-chip.is-primary {
  background: var(--primary, #c1ff72);
  border-color: rgba(193, 255, 114, 0.9);
  text-align: center;
}

.ss-chat-confirm {
  align-self: stretch;
  background: var(--white, #fff);
  border: 1px solid var(--border, #e0e6eb);
  border-radius: 14px;
  padding: 0.85rem 0.95rem;
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.45;
  color: var(--dark, #1f2a2e);
}

.ss-chat-confirm-kicker {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted, #6b7a86);
  margin-bottom: 0.35rem;
}

.ss-chat-confirm b {
  font-weight: 800;
}

.ss-chat-confirm div + div {
  margin-top: 0.25rem;
  color: var(--muted, #6b7a86);
  font-weight: 650;
}

.ss-chat-form[hidden] {
  display: none !important;
}

.ss-chat-form {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  padding: 0.75rem 0.85rem;
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border, #e0e6eb);
  background: var(--white, #fff);
}

.ss-chat-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border, #e0e6eb);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  font: inherit;
  font-weight: 600;
  font-size: 16px;
  min-height: 3rem;
  background: var(--surface, #f4f8fa);
  color: var(--dark, #1f2a2e);
}

.ss-chat-form input:focus {
  outline: none;
  border-color: #b7d48a;
  background: var(--white, #fff);
}

.ss-chat-send {
  flex-shrink: 0;
  border: none;
  border-radius: 12px;
  min-width: 3rem;
  min-height: 3rem;
  padding: 0 0.85rem;
  background: var(--primary, #c1ff72);
  color: var(--dark, #1f2a2e);
  font: inherit;
  font-weight: 800;
  font-size: 1.25rem;
  cursor: pointer;
}

.ss-chat-send:disabled,
.ss-chat-form input:disabled {
  opacity: 0.55;
  cursor: default;
}

@media (max-width: 520px) {
  .ss-chat {
    right: 0.75rem;
    bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  }

  .ss-chat.is-open {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: stretch;
    padding: 0;
    pointer-events: none;
  }

  .ss-chat.is-open .ss-chat-backdrop {
    pointer-events: auto;
  }

  .ss-chat.is-open .ss-chat-panel {
    pointer-events: auto;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: min(72dvh, calc(100svh - env(safe-area-inset-top, 0px) - 3rem));
    margin: 0;
    border-radius: 18px 18px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    box-shadow: 0 -8px 32px rgba(31, 42, 46, 0.2);
  }

  .ss-chat-head strong {
    font-size: 1.1rem;
  }

  .ss-chat-bubble {
    font-size: 1.05rem;
  }

  .ss-chat-chip {
    font-size: 1.05rem;
    min-height: 3rem;
  }
}
