:root {
  /* Sand / stone palette */
  --sand-50:  #faf6ee;
  --sand-100: #f3ecdd;
  --sand-200: #e7dcc4;
  --sand-300: #d8c7a5;
  --stone-500:#8a7f6b;
  --stone-700:#544c3d;
  --stone-900:#2b2620;
  --terra:    #a8622f;   /* terracotta accent */
  --terra-dark:#8a4f26;
  --olive:    #7d7a52;
  --ok:       #4c7a4c;
  --warn:     #b5892f;
  --danger:   #a5433a;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(43, 38, 32, 0.08);
}

* { box-sizing: border-box; }

/* Ensure the [hidden] attribute always wins over display rules below. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--stone-900);
  background: linear-gradient(160deg, var(--sand-100), var(--sand-200));
  min-height: 100vh;
}

/* Header */
.site-header {
  display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap;
  padding: 1.1rem 1.6rem;
  background: var(--sand-50);
  border-bottom: 1px solid var(--sand-300);
}
.brand { display: flex; align-items: baseline; gap: .55rem; }
.brand-mark { font-size: 1.6rem; color: var(--terra); font-weight: 700; }
.brand-name { font-size: 1.35rem; font-weight: 700; letter-spacing: .02em; }
.brand-tagline { margin: 0; color: var(--stone-500); font-size: .9rem; }

/* Cards */
.card {
  background: var(--sand-50);
  border: 1px solid var(--sand-300);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem;
}
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.05rem; margin: 0 0 .3rem; color: var(--stone-700); }
.lede, .hint, .opt { color: var(--stone-500); }
.lede { margin: 0 0 1.2rem; line-height: 1.5; }
.hint { font-size: .88rem; margin: 0 0 .8rem; }
.opt { font-weight: 400; font-size: .8rem; }

/* Gate */
.gate { display: grid; place-items: center; padding: 3rem 1.2rem; }
.gate-card { max-width: 460px; width: 100%; }

/* App layout */
.app { padding: 1.6rem; }
.intro {
  max-width: 1400px; margin: 0 auto 1.4rem;
  background: var(--sand-50);
  border: 1px solid var(--sand-300);
  border-left: 4px solid var(--terra);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.3rem;
}
.intro h1 { font-size: 1.15rem; margin: 0 0 .3rem; }
.intro p { margin: 0; color: var(--stone-700); line-height: 1.5; }
.columns {
  display: grid; gap: 1.4rem;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: start;
  max-width: 1400px; margin: 0 auto;
}
@media (max-width: 1100px) { .columns { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px)  { .columns { grid-template-columns: 1fr; } }

/* Forms */
.form { display: flex; flex-direction: column; gap: .7rem; }
.form label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; font-weight: 600; color: var(--stone-700); }
.form input, .form select, .form textarea {
  font: inherit; padding: .5rem .6rem;
  border: 1px solid var(--sand-300); border-radius: 8px;
  background: #fff; color: var(--stone-900);
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none; border-color: var(--terra); box-shadow: 0 0 0 3px rgba(168,98,47,.15);
}
.row, .coords { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }

/* Buttons */
.btn { font: inherit; font-weight: 600; padding: .6rem 1rem; border-radius: 9px; border: 1px solid transparent; cursor: pointer; }
.btn-primary { background: var(--terra); color: #fff; }
.btn-primary:hover { background: var(--terra-dark); }
.btn-primary:disabled { background: var(--stone-500); opacity: .5; cursor: not-allowed; }

/* Map */
.map { height: 300px; border-radius: 10px; overflow: hidden; margin-bottom: .8rem; border: 1px solid var(--sand-300); }

/* File drop */
.filedrop { position: relative; border: 1.5px dashed var(--sand-300); border-radius: 10px; padding: 1rem; text-align: center; color: var(--stone-500); cursor: pointer; }
.filedrop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.filedrop span.has-file { color: var(--stone-900); font-weight: 600; }
.filedrop:has(span.has-file) { border-color: var(--terra); border-style: solid; background: var(--sand-100); }

/* Feed */
.feed-title { margin-top: 1.4rem; }
.feed { list-style: none; padding: 0; margin: .4rem 0 0; display: flex; flex-direction: column; gap: .5rem; }
.feed-empty { color: var(--stone-500); font-size: .88rem; }
.feed-item { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .6rem .8rem; background: var(--sand-100); border: 1px solid var(--sand-300); border-radius: 9px; font-size: .88rem; }
.feed-item .label { display: flex; flex-direction: column; }
.feed-item .kind { color: var(--stone-500); font-size: .78rem; }
.badge { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: .2rem .5rem; border-radius: 999px; }
.badge.received { background: #eee7d6; color: var(--warn); }
.badge.processing { background: #e6ecdd; color: var(--olive); }
.badge.published { background: #dcecdc; color: var(--ok); }
.badge-link { text-decoration: none; cursor: pointer; }
.badge-link:hover { text-decoration: underline; filter: brightness(0.96); }
.badge.failed { background: #f0dcd9; color: var(--danger); }

.error { color: var(--danger); font-size: .85rem; margin: .2rem 0 0; }
