/* FloraFauna Vision: styles.
 *
 * The look comes from the two background photos: deep emerald water, mint
 * light lines, and the tiger's amber for animals. Panels are dark glass so
 * the photo stays visible around them.
 *
 * One memorable element: the viewfinder drop zone. Its corner brackets close
 * in when a photo is dragged over it and light up once a photo is chosen.
 * Everything else stays quiet.
 *
 * No inline styles are written in HTML; JS sets custom properties through
 * the CSSOM. Fonts are system fonts only (CSP font-src is 'self').
 */

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: dark;

  --ground: #031a14;
  --panel: #06281f;
  --raised: #0b3a2d;
  --glass: rgba(4, 32, 25, 0.76);

  --mint: #4be3a8;
  --mint-hi: #a9f3d4;
  --amber: #f5a94b;
  --yellow: #e7d56a;
  --rose: #ff9187;

  --text: #ecfff7;
  --muted: #a3cfbc;
  --line: rgba(93, 235, 177, 0.3);
  --line-soft: rgba(93, 235, 177, 0.16);

  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;

  --font-sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system,
    "Helvetica Neue", "Leelawadee UI", "Noto Sans Thai", Thonburi, Tahoma,
    Arial, sans-serif;
  /* Scientific names are Latin binomials, which are conventionally italic. */
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino,
    "Book Antiqua", Georgia, "Noto Serif", serif;
}

/* -------------------------------------------------------------------- base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--ground);
  color: var(--text);
  font: 400 1rem/1.65 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

/* Thai stacks vowels and tone marks, so it needs more line height. */
html[lang="th"] body {
  line-height: 1.85;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--mint-hi);
}

:focus-visible {
  outline: 3px solid var(--mint-hi);
  outline-offset: 3px;
}

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

.skip {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--mint);
  color: #032a1e;
  font-weight: 650;
  transform: translateY(-200%);
}

.skip:focus {
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* -------------------------------------------------------------- background */
/* A fixed element, not background-attachment: fixed, which iOS ignores.
 * Landscape (PC) uses the 16:9 photo; portrait (phones) uses the 9:16 one. */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--ground) url("/images/bg-16-9.webp") center / cover
    no-repeat;
}

@media (orientation: portrait) {
  .bg {
    background-image: url("/images/bg-9-16.webp");
  }
}

/* Darken the top (header and headline) and the bottom (console and text)
 * and leave the middle open so the animals and plants stay visible. */
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(3, 26, 20, 0.62) 0%,
    rgba(3, 26, 20, 0.1) 26%,
    rgba(3, 26, 20, 0) 52%,
    rgba(3, 26, 20, 0.72) 100%
  );
}

.bg-dim::after {
  background: rgba(3, 26, 20, 0.9);
}

/* ------------------------------------------------------------------ header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) clamp(14px, 3vw, 32px) 10px;
  background: rgba(3, 26, 20, 0.58);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  min-width: 0;
}

.brand-mark {
  flex: none;
  color: var(--mint);
}

.brand-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(3, 26, 20, 0.5);
}

.lang-btn {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.lang-btn[aria-pressed="true"] {
  background: var(--mint);
  color: #032a1e;
  font-weight: 650;
}

/* ----------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

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

.btn-sm {
  min-height: 38px;
  padding: 0 14px;
  font-size: 0.92rem;
}

.btn-primary {
  background: var(--mint);
  color: #032a1e;
  box-shadow: 0 8px 24px rgba(75, 227, 168, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: #6df0bc;
}

.btn-quiet {
  background: rgba(3, 26, 20, 0.5);
  border-color: var(--line);
  color: var(--text);
}

.btn-quiet:hover:not(:disabled) {
  background: rgba(11, 58, 45, 0.85);
}

.btn-danger {
  background: var(--rose);
  color: #340a06;
}

.btn-danger:hover:not(:disabled) {
  background: #ffa79f;
}

.link-btn {
  padding: 6px 2px;
  border: 0;
  background: none;
  color: var(--mint-hi);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid rgba(3, 42, 30, 0.3);
  border-top-color: #032a1e;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ------------------------------------------------------------------- stage */
.stage {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  max-width: 1180px;
  min-height: calc(100svh - 62px);
  margin: 0 auto;
  padding: clamp(22px, 6vh, 64px) clamp(14px, 3vw, 32px)
    clamp(16px, 4vh, 40px);
}

.headline {
  position: relative;
  isolation: isolate;
  max-width: 760px;
  margin: 0 auto;
  text-align: center;
  text-shadow: 0 2px 22px rgba(1, 16, 12, 0.92);
}

.headline h1 {
  margin: 0 0 12px;
  font-size: clamp(1.85rem, 1.2rem + 3.2vw, 3.35rem);
  font-weight: 750;
  line-height: 1.18;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.headline::before {
  content: "";
  position: absolute;
  inset: -36px -9vw;
  z-index: -1;
  background: radial-gradient(
    ellipse at center,
    rgba(3, 26, 20, 0.66) 0%,
    rgba(3, 26, 20, 0.4) 46%,
    rgba(3, 26, 20, 0) 74%
  );
  pointer-events: none;
}

html[lang="th"] .headline h1 {
  line-height: 1.4;
  letter-spacing: 0;
}

.headline p {
  max-width: 56ch;
  margin: 0 auto;
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.18rem);
  text-wrap: pretty;
}

/* ------------------------------------------------------------------- glass */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  backdrop-filter: blur(16px) saturate(1.2);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42), 0 0 38px rgba(75, 227, 168, 0.1);
}

.console {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: clamp(14px, 2.2vw, 22px);
  border-radius: var(--radius-lg);
}

.console-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}

@media (min-width: 820px) {
  .console-grid {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    align-items: stretch;
  }
}

/* ------------------------------------------------------------- drop zone */
.viewfinder {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 156px;
  padding: 28px 24px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(2, 20, 15, 0.5);
  text-align: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.viewfinder:hover,
.viewfinder.is-dragging {
  background: rgba(5, 44, 34, 0.62);
  border-color: rgba(93, 235, 177, 0.55);
}

.viewfinder[aria-disabled="true"] {
  cursor: progress;
  opacity: 0.7;
}

.vf {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 3px solid var(--mint);
  pointer-events: none;
  transition: transform 0.2s ease, filter 0.2s ease, border-color 0.2s ease;
}

.vf-tl {
  top: 7px;
  left: 7px;
  border-right: 0;
  border-bottom: 0;
  border-radius: 9px 0 0;
}

.vf-tr {
  top: 7px;
  right: 7px;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0 9px 0 0;
}

.vf-bl {
  bottom: 7px;
  left: 7px;
  border-top: 0;
  border-right: 0;
  border-radius: 0 0 0 9px;
}

.vf-br {
  right: 7px;
  bottom: 7px;
  border-top: 0;
  border-left: 0;
  border-radius: 0 0 9px;
}

/* Dragging: the frame closes in, like a camera focusing. */
.is-dragging .vf-tl {
  transform: translate(9px, 9px);
}

.is-dragging .vf-tr {
  transform: translate(-9px, 9px);
}

.is-dragging .vf-bl {
  transform: translate(9px, -9px);
}

.is-dragging .vf-br {
  transform: translate(-9px, -9px);
}

/* A photo is chosen: the frame locks and glows. */
.has-file .vf {
  border-color: var(--mint-hi);
  filter: drop-shadow(0 0 7px rgba(75, 227, 168, 0.9));
}

.dz-empty {
  display: grid;
  justify-items: center;
  gap: 4px;
  color: var(--mint);
}

.dz-title {
  margin: 8px 0 0;
  color: var(--text);
  font-weight: 650;
}

.dz-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.dz-preview {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  text-align: left;
}

.dz-preview img {
  flex: none;
  width: min(42%, 180px);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.dz-preview-text {
  min-width: 0;
}

.dz-name {
  margin: 0 0 4px;
  overflow: hidden;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- controls */
.controls {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}

.turnstile {
  min-height: 65px;
}

.control-buttons {
  display: flex;
  gap: 10px;
}

.control-buttons .btn-primary {
  flex: 1;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.notice-wrap:empty {
  display: none;
}

.notice-wrap {
  margin-top: 14px;
}

.notice {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(11, 58, 45, 0.7);
  font-size: 0.95rem;
}

.notice[data-tone="success"] {
  border-color: rgba(75, 227, 168, 0.65);
}

.notice[data-tone="error"] {
  border-color: rgba(255, 145, 135, 0.65);
  background: rgba(82, 20, 16, 0.65);
  color: #ffdcd7;
}

.privacy-note {
  max-width: 72ch;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ------------------------------------------------------------------ result */
.result-region {
  max-width: 980px;
  margin: 0 auto;
  padding: 8px clamp(14px, 3vw, 32px) 40px;
  scroll-margin-top: 72px;
}

.card {
  border-radius: var(--radius-lg);
}

.result-card {
  padding: clamp(20px, 4vw, 38px);
  background: rgba(3, 28, 21, 0.9);
}

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

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 12px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
}

.badge-plant {
  color: var(--mint);
}

.badge-animal {
  color: var(--amber);
}

.badge-unknown {
  color: var(--muted);
}

.badge-neutral {
  color: var(--mint-hi);
  border-style: dashed;
}

.sci-name {
  margin: 12px 0 0;
  font: italic 600 clamp(1.8rem, 1.2rem + 3vw, 3rem) / 1.15 var(--font-serif);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.sci-name.is-plain {
  font-family: var(--font-sans);
  font-size: clamp(1.5rem, 1.1rem + 2vw, 2.2rem);
  font-style: normal;
  font-weight: 700;
}

.sci-name:focus {
  outline: none;
}

.common-name {
  margin: 4px 0 0;
  color: var(--mint-hi);
  font-size: 1.25rem;
}

.kind-animal .common-name {
  color: #ffd29b;
}

.result-body {
  display: grid;
  gap: 26px;
  margin-top: 24px;
}

@media (min-width: 820px) {
  .result-body {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    gap: 40px;
  }
}

.result-col {
  display: grid;
  align-content: start;
  gap: 24px;
}

.section-title {
  margin: 0 0 10px;
  color: var(--mint-hi);
  font-size: 1rem;
  font-weight: 650;
}

.conf-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.conf-pct {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.meter {
  height: 10px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.meter-fill {
  width: var(--pct, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--mint);
  animation: fill 0.7s ease-out;
}

.meter-fill[data-level="medium"] {
  background: var(--yellow);
}

.meter-fill[data-level="low"] {
  background: var(--rose);
}

@keyframes fill {
  from {
    width: 0;
  }
}

/* Taxonomy is a hierarchy, so each rank steps in a little further. */
.ladder {
  display: grid;
  margin: 0;
  border-left: 2px solid var(--line);
}

.ladder > div {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 6px 0 6px calc(14px + var(--i, 0) * 12px);
}

.ladder > div::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--mint);
  transform: translateY(-50%);
}

.ladder dt {
  flex: none;
  width: calc(8.5em - var(--i, 0) * 12px);
  color: var(--muted);
  font-size: 0.92rem;
}

.ladder dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: var(--font-serif);
  font-size: 1.05rem;
}

.ladder dd.is-latin {
  font-style: italic;
}

.cue-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cue-list li {
  padding: 5px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(75, 227, 168, 0.12);
  font-size: 0.92rem;
}

.prose-text {
  max-width: 62ch;
  margin: 0;
  line-height: 1.75;
}

html[lang="th"] .prose-text {
  line-height: 1.95;
}

.callout {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-left: 3px solid var(--mint);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: rgba(75, 227, 168, 0.08);
}

.disclaimer {
  margin: 26px 0 0;
  padding: 12px 14px;
  border: 1px solid rgba(245, 169, 75, 0.45);
  border-radius: var(--radius-sm);
  background: rgba(245, 169, 75, 0.08);
  color: #ffe2bd;
  font-size: 0.9rem;
}

.feedback {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}

.feedback-title {
  margin: 0;
  font-weight: 650;
}

.feedback-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.fb-btn {
  min-height: 42px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(3, 26, 20, 0.5);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.fb-btn:disabled {
  cursor: progress;
  opacity: 0.6;
}

.fb-correct[aria-pressed="true"] {
  border-color: var(--mint);
  background: var(--mint);
  color: #032a1e;
}

.fb-wrong[aria-pressed="true"] {
  border-color: var(--rose);
  background: var(--rose);
  color: #340a06;
}

/* Loading card */
.loading-card {
  display: grid;
  gap: 14px;
  padding: clamp(20px, 4vw, 34px);
}

.loading-text {
  margin: 0;
  color: var(--mint-hi);
  font-weight: 600;
}

.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.07),
    rgba(255, 255, 255, 0.17),
    rgba(255, 255, 255, 0.07)
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

.sk-title {
  height: 44px;
  width: min(70%, 420px);
}

.sk-line {
  height: 16px;
}

.sk-short {
  width: 60%;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ----------------------------------------------------------------- footer */
.site-footer {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px clamp(14px, 3vw, 32px) calc(32px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  justify-content: center;
  margin-top: 8px !important;
}

/* ----------------------------------------------------------------- dialogs */
.dialog {
  width: min(640px, calc(100vw - 24px));
  max-height: min(86svh, 760px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(3, 26, 20, 0.97);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

.dialog-small {
  width: min(460px, calc(100vw - 24px));
}

.dialog::backdrop {
  background: rgba(1, 12, 9, 0.72);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.dialog-panel {
  display: grid;
  gap: 16px;
  padding: clamp(18px, 3vw, 28px);
}

.dialog h2 {
  margin: 0;
  font-size: 1.3rem;
}

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

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.history-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: rgba(11, 58, 45, 0.45);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.history-item:hover {
  border-color: var(--line);
  background: rgba(11, 58, 45, 0.8);
}

.history-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-name {
  font: italic 600 1.15rem / 1.3 var(--font-serif);
  overflow-wrap: anywhere;
}

.history-name.is-plain {
  font-family: var(--font-sans);
  font-style: normal;
}

.history-sub {
  color: var(--mint-hi);
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  color: var(--muted);
  font-size: 0.85rem;
}

.fb-tag-correct {
  color: var(--mint);
}

.fb-tag-wrong {
  color: var(--rose);
}

/* ------------------------------------------------------- phones, portrait */
@media (max-width: 560px) {
  .brand-name {
    display: none;
  }

  .stage {
    gap: 14px;
    padding-top: 18px;
  }

  .headline p {
    font-size: 0.95rem;
  }

  .console {
    padding: 12px;
  }

  .viewfinder {
    min-height: 118px;
    padding: 18px 14px;
  }

  .dz-empty svg {
    width: 34px;
    height: 34px;
  }

  .dz-title {
    margin-top: 4px;
  }

  .controls {
    gap: 10px;
  }

  .privacy-note {
    margin-top: 10px;
    font-size: 0.8rem;
  }

  .dz-preview {
    flex-direction: column;
    text-align: center;
  }

  .dz-preview img {
    width: min(70%, 220px);
  }
}

/* ============================================ extended result card content */

/* ---- Toxicity badge (Flora) ---- */
.tox-badge {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border-left: 4px solid;
}

.tox-safe    { background: rgba(75, 227, 168, 0.12); border-color: var(--mint); }
.tox-mild    { background: rgba(231, 213, 106, 0.12); border-color: var(--yellow); }
.tox-moderate { background: rgba(245, 169, 75, 0.14); border-color: var(--amber); }
.tox-severe  { background: rgba(255, 145, 135, 0.14); border-color: var(--rose); }

.tox-icon { font-size: 1.3rem; flex: none; line-height: 1.4; }
.tox-label { font-weight: 650; display: block; }
.tox-note { margin: 2px 0 0; font-size: 0.88rem; color: var(--muted); }

/* ---- Danger bar (Fauna) ---- */
.danger-bar {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border-left: 4px solid;
}

.danger-none     { background: rgba(75, 227, 168, 0.12); border-color: var(--mint); }
.danger-mild     { background: rgba(231, 213, 106, 0.12); border-color: var(--yellow); }
.danger-moderate { background: rgba(245, 169, 75, 0.14); border-color: var(--amber); }
.danger-severe   { background: rgba(255, 145, 135, 0.18); border-color: var(--rose); }

.danger-icon { font-size: 1.3rem; flex: none; line-height: 1.4; }
.danger-label { font-weight: 650; display: block; }
.danger-note { margin: 2px 0 0; font-size: 0.88rem; color: var(--muted); }

/* ---- Care info row (Flora) ---- */
.care-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.care-difficulty {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 650;
  font-size: 0.9rem;
  width: fit-content;
}

.care-difficulty[data-level="beginner"]    { background: rgba(75, 227, 168, 0.18); color: var(--mint-hi); }
.care-difficulty[data-level="intermediate"]{ background: rgba(231, 213, 106, 0.16); color: var(--yellow); }
.care-difficulty[data-level="expert"]      { background: rgba(245, 169, 75, 0.16); color: var(--amber); }

.care-diff-icon { font-size: 1rem; }

.care-icons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.care-icon-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  min-width: 100px;
}

.care-icon-emoji { font-size: 1.2rem; }

.care-icon-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.2;
}

.care-icon-val {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
}

/* ---- Tag lists (Uses, Propagation) ---- */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.tag-item {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.88rem;
  background: var(--raised);
  border: 1px solid var(--line-soft);
  color: var(--text);
}

.tag-item.tag-green {
  background: rgba(75, 227, 168, 0.1);
  border-color: rgba(75, 227, 168, 0.3);
  color: var(--mint-hi);
}

/* ---- Fauna row (Diet + Activity) ---- */
.fauna-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.fauna-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
}

.fauna-icon { font-size: 1.1rem; }

/* ---- Conservation status (Fauna) ---- */
.conservation-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.iucn-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 650;
}

.iucn-lc  { background: rgba(75, 227, 168, 0.18); color: var(--mint-hi); }
.iucn-nt  { background: rgba(169, 243, 212, 0.14); color: var(--mint-hi); }
.iucn-vu  { background: rgba(231, 213, 106, 0.18); color: var(--yellow); }
.iucn-en  { background: rgba(245, 169, 75, 0.18); color: var(--amber); }
.iucn-cr  { background: rgba(255, 145, 135, 0.18); color: var(--rose); }
.iucn-ew  { background: rgba(255, 145, 135, 0.22); color: var(--rose); }
.iucn-ex  { background: rgba(180, 50, 50, 0.3); color: #ffb0b0; }
.iucn-dd  { background: rgba(100, 120, 110, 0.3); color: var(--muted); }

.fauna-flags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.fauna-flag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.84rem;
}

.flag-protected { background: rgba(75, 227, 168, 0.1); border: 1px solid rgba(75, 227, 168, 0.3); color: var(--mint-hi); }
.flag-alien     { background: rgba(245, 169, 75, 0.1); border: 1px solid rgba(245, 169, 75, 0.3); color: var(--amber); }

/* ---- Look-alikes ---- */
.lookalike-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.lookalike-item {
  padding: 10px 12px;
  background: var(--raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}

.lookalike-name {
  display: block;
  font-weight: 650;
  font-style: italic;
  color: var(--mint-hi);
}

.lookalike-dist {
  display: block;
  font-size: 0.88rem;
  color: var(--muted);
  margin-top: 2px;
}

/* ---- Did You Know callout ---- */
.did-you-know {
  margin-top: 4px;
  padding: 14px 16px;
  background: rgba(75, 227, 168, 0.07);
  border: 1px solid rgba(75, 227, 168, 0.22);
  border-radius: var(--radius);
}

.dyk-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.dyk-icon { font-size: 1.1rem; }

.dyk-title {
  font-weight: 650;
  font-size: 0.95rem;
  color: var(--mint-hi);
}

.dyk-text {
  margin: 0;
  font-size: 0.93rem;
  color: var(--muted);
  line-height: 1.6;
}

/* ---- Mini badges in history list ---- */
.mini-badge {
  display: inline-block;
  font-size: 0.85rem;
  line-height: 1;
  padding: 1px 2px;
  border-radius: 4px;
  margin-left: 2px;
}

/* ===================================================== privacy policy page */
.doc-wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: clamp(20px, 5vh, 56px) clamp(14px, 3vw, 32px) 56px;
}

.doc {
  padding: clamp(20px, 4vw, 40px);
  background: rgba(3, 26, 20, 0.92);
}

.doc h1 {
  margin: 0 0 6px;
  font-size: clamp(1.6rem, 1.2rem + 2vw, 2.3rem);
  line-height: 1.25;
}

.doc h2 {
  margin: 30px 0 8px;
  color: var(--mint-hi);
  font-size: 1.15rem;
}

.doc p,
.doc li {
  max-width: 66ch;
}

.doc ul {
  padding-left: 1.2em;
}

.doc-note {
  margin: 16px 0 0;
  padding: 12px 14px;
  border: 1px solid rgba(245, 169, 75, 0.45);
  border-radius: var(--radius-sm);
  background: rgba(245, 169, 75, 0.08);
  color: #ffe2bd;
}

.doc-lang {
  display: inline-flex;
  gap: 8px;
  margin: 14px 0 6px;
}

/* Language switch with no JavaScript: #th shows Thai, anything else English.
 * The Thai section comes first in the HTML so the sibling selector works. */
.doc-section {
  display: none;
}

#en {
  display: block;
}

#th:target {
  display: block;
}

#th:target ~ #en {
  display: none;
}

/* ===================================================== admin dashboard */
.adm-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(18px, 4vh, 40px) clamp(14px, 3vw, 32px) 64px;
}

.adm-panel {
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(3, 26, 20, 0.9);
}

.adm-login {
  max-width: 440px;
  margin: 8vh auto 0;
}

.adm-login h1,
.adm-head h1 {
  margin: 0;
  font-size: 1.6rem;
}

.adm-form {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-weight: 600;
}

.input {
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(2, 20, 15, 0.7);
  color: var(--text);
  font: inherit;
}

.adm-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.adm-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.adm-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  margin: 0;
}

.adm-metric {
  padding: 16px 18px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(11, 58, 45, 0.82);
}

.adm-metric dt {
  color: var(--muted);
  font-size: 0.92rem;
}

.adm-metric dd {
  margin: 4px 0 0;
  font-size: 1.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.adm-metric .adm-note {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
}

.adm-section {
  margin-top: 20px;
}

.adm-section h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.adm-usage-text {
  margin: 0 0 8px;
}

.chart {
  display: block;
  width: 100%;
  height: auto;
}

.chart text {
  fill: var(--muted);
  font: 11px var(--font-sans);
}

.chart .bar-new {
  fill: var(--mint);
}

.chart .bar-cached {
  fill: rgba(169, 243, 212, 0.45);
}

.chart .axis {
  stroke: var(--line-soft);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 10px 0 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.88rem;
  list-style: none;
}

.legend i {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border-radius: 3px;
  vertical-align: -1px;
}

.legend .sw-new {
  background: var(--mint);
}

.legend .sw-cached {
  background: rgba(169, 243, 212, 0.45);
}

details.adm-details {
  margin-top: 12px;
}

details.adm-details summary {
  cursor: pointer;
  color: var(--mint-hi);
}

.table-scroll {
  overflow-x: auto;
}

.adm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.adm-table th,
.adm-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
}

.adm-table th {
  color: var(--muted);
  font-weight: 600;
}

.adm-table td.num,
.adm-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.adm-table .sci {
  font-family: var(--font-serif);
  font-style: italic;
}

.adm-empty {
  margin: 0;
  color: var(--muted);
}
