:root {
  color-scheme: dark;
  --purple: #7655e8;
  --purple-dark: #5938c2;
  --green: #17643f;
  --green-soft: #e9f7ef;
  --red: #963f48;
  --red-soft: #fff0ee;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100svh;
}

button,
input {
  font: inherit;
}

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

.camera-view {
  overflow: hidden;
  color: white;
  background: #0e0c13;
}

.page-shell {
  position: relative;
  width: min(100%, 430px);
  height: 100dvh;
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: #17131f;
}

.workspace,
.experience,
.camera-stage {
  position: relative;
  width: 100%;
  height: 100%;
}

.workspace {
  overflow: hidden;
}

.language-picker {
  position: absolute;
  top: max(10px, calc(env(safe-area-inset-top) + 8px));
  right: 12px;
  left: 12px;
  z-index: 10;
  min-width: 0;
  margin: 0;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 17px;
  background: rgba(18, 14, 27, 0.52);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.language-picker[disabled] {
  opacity: 1;
  pointer-events: none;
}

.language-picker legend {
  margin: 0 0 7px;
  padding: 0 2px;
  color: white;
  font-size: 0.72rem;
  font-weight: 850;
}

.language-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}

.language-option {
  position: relative;
  min-width: 0;
  cursor: pointer;
}

.language-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.language-option span {
  display: grid;
  min-height: 45px;
  padding: 5px 2px;
  place-content: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 11px;
  color: white;
  text-align: center;
  background: rgba(255, 255, 255, 0.1);
  transition: 140ms ease;
}

.language-option strong,
.language-option small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.language-option strong {
  font-size: 0.66rem;
  line-height: 1.15;
}

.language-option small {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.43rem;
  line-height: 1;
}

.language-option input:checked + span {
  border-color: white;
  color: var(--purple-dark);
  background: white;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.24);
}

.language-option input:checked + span small {
  color: #6c6677;
}

.language-option input:focus-visible + span,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.72);
  outline-offset: 2px;
}

.camera-stage {
  overflow: hidden;
  background: #17131f;
}

.camera-stage::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  content: "";
  background: linear-gradient(
    to bottom,
    rgba(10, 8, 14, 0.5),
    transparent 28%,
    transparent 58%,
    rgba(10, 8, 14, 0.62)
  );
  pointer-events: none;
}

.camera-stage video,
.camera-stage canvas,
.captured-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-stage canvas[hidden],
.camera-stage video[hidden] {
  display: none;
}

.captured-image:not([src]) {
  display: none;
}

.camera-loading {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.82rem;
  font-weight: 750;
}

.camera-loading[hidden],
.open-camera-button[hidden] {
  display: none;
}

.open-camera-button {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  min-height: 48px;
  padding: 0 20px;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 999px;
  color: white;
  background: var(--purple);
  font-size: 0.82rem;
  font-weight: 850;
  cursor: pointer;
}

.shutter-button {
  position: absolute;
  bottom: max(22px, calc(env(safe-area-inset-bottom) + 16px));
  left: 50%;
  z-index: 3;
  display: grid;
  width: 72px;
  height: 72px;
  padding: 6px;
  transform: translateX(-50%);
  place-items: center;
  border: 3px solid rgba(255, 255, 255, 0.94);
  border-radius: 50%;
  background: rgba(17, 12, 24, 0.28);
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  touch-action: manipulation;
}

.shutter-button span {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: white;
  transition: transform 120ms ease;
}

.shutter-button:active span {
  transform: scale(0.88);
}

.shutter-button:disabled {
  cursor: wait;
  opacity: 0.38;
}

.camera-stage.is-captured .shutter-button {
  display: none;
}

.camera-status {
  position: absolute;
  right: 18px;
  bottom: max(106px, calc(env(safe-area-inset-bottom) + 98px));
  left: 18px;
  z-index: 3;
  min-height: 18px;
  margin: 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.69rem;
  font-weight: 680;
  line-height: 1.35;
  text-align: center;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.72);
}

.camera-status.is-error {
  color: #ffd0d5;
}

.error-banner {
  position: absolute;
  top: max(102px, calc(env(safe-area-inset-top) + 100px));
  right: 14px;
  left: 14px;
  z-index: 12;
  padding: 11px 13px;
  border-radius: 12px;
  color: #7e2832;
  background: rgba(255, 240, 238, 0.96);
  font-size: 0.74rem;
  line-height: 1.4;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.result-card {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 4;
  display: grid;
  max-height: calc(100dvh - 174px);
  gap: 9px;
  padding: 17px 16px max(14px, calc(env(safe-area-inset-bottom) + 9px));
  overflow-y: auto;
  color: white;
  text-align: center;
  background: linear-gradient(
    to bottom,
    rgba(20, 16, 29, 0.18),
    rgba(20, 16, 29, 0.34)
  );
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -16px 44px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  overscroll-behavior: contain;
}

.word-panel {
  display: grid;
  justify-items: center;
  gap: 6px;
}

.result-label {
  color: #cfc4ff;
  font-size: 0.61rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.result-card h2 {
  max-width: 100%;
  margin: -2px 0 0;
  overflow-wrap: anywhere;
  font-size: clamp(2.25rem, 11.8vw, 3.35rem);
  line-height: 1;
  letter-spacing: -0.04em;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.72);
}

.english-name,
.pronunciation-guide {
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.78rem;
  font-weight: 750;
}

.english-name span,
.pronunciation-guide span {
  display: inline-block;
  margin-right: 5px;
  padding: 3px 6px;
  border-radius: 999px;
  color: #ded6ff;
  background: rgba(118, 85, 232, 0.34);
  font-size: 0.59rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

mark {
  color: inherit;
  background: none;
}

.object-highlight,
.practice-card mark {
  padding: 0 0.13em;
  border-radius: 0.25em;
  color: white;
  background: rgba(118, 85, 232, 0.75);
  font-weight: 880;
}

.sentence {
  max-width: 340px;
  margin: 2px 0 0;
  color: rgba(255, 255, 255, 0.93);
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 1.35;
}

[data-result-audio] {
  display: none;
}

.repeat-button,
.microphone-button,
.secondary-button {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 13px;
  font-weight: 850;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.repeat-button {
  border: 1px solid rgba(255, 255, 255, 0.46);
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.repeat-button span {
  font-size: 1.08rem;
}

.practice-card {
  display: grid;
  gap: 8px;
  padding: 11px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.11);
}

.practice-card > strong {
  font-size: 0.84rem;
}

.microphone-button {
  width: 100%;
  padding: 0 14px;
  border: 0;
  color: white;
  background: var(--purple);
}

.microphone-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.microphone-button.is-listening {
  background: #b63d4f;
}

.microphone-icon {
  font-size: 1.06rem;
}

.is-listening .microphone-icon {
  animation: pulse 850ms ease-in-out infinite;
}

.pronunciation-feedback {
  min-height: 31px;
  padding: 7px 9px;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.76);
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.3;
}

.pronunciation-feedback:empty {
  display: none;
}

.pronunciation-feedback.is-correct {
  color: var(--green);
  background: var(--green-soft);
}

.pronunciation-feedback.is-retry {
  color: var(--red);
  background: var(--red-soft);
}

.pronunciation-feedback.is-listening {
  color: #5332b8;
  background: #f0ebff;
}

.pronunciation-feedback.is-unsupported {
  color: #625c69;
  background: #efedf1;
}

.secondary-button {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.78rem;
}

@keyframes pulse {
  50% {
    transform: scale(1.2);
  }
}

@media (max-height: 720px) {
  .result-card {
    max-height: calc(100dvh - 145px);
    gap: 7px;
    padding-top: 13px;
  }

  .result-card h2 {
    font-size: 2.15rem;
  }

  .word-panel {
    gap: 4px;
  }
}

@media (min-width: 431px) {
  .page-shell {
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.55);
  }
}

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