:root {
  --chat-bg: #f2f2f0;
  --chat-ink: #000000;
  --chat-line: #000000;
  --chat-link: #78bce8;
  --balloon-bg: #ffffe1;
  --balloon-border: #000000;
  --balloon-ink: #000000;
  --page-gutter: 20px;
  color-scheme: light dark;
}

html[data-theme="dark"],
[data-theme="dark"] {
  --chat-bg: #151618;
  --chat-ink: #f0f0f0;
  --chat-line: rgba(240, 240, 240, 0.3);
  --chat-link: #6ea8fe;
  --balloon-bg: #ffffdf;
  --balloon-border: #000000;
  --balloon-ink: #000000;
}

html[data-theme="light"],
[data-theme="light"] {
  --chat-bg: #f2f2f0;
  --chat-ink: #000000;
  --chat-line: #000000;
  --chat-link: #78bce8;
  --balloon-bg: #ffffe1;
  --balloon-border: #000000;
  --balloon-ink: #000000;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--chat-bg);
  color: var(--chat-ink);
  font-family: Arial, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
}

button,
input,
textarea,
a {
  font-family: inherit;
  color: inherit;
  user-select: auto;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid #0000ee;
  outline-offset: 1px;
}

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

/* Header & Nav */
.chat-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  padding: var(--page-gutter);
  background: var(--chat-bg);
  border-bottom: none;
  z-index: 20;
}

.chat-nav {
  display: flex;
  align-items: center;
  gap: 28px;
  font-size: 20px;
  line-height: 25px;
}

.chat-nav a {
  color: var(--chat-ink);
  text-decoration: none;
  font-weight: 400;
  opacity: 1;
}

.chat-nav a:hover,
.chat-nav a:focus-visible {
  color: #78bce8;
}

.chat-nav a[aria-current="page"] {
  text-decoration-line: underline;
  text-decoration-style: solid;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 5px;
}

/* Main Container */
.chat-main {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Canvas Physics Container */
.chat-physics-container {
  position: absolute;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  z-index: 1;
}

#chat-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#chat-canvas:active {
  cursor: grabbing;
}

/* Empty hint */
.chat-empty-hint {
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--chat-ink);
  opacity: 0.45;
  font-size: 15px;
  line-height: 1.7;
  pointer-events: none;
  max-width: 440px;
  padding: 0 20px;
}

/* Assistant Rover & Speech Balloon Container */
.chat-assistant-container {
  position: absolute;
  bottom: 16px;
  right: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  z-index: 30;
  pointer-events: none;
}

/* Speech Balloon (노란색 박스) */
.chat-balloon {
  position: relative;
  width: 290px;
  background: var(--balloon-bg);
  border: none;
  border-radius: 6px;
  box-shadow: none;
  color: var(--balloon-ink);
  padding: 12px 14px 10px;
  margin-bottom: 26px;
  pointer-events: auto;
  animation: balloon-appear 250ms ease-out;
}

@keyframes balloon-appear {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.balloon-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 4px;
}

.balloon-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: #000000;
  letter-spacing: -0.01em;
}

.balloon-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  padding: 0;
  margin-top: -2px;
  margin-right: -2px;
  background: transparent;
  border: none;
  border-radius: 0;
  cursor: pointer;
  color: #000000;
  opacity: 0.65;
  transition: opacity 120ms ease;
}

.balloon-toggle-btn:hover {
  opacity: 1;
  background: transparent;
  border: none;
}

.chat-balloon.is-collapsed {
  display: none;
}

.balloon-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.balloon-inputs-row {
  display: flex;
  gap: 6px;
}

.balloon-field {
  flex: 1;
  min-width: 0;
}

.balloon-input {
  width: 100%;
  height: 27px;
  padding: 0 8px;
  font-size: 12px;
  background: #ffffff;
  color: #000000;
  border: 1px solid #d4d4aa;
  border-radius: 3px;
  box-shadow: none;
}

.balloon-input:focus,
.balloon-textarea:focus {
  border-color: #000000;
  outline: none;
}

.balloon-textarea-wrap {
  width: 100%;
}

.balloon-textarea {
  width: 100%;
  height: 60px;
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.45;
  background: #ffffff;
  color: #000000;
  border: 1px solid #d4d4aa;
  border-radius: 3px;
  box-shadow: none;
  resize: none;
}

.balloon-status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 14px;
  font-size: 11px;
}

.balloon-alert {
  color: #dc2626;
  font-weight: 600;
}

.balloon-counter {
  color: #666666;
  margin-left: auto;
}

.balloon-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 4px;
}

.balloon-link-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  font-family: inherit;
  color: #000000;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  transition: color 120ms ease;
}

.balloon-link-btn:hover {
  color: #0000ee;
}

.balloon-action-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.balloon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 25px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 500;
  background: #ffffe8;
  color: #000000;
  border: 1px solid #999980;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: none;
  transition: all 120ms ease;
}

.balloon-btn:hover {
  background: #ffffff;
  border-color: #000000;
}

.balloon-btn:active {
  background: #eae8d0;
}

.balloon-btn.submit-btn {
  font-weight: 600;
}

.balloon-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Balloon Tail (말풍선 꼬리) */
.balloon-tail {
  position: absolute;
  bottom: -15px;
  right: 36px;
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.balloon-tail::before {
  display: none;
}

.balloon-tail::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  border-width: 16px 14px 0 0;
  border-style: solid;
  border-color: var(--balloon-bg) transparent transparent transparent;
}

/* 3D Rover Dog Avatar */
.chat-dog-avatar {
  position: relative;
  display: inline-block;
  margin-right: 14px;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 120ms ease;
}

.chat-dog-avatar:hover {
  transform: scale(1.06);
}

.chat-dog-avatar:active {
  transform: scale(0.95);
}

.chat-dog-img {
  display: block;
  width: 74px;
  height: auto;
  image-rendering: pixelated;
}

/* Theme toggle button positioned at bottom-left */
.theme-toggle-btn {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 9999;
  width: 12px;
  height: 12px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--chat-ink);
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 200ms ease, transform 200ms ease;
}

.theme-toggle-btn:hover {
  opacity: 1;
  transform: scale(1.3);
}

/* Responsive Rules */
@media (max-width: 768px) {
  .chat-header {
    padding: 15px;
    height: auto;
  }

  .chat-nav {
    gap: 20px;
    min-width: 0;
    overflow-x: auto;
    scroll-padding-right: 8px;
    scrollbar-width: none;
    font-size: 16px;
    line-height: 22px;
  }

  .chat-nav a {
    white-space: nowrap;
  }

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

  .chat-assistant-container {
    bottom: 10px;
    right: 12px;
    left: 12px;
    align-items: flex-end;
  }

  .chat-balloon {
    width: 100%;
    max-width: 320px;
    padding: 10px 12px 8px;
    margin-bottom: 20px;
  }

  .chat-dog-img {
    width: 58px;
  }

  .balloon-input,
  .balloon-textarea,
  .paw-edit-input,
  .paw-edit-textarea {
    font-size: 16px;
  }
}

/* ==========================================================================
   Dog Paw Inspection & In-Place Card Edit Stage (강아지 손바닥 카드 인터랙션)
   ========================================================================== */
.chat-paw-stage {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  overflow: hidden;
  display: block;
}

.chat-paw-stage.is-active {
  pointer-events: auto;
}

.chat-paw-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms ease;
}

.chat-paw-stage.is-active .chat-paw-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.chat-paw-wrap {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 380px;
  max-width: 90vw;
  transform: translate(-50%, 105%);
  transition: transform 450ms cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
  will-change: transform;
}

.chat-paw-stage.is-active .chat-paw-wrap {
  transform: translate(-50%, 0);
}

.chat-paw-img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  pointer-events: none;
}

.chat-paw-card {
  position: absolute;
  top: 24%;
  left: 50%;
  transform: translateX(-50%) rotate(var(--paw-card-rot, -6deg));
  width: 320px;
  max-width: 86vw;
  background: #ffffec;
  border: 1px solid #111111;
  border-radius: 4px;
  padding: 12px 14px 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  color: #111111;
  font-family: inherit;
  box-sizing: border-box;
  transform-origin: center center;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.chat-paw-card.is-green {
  background: #eaf6ec;
}

.chat-paw-card:hover {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

/* Card Header */
.paw-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
  line-height: 1.3;
}

.paw-card-user {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  color: #000000;
}

.paw-card-lock {
  font-size: 11px;
  line-height: 1;
}

.paw-card-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #666666;
}

.paw-card-close {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font-size: 16px;
  line-height: 1;
  color: #222222;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 120ms ease;
}

.paw-card-close:hover {
  opacity: 1;
}

/* Card Body */
.paw-card-body {
  font-size: 13px;
  line-height: 1.45;
  color: #111111;
  word-break: break-word;
  white-space: pre-wrap;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 8px;
}

/* Card Footer */
.paw-card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 18px;
}

.paw-card-edit-link {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  font-family: inherit;
  color: #000000;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  transition: color 120ms ease;
}

.paw-card-edit-link:hover {
  color: #0000ee;
}

/* Card In-Place Edit Form */
.paw-edit-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.paw-edit-label {
  font-size: 11px;
  font-weight: 700;
  color: #333333;
}

.paw-edit-input {
  width: 100%;
  height: 27px;
  padding: 0 8px;
  font-size: 12px;
  background: #ffffff;
  color: #000000;
  border: 1px solid #d4d4aa;
  border-radius: 3px;
  box-sizing: border-box;
}

.paw-edit-textarea {
  width: 100%;
  height: 72px;
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.42;
  background: #ffffff;
  color: #000000;
  border: 1px solid #d4d4aa;
  border-radius: 3px;
  box-sizing: border-box;
  resize: none;
}

.paw-edit-input:focus,
.paw-edit-textarea:focus {
  border-color: #000000;
  outline: none;
}

.paw-edit-alert {
  font-size: 11px;
  color: #dc2626;
  font-weight: 600;
  min-height: 14px;
}

.paw-edit-alert.is-success {
  color: #16a34a;
}

.paw-edit-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 4px;
}

.paw-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: auto;
  padding: 0;
  font-size: 12px;
  font-family: inherit;
  background: none;
  color: #000000;
  border: none;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  transition: color 120ms ease;
}

.paw-edit-btn:hover {
  color: #0000ee;
}

.paw-edit-btn.save-btn {
  font-weight: 600;
}

.paw-edit-btn.delete-btn {
  margin-right: auto;
  color: #dc2626;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.paw-edit-btn.delete-btn:hover {
  color: #b91c1c;
}

.paw-edit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mobile responsive for dog paw */
@media (max-width: 640px) {
  .chat-paw-wrap {
    width: 275px;
  }
  .chat-paw-card {
    top: 22%;
    width: 240px;
    padding: 10px 12px 8px;
  }
  .paw-card-body {
    font-size: 12px;
    max-height: 130px;
  }
  .paw-edit-textarea {
    height: 60px;
  }
}

