:root {
    --bg:       #1e1e1c;
    --bg-card:  #252523;
    --bg-hover: #2e2e2b;
    --sand:     #c8b99a;
    --stone:    #7a6e60;
    --text:     #ddd5c4;
    --palm:     #5a7a50;
    --water:    #3d6070;
    --rule:     rgba(200,185,154,0.11);
  }

  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html { scroll-behavior: smooth; }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
  }

  body::before {
    content: '';
    position: fixed; inset: 0; z-index: 1000;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.045'/%3E%3C/svg%3E");
    background-size: 180px;
    opacity: 0.5;
    mix-blend-mode: screen;
  }

  /* ── HEADER ── */
  header {
    display: flex;
    align-items: flex-end;
    padding: 1.2rem 1.5rem 1rem;
    border-bottom: 1px solid var(--rule);
    opacity: 0;
    animation: fadeUp 1.2s ease 0.1s forwards;
  }

  header h1 {
    font-weight: 700;
    font-size: clamp(1.4rem, 4vw, 2.4rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text);
    line-height: 1.1;
  }

  header h1 em {
    font-style: normal;
    font-weight: 600;
    color: var(--sand);
  }

  header .subtitle {
    margin-top: 0.35rem;
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--sand);
    opacity: 0.6;
  }

  /* ── MAP ── */
  .map-section {
    padding: 0;
    background: var(--bg);
    opacity: 0;
    animation: fadeUp 1.4s ease 0.3s forwards;
  }

  /* Map embed — full image, fit to width, no cropping */
  .map-frame {
    position: relative;
    width: 100%;
    background: var(--bg);
    border: none;
    overflow: hidden;
  }

  .map-img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
    background: var(--bg);
  }

  .map-download-bar {
    display: flex;
    align-items: center;
    padding: 0.7rem 1rem;
    background: var(--bg);
    border-top: none;
  }

  .btn-download {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    border: 1px solid var(--sand);
    background: transparent;
    color: var(--sand);
    font-size: 0.62rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
  }

  .btn-download:hover { background: var(--sand); color: var(--bg); }
  .btn-download svg { width: 11px; height: 11px; fill: currentColor; }

  /* ── SHARED SWIPE ROW ── */
  .swipe-section {
    padding: 0;
  }

  .swipe-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 0.7rem 1.5rem 0.6rem;
  }

  .swipe-label {
    font-size: 0.65rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--sand);
    opacity: 0.75;
    transition: opacity 0.15s ease;
  }

  .swipe-hint {
    font-size: 0.6rem;
    letter-spacing: 0.12em;
    color: var(--sand);
    opacity: 0.3;
  }

  .swipe-link {
    font-size: 0.6rem;
    letter-spacing: 0.12em;
    color: var(--sand);
    opacity: 0.55;
    text-decoration: none;
    transition: opacity 0.2s;
  }
  .swipe-link:hover { opacity: 1; }

  .swipe-track {
    display: flex;
    gap: 1px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    cursor: grab;
    user-select: none;
    align-items: stretch;
  }
  .swipe-track::-webkit-scrollbar { display: none; }

  /* ── PANEL CARDS (Field Notes) ── */
  .panel-card {
    flex: 0 0 300px;
    scroll-snap-align: start;
    background: var(--bg-card);
    padding: 1.3rem 1.4rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  @media (min-width: 600px) { .panel-card { flex: 0 0 340px; } }

  .panel-number {
    font-size: 0.58rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--sand);
    opacity: 0.45;
  }

  .panel-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.25;
    letter-spacing: 0.02em;
  }

  .panel-subtitle {
    font-size: 0.7rem;
    color: var(--sand);
    opacity: 0.6;
    line-height: 1.4;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--rule);
  }

  .panel-text {
    font-size: 0.78rem;
    color: var(--text);
    opacity: 0.72;
    line-height: 1.65;
    flex: 1;
  }

  /* ── REALM CARDS ── */
  .realm-card {
    flex: 0 0 300px;
    scroll-snap-align: start;
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
  }

  @media (min-width: 600px) { .realm-card { flex: 0 0 340px; } }

  .realm-track {
    overflow-y: clip;
    align-items: flex-start;
  }

  .card-img-wrap {
    width: 100%;
    flex-shrink: 0;
    padding: 0.9rem 0.9rem 0;
  }

  .card-img-wrap img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
    border-radius: 8px;
  }

  .card-img-placeholder {
    width: 100%; height: 100%;
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--rule);
  }

  .card-img-placeholder span {
    font-size: 2rem;
    font-weight: 700;
    color: var(--sand);
    opacity: 0.1;
  }

  .card-body {
    padding: 1rem 1.2rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
  }

  .card-eyebrow {
    font-size: 0.58rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--sand);
    opacity: 0.45;
  }

  .card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
  }

  .card-subtitle {
    font-size: 0.7rem;
    color: var(--sand);
    opacity: 0.6;
    line-height: 1.35;
    padding-bottom: 0.4rem;
  }

  .card-text {
    font-size: 0.77rem;
    color: var(--text);
    opacity: 0.68;
    line-height: 1.62;
    flex: 1;
  }

  /* ── Collapsible text (all screens) ── */
  .expandable {
    position: relative;
    max-height: 8.1em;
    overflow: hidden;
    transition: max-height 0.35s ease;
  }

  .expandable.open {
    max-height: 2000px;
  }

  .expandable::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2em;
    background: linear-gradient(transparent, var(--bg-card));
    pointer-events: none;
    transition: opacity 0.2s;
  }

  .expandable.open::after {
    opacity: 0;
  }

  .expand-btn {
    display: inline-flex;
    align-items: center;
    background: none;
    border: none;
    padding: 0;
    margin-top: auto;
    font-size: 0.6rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--sand);
    opacity: 0.5;
    cursor: pointer;
    transition: opacity 0.2s;
    text-align: left;
    line-height: 1;
  }

  .expand-btn:hover { opacity: 1; }

  .btn-chapter {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: none;
    border: none;
    color: #cc3322;
    font-family: inherit;
    font-size: 0.65rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    cursor: pointer;
    opacity: 0.85;
    padding: 0;
    transition: opacity 0.2s;
    line-height: 1;
  }
  .btn-chapter:hover { opacity: 1; }
  .btn-chapter svg {
    width: 13px;
    height: 13px;
    stroke: #cc3322;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  

  .card-metrics {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--rule);
    flex-wrap: wrap;
  }

  .metric {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.66rem;
    color: var(--sand);
    opacity: 0.65;
  }

  .metric svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.3; flex-shrink: 0; }
  .metric.alt { margin-left: auto; opacity: 0.38; font-size: 0.6rem; letter-spacing: 0.06em; }

  /* ── SOUND CARDS ── */
  .sound-card {
    flex: 0 0 300px;
    scroll-snap-align: start;
    background: var(--bg-card);
    padding: 1.1rem 1.2rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
  }

  @media (min-width: 600px) { .sound-card { flex: 0 0 340px; } }

  .sound-top { display: flex; justify-content: space-between; align-items: flex-start; }

  .sound-realm {
    font-size: 0.57rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--sand);
    opacity: 0.5;
  }

  .sound-dur { font-size: 0.6rem; color: var(--sand); opacity: 0.35; white-space: nowrap; }

  .sound-title { font-size: 0.92rem; font-weight: 600; color: var(--text); line-height: 1.25; }

  .sound-desc { font-size: 0.75rem; color: var(--text); opacity: 0.58; line-height: 1.55; flex: 1; }

  .sound-controls { display: flex; align-items: center; gap: 0.8rem; }

  .play-btn {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(200,185,154,0.4);
    background: transparent;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0;
    transition: background 0.2s, color 0.2s;
    color: var(--sand);
  }

  .play-btn:hover, .sound-card.playing .play-btn { background: var(--sand); color: var(--bg); }
  .play-btn svg { width: 11px; height: 11px; fill: currentColor; }

  .progress-track {
    flex: 1; height: 1px;
    background: rgba(200,185,154,0.12);
    position: relative; cursor: pointer;
  }

  .progress-fill {
    position: absolute; left: 0; top: 0; bottom: 0;
    background: var(--sand); width: 0%;
    transition: width 0.2s linear;
  }

  .waveform { display: none; align-items: flex-end; gap: 2px; height: 14px; }
  .sound-card.playing .waveform { display: flex; }

  .waveform span {
    display: block; width: 2px; background: var(--palm); border-radius: 1px;
    animation: wave 0.8s ease-in-out infinite;
  }
  .waveform span:nth-child(1) { height: 100%; }
  .waveform span:nth-child(2) { animation-delay: 0.1s; height: 70%; }
  .waveform span:nth-child(3) { animation-delay: 0.2s; height: 100%; }
  .waveform span:nth-child(4) { animation-delay: 0.15s; height: 60%; }
  .waveform span:nth-child(5) { animation-delay: 0.05s; height: 80%; }

  .sound-link {
    font-size: 0.58rem; letter-spacing: 0.12em;
    color: var(--sand); opacity: 0.45;
    text-decoration: none; transition: opacity 0.2s;
    margin-top: 0.1rem;
  }
  .sound-link:hover { opacity: 1; }

  /* ── FOOTER ── */
  footer {
    padding: 1.5rem;
    margin-top: 1.2rem;
    opacity: 0;
    animation: fadeUp 1.2s ease 0.5s forwards;
  }

  footer p {
    font-size: 0.6rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--sand);
    opacity: 0.35;
    text-align: center;
  }


  /* ── SPECIES CARDS (Flora / Fauna) ── */
  .species-card {
    flex: 0 0 200px;
    scroll-snap-align: start;
    background: var(--bg-card);
    padding: 1.2rem 1rem 1.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    text-align: center;
  }

  @media (min-width: 600px) { .species-card { flex: 0 0 220px; } }

  .species-img-wrap {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid rgba(200,185,154,0.15);
  }

  #flora .species-img-wrap { border: 2px solid rgba(157,186,26,0.55); }
  #fauna .species-img-wrap { border: 2px solid rgba(212,64,90,0.55); }

  .species-img-wrap img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
  }

  .species-img-placeholder {
    width: 100%; height: 100%;
    background: var(--bg-hover);
    display: flex; align-items: center; justify-content: center;
  }

  .species-img-placeholder span {
    font-size: 1.8rem; opacity: 0.15;
  }

  .species-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
  }

  .flora-name  { color: #9dba1a; }
  .fauna-name  { color: #d4405a; }

  .species-link {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.5rem;
    font-size: 0.6rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--sand);
    opacity: 0.45;
    text-decoration: none;
    transition: opacity 0.2s;
  }
  .species-link:hover { opacity: 1; }
  .species-link svg { width: 10px; height: 10px; flex-shrink: 0; }

  .species-latin {
    font-size: 0.65rem;
    font-style: italic;
    color: var(--sand);
    opacity: 0.55;
    line-height: 1.3;
  }

  .species-desc {
    font-size: 0.72rem;
    color: var(--text);
    opacity: 0.62;
    line-height: 1.55;
  }

  .species-desc.expandable {
    text-align: left;
    width: 100%;
  }

  /* ── ANIMATIONS ── */
  @keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  @keyframes wave {
    0%, 100% { transform: scaleY(0.35); }
    50%       { transform: scaleY(1); }
  }

  /* ── Lang toggle ── */
  #lang-toggle {
    position: fixed; top: 0.85rem; right: 1rem; z-index: 9999;
    display: flex; align-items: center;
    background: rgba(30,30,28,0.9); border: 1px solid rgba(200,185,154,0.2);
    backdrop-filter: blur(6px); border-radius: 3px; overflow: hidden;
    font-family: 'DM Sans', sans-serif; font-size: 0.65rem; letter-spacing: 0.1em;
  }
  #lang-toggle button {
    background: none; border: none; padding: 0.35rem 0.65rem;
    color: var(--sand); opacity: 0.4; cursor: pointer;
    font-family: inherit; font-size: inherit; transition: opacity 0.2s, background 0.2s;
  }
  #lang-toggle button.active { opacity: 1; background: rgba(200,185,154,0.12); }
  #lang-toggle .div { width: 1px; height: 1rem; background: rgba(200,185,154,0.2); }
  body.ar, body.ar * { font-family: 'IBM Plex Arabic', sans-serif; direction: rtl; }
  body.ar .swipe-hint { display: inline-block; transform: scaleX(-1); }
  body.ar .metric.alt { margin-left: 0; margin-right: auto; }
  body.ar .card-eyebrow, body.ar .panel-number,
  body.ar .sound-realm  { letter-spacing: 0; }
  body.ar #lang-toggle  { right: auto; left: 1rem; }
  body.zh, body.zh * { font-family: 'Noto Sans SC', 'DM Sans', sans-serif; }

  /* ── FEEDBACK SECTION ── */
  .feedback-form {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    flex: 1;
  }

  .feedback-form input[type="text"],
  .feedback-form input[type="email"],
  .feedback-form select,
  .feedback-form textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid rgba(200,185,154,0.18);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    padding: 0.55rem 0.7rem;
    outline: none;
    transition: border-color 0.2s;
    appearance: none;
    -webkit-appearance: none;
    border-radius: 0;
  }

  .feedback-form input[type="text"]::placeholder,
  .feedback-form input[type="email"]::placeholder,
  .feedback-form textarea::placeholder {
    color: var(--sand);
    opacity: 0.3;
    text-transform: uppercase;
    font-size: 0.62rem;
    letter-spacing: 0.1em;
  }

  .feedback-form input:focus,
  .feedback-form select:focus,
  .feedback-form textarea:focus {
    border-color: rgba(200,185,154,0.45);
  }

  .feedback-form select {
    color: var(--text);
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23c8b99a' stroke-opacity='.35' stroke-width='1.2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    padding-right: 1.8rem;
  }

  .feedback-form select option { background: var(--bg); color: var(--text); }
  .feedback-form textarea { resize: vertical; min-height: 68px; line-height: 1.55; }


  .feedback-submit-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-top: 0.55rem;
    border-top: 1px solid var(--rule);
  }

  .feedback-note {
    font-size: 0.55rem;
    letter-spacing: 0.1em;
    color: var(--sand);
    opacity: 0.28;
    text-transform: uppercase;
  }


  /* ── CHAPTER PANEL ── */
  .chapter-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    z-index: 500;
    pointer-events: none;
  }
  .chapter-overlay.active { pointer-events: all; }

  .chapter-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background: rgba(10,10,9,0);
    transition: background 0.35s ease;
  }
  .chapter-overlay.active .chapter-backdrop {
    background: rgba(10,10,9,0.65);
  }

  .chapter-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    height: 100%;
    height: 100dvh;
    width: min(100vw, 680px);
    background: var(--bg);
    transform: translateX(100%);
    transition: transform 0.38s cubic-bezier(.4,0,.2,1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .chapter-overlay.active .chapter-panel {
    transform: translateX(0);
  }

  .chapter-head {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 1rem 1.4rem;
    border-bottom: 1px solid var(--rule);
    flex-shrink: 0;
  }
  .chapter-back {
    background: none;
    border: none;
    color: var(--sand);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    opacity: 0.6;
    padding: 0;
    transition: opacity 0.2s;
    font-family: inherit;
  }
  .chapter-back:hover { opacity: 1; }
  .chapter-eyebrow {
    font-size: 0.58rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--sand);
    opacity: 0.35;
  }

  .chapter-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.8rem 1.4rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
    -webkit-overflow-scrolling: touch;
  }

  .chapter-hero {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    display: block;
    background: var(--bg-card);
  }

  .chapter-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    letter-spacing: 0.01em;
  }

  .chapter-intro {
    font-size: 0.82rem;
    color: var(--text);
    opacity: 0.7;
    line-height: 1.7;
  }

  .chapter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem;
  }
  @media (max-width: 480px) { .chapter-grid { grid-template-columns: 1fr; } }

  .chapter-col-label {
    font-size: 0.58rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--sand);
    opacity: 0.45;
    margin-bottom: 0.45rem;
  }
  .chapter-col-text {
    font-size: 0.78rem;
    color: var(--text);
    opacity: 0.7;
    line-height: 1.65;
  }

  .chapter-img-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
  }
  .chapter-img-row img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    display: block;
    background: var(--bg-card);
  }
  .chapter-img-caption {
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--sand);
    opacity: 0.35;
    margin-top: 0.3rem;
  }
  .chapter-rule {
    border: none;
    border-top: 1px solid var(--rule);
  }
  .chapter-note {
    font-size: 0.72rem;
    color: var(--sand);
    opacity: 0.5;
    line-height: 1.6;
    padding: 0.8rem;
    border: 1px solid var(--rule);
    letter-spacing: 0.01em;
  }
