:root {
  --bg: #f4f7fb;
  --bg-strong: #e3ecff;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-solid: #ffffff;
  --text: #172033;
  --muted: #68758f;
  --line: rgba(35, 48, 79, 0.13);
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #0f9f6e;
  --warning: #d97706;
  --danger: #dc2626;
  --shadow: 0 22px 60px rgba(20, 37, 72, 0.14);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 16% 0%, #ffffff 0, transparent 30rem),
    radial-gradient(circle at 88% 8%, rgba(40, 224, 163, 0.18) 0, transparent 24rem),
    linear-gradient(135deg, var(--bg), var(--bg-strong) 54%, #f8fbff);
}

button {
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
  min-height: 44px;
  padding: 0 18px;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease,
    opacity 160ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 28px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(34px, 5.4vw, 56px);
  line-height: 1.08;
  letter-spacing: 0;
}

.subtitle {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.hero-badges,
.camera-panel,
.results-panel,
.info-section article {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 10px;
  border-radius: var(--radius);
  padding: 12px;
  color: #2c3b58;
}

.hero-badges span {
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #315179;
  font-size: 13px;
  font-weight: 800;
  padding: 8px 12px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 22px;
  align-items: start;
}

.camera-panel,
.results-panel {
  border-radius: var(--radius);
  padding: 16px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 14px;
}

.panel-header h2,
.info-section h2 {
  margin-bottom: 6px;
  font-size: 18px;
}

.panel-header p,
.info-section p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.65;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 800;
  padding: 7px 12px;
}

.video-shell {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: var(--radius);
  background: #111827;
  aspect-ratio: 16 / 9;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

video,
canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

video {
  object-fit: contain;
}

canvas {
  pointer-events: none;
}

.video-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  color: #dce8ff;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.2), rgba(15, 159, 110, 0.12)),
    #111827;
}

.video-placeholder.is-hidden {
  display: none;
}

.placeholder-icon {
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 4px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
}

.video-placeholder small {
  color: #a8b6d5;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.primary-button {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.26);
}

.primary-button:hover:not(:disabled) {
  background: var(--primary-dark);
}

.secondary-button {
  background: #111827;
  color: #ffffff;
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--panel-solid);
  color: var(--text);
}

.error-message {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--danger);
  font-weight: 700;
  line-height: 1.5;
}

.results-panel {
  display: grid;
  gap: 14px;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.result-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-solid);
  padding: 14px;
}

.result-card strong {
  display: block;
  overflow-wrap: anywhere;
  margin: 8px 0 4px;
  font-size: 24px;
  line-height: 1.2;
}

.result-card small,
.result-card p,
.card-label {
  color: var(--muted);
}

.result-card p {
  margin: 8px 0 6px;
  line-height: 1.6;
}

.card-label {
  display: block;
  font-size: 13px;
  font-weight: 800;
}

.mood-card {
  border-color: rgba(37, 99, 235, 0.28);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), #ffffff 54%);
  min-height: 126px;
}

.mood-card strong {
  color: var(--primary-dark);
  font-size: 34px;
}

.mood-card[data-mood="happy"] {
  border-color: rgba(15, 159, 110, 0.35);
  background: linear-gradient(135deg, rgba(15, 159, 110, 0.14), #ffffff 56%);
}

.mood-card[data-mood="sad"],
.mood-card[data-mood="fearful"] {
  border-color: rgba(37, 99, 235, 0.35);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.14), #ffffff 56%);
}

.mood-card[data-mood="angry"],
.mood-card[data-mood="disgusted"] {
  border-color: rgba(220, 38, 38, 0.3);
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.12), #ffffff 56%);
}

.mood-card[data-mood="surprised"] {
  border-color: rgba(217, 119, 6, 0.34);
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.14), #ffffff 56%);
}

.wide-card {
  grid-column: 1 / -1;
}

.local-card {
  border-color: rgba(15, 159, 110, 0.24);
  background: linear-gradient(135deg, rgba(15, 159, 110, 0.09), #ffffff 54%);
}

.local-card strong {
  color: #087f5b;
  font-size: 22px;
}

.info-section {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.info-section article {
  border-radius: var(--radius);
  box-shadow: none;
  padding: 14px;
}

.info-section h2 {
  font-size: 15px;
}

.info-section p {
  font-size: 14px;
  line-height: 1.55;
}

.noscript-warning {
  margin-top: 18px;
  border: 1px solid rgba(220, 38, 38, 0.28);
  border-radius: var(--radius);
  background: #fff7f7;
  color: var(--danger);
  padding: 16px;
  font-weight: 800;
}

@media (max-width: 900px) {
  .hero,
  .workspace,
  .info-section {
    grid-template-columns: 1fr;
  }

  .hero-badges {
    justify-content: start;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 18px 0;
  }

  .camera-panel,
  .results-panel,
  .info-section article {
    padding: 14px;
  }

  .panel-header {
    display: grid;
  }

  .controls button {
    width: 100%;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .result-card strong {
    font-size: 22px;
  }

  .mood-card strong {
    font-size: 30px;
  }
}
