:root {
  --bg: #faf6f0;
  --surface: #ffffff;
  --text: #2b2320;
  --muted: #7a6e68;
  --border: #e8dfd6;
  --primary: #1f6f5f;
  --primary-dark: #185649;
  --accent: #c2410c;
  --danger: #b3261e;
  --ok-bg: #e4f3ec;
  --ok-text: #14532d;
  --error-bg: #fdecea;
  --error-text: #8a1c15;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(43, 35, 32, 0.06), 0 8px 24px -12px rgba(43, 35, 32, 0.18);
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5rem; }
h1 { font-size: clamp(1.75rem, 2vw + 1.2rem, 2.5rem); letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75rem; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem clamp(1rem, 4vw, 2.5rem);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}
.brand-icon { font-size: 1.4rem; }
.badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--primary);
  color: #fff;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}
.site-nav { display: flex; align-items: center; gap: 1rem; }
.site-nav form { margin: 0; }

.container {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2.5rem) clamp(1rem, 4vw, 2.5rem) 3rem;
}

.site-footer {
  padding: 1.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}
.site-footer a { color: inherit; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.25rem, 3vw, 2rem);
}
.narrow { max-width: 480px; margin: 2rem auto; }
.narrow-wide { max-width: 680px; }
.link-rows { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 1rem; }
.link-row { padding: 1rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); display: flex; flex-direction: column; gap: 0.75rem; }
.link-row-tail { align-items: flex-end; }
.link-row-tail .btn { margin-bottom: 0.2rem; }
.hero { max-width: 640px; margin: 3rem auto; text-align: center; }
.hero h1 { font-size: 2.5rem; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.4rem;
}
.lead { font-size: 1.1rem; }
.muted { color: var(--muted); }
.hint { display: block; font-size: 0.85rem; color: var(--muted); margin-top: 0.3rem; }
.error { color: var(--error-text); background: var(--error-bg); padding: 0.6rem 0.8rem; border-radius: 8px; }

.page-head { margin-bottom: 1.5rem; }

.flash {
  padding: 0.85rem 1rem;
  border-radius: 10px;
  margin-bottom: 1.5rem;
  font-weight: 500;
}
.flash-ok { background: var(--ok-bg); color: var(--ok-text); }
.flash-error { background: var(--error-bg); color: var(--error-text); }

/* Forms */
.form { display: flex; flex-direction: column; gap: 1rem; }
.form label { display: flex; flex-direction: column; gap: 0.3rem; }
.form label.check { flex-direction: row; align-items: center; gap: 0.6rem; }
.label { font-weight: 600; font-size: 0.9rem; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row > label { flex: 1 1 140px; }
input[type="text"], input[type="email"], input[type="url"], input[type="password"], textarea {
  font: inherit;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  width: 100%;
}
input:focus-visible, textarea:focus-visible, .btn:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(31, 111, 95, 0.35);
  outline-offset: 1px;
}
textarea { resize: vertical; }

.btn {
  font: inherit;
  font-weight: 600;
  padding: 0.65rem 1.1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  line-height: 1.2;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8f1d17; color: #fff; }
.btn-link { background: none; color: var(--primary); padding: 0.4rem 0.5rem; }
.btn-link.danger { color: var(--danger); }
.btn-link:hover { text-decoration: underline; }

.draft {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px dashed var(--border);
}
.preview img { max-width: 220px; max-height: 220px; border-radius: 10px; border: 1px solid var(--border); }
.danger-zone { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px dashed var(--border); }

/* Slug input with fixed prefix */
.slug-input { display: flex; align-items: stretch; }
.slug-prefix {
  display: flex;
  align-items: center;
  padding: 0 0.6rem;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-right: 0;
  border-radius: 10px 0 0 10px;
  white-space: nowrap;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slug-input input { border-radius: 0 10px 10px 0; min-width: 0; }

/* Share link */
.share { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.share input { flex: 1 1 260px; font-size: 0.9rem; background: var(--bg); }

/* Public item grid */
.items {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.item {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.item-image {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  background: #f3ede6;
  overflow: hidden;
}
.item-image img { width: 100%; height: 100%; object-fit: contain; display: block; }
.item-placeholder { display: grid; place-items: center; height: 100%; font-size: 3rem; }
.item-ribbon {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background: var(--text);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
}
.is-mine .item-ribbon { background: var(--primary); }
.is-claimed .item-image img { filter: grayscale(1) opacity(0.6); }
.item-body { padding: 1rem 1.1rem 0.5rem; flex: 1; }
.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; }
.item-title { font-size: 1.05rem; margin: 0; }
.is-claimed .item-title { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.price {
  flex-shrink: 0;
  font-weight: 700;
  color: var(--accent);
  background: #fff4ec;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.9rem;
}
.item-desc {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0.5rem 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item-links { list-style: none; padding: 0; margin: 0.5rem 0 0; display: flex; flex-direction: column; gap: 0.35rem; }
.item-links a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  background: #fff;
}
.item-links a:hover { background: var(--bg); }
.item-link-price { font-weight: 600; color: var(--text); white-space: nowrap; }
.is-claimed .item-links a { color: var(--muted); }
.is-claimed .item-link-price { color: var(--muted); }
.item-actions { padding: 0.75rem 1.1rem 1.1rem; }
.claim summary { list-style: none; width: 100%; }
.claim summary::-webkit-details-marker { display: none; }
.claim[open] summary { display: none; }
.form-inline { margin-top: 0.25rem; }
.claimed-note { margin: 0; color: var(--muted); font-size: 0.9rem; }

/* Admin */
.admin-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: minmax(280px, 380px) 1fr;
  align-items: start;
}
@media (max-width: 820px) {
  .admin-grid { grid-template-columns: 1fr; }
}
.stack { display: flex; flex-direction: column; gap: 1.5rem; }
.list-cards, .admin-items { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 1rem; }
.list-card { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.list-card h2 a { text-decoration: none; color: var(--text); }
.list-card-actions { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }
.admin-item { display: grid; grid-template-columns: 72px 1fr auto; gap: 1rem; padding: 1rem; align-items: center; }
@media (max-width: 560px) {
  .admin-item { grid-template-columns: 72px 1fr; }
  .admin-item-actions { grid-column: 1 / -1; flex-direction: row !important; }
}
.admin-item-image {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  background: #f3ede6;
  display: grid;
  place-items: center;
  font-size: 1.8rem;
  overflow: hidden;
}
.admin-item-image img { width: 100%; height: 100%; object-fit: contain; }
.admin-item-body h3 { margin-bottom: 0.2rem; }
.admin-item-body h3 a { color: var(--text); text-decoration: none; }
.admin-item-body p { margin: 0; font-size: 0.9rem; }
.admin-item.is-claimed { background: #fbf8f3; }
.claim-info { color: var(--ok-text); }
.admin-item-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 0.1rem; }
.admin-item-actions form { margin: 0; }
