:root {
  --paper: #f4f6f5;
  --sheet: #ffffff;
  --ink: #121614;
  --muted: #5c6760;
  --line: #e3e8e5;
  --green: #0e7a4f;
  --green-deep: #0a5c3c;
  --green-soft: #e8f6ef;
  --soil: #8a5a12;
  --danger: #b42318;
  --shadow: 0 1px 2px rgba(16, 24, 20, 0.04), 0 16px 40px rgba(16, 24, 20, 0.06);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(880px 420px at 100% -12%, #e5f4ec, transparent 55%),
    radial-gradient(640px 320px at -8% -6%, #eef1f0, transparent 48%),
    var(--paper);
  font-family: var(--sans);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body.viewer-open { overflow: hidden; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 64px;
  padding: 0 1.25rem;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(18, 22, 20, 0.06);
}
.brand { display: flex; align-items: center; gap: 0.7rem; }
.mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--ink);
  color: white;
  font-weight: 700;
  letter-spacing: -0.04em;
}
.brand-text { display: grid; line-height: 1.15; }
.brand-text strong { font-size: 0.95rem; letter-spacing: -0.03em; }
.brand-text span, .brand-note {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}
.brand-note { margin: 0; letter-spacing: 0.08em; text-transform: uppercase; }

main {
  width: min(1080px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.75rem 0 4rem;
}
h1, h2, h3 { font-weight: 620; letter-spacing: -0.03em; }
h1 {
  margin: 0.15rem 0 0;
  font-size: clamp(2.1rem, 5vw, 3rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
}
.sheet h2, .group h3 {
  margin: 0 0 0.85rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.group h3 { margin-bottom: 0.75rem; }
.eyebrow {
  margin: 0;
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.lede { max-width: 38rem; margin: 0.7rem 0 0; color: var(--muted); font-size: 1.05rem; }
.mast { margin-bottom: 1.4rem; }
.sheet {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 1.25rem 1.15rem 1.35rem;
}
section + section { margin-top: 1.6rem; padding-top: 1.45rem; border-top: 1px solid var(--line); }
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.8rem;
}
.group + .group { margin-top: 1.25rem; }
label {
  display: grid;
  gap: 0.35rem;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 650;
}
.hint {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}
.with-unit { position: relative; display: block; }
.with-unit > input:not(.unit) { padding-right: 5.8rem; }
input.unit {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  width: 5rem;
  padding: 0.3rem 0.35rem;
  text-align: right;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--green-deep);
  border-color: transparent;
  background: transparent;
}
input.unit:focus {
  background: var(--green-soft);
  border-color: var(--line);
}
textarea {
  width: 100%;
  min-height: 6.5rem;
  resize: vertical;
  font: inherit;
  color: var(--ink);
  font-weight: 500;
  font-size: 1rem;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}
textarea:focus, input:focus, select:focus {
  outline: 2px solid #bfe6d1;
  border-color: var(--green);
}
.comment {
  margin: 0.7rem 0 0;
  white-space: pre-wrap;
  color: var(--ink);
}
input, select, button { font: inherit; color: var(--ink); }
input, select {
  width: 100%;
  font-weight: 500;
  font-size: 1rem;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}
.codes { display: grid; gap: 0.75rem; }
.codes div {
  padding: 0.95rem 1rem;
  border-radius: 16px;
  background: #f6f8f7;
  border: 1px solid var(--line);
}
.codes span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.codes strong {
  display: block;
  margin-top: 0.2rem;
  font-family: var(--mono);
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 650;
  letter-spacing: -0.04em;
  word-break: break-all;
}
.location-stack { display: grid; gap: 0.7rem; }
.location-pair { display: grid; gap: 0.3rem; }
.location-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.location-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.8rem;
}
.location {
  margin: 0;
  padding: 0.8rem 0.9rem;
  border-radius: 14px;
  background: #f6f8f7;
  border: 1px dashed var(--line);
  color: var(--muted);
}
.location.ok { border-style: solid; color: var(--green-deep); background: var(--green-soft); }
.location.bad { color: var(--danger); border-style: solid; background: #fdf4f3; }
.location.warn { color: var(--soil); border-style: solid; background: #fbf6ee; }
.ghost-btn {
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.7rem 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(16, 24, 20, 0.04);
}
.ghost-btn:hover { border-color: var(--green); color: var(--green-deep); }
.ghost-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ghost-btn.danger-btn { color: var(--danger); }
.ghost-btn.danger-btn:hover { border-color: var(--danger); color: var(--danger); }
#set-location {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}
#set-location:hover { background: var(--green-deep); border-color: var(--green-deep); color: white; }
#set-location:disabled { background: var(--ink); color: white; border-color: var(--ink); }
#get-location:disabled { cursor: progress; }
.uploads { display: grid; gap: 0.8rem; }
.upload { display: grid; gap: 0.55rem; align-content: start; }
.drop {
  display: grid;
  gap: 0.35rem;
  padding: 0.95rem;
  border-radius: 16px;
  border: 1px dashed #c5d0c9;
  background: #fbfcfb;
  cursor: pointer;
}
.drop:hover { border-color: var(--green); background: #f4faf7; }
.file-note {
  font-weight: 600;
  color: var(--ink);
  word-break: break-word;
}
.progress {
  display: block;
  height: 6px;
  border-radius: 999px;
  background: #e7eeea;
  overflow: hidden;
}
.progress-bar {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--green);
  transition: width 0.15s linear;
}
.progress-label {
  min-height: 1rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--green-deep);
}
[hidden] { display: none !important; }

.mode {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.2rem;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  background: var(--green-soft);
  color: var(--green-deep);
}
.mode p { margin: 0; }
.text {
  border: 0;
  background: transparent;
  color: var(--green-deep);
  font-weight: 700;
  cursor: pointer;
  padding: 0.2rem 0.15rem;
}
.actions { display: flex; justify-content: flex-end; margin-top: 1.1rem; }
button[type="submit"], .edit {
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-weight: 700;
  cursor: pointer;
}
button[type="submit"] {
  padding: 0.9rem 1.35rem;
  font-size: 1rem;
}
button[type="submit"]:disabled { opacity: 0.4; cursor: not-allowed; }
button[type="submit"]:not(:disabled):hover, .edit:hover { background: var(--green-deep); }
.status { min-height: 1.2rem; margin: 0.9rem 0 0; color: var(--green-deep); font-weight: 600; }
.status.error { color: var(--danger); }

.list-section { margin-top: 0.4rem; }
.list-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin: 1.7rem 0 0.8rem;
}
.list-head h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  text-transform: none;
  color: var(--ink);
}
.list-head p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.list { display: grid; gap: 0.75rem; }
.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1rem 1rem 1.05rem;
}
.card-top { display: flex; justify-content: space-between; gap: 0.75rem; align-items: flex-start; }
.card h3 {
  margin: 0;
  font-family: var(--mono);
  font-size: 1.15rem;
  letter-spacing: -0.04em;
}
.place { margin: 0.25rem 0 0; color: var(--muted); }
.meta { margin: 0.8rem 0 0; color: var(--muted); font-size: 0.82rem; }
.facts { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.8rem; }
.pill {
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  background: #f4f7f5;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 650;
}
.card-actions { display: flex; gap: 0.25rem; flex-shrink: 0; align-items: center; }
.edit, .danger { padding: 0.48rem 0.85rem; font-size: 0.85rem; }
.danger {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--danger);
  font-weight: 700;
  cursor: pointer;
}
.danger:hover { background: #fdf4f3; }
.empty {
  margin: 0;
  padding: 1.4rem 1.1rem;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: white;
  color: var(--muted);
}

.saved { margin-bottom: 0.9rem; }
.saved-label {
  margin: 0 0 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.media-grid, .previews {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}
.card > .media-grid { margin-top: 0.85rem; }
.previews:empty { display: none; }
.media-card {
  display: grid;
  gap: 0.4rem;
  align-content: start;
  width: 168px;
  padding: 0.45rem;
  border-radius: 14px;
  background: #f7f9f8;
  border: 1px solid var(--line);
}
.media-card:has(audio),
.media-card:has(video) { width: min(100%, 420px); }
.media-card.is-removed { opacity: 0.42; }
.media-visual { display: grid; gap: 0.3rem; }
.thumb {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  border-radius: 12px;
}
.thumb img, .viewer-body img {
  display: block;
  width: 100%;
  object-fit: cover;
  background: #101412;
}
.thumb img {
  aspect-ratio: 1;
  border-radius: 12px;
}
.media-card audio, .media-card video {
  width: 100%;
  border-radius: 10px;
  background: #101412;
}
.media-card video { max-height: 180px; }
.media-meta { display: grid; gap: 0.1rem; padding: 0 0.15rem 0.15rem; }
.media-name, .media-size {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-name { font-size: 0.78rem; font-weight: 700; }
.media-size { color: var(--muted); font-size: 0.75rem; }
.media-meta .remove { justify-self: start; color: var(--danger); font-size: 0.8rem; }
.view-link { justify-self: start; font-size: 0.8rem; }
.file-card {
  display: grid;
  gap: 0.45rem;
  align-content: space-between;
  min-height: 112px;
  padding: 0.75rem;
  border-radius: 12px;
  background: white;
  border: 1px solid var(--line);
}
.badge {
  justify-self: start;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.18rem 0.4rem;
  border-radius: 6px;
  background: var(--ink);
  color: white;
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end center;
  padding: 0.75rem;
}
.viewer-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  background: rgba(10, 14, 12, 0.64);
  backdrop-filter: blur(8px);
  cursor: pointer;
}
.viewer-panel {
  position: relative;
  width: min(880px, 100%);
  max-height: min(92vh, 920px);
  overflow: auto;
  background: white;
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  padding: 0.95rem 1rem 1.15rem;
}
.viewer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}
.viewer-bar p {
  margin: 0;
  font-weight: 700;
  word-break: break-word;
}
.viewer-actions { display: flex; gap: 0.55rem; align-items: center; flex-shrink: 0; }
.viewer-body img, .viewer-body video {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 14px;
  background: #101412;
}
.viewer-body audio { width: 100%; }
.viewer-file {
  display: grid;
  gap: 0.45rem;
  justify-items: start;
  padding: 1.2rem 0.2rem 0.4rem;
}
.viewer-file strong { font-size: 1.05rem; word-break: break-word; }
.viewer-file a {
  color: var(--green-deep);
  font-weight: 700;
}

@media (max-width: 640px) {
  .location-actions { flex-direction: column; }
  .ghost-btn, button[type="submit"] { width: 100%; }
  .actions { justify-content: stretch; }
  .viewer-bar { align-items: flex-start; }
  .viewer { place-items: end stretch; padding: 0; }
  .viewer-panel { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
}

@media (min-width: 720px) {
  .grid, .codes, .uploads { grid-template-columns: 1fr 1fr; }
  .wide { grid-column: 1 / -1; }
  .viewer { place-items: center; padding: 1.5rem; }
}

.top-actions { display: flex; align-items: center; gap: 0.85rem; }
.top-actions a {
  color: var(--ink);
  font-weight: 700;
  font-size: 0.88rem;
  text-decoration: none;
}
.auth-main { width: min(480px, calc(100% - 2rem)); }
.auth-form { display: grid; gap: 0.9rem; }
.auth-form .actions { margin-top: 0.2rem; }
.auth-links {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem 0 0;
}
.auth-links a { color: var(--green-deep); font-weight: 700; }
#turnstile:empty, #turnstile-resend:empty { display: none; }
.stack { display: grid; gap: 0.9rem; margin-bottom: 0.2rem; }
.stack[hidden] { display: none; }
.account-card {
  margin: 0;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  background: var(--green-soft);
  color: var(--green-deep);
}
.account-card p { margin: 0.2rem 0; }
