/* ============================================================
   Stashly — "The Field Journal" theme
   Warm parchment + espresso ink, single marigold accent.
   ============================================================ */
:root {
  --paper:    #f4ead2;
  --paper-2:  #efe2c4;
  --card:     #fbf4e3;
  --ink:      #2c2420;
  --ink-soft: #6f6051;
  --ink-faint:#9a8a76;
  --line:     rgba(44,36,32,0.13);
  --line-2:   rgba(44,36,32,0.08);
  --accent:   #e0892e;   /* marigold — "found it" */
  --accent-d: #c5701b;
  --teal:     #2f6e63;   /* location pins */
  --danger:   #b23a2e;
  --shadow:   0 1px 2px rgba(44,36,32,.10), 0 10px 26px -12px rgba(44,36,32,.32);
  --shadow-lg:0 24px 60px -18px rgba(44,36,32,.45);
  --r:        16px;
  --r-lg:     22px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Hanken Grotesk", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
html[data-theme="dark"] {
  --paper:    #211d1a;
  --paper-2:  #1a1715;
  --card:     #2b2521;
  --ink:      #f1e7d4;
  --ink-soft: #c2b09a;
  --ink-faint:#8a7866;
  --line:     rgba(241,231,212,0.14);
  --line-2:   rgba(241,231,212,0.07);
  --accent:   #f0a14a;
  --accent-d: #e0892e;
  --teal:     #67b3a4;
  --danger:   #e0705f;
  --shadow:   0 1px 2px rgba(0,0,0,.4), 0 12px 30px -14px rgba(0,0,0,.6);
  --shadow-lg:0 28px 70px -20px rgba(0,0,0,.7);
}
@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --paper:#211d1a;--paper-2:#1a1715;--card:#2b2521;--ink:#f1e7d4;--ink-soft:#c2b09a;
    --ink-faint:#8a7866;--line:rgba(241,231,212,0.14);--line-2:rgba(241,231,212,0.07);
    --accent:#f0a14a;--accent-d:#e0892e;--teal:#67b3a4;--danger:#e0705f;
    --shadow:0 1px 2px rgba(0,0,0,.4),0 12px 30px -14px rgba(0,0,0,.6);
    --shadow-lg:0 28px 70px -20px rgba(0,0,0,.7);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* beat element display rules (e.g. .danger-text) */
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(120% 80% at 100% 0%, var(--paper-2), transparent 60%),
    radial-gradient(110% 70% at 0% 100%, var(--paper-2), transparent 55%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
/* paper grain */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 1; opacity: .5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}
html[data-theme="dark"] .grain { mix-blend-mode: screen; opacity: .06; }
@media (prefers-color-scheme: dark){ html[data-theme="auto"] .grain{ mix-blend-mode: screen; opacity:.06; } }

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ---------- App bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top,0px) + 14px) 20px 12px;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(12px) saturate(1.2);
  border-bottom: 1px solid var(--line-2);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand .mark { color: var(--accent); display: grid; place-items: center; transform: translateY(1px); }
.brand h1 {
  font-family: var(--font-display); font-optical-sizing: auto;
  font-weight: 600; font-size: 27px; letter-spacing: -.02em; margin: 0;
}
.appbar-actions { display: flex; align-items: center; gap: 6px; }
.counter {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13px;
  color: var(--ink-soft); background: var(--card); border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 999px; min-width: 30px; text-align: center;
}
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-soft);
  transition: transform .15s, color .15s, border-color .15s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn .i-moon { display: none; }
html[data-theme="dark"] .icon-btn .i-sun { display: none; }
html[data-theme="dark"] .icon-btn .i-moon { display: block; }
@media (prefers-color-scheme: dark){
  html[data-theme="auto"] .icon-btn .i-sun{display:none;}
  html[data-theme="auto"] .icon-btn .i-moon{display:block;}
}

/* ---------- Screen ---------- */
.screen { position: relative; z-index: 2; padding: 16px 18px 140px; max-width: 720px; margin: 0 auto; }

/* ---------- Search ---------- */
.search-wrap { position: relative; margin-bottom: 14px; }
.search-ico { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); }
#search {
  width: 100%; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 14px; padding: 14px 16px 14px 44px; font-size: 16px; box-shadow: var(--shadow);
  transition: border-color .18s, box-shadow .18s;
}
#search::placeholder { color: var(--ink-faint); }
#search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }

/* ---------- Chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 14px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; border: 1px solid var(--line); background: transparent; color: var(--ink-soft);
  padding: 8px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; transition: all .15s;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--teal); }

/* ---------- List + cards ---------- */
.list { display: flex; flex-direction: column; gap: 12px; }
.card {
  position: relative; display: grid; grid-template-columns: 64px 1fr; gap: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 13px; box-shadow: var(--shadow); text-align: left; width: 100%; color: inherit;
  animation: rise .5s cubic-bezier(.2,.8,.2,1) both;
  transition: transform .14s ease, box-shadow .2s;
}
.card:active { transform: scale(.985); }
.card::before { /* tape/notch accent */
  content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 3px;
  background: var(--accent); border-radius: 0 3px 3px 0; opacity: .9;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.thumb {
  width: 64px; height: 64px; border-radius: 12px; overflow: hidden; flex: none;
  background: var(--paper-2); display: grid; place-items: center; border: 1px solid var(--line-2);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .mono {
  font-family: var(--font-display); font-weight: 600; font-size: 26px; color: var(--accent-d);
}
.card-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.card-name { font-weight: 700; font-size: 16.5px; letter-spacing: -.01em; line-height: 1.15;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-loc { display: inline-flex; align-items: center; gap: 5px; color: var(--teal); font-size: 13.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-loc svg { flex: none; }
.card-meta { display: flex; align-items: center; gap: 8px; margin-top: 2px; flex-wrap: wrap; }
.tag { font-size: 11.5px; font-weight: 600; color: var(--ink-soft); background: var(--paper-2);
  border: 1px solid var(--line-2); padding: 2px 8px; border-radius: 999px; }
.ago { font-size: 12px; color: var(--ink-faint); }
.card.retrieved { opacity: .62; }
.card.retrieved .card-name { text-decoration: line-through; text-decoration-color: var(--ink-faint); }
.card .found-badge {
  position: absolute; right: 10px; top: 10px; font-family: var(--font-display); font-weight: 900;
  font-size: 11px; letter-spacing: .14em; color: var(--teal); border: 2px solid var(--teal);
  padding: 1px 6px; border-radius: 5px; transform: rotate(-9deg); opacity: .85;
}

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 40px 24px; color: var(--ink-soft); }
.empty-art { color: var(--accent); opacity: .55; margin-bottom: 6px; }
.empty h2 { font-family: var(--font-display); font-weight: 600; font-size: 23px; color: var(--ink); margin: 6px 0 8px; }
.empty p { max-width: 34ch; margin: 0 auto; line-height: 1.5; font-size: 15px; }

/* ---------- FAB ---------- */
.fab {
  position: fixed; z-index: 25; right: 18px; bottom: calc(20px + var(--safe-b));
  display: inline-flex; align-items: center; gap: 7px; padding: 15px 20px 15px 16px;
  background: var(--accent); color: #2c2017; border: none; border-radius: 999px;
  font-weight: 700; font-size: 15.5px; box-shadow: 0 10px 28px -8px color-mix(in srgb, var(--accent) 70%, black);
  transition: transform .16s cubic-bezier(.2,1.3,.4,1);
}
.fab:active { transform: scale(.93); }
.fab svg { color: #2c2017; }

/* ---------- Sheets ---------- */
.sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(20,15,12,.46); backdrop-filter: blur(2px); animation: fade .25s ease both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet-card {
  position: relative; width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  background: var(--paper); border-radius: 26px 26px 0 0; padding: 8px 20px calc(28px + var(--safe-b));
  box-shadow: var(--shadow-lg); border: 1px solid var(--line);
  animation: slideUp .34s cubic-bezier(.2,.9,.25,1) both;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 6px auto 12px; }
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-bottom: 14px; }
.sheet-head h2 { font-family: var(--font-display); font-weight: 600; font-size: 20px; text-align: center; margin: 0; }
.ghost { background: none; border: none; color: var(--ink-soft); font-weight: 600; font-size: 15px; justify-self: start; padding: 6px; }
.solid { background: var(--accent); color: #2c2017; border: none; font-weight: 700; font-size: 15px; padding: 9px 18px; border-radius: 999px; justify-self: end; transition: transform .14s; }
.solid:active { transform: scale(.94); }

/* photo field */
.photo-field { display: block; margin-bottom: 16px; }
.photo-preview {
  height: 168px; border-radius: 18px; border: 2px dashed var(--line); background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: var(--ink-faint); font-weight: 600; font-size: 14px; overflow: hidden;
}
.photo-preview.has-img { border-style: solid; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }

/* fields */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 13.5px; color: var(--ink-soft); margin-bottom: 6px; }
.field .muted { color: var(--ink-faint); font-weight: 500; }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 12px; padding: 13px 14px; font-size: 16px; resize: none;
  transition: border-color .16s, box-shadow .16s;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.suggest button { font-size: 12.5px; font-weight: 600; color: var(--teal); background: color-mix(in srgb, var(--teal) 12%, transparent); border: 1px solid color-mix(in srgb, var(--teal) 30%, transparent); padding: 4px 10px; border-radius: 999px; }
.danger-text { display: block; margin: 6px auto 0; background: none; border: none; color: var(--danger); font-weight: 600; font-size: 14px; padding: 10px; }

/* ---------- Detail ---------- */
.detail-hero { margin: -8px -20px 16px; height: 240px; background: var(--paper-2); overflow: hidden; position: relative; }
.detail-hero img { width: 100%; height: 100%; object-fit: cover; }
.detail-hero.no-img { display: grid; place-items: center; }
.detail-hero .mono-lg { font-family: var(--font-display); font-weight: 600; font-size: 86px; color: var(--accent); opacity: .5; }
.detail-name { font-family: var(--font-display); font-weight: 600; font-size: 27px; letter-spacing: -.02em; line-height: 1.1; margin: 4px 0 10px; }
.detail-loc { display: inline-flex; align-items: center; gap: 7px; color: var(--teal); font-weight: 700; font-size: 16px; margin-bottom: 14px; }
.detail-note { color: var(--ink-soft); line-height: 1.55; font-size: 15px; background: var(--card); border: 1px solid var(--line-2); border-left: 3px solid var(--accent); padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 18px; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.detail-actions .wide { grid-column: 1 / -1; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px; border-radius: 14px; font-weight: 700; font-size: 15px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); transition: transform .14s;
}
.btn:active { transform: scale(.96); }
.btn-found { background: var(--accent); color: #2c2017; border-color: transparent; }
.btn-found.is-found { background: var(--teal); color: #fff; }
.btn-del { color: var(--danger); }
.detail-when { text-align: center; color: var(--ink-faint); font-size: 12.5px; margin-top: 14px; }

/* ---------- FOUND stamp ---------- */
.stamp {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; pointer-events: none;
}
.stamp span {
  font-family: var(--font-display); font-weight: 900; font-size: 64px; letter-spacing: .06em;
  color: var(--teal); border: 6px solid var(--teal); border-radius: 14px; padding: 10px 26px;
  transform: rotate(-13deg) scale(2.4); opacity: 0; text-transform: uppercase;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 30%, transparent) inset;
  animation: stamp 1.1s cubic-bezier(.2,1.4,.3,1) forwards;
}
@keyframes stamp {
  0% { opacity: 0; transform: rotate(-13deg) scale(2.6); }
  16% { opacity: 1; transform: rotate(-13deg) scale(.92); }
  26% { transform: rotate(-13deg) scale(1.02); }
  70% { opacity: 1; transform: rotate(-13deg) scale(1); }
  100% { opacity: 0; transform: rotate(-13deg) scale(1); }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 70; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
