:root {
  --page-bg: #f5f6fb;
  --ink: #111827;
  --muted: #667085;
  --line: #e5e7eb;
  --card: #ffffff;
  --indigo: #4f46e5;
  --purple: #9333ea;
  --pink: #db2777;
  --blue: #2563eb;
  --green: #4ade80;
  --shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
  --radius-xl: 20px;
  --radius-lg: 20px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family:
    "PingFang SC",
    "Microsoft YaHei",
    "Noto Sans CJK SC",
    system-ui,
    sans-serif;
  background: var(--page-bg);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.page-shell {
  min-height: 100vh;
  overflow: hidden;
  padding: 48px 24px 56px;
}

.hero {
  max-width: 920px;
  margin: 0 auto 32px;
  text-align: center;
}

.hero-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 14px;
}

.hero-icon {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  color: var(--indigo);
}

.hero-icon svg {
  width: 44px;
  height: 44px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  background: linear-gradient(90deg, var(--indigo), var(--purple));
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  font-size: clamp(2.25rem, 6vw, 4.75rem);
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1.05;
}

.demo-notice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: min(100%, 780px);
  margin: 0 auto 14px;
  padding: 9px 14px;
  border: 1px solid rgba(79, 70, 229, 0.18);
  border-radius: 999px;
  color: #4b5563;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.08);
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 1.55;
}

.demo-notice svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-right: 8px;
  color: var(--indigo);
}

.demo-notice span {
  min-width: 0;
}

.hero p {
  max-width: 720px;
  margin: 0 auto;
  color: #5f6675;
  font-size: clamp(1rem, 2.4vw, 1.24rem);
  line-height: 1.8;
}

.content {
  display: grid;
  gap: 20px;
  max-width: 1040px;
  margin: 0 auto;
}

.card {
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: var(--shadow);
}

.input-card,
.examples-card {
  padding: 20px;
}

.recognition-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
}

.runtime-controls {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 2px;
}

.control-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #4b5563;
  font-size: 0.92rem;
  font-weight: 600;
}

.control-checkbox input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--indigo);
}

.control-select {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #4b5563;
  font-size: 0.9rem;
  font-weight: 600;
}

.control-select select {
  min-height: 38px;
  min-width: 228px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: #111827;
  background: #ffffff;
  outline: none;
}

.control-select select:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.input-wrap {
  position: relative;
}

.input-wrap input {
  width: 100%;
  min-height: 64px;
  padding: 16px 60px 16px 20px;
  border: 2px solid var(--line);
  border-radius: 18px;
  outline: none;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  font-size: 1.06rem;
  transition:
    border-color 180ms var(--ease),
    box-shadow 180ms var(--ease),
    transform 180ms var(--ease);
}

.input-wrap input:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 5px rgba(79, 70, 229, 0.11);
}

.listen-button {
  position: absolute;
  top: 50%;
  right: 12px;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 0;
  border-radius: 14px;
  color: #5f6675;
  background: #f3f4f6;
  transform: translateY(-50%);
  transition:
    color 180ms var(--ease),
    background 180ms var(--ease),
    transform 180ms var(--ease);
}

.listen-button:hover {
  background: #e5e7eb;
}

.listen-button.is-listening {
  color: #dc2626;
  background: #fee2e2;
  animation: breathe 1s ease-in-out infinite;
}

.listen-button svg,
.submit-button svg,
.result-card h2 svg {
  width: 22px;
  height: 22px;
}

.submit-button {
  min-width: 138px;
  min-height: 64px;
  padding: 0 24px;
  border: 0;
  border-radius: 18px;
  color: #ffffff;
  background: linear-gradient(90deg, var(--indigo), var(--purple));
  box-shadow: 0 16px 34px rgba(79, 70, 229, 0.24);
  font-weight: 750;
  transition:
    opacity 180ms var(--ease),
    transform 180ms var(--ease),
    box-shadow 180ms var(--ease);
}

.submit-button:hover:not(:disabled) {
  box-shadow: 0 20px 44px rgba(79, 70, 229, 0.32);
  transform: translateY(-1px);
}

.submit-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.submit-idle,
.submit-loading {
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.submit-idle {
  display: flex;
}

.submit-loading {
  display: none;
}

.submit-button.is-loading .submit-idle {
  display: none;
}

.submit-button.is-loading .submit-loading {
  display: flex;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 720ms linear infinite;
}

.results-grid {
  width: 100%;
}

.results-grid[hidden] {
  display: none;
}

.results-grid.is-visible {
  animation: popIn 420ms var(--ease) both;
}

.result-card {
  padding: 20px;
}

.result-card h2,
.examples-card h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #1f2937;
  font-size: 1.16rem;
  font-weight: 800;
}

.result-card h2 svg {
  color: #eab308;
}

.tag-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.result-tag {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
  border-radius: 20px;
}

.tag-emotion {
  color: var(--pink);
  background: #fdf2f8;
}

.tag-scene {
  color: var(--blue);
  background: #eff6ff;
}

.tag-state {
  color: var(--purple);
  background: #faf5ff;
}

.tag-icon {
  display: grid;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  place-items: center;
}

.tag-icon svg {
  width: 22px;
  height: 22px;
}

.tag-label {
  display: block;
  margin-bottom: 3px;
  color: #667085;
  font-size: 0.88rem;
}

.result-tag strong {
  color: var(--ink);
  font-size: 1.04rem;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.detail-card {
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  background: #f8fafc;
  padding: 20px;
}

.detail-card h3 {
  margin: 0 0 10px;
  color: #475467;
  font-size: 0.92rem;
  font-weight: 700;
}

.json-detail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.json-scroll-wrap {
  width: 100%;
  flex: 1;
  min-height: 0;
  padding-right: 12px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(59, 130, 246, 0.58) transparent;
}

#jsonValue {
  margin: 0;
  width: 100%;
  min-height: 100%;
  box-sizing: border-box;
  padding: 20px;
  border-radius: 20px;
  color: #1e3a8a;
  background: #dbeafe;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  overflow: visible;
  white-space: pre-wrap;
  word-break: break-word;
}

.json-scroll-wrap::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.json-scroll-wrap::-webkit-scrollbar-track,
.json-scroll-wrap::-webkit-scrollbar-track-piece {
  background: transparent;
  border-radius: 999px;
}

.json-scroll-wrap::-webkit-scrollbar-thumb {
  background: rgba(59, 130, 246, 0.58);
  border-radius: 999px;
}

.timing-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.timing-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 30px;
  border-bottom: 1px dashed #dde3ec;
  color: #344054;
  font-size: 0.88rem;
}

.timing-list li:last-child {
  border-bottom: 0;
}

.timing-key {
  color: #667085;
}

.timing-value {
  color: #111827;
  font-weight: 700;
}

.timing-empty {
  display: block;
  border-bottom: 0;
  color: #98a2b3;
}

.examples-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.refresh-examples-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid #dbe1ff;
  border-radius: 999px;
  color: var(--indigo);
  background: #eef2ff;
  font-size: 0.92rem;
  font-weight: 700;
  transition:
    background 180ms var(--ease),
    border-color 180ms var(--ease),
    transform 180ms var(--ease),
    opacity 180ms var(--ease);
}

.refresh-examples-button:hover,
.refresh-examples-button:focus-visible {
  border-color: #c7d2fe;
  outline: none;
  background: #e0e7ff;
  transform: translateY(-1px);
}

.refresh-examples-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.refresh-examples-button svg {
  width: 18px;
  height: 18px;
}

.refresh-examples-button.is-loading svg {
  animation: spin 900ms linear infinite;
}

.examples-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.example-button {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  padding: 20px;
  border: 2px solid var(--line);
  border-radius: 20px;
  color: #374151;
  background: rgba(255, 255, 255, 0.64);
  text-align: left;
  transition:
    border-color 180ms var(--ease),
    background 180ms var(--ease),
    transform 180ms var(--ease);
}

.example-button:hover,
.example-button:focus-visible {
  border-color: var(--indigo);
  outline: none;
  background: #eef2ff;
  transform: translateY(-2px);
}

.example-button span {
  display: grid;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 12px;
  color: var(--indigo);
  background: linear-gradient(135deg, #eef2ff, #faf5ff);
  font-weight: 850;
  transition: transform 180ms var(--ease);
}

.example-button:hover span {
  transform: scale(1.08);
}

.example-button strong {
  color: #4b5563;
  font-weight: 500;
  line-height: 1.7;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.feature-card {
  padding: 20px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow);
}

.feature-card svg {
  width: 42px;
  height: 42px;
  margin-bottom: 14px;
}

.feature-card h3 {
  margin-bottom: 8px;
  color: #1f2937;
  font-size: 1.08rem;
  font-weight: 800;
}

.feature-card p {
  color: #667085;
  font-size: 0.94rem;
  line-height: 1.7;
}

.feature-emotion {
  color: var(--pink);
  background: linear-gradient(135deg, #fdf2f8, #fff1f2);
}

.feature-scene {
  color: var(--blue);
  background: linear-gradient(135deg, #eff6ff, #eef2ff);
}

.feature-state {
  color: var(--purple);
  background: linear-gradient(135deg, #faf5ff, #f5f3ff);
}

.reveal {
  animation: fadeUp 620ms var(--ease) both;
}

.delay-1 {
  animation-delay: 90ms;
}

.delay-2 {
  animation-delay: 180ms;
}

.delay-3 {
  animation-delay: 270ms;
}

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

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(22px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes breathe {
  50% {
    transform: translateY(-50%) scale(1.08);
  }
}

@media (max-width: 820px) {
  .page-shell {
    padding: 34px 18px 42px;
  }

  .hero-title {
    flex-direction: column;
    gap: 8px;
  }

  .recognition-form,
  .examples-grid,
  .features-grid {
    grid-template-columns: 1fr;
  }

  .tag-list,
  .details-grid {
    grid-template-columns: 1fr;
  }

  .submit-button {
    width: 100%;
  }

  .runtime-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .examples-header {
    flex-direction: column;
    align-items: stretch;
  }

  .refresh-examples-button {
    justify-content: center;
  }

  .control-select {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .control-select select {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 520px) {
  .demo-notice {
    align-items: flex-start;
    border-radius: 16px;
    padding: 10px 12px;
    text-align: left;
  }

  .demo-notice svg {
    margin-top: 3px;
  }

  .input-card,
  .examples-card,
  .result-card,
  .feature-card {
    border-radius: 20px;
  }

  .input-wrap input {
    min-height: 58px;
    font-size: 1rem;
  }

  .submit-button {
    min-height: 58px;
  }

  .example-button {
    padding: 20px;
  }
}
