:root {
  /* Default theme = Ocean (bluish). Other themes override these below. */
  --bg: linear-gradient(160deg, #5ee7df 0%, #4facfe 45%, #6a8cff 100%);
  --card: #fff;
  --accent: #ff6b6b;
  --accent-2: #1fd1a5;
  --accent-3: #845ef7;
  --header: linear-gradient(120deg, #00c6fb, #005bea);
  --header-text: #ffffff;
  --text: #15233f;
  --on-bg: #ffffff; /* text that sits directly on the background gradient */
  --on-bg-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
  --shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  font-family: "Baloo 2", "Segoe UI", system-ui, sans-serif;
}

:root[data-theme="ocean"] {
  --bg: linear-gradient(160deg, #5ee7df 0%, #4facfe 45%, #6a8cff 100%);
  --header: linear-gradient(120deg, #00c6fb, #005bea);
  --header-text: #ffffff;
  --accent: #ff6b6b;
  --accent-2: #1fd1a5;
  --accent-3: #845ef7;
  --on-bg: #ffffff;
  --on-bg-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
}

:root[data-theme="galaxy"] {
  --bg: linear-gradient(160deg, #3a1c71 0%, #2b5bd7 52%, #00c6fb 100%);
  --header: linear-gradient(120deg, #7b2ff7, #2b5bd7);
  --header-text: #ffffff;
  --accent: #ff8fab;
  --accent-2: #2fe0c0;
  --accent-3: #ffd93d;
  --on-bg: #ffffff;
  --on-bg-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

:root[data-theme="sky"] {
  --bg: linear-gradient(160deg, #a1ffce 0%, #5ee7ff 40%, #4f9cff 100%);
  --header: linear-gradient(120deg, #2af5e0, #2b8cff);
  --header-text: #053b6b;
  --accent: #ff7a59;
  --accent-2: #12b886;
  --accent-3: #5b6cff;
  --on-bg: #08365f;
  --on-bg-shadow: 0 1px 2px rgba(255, 255, 255, 0.45);
}

:root[data-theme="sunshine"] {
  /* The original warm yellow look, kept as an option. */
  --bg: #fff7df;
  --header: linear-gradient(120deg, #ffd166, #ff9f1c);
  --header-text: #1f1300;
  --accent: #ff9f1c;
  --accent-2: #2ec4b6;
  --accent-3: #6c63ff;
  --on-bg: #2d2a32;
  --on-bg-shadow: none;
}

* {
  box-sizing: border-box;
}

/* Kiosk lock: keep the page pinned so a baby/toddler can't scroll, bounce,
   pull-to-refresh, or pinch-zoom it. Taps and the drag-to-complete gestures
   still work; only browser pan/scroll/zoom is disabled. Parent-facing
   scrollable areas (settings, image manager) re-enable scrolling below. */
html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  /* manipulation = taps fire instantly (no double-tap-zoom delay) while child
     scroll containers (settings) can still pan. position:fixed + overflow
     hidden already remove any page scroll/bounce. */
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  position: fixed;
  inset: 0;
  margin: 0;
  background: var(--bg);
  background-attachment: fixed;
  color: var(--text);
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--header);
  color: var(--header-text);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.logo {
  font-size: 1.4rem;
}

.header-actions {
  display: flex;
  gap: 8px;
}

header button {
  font-size: 1.2rem;
  background: rgba(255, 255, 255, 0.85);
  border: none;
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: var(--shadow);
}

main {
  padding: 12px 12px 32px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  /* Only scrolls if a screen is taller than the viewport; stays self-contained
     so it never rubber-bands or pulls the locked page around. */
  overflow-y: auto;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

#home-screen h1 {
  margin: 8px 0 12px;
  color: var(--on-bg);
  text-shadow: var(--on-bg-shadow);
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.tile {
  background: #fff;
  border: none;
  border-radius: 16px;
  padding: 16px;
  text-align: left;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
}

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

.tile-emoji {
  font-size: 1.8rem;
}

.tile-title {
  font-size: 1.2rem;
  font-weight: 800;
}

.tile-sub {
  color: #5a5564;
  font-size: 0.95rem;
}

#status {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-weight: 600;
  color: var(--on-bg);
  text-shadow: var(--on-bg-shadow);
}

#voice-warning {
  color: #c0392b;
}

#category-quick-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--on-bg);
  text-shadow: var(--on-bg-shadow);
}

#category-quick {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #ddd;
}

#mode-switcher {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-btn {
  border: none;
  background: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-weight: 700;
}

.mode-btn.active {
  background: var(--accent-2);
  color: #fff;
}

#find-count-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.find-count-label {
  font-weight: 700;
}

.find-count-options {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.find-count-btn {
  border: none;
  background: #fff;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-weight: 800;
  font-size: 1.1rem;
  cursor: pointer;
}

.find-count-btn.active {
  background: var(--accent);
  color: #fff;
}

#prompt-area {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

#prompt-word {
  font-size: clamp(2rem, 7vw, 3rem);
  font-weight: 800;
  padding: 12px 16px;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

#speak-btn {
  font-size: 2rem;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: var(--accent-2);
  color: #fff;
  box-shadow: var(--shadow);
}

#feedback {
  min-height: 28px;
  font-size: 1.4rem;
  color: var(--on-bg);
  text-shadow: var(--on-bg-shadow);
}

.cards {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.card {
  position: relative;
  background: var(--card);
  border: 3px solid transparent;
  border-radius: 24px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.08);
  padding: 10px 10px 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.card:active {
  transform: scale(0.97);
}

@media (hover: hover) {
  .card:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.18), 0 3px 8px rgba(0, 0, 0, 0.1);
  }
}

.card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 18px;
  display: block;
  /* soft placeholder + subtle inner frame while the real photo loads */
  background: linear-gradient(135deg, #fef3da, #ffe4c4);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.card .label-ja {
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.1;
}
.card.kana .label-ja {
  font-size: 2rem;
}

.card .label-en {
  font-size: 1rem;
  color: #5a5564;
}

.card.dragging {
  opacity: 0.6;
  transform: scale(0.98);
}

.card.correct {
  border-color: #2ec4b6;
  box-shadow: 0 0 0 4px rgba(46, 196, 182, 0.25), 0 10px 22px rgba(0, 0, 0, 0.14);
}

.card.wrong {
  border-color: #ff595e;
  box-shadow: 0 0 0 4px rgba(255, 89, 94, 0.25), 0 10px 22px rgba(0, 0, 0, 0.14);
}

#dropzone-section {
  display: flex;
  justify-content: center;
}

.dropzone {
  width: min(90vw, 360px);
  height: 200px;
  border: 4px dashed #555;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  text-align: center;
}

#complete-word-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#complete-word-display {
  background: #fff;
  padding: 16px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.letter-cell {
  width: clamp(64px, 18vw, 96px);
  height: clamp(64px, 18vw, 96px);
  display: grid;
  place-items: center;
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  font-weight: 700;
  border-radius: 14px;
  background: #faf3e7;
  color: var(--text);
  user-select: none;
}

.word-section {
  display: inline-flex;
  align-items: center;
  padding: 10px 18px;
  min-height: clamp(64px, 18vw, 96px);
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  font-weight: 700;
  border-radius: 14px;
  background: #faf3e7;
  color: var(--text);
  user-select: none;
  letter-spacing: 0.04em;
}

.blank-slot {
  background: transparent;
  border: 3px dashed #b3a895;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.choices-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 10px;
}

.choice-chip {
  background: #fff;
  border-radius: 14px;
  padding: 12px;
  font-size: 1.4rem;
  text-align: center;
  box-shadow: var(--shadow);
  touch-action: none;
  cursor: grab;
}

.choice-chip.dragging {
  opacity: 0.85;
  cursor: grabbing;
  pointer-events: none;
  z-index: 1100;
  position: relative;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25);
}

.blank-slot.hover {
  background: rgba(46, 196, 182, 0.18);
  border-color: var(--accent-2);
  transform: scale(1.05);
}

#settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  /* Parent settings still scroll, but kept self-contained so the page stays locked */
  touch-action: pan-y;
  overscroll-behavior: contain;
}

#settings {
  background: #fff;
  padding: 20px;
  border-radius: 16px;
  width: min(480px, 95vw);
  max-height: 90vh;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  touch-action: pan-y;
  overscroll-behavior: contain;
  overflow-y: auto;
}

#settings label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

#settings select {
  flex: 1;
  padding: 8px;
  border-radius: 10px;
}

#settings button {
  align-self: flex-end;
  padding: 10px 16px;
  border: none;
  border-radius: 12px;
  background: var(--accent-2);
  color: #fff;
}

.settings-subheader {
  font-weight: 800;
  margin-top: 8px;
}

#image-search {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #ddd;
}

.theme-hint {
  font-size: 0.9rem;
  color: #666;
}

.image-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

.image-card {
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 12px;
  padding: 8px;
  display: grid;
  gap: 6px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.image-card .image-preview {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  display: grid;
  place-items: center;
}

.image-card .image-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-card .title {
  font-weight: 700;
  font-size: 0.95rem;
}

.image-card .subtitle {
  color: #555;
  font-size: 0.85rem;
}

.sync-indicator {
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: -4px;
}

/* Add-a-word form */
#settings input[type="text"],
#settings input[type="url"] {
  flex: 1;
  min-width: 0;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid #ddd;
}

#settings #new-word-add {
  align-self: stretch;
  background: var(--accent);
  font-weight: 800;
  font-size: 1.05rem;
}

.image-card {
  position: relative;
}

#settings .image-card .word-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  background: rgba(230, 57, 70, 0.92);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1;
  z-index: 2;
}

.hidden {
  display: none !important;
}

#alphabet-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 8px 0 24px;
}

.alphabet-card {
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.alphabet-emoji {
  font-size: clamp(5rem, 22vw, 8rem);
  line-height: 1;
}

.alphabet-kana {
  font-size: clamp(5rem, 22vw, 8rem);
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.alphabet-example {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

#alphabet-example-word {
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  font-weight: 700;
  color: var(--text);
}

#alphabet-example-romaji {
  font-size: clamp(1rem, 4vw, 1.25rem);
  color: #888;
  font-style: italic;
}

#alphabet-example-en {
  font-size: clamp(1.1rem, 4.5vw, 1.4rem);
  color: var(--text);
}

.alphabet-controls {
  display: flex;
  gap: 18px;
  align-items: center;
}

.alphabet-controls button {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: var(--accent-2, #2ec4b6);
  color: white;
  font-size: 1.6rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.alphabet-controls button:disabled {
  opacity: 0.4;
  cursor: default;
}

#alphabet-progress {
  font-size: 1rem;
  color: var(--on-bg);
  text-shadow: var(--on-bg-shadow);
  opacity: 0.85;
}

#alphabet-quiz-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 8px 0 24px;
}

.quiz-card {
  padding: 24px 16px 18px;
  gap: 8px;
}

.quiz-prompt-text {
  font-size: 1rem;
  color: #777;
  font-weight: 500;
}

.quiz-choices {
  width: 100%;
  max-width: 480px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.quiz-choice {
  background: #fff;
  border: none;
  border-radius: 20px;
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  font-size: clamp(2.4rem, 12vw, 4rem);
  padding: 22px 6px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
  min-height: 100px;
  line-height: 1;
}

.quiz-choice:active {
  transform: scale(0.95);
}

.quiz-choice.correct {
  background: rgba(46, 196, 182, 0.35);
  animation: quiz-pop 0.4s ease;
}

.quiz-choice.wrong {
  background: rgba(230, 57, 70, 0.25);
  animation: quiz-shake 0.35s ease;
}

@keyframes quiz-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes quiz-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  50% { transform: translateX(8px); }
  75% { transform: translateX(-4px); }
}

.quiz-feedback {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--on-bg);
  text-shadow: var(--on-bg-shadow);
  min-height: 1.5em;
  text-align: center;
}

#quiz-progress {
  font-size: 1rem;
  color: var(--on-bg);
  text-shadow: var(--on-bg-shadow);
  opacity: 0.85;
}

#install-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 1400;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#install-text {
  font-weight: 600;
  color: var(--text);
  flex: 1;
  font-size: 0.95rem;
}

.install-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

#install-btn {
  background: var(--accent-2, #2ec4b6);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 700;
  cursor: pointer;
}

#install-dismiss {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  color: #999;
  cursor: pointer;
  padding: 4px 8px;
}

#image-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.image-modal-content {
  background: #fff;
  border-radius: 14px;
  padding: 16px;
  width: min(420px, 95vw);
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow);
}

.image-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.image-modal-header button {
  border: none;
  background: #f3f3f3;
  border-radius: 8px;
  padding: 6px 10px;
}

.image-modal-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 4px;
  border-radius: 12px;
  background: #fafafa;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

.modal-photo-wrap {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #eee;
}

.modal-photo-wrap.default {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  aspect-ratio: auto;
  padding: 12px;
  grid-column: 1 / -1;
}

.modal-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.modal-photo-wrap.default .modal-photo {
  width: auto;
  max-width: 60%;
  max-height: 140px;
  object-fit: contain;
}

.modal-photo-note {
  font-size: 0.85rem;
  color: #888;
  margin-top: 6px;
}

.modal-photo-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.image-modal-help {
  font-size: 0.85rem;
  color: #888;
}

.library-help {
  font-size: 0.85rem;
  color: #777;
  line-height: 1.4;
}

.library-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.library-actions button {
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
}

.library-actions .reset {
  background: #ffe9e9;
  border-color: #ffb3b3;
}

.library-status {
  font-size: 0.85rem;
  color: #555;
  font-style: italic;
}

.image-card .image-preview {
  position: relative;
}

.image-thumb.stack-0 {
  object-fit: cover;
  z-index: 2;
  position: relative;
}

.image-thumb.stack-1,
.image-thumb.stack-2 {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.image-thumb.stack-1 {
  transform: rotate(4deg) translate(6px, 4px);
  z-index: 1;
  opacity: 0.65;
}

.image-thumb.stack-2 {
  transform: rotate(-4deg) translate(-6px, 4px);
  z-index: 0;
  opacity: 0.45;
}

.image-modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.image-modal-actions button {
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.image-modal-actions .reset {
  background: #ffe9e9;
  border-color: #ffb3b3;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill-btn {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #ddd;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
}

.pill-btn.active {
  background: var(--accent-2);
  color: #fff;
  border-color: var(--accent-2);
}

#wrong-overlay,
#correct-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 1500;
  animation: feedback-pop 0.7s ease-out forwards;
}

#wrong-overlay {
  background: rgba(230, 57, 70, 0.18);
}

#wrong-overlay svg {
  width: min(70vw, 70vh);
  height: min(70vw, 70vh);
  fill: none;
  stroke: #e63946;
  stroke-width: 16;
  stroke-linecap: round;
  filter: drop-shadow(0 8px 24px rgba(230, 57, 70, 0.5));
}

#correct-overlay {
  background: rgba(46, 196, 182, 0.18);
}

#correct-overlay svg {
  width: min(70vw, 70vh);
  height: min(70vw, 70vh);
  fill: none;
  stroke: #1aa37a;
  stroke-width: 16;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 8px 24px rgba(26, 163, 122, 0.5));
}

#correct-overlay svg circle {
  fill: rgba(46, 196, 182, 0.22);
}

@keyframes feedback-pop {
  0% { opacity: 0; transform: scale(0.6); }
  25% { opacity: 1; transform: scale(1.05); }
  60% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

@media (hover: hover) {
  .card:hover {
    transform: translateY(-2px);
    transition: 0.1s;
  }
}

/* ---- First-run onboarding ---- */
#onboarding {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--bg);
  background-attachment: fixed;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  touch-action: pan-y;
}

.onboarding-card {
  background: rgba(255, 255, 255, 0.96);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 24px 20px;
  width: min(440px, 100%);
  text-align: center;
}

.onboarding-logo {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent);
}

.onboarding-sub {
  margin: 6px 0 16px;
  font-weight: 600;
  color: #5a5564;
}

.onboarding-langs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.onboarding-lang {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border: 3px solid transparent;
  border-radius: 16px;
  background: #f4f4f8;
  box-shadow: var(--shadow);
  font-weight: 700;
  cursor: pointer;
}

.onboarding-lang .ob-flag {
  font-size: 1.8rem;
  line-height: 1;
}

.onboarding-lang .ob-name {
  font-size: 0.85rem;
}

.onboarding-lang.active {
  border-color: var(--accent-2);
  background: #fff;
}

.onboarding-account {
  margin: 16px 0 0;
  text-align: left;
}

.onboarding-account summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--accent-3);
  padding: 6px 0;
}

.onboarding-hint {
  font-size: 0.85rem;
  color: #5a5564;
  margin: 6px 0 10px;
}

.onboarding-account label {
  display: block;
  font-weight: 600;
  margin-bottom: 10px;
}

.onboarding-account input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 1.1rem;
}

.onboarding-start {
  margin-top: 18px;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: var(--accent-2);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 800;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.onboarding-status {
  min-height: 20px;
  margin-top: 10px;
  font-weight: 600;
  color: #d62828;
}

/* Brand logo images (loaded from Supabase; fall back to text title) */
#app-logo {
  height: 34px;
  width: auto;
  display: block;
}
.onboarding-logo-img {
  max-height: 110px;
  width: auto;
  margin: 0 auto 4px;
  display: block;
}

/* ---- Stock photo search (in the image manager) ---- */
.image-modal-stock {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stock-search-bar {
  display: flex;
  gap: 8px;
}
.stock-search-bar input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 1rem;
}
.stock-search-bar button {
  border: none;
  background: var(--accent-2);
  color: #fff;
  font-weight: 700;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
}
.stock-search-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
  max-height: 46vh;
  overflow-y: auto;
  touch-action: pan-y;
  overscroll-behavior: contain;
}
.stock-result {
  padding: 0;
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  background: #f3f3f3;
  cursor: pointer;
  aspect-ratio: 1 / 1;
}
.stock-result img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.stock-result.picking {
  opacity: 0.5;
  border-color: var(--accent-2);
}
.stock-status {
  grid-column: 1 / -1;
  padding: 14px;
  text-align: center;
  color: #5a5564;
  font-weight: 600;
}
