:root {
  color-scheme: light;
  --bg: #f5f8f8;
  --surface: #ffffff;
  --text: #27313a;
  --muted: #66737d;
  --primary-dark: #007c80;
  --primary: #0fa7a5;
  --border: #dbe4e7;
  --subtle: #eef3f4;
  --primary-soft: rgba(15, 167, 165, 0.16);
  --error: #b42318;
  --warning: #b54708;
  --shadow: 0 18px 45px rgba(39, 49, 58, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Arial, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--primary-soft);
  outline-offset: 2px;
}

[v-cloak] {
  display: none;
}

.app-shell {
  display: flex;
  flex-direction: column;
  width: min(100%, 720px);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  border-right: 1px solid var(--border);
  border-left: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  gap: 14px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.language-switcher {
  display: inline-flex;
  align-items: center;
}

.language-switcher button {
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.language-switcher button + button {
  margin-left: -1px;
}

.language-switcher button:hover,
.language-switcher button:focus-visible {
  border-color: var(--primary);
  position: relative;
  z-index: 1;
}

.language-switcher button:focus-visible {
  outline: 2px solid var(--primary-soft);
}

.language-switcher button.active {
  position: relative;
  z-index: 2;
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
}

.composer-actions,
.product-meta,
.product-actions {
  display: flex;
  align-items: center;
}

.app-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.ghost-button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--primary);
  color: var(--primary-dark);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.workspace {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.intro-panel {
  flex: 0 0 auto;
  margin: 14px 14px 0;
  padding: 16px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.intro-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.chat-panel {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border: 0;
  background: var(--surface);
  box-shadow: none;
}

.message-list {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 14px;
  scroll-behavior: smooth;
  scrollbar-color: var(--border) transparent;
}

.message-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
}

.message-row.user {
  flex-direction: row-reverse;
}

.avatar {
  display: grid;
  flex: 0 0 30px;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  color: var(--primary-dark);
  background: var(--surface);
  font-size: 12px;
  font-weight: 800;
}

.message-row.user .avatar {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
}

.message-column {
  width: min(100%, 600px);
}

.message-row.user .message-column {
  display: flex;
  justify-content: flex-end;
}

.message-bubble {
  display: inline-block;
  max-width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.message-row.user .message-bubble {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
}

.message-row.user .message-bubble p {
  margin: 0;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.6;
}

.markdown-content {
  max-width: 100%;
  overflow-x: auto;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.65;
}

.markdown-content > :first-child {
  margin-top: 0;
}

.markdown-content > :last-child {
  margin-bottom: 0;
}

.markdown-content p,
.markdown-content ul,
.markdown-content ol,
.markdown-content blockquote,
.markdown-content pre,
.markdown-content table {
  margin: 0 0 12px;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4 {
  margin: 18px 0 8px;
  color: var(--text);
  line-height: 1.35;
}

.markdown-content h1 {
  font-size: 20px;
}

.markdown-content h2 {
  font-size: 18px;
}

.markdown-content h3,
.markdown-content h4 {
  font-size: 15px;
}

.markdown-content ul,
.markdown-content ol {
  padding-left: 22px;
}

.markdown-content li + li {
  margin-top: 4px;
}

.markdown-content blockquote {
  padding: 8px 12px;
  border-left: 3px solid var(--primary);
  color: var(--muted);
  background: var(--primary-soft);
}

.markdown-content code {
  padding: 1px 4px;
  border-radius: 2px;
  background: var(--subtle);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
}

.markdown-content pre {
  overflow-x: auto;
  padding: 12px;
  background: var(--subtle);
}

.markdown-content pre code {
  padding: 0;
  background: transparent;
}

.markdown-content a {
  color: var(--primary-dark);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.markdown-content table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.markdown-content th,
.markdown-content td {
  padding: 8px 10px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.markdown-content th {
  color: var(--primary-dark);
  background: var(--subtle);
  font-weight: 800;
}

.markdown-content tr:nth-child(even) td {
  background: var(--bg);
}

.question-card {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.question-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.question-heading span {
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 800;
}

.question-heading small,
.answered-note {
  color: var(--muted);
  font-size: 12px;
}

.option-list {
  display: grid;
  gap: 9px;
}

.option-card {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.option-card:hover:not(:disabled),
.option-card.active,
.option-card.selected,
.option-card.selected:disabled {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-1px);
}

.option-card:disabled {
  cursor: default;
  opacity: 0.62;
}

.option-card.selected:disabled {
  opacity: 1;
}

.option-radio {
  position: relative;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  border: 2px solid var(--primary);
  border-radius: 50%;
}

.option-card.selected .option-radio::after {
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--primary);
  content: "";
}

.option-copy {
  display: grid;
  gap: 4px;
}

.option-copy strong {
  color: var(--text);
  font-size: 14px;
}

.option-copy small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.custom-answer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 10px;
}

.custom-answer input {
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface);
}

.custom-answer input:focus {
  border-color: var(--primary);
}

.custom-answer button,
.send-button {
  border: 1px solid var(--primary);
  color: #fff;
  background: var(--primary);
  cursor: pointer;
  font-weight: 800;
}

.custom-answer button {
  padding: 0 18px;
}

.answered-note {
  margin: 12px 0 0;
}

.product-card {
  display: grid;
  grid-template-columns: 1fr;
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}

.product-image-wrap {
  position: relative;
  min-height: 210px;
  border-right: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.product-image-wrap img {
  width: 100%;
  height: 100%;
  min-height: 210px;
  max-height: 280px;
  object-fit: contain;
}

.match-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 6px 9px;
  color: #fff;
  background: var(--primary-dark);
  font-size: 11px;
  font-weight: 800;
}

.match-badge.approximate {
  background: var(--warning);
}

.product-content {
  min-width: 0;
  padding: 17px;
}

.product-meta,
.product-actions {
  justify-content: space-between;
  gap: 16px;
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.product-content h3 {
  margin: 10px 0 4px;
  font-size: 22px;
  line-height: 1.2;
}

.reason-block {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--bg);
}

.reason-block h4 {
  margin: 0 0 7px;
  font-size: 12px;
}

.reason-block ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.specification-panel {
  margin-top: 15px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.specification-panel summary {
  padding: 11px 0;
  color: var(--primary-dark);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.specification-panel dl {
  display: grid;
  grid-template-columns: minmax(90px, 0.7fr) minmax(0, 1.3fr);
  margin: 0 0 12px;
  border-top: 1px solid var(--border);
}

.specification-panel dt,
.specification-panel dd {
  margin: 0;
  padding: 7px 8px;
  border-bottom: 1px solid var(--subtle);
  font-size: 11px;
  line-height: 1.4;
}

.specification-panel dt {
  color: var(--text);
  background: var(--bg);
  font-weight: 700;
}

.specification-panel dd {
  color: var(--muted);
}

.product-actions {
  margin-top: 14px;
  align-items: flex-end;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 0;
}

.product-actions a,
.source-list a {
  color: var(--primary-dark);
  font-weight: 800;
  text-decoration: none;
}

.product-actions a:hover,
.source-list a:hover {
  text-decoration: underline;
}

.human-use-warning {
  display: grid;
  gap: 4px;
  margin-top: 16px;
  padding: 11px 12px;
  border: 1px solid var(--warning);
  color: var(--warning);
  background: #fff7ed;
  font-size: 11px;
  line-height: 1.5;
}

.human-use-warning strong:first-child {
  letter-spacing: 0.08em;
}

.source-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 10px;
  padding: 10px 12px;
  border-left: 3px solid var(--primary);
  background: var(--bg);
  font-size: 11px;
}

.source-list span {
  color: var(--muted);
  font-weight: 700;
}

.speech-button {
  margin-top: 9px;
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
}

.speech-button:hover {
  color: var(--primary-dark);
}

.speech-button.playing {
  color: var(--primary-dark);
  font-weight: 800;
}

.pending-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.pending-bubble > span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  animation: bounce 1.1s infinite ease-in-out;
}

.pending-bubble > span:nth-child(2) {
  animation-delay: 0.15s;
}

.pending-bubble > span:nth-child(3) {
  animation-delay: 0.3s;
}

.pending-bubble p {
  margin: 0 0 0 7px;
  color: var(--muted);
  font-size: 12px;
}

@keyframes bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-4px);
  }
}

.configuration-warning,
.error-banner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0 20px 12px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
}

.configuration-warning {
  border-left: 3px solid var(--warning);
  color: var(--warning);
  background: #fff7ed;
}

.error-banner {
  border-left: 3px solid var(--error);
  color: var(--error);
  background: #fef3f2;
}

.error-banner button {
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.composer {
  flex: 0 0 auto;
  padding: 13px 14px;
  padding-bottom: calc(13px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  max-height: 140px;
  resize: vertical;
  padding: 11px 12px;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}

.composer textarea:focus {
  border-color: var(--primary);
  background: var(--surface);
}

.composer-actions {
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.record-button,
.send-button {
  min-height: 42px;
  padding: 0 18px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.record-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 150px;
  border: 1px solid var(--primary);
  color: var(--primary-dark);
  background: var(--surface);
  touch-action: none;
  user-select: none;
}

.record-button.recording {
  color: #fff;
  background: var(--primary-dark);
  box-shadow: 0 0 0 5px var(--primary-soft);
}

.mic-icon {
  position: relative;
  width: 10px;
  height: 15px;
  border: 2px solid currentColor;
  border-radius: 6px;
}

.mic-icon::after {
  position: absolute;
  right: -5px;
  bottom: -6px;
  left: -5px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  border-left: 2px solid currentColor;
  border-radius: 0 0 7px 7px;
  content: "";
}

.send-button {
  min-width: 88px;
}

button:disabled,
textarea:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.composer-hint {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 640px) {
  .app-shell {
    width: 100%;
    border-right: 0;
    border-left: 0;
    box-shadow: none;
  }

  .topbar {
    min-height: 64px;
    padding: 0 12px;
  }

  .app-title {
    font-size: 18px;
  }

  .intro-panel {
    margin: 10px 12px 0;
    padding: 14px;
  }

  .message-list {
    padding: 16px 12px;
  }

  .message-row {
    gap: 8px;
  }

  .question-heading {
    display: grid;
  }

  .product-actions {
    display: grid;
  }

  .configuration-warning,
  .error-banner {
    margin-right: 14px;
    margin-left: 14px;
  }

  .composer {
    padding-right: 12px;
    padding-left: 12px;
  }

  .composer-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 84px;
  }

  .record-button,
  .send-button {
    width: 100%;
    min-width: 0;
  }

  .composer-hint {
    display: none;
  }
}

@media (max-width: 420px) {
  .app-title {
    font-size: 15px;
  }

  .topbar {
    gap: 8px;
  }

  .topbar-actions {
    gap: 6px;
  }

  .language-switcher button {
    min-height: 32px;
    padding: 0 6px;
    font-size: 10px;
  }

  .ghost-button {
    padding: 0 9px;
  }

  .configuration-warning {
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
