:root {
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --line: #e8e8e8;
  --soft: #f4f4f4;
  --accent: #e31c23;
  --user: #1a1a1a;
  --font: "Noto Sans", sans-serif;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: #ffffff;
  min-height: 100dvh;
  overflow: hidden;
}

.shell {
  position: relative;
  width: min(680px, 100%);
  height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #ffffff;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  display: block;
  height: 36px;
  width: auto;
  object-fit: contain;
}

.reset-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.4rem 0;
  cursor: pointer;
}

.reset-btn:hover {
  color: var(--ink);
}

.chat {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 0;
  background: #ffffff;
}

.messages-wrap {
  position: relative;
  min-height: 0;
  display: grid;
}

.messages {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 16px 48px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  scroll-behavior: smooth;
  background: #ffffff;
}

.messages-fade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 72px;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), #ffffff 85%);
}

.row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: min(92%, 420px);
}

.row.bot {
  align-self: flex-start;
  margin-right: auto;
  max-width: min(100%, 520px);
}

.row.bot + .row.bot {
  margin-top: -2px;
}

.row.user {
  align-self: flex-end;
  align-items: flex-end;
  margin-left: auto;
  margin-top: 8px;
  margin-bottom: 4px;
}

.row.full {
  max-width: 100%;
  width: 100%;
  margin-top: 4px;
  margin-bottom: 4px;
}

.row.options-row {
  align-self: flex-end;
  align-items: flex-end;
  margin-left: auto;
  max-width: min(100%, 520px);
  width: 100%;
}

.bubble {
  font-size: 0.95rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.row.bot .bubble {
  color: var(--ink);
  padding: 0;
}

.row.user .bubble {
  background: var(--user);
  color: #fff;
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  text-align: left;
  width: fit-content;
  max-width: 100%;
}

.row.bot .bubble.streaming::after {
  content: "";
  display: inline-block;
  width: 0.45em;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -0.15em;
  background: var(--ink);
  animation: caret 0.8s steps(1) infinite;
}

.bubble strong {
  font-weight: 700;
}

.bubble p {
  margin: 0 0 0.45em;
}

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

.options {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  width: 100%;
}

.options.enter .option-btn,
.row.enter .card-btn {
  opacity: 0;
  animation: option-enter 0.38s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: var(--enter-delay, 0ms);
}

.option-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.option-btn:hover:not(:disabled) {
  border-color: #bbb;
  background: var(--soft);
}

.option-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.cards-scroll {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
  scrollbar-width: thin;
}

.cards {
  display: flex;
  gap: 12px;
  width: max-content;
}

.card-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0;
  width: 200px;
  flex: 0 0 auto;
  border-radius: 12px;
  overflow: hidden;
  text-align: left;
  cursor: pointer;
  scroll-snap-align: start;
  font: inherit;
  transition: border-color 0.15s ease;
}

.card-btn:hover:not(:disabled) {
  border-color: #bbb;
}

.card-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.card-skeleton {
  pointer-events: none;
  cursor: default;
}

.skeleton-bone,
.skeleton-line {
  background: linear-gradient(
    90deg,
    #ececec 0%,
    #f6f6f6 45%,
    #ececec 90%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.15s ease-in-out infinite;
}

.skeleton-line {
  display: block;
  height: 10px;
  border-radius: 4px;
}

.skeleton-title {
  width: 42%;
  height: 13px;
}

.skeleton-loc {
  width: 88%;
}

.skeleton-price {
  width: 52%;
  margin-top: 2px;
}

.card-image {
  display: block;
  width: 100%;
  height: 120px;
  background-color: var(--soft);
  background-size: cover;
  background-position: center;
}

.card-image.tone-a {
  background-image: linear-gradient(145deg, #e8e8e8 0%, #cfcfcf 100%);
}

.card-image.tone-b {
  background-image: linear-gradient(145deg, #ece7e2 0%, #d4cdc5 100%);
}

.card-image.tone-c {
  background-image: linear-gradient(145deg, #e4e8ec 0%, #c8d0d8 100%);
}

.card-image.tone-d {
  background-image: linear-gradient(145deg, #ebe6e6 0%, #d2c8c8 100%);
}

.card-body {
  display: grid;
  gap: 3px;
  padding: 10px 12px 12px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.card-loc,
.card-price {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.35;
}

.card-price {
  color: var(--ink);
  font-weight: 600;
  margin-top: 2px;
}

.thinking {
  display: inline-flex;
  align-items: center;
  padding: 4px 0;
  min-height: 1.2em;
}

.thinking span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9a9a9a;
  animation: pulse-dot 0.7s ease-in-out infinite;
}

.composer {
  position: relative;
  z-index: 2;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.composer form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.composer input {
  flex: 1;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  outline: none;
  font: inherit;
  font-size: 0.95rem;
  background: transparent;
  color: var(--ink);
  min-width: 0;
  padding: 10px 0;
}

.composer input:focus {
  border-bottom-color: var(--ink);
}

.composer input::placeholder {
  color: #aaa;
}

.composer button {
  appearance: none;
  border: 0;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  cursor: pointer;
}

.composer button:hover {
  filter: brightness(0.95);
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.12);
  display: grid;
  gap: 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.modal-body {
  padding: 16px 18px;
}

.summary-list {
  margin: 0;
  display: grid;
  gap: 10px;
}

.summary-list div {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px;
  font-size: 0.9rem;
  line-height: 1.4;
}

.summary-list dt {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
}

.summary-list dd {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
}

.summary-note {
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--muted);
}

.modal-footer {
  padding: 0 18px 18px;
  display: flex;
  justify-content: flex-end;
}

.modal-primary {
  appearance: none;
  border: 0;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
}

.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;
}

@keyframes pulse-dot {
  0%,
  100% {
    transform: scale(0.75);
    opacity: 0.35;
  }
  50% {
    transform: scale(1.15);
    opacity: 1;
  }
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

@keyframes option-enter {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes caret {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

@media (min-width: 640px) {
  .topbar {
    padding: 20px 24px 14px;
  }

  .brand-logo {
    height: 42px;
  }

  .messages {
    padding: 28px 24px 56px;
  }

  .cards-scroll {
    margin: 0 -24px;
    padding-left: 24px;
    padding-right: 24px;
  }

  .card-btn {
    width: 220px;
  }

  .card-image {
    height: 132px;
  }

  .composer {
    padding: 14px 24px 24px;
  }

  .summary-list div {
    grid-template-columns: 140px 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .thinking span,
  .options.enter .option-btn,
  .row.enter .card-btn {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .messages {
    scroll-behavior: auto;
  }
}
