/* Shared public AI counselor shell. The API state remains server-authoritative. */
:root {
  --rm-ai-ink: #17131e;
  --rm-ai-muted: #6c6674;
  --rm-ai-line: rgba(28, 20, 44, 0.13);
  --rm-ai-paper: #fffdf9;
  --rm-ai-purple: #6739e8;
  --rm-ai-pink: #f32b8b;
  --rm-ai-aqua: #08bdb9;
  --rm-ai-shadow: 0 20px 60px rgba(38, 22, 70, 0.2);
}

.rm-ai-assistant,
.rm-ai-assistant * { box-sizing: border-box; }

.rm-ai-assistant {
  position: fixed;
  right: 18px;
  bottom: 18px;
  left: auto;
  z-index: 2400;
  color: var(--rm-ai-ink);
  font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", Inter, system-ui, sans-serif;
}

.rm-ai-launcher-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.rm-ai-launcher {
  position: relative;
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  padding: 0;
  overflow: hidden;
  border: 3px solid #fff;
  border-radius: 50%;
  background: linear-gradient(145deg, #703cf0, #3d1da0);
  box-shadow: 0 12px 32px rgba(45, 24, 100, 0.27), 0 0 0 1px rgba(103, 57, 232, 0.22);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.rm-ai-launcher:hover,
.rm-ai-launcher:focus-visible {
  transform: translateY(-3px) rotate(-2deg);
  box-shadow: 0 17px 36px rgba(45, 24, 100, 0.34), 0 0 0 4px rgba(243, 43, 139, 0.2);
}

.rm-ai-launcher:focus-visible,
.rm-ai-dialog button:focus-visible,
.rm-ai-dialog textarea:focus-visible {
  outline: 3px solid rgba(8, 189, 185, 0.62);
  outline-offset: 3px;
}

.rm-ai-launcher-character {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: right center;
}

.rm-ai-launcher-spark {
  position: absolute;
  top: 5px;
  right: 9px;
  color: #ffe052;
  font-size: 1rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.24);
}

.rm-ai-speech-bubble {
  position: relative;
  max-width: 196px;
  margin-bottom: 46px;
  padding: 11px 15px;
  border: 2px solid var(--rm-ai-ink);
  border-radius: 18px 18px 18px 4px;
  background: var(--rm-ai-paper);
  box-shadow: 5px 5px 0 var(--rm-ai-pink);
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: -0.035em;
}

.rm-ai-speech-bubble::after {
  content: "";
  position: absolute;
  right: -10px;
  bottom: -2px;
  width: 16px;
  height: 16px;
  border-right: 2px solid var(--rm-ai-ink);
  border-bottom: 2px solid var(--rm-ai-ink);
  background: var(--rm-ai-paper);
  transform: skew(28deg) rotate(28deg);
}

.rm-ai-speech-bubble small {
  display: block;
  margin-top: 3px;
  color: var(--rm-ai-purple);
  font-size: 0.68rem;
  letter-spacing: 0.03em;
}

.rm-ai-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(19, 13, 30, 0.28);
  backdrop-filter: blur(2px);
}

.rm-ai-dialog {
  position: fixed;
  right: 18px;
  bottom: 18px;
  left: auto;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  width: min(404px, calc(100vw - 36px));
  max-height: min(720px, calc(100dvh - 36px));
  overflow: hidden;
  border: 1px solid var(--rm-ai-line);
  border-radius: 24px;
  background: var(--rm-ai-paper);
  box-shadow: var(--rm-ai-shadow);
}

[data-theme="dark"] .rm-ai-dialog,
[data-theme="dark"] .rm-ai-speech-bubble { background: #211d2c; color: #fff; }

[data-theme="dark"] .rm-ai-speech-bubble::after { background: #211d2c; }

.rm-ai-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 12px;
  background: linear-gradient(120deg, rgba(103, 57, 232, 0.12), rgba(243, 43, 139, 0.1));
}

.rm-ai-dialog-kicker {
  margin: 0 0 3px;
  color: var(--rm-ai-pink);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.rm-ai-dialog-header h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.055em;
}

.rm-ai-dialog-header p {
  margin: 4px 0 0;
  color: var(--rm-ai-muted);
  font-size: 0.73rem;
}

.rm-ai-close {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--rm-ai-line);
  border-radius: 50%;
  background: transparent;
  font-size: 1.2rem;
  line-height: 1;
}

.rm-ai-status {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 35px;
  padding: 0 18px;
  border-bottom: 1px solid var(--rm-ai-line);
  color: var(--rm-ai-muted);
  font-size: 0.72rem;
}

.rm-ai-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rm-ai-aqua);
  box-shadow: 0 0 0 4px rgba(8, 189, 185, 0.13);
}

.rm-ai-status.is-busy .rm-ai-status-dot { background: var(--rm-ai-pink); animation: rm-ai-pulse 900ms ease-in-out infinite; }
.rm-ai-status.is-locked .rm-ai-status-dot { background: #e4572e; box-shadow: 0 0 0 4px rgba(228, 87, 46, 0.13); }

@keyframes rm-ai-pulse {
  50% { opacity: 0.35; transform: scale(0.76); }
}

.rm-ai-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 160px;
  overflow: auto;
  padding: 16px 16px 12px;
  overscroll-behavior: contain;
}

.rm-ai-message {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 15px;
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.rm-ai-message.is-assistant { align-self: flex-start; border: 1px solid var(--rm-ai-line); background: rgba(103, 57, 232, 0.08); }
.rm-ai-message.is-user { align-self: flex-end; color: #fff; background: var(--rm-ai-purple); }
.rm-ai-message.is-system { align-self: stretch; max-width: none; border: 1px dashed rgba(228, 87, 46, 0.45); background: rgba(228, 87, 46, 0.08); color: var(--rm-ai-muted); font-size: 0.75rem; }

.rm-ai-message a { color: inherit; font-weight: 800; text-decoration: underline; }

.rm-ai-quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 12px;
}

.rm-ai-quick-prompts button {
  padding: 7px 9px;
  border: 1px solid rgba(103, 57, 232, 0.2);
  border-radius: 999px;
  background: rgba(103, 57, 232, 0.06);
  color: var(--rm-ai-purple);
  font-size: 0.7rem;
  font-weight: 750;
}

.rm-ai-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--rm-ai-line);
}

.rm-ai-compose textarea {
  min-height: 48px;
  max-height: 120px;
  resize: vertical;
  padding: 11px 12px;
  border: 1px solid var(--rm-ai-line);
  border-radius: 13px;
  background: transparent;
  font-size: 0.82rem;
  line-height: 1.4;
}

.rm-ai-compose button[type="submit"] {
  align-self: end;
  min-width: 64px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: var(--rm-ai-pink);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 850;
}

.rm-ai-compose button:disabled { cursor: not-allowed; opacity: 0.42; }

.rm-ai-turn-meter {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--rm-ai-muted);
  font-size: 0.68rem;
}

.rm-ai-turn-meter strong { color: var(--rm-ai-purple); }

.rm-ai-locked-note {
  grid-column: 1 / -1;
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(228, 87, 46, 0.1);
  color: #9a3c22;
  font-size: 0.72rem;
  line-height: 1.45;
}

@media (max-width: 640px) {
  .rm-ai-assistant { right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); left: auto; }
  .rm-ai-dialog { right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); left: max(12px, env(safe-area-inset-left)); width: auto; max-height: calc(100dvh - 24px); }
  .rm-ai-speech-bubble { max-width: 156px; margin-bottom: 42px; }
  .rm-ai-launcher { width: 66px; height: 66px; }
}

@media (prefers-reduced-motion: reduce) {
  .rm-ai-launcher,
  .rm-ai-status-dot { transition: none; animation: none; }
}
