:root {
  --bg: #f7f4ea;
  --ink: #1f2b38;
  --ink-soft: #435166;
  --panel: rgba(255, 255, 255, 0.9);
  --line: rgba(31, 43, 56, 0.12);
  --accent: #007a6f;
  --accent-strong: #005f56;
  --sun: #f7b267;
  --berry: #c84b7f;
  --radius: 18px;
  --shadow: 0 10px 35px rgba(14, 24, 34, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, rgba(247, 178, 103, 0.2), transparent 35%),
    radial-gradient(circle at 90% 30%, rgba(200, 75, 127, 0.2), transparent 35%),
    linear-gradient(155deg, #f6efe0, #eaf4f3 60%, #fffaf0);
  padding: 1.2rem;
}

.bg-shape {
  position: fixed;
  pointer-events: none;
  z-index: -1;
}

.bg-shape-a {
  width: 42vw;
  height: 42vw;
  max-width: 360px;
  max-height: 360px;
  border: 2px dashed rgba(0, 122, 111, 0.18);
  border-radius: 40% 60% 55% 45%;
  top: -8vw;
  right: -10vw;
}

.bg-shape-b {
  width: 30vw;
  height: 30vw;
  max-width: 250px;
  max-height: 250px;
  border: 2px solid rgba(200, 75, 127, 0.2);
  border-radius: 50% 50% 70% 30%;
  left: -8vw;
  bottom: 10vh;
}

.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  gap: 1rem;
}

.hero {
  background: linear-gradient(135deg, rgba(0, 122, 111, 0.14), rgba(255, 255, 255, 0.75));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem;
  animation: rise 0.5s ease-out;
}

.hero-kicker {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-strong);
  font-weight: 700;
}

.hero h1 {
  margin: 0.35rem 0;
  font-family: "Literata", serif;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
}

.hero h1 span {
  color: var(--berry);
}

.hero-subtitle {
  margin: 0;
  max-width: 60ch;
  color: var(--ink-soft);
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(7px);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 1rem;
  animation: rise 0.6s ease-out;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.panel h2 {
  margin: 0;
  font-size: 1.1rem;
}

.direction-picker {
  display: grid;
  gap: 0.45rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.direction-toggle {
  display: inline-flex;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.2rem;
  gap: 0.25rem;
}

.direction-btn,
.lookup-form input,
.lookup-form button,
.mic-btn {
  font: inherit;
}

.direction-btn {
  border: 0;
  background: transparent;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
}

.lookup-form input {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
}

.direction-btn {
  font-size: 0.84rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.direction-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
}

.lookup-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem;
  margin: 0.8rem 0 0.35rem;
  align-items: stretch;
}

.lookup-form input {
  width: 100%;
  min-width: 0;
}

.lookup-form button {
  white-space: nowrap;
}

.lookup-form button,
.mic-btn,
.camera-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  border: none;
  border-radius: 11px;
  font-weight: 700;
  cursor: pointer;
  padding: 0.65rem 0.9rem;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.lookup-form button:hover,
.mic-btn:hover,
.camera-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.mic-btn.listening {
  background: linear-gradient(140deg, #b93862, #8e2046);
}

.mic-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.scan-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.proficiency-wrap {
  margin-top: 0.45rem;
}

.proficiency-toggle {
  display: inline-flex;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.2rem;
  gap: 0.25rem;
}

.proficiency-btn {
  border: 0;
  background: transparent;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.proficiency-btn.active[data-mode="off"] {
  background: linear-gradient(140deg, #c9d0d8, #aeb8c4);
  color: #253244;
}

.proficiency-btn.active:not([data-mode="off"]) {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
}

.proficiency-wrap.disabled .proficiency-toggle {
  opacity: 0.75;
}

.proficiency-btn:disabled {
  cursor: not-allowed;
  opacity: 0.8;
}

.camera-btn.secondary {
  background: linear-gradient(140deg, #45566f, #2f3d52);
}

.camera-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.camera-preview {
  margin-top: 0.6rem;
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
}

#cameraResultCard {
  margin-top: 0.7rem;
}

.status-text {
  min-height: 1.2rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin: 0.3rem 0 0;
}

.results-grid,
.live-grid {
  margin-top: 0.8rem;
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 0.7rem;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 0.85rem;
}

.result-card.highlight {
  background: linear-gradient(165deg, rgba(0, 122, 111, 0.08), rgba(255, 255, 255, 0.95));
}

.result-card.gemini-result {
  border: 2px solid transparent;
  background:
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(120deg, #ff8a00, #e52e71, #007a6f, #35a7ff) border-box;
}

.gemini-label {
  display: inline-block;
  margin-top: 0.3rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #8e2046;
}

.result-card h3 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
}

.result-card ul {
  margin: 0;
  padding-left: 1rem;
  color: var(--ink-soft);
}

.result-card li {
  margin-bottom: 0.3rem;
}

.empty-text,
.live-text {
  margin: 0;
  color: var(--ink-soft);
}

.word-pill {
  display: inline-flex;
  border: 1px solid transparent;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: rgba(31, 43, 56, 0.06);
  margin-right: 0.35rem;
  margin-bottom: 0.35rem;
  font-size: 0.86rem;
  cursor: pointer;
}

.word-pill:hover {
  border-color: rgba(0, 122, 111, 0.35);
}

.browser-note {
  color: var(--ink-soft);
  font-size: 0.83rem;
  margin-top: 0.8rem;
}

.hidden {
  display: none;
}

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

@media (min-width: 760px) {
  body {
    padding: 1.5rem;
  }

  .lookup-panel .results-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .live-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .panel-head {
    align-items: flex-start;
  }

  .direction-picker {
    width: 100%;
  }

  .direction-toggle {
    width: 100%;
  }

  .direction-btn {
    flex: 1 1 0;
    text-align: center;
  }

  .lookup-form {
    grid-template-columns: 1fr;
  }

  .lookup-form button {
    width: 100%;
  }
}

@media (min-width: 1080px) {
  .app-shell {
    grid-template-columns: 1.6fr 1fr;
    grid-template-areas:
      "hero hero"
      "lookup live"
      "scan scan";
  }

  .hero {
    grid-area: hero;
  }

  .lookup-panel {
    grid-area: lookup;
  }

  .live-panel {
    grid-area: live;
  }

  .scan-panel {
    grid-area: scan;
  }

  .lookup-panel .results-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(9px);
  }

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