/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --border: #e2e0d8;
  --text: #1a1a18;
  --text-muted: #888880;
  --accent: #2d5a27;
  --accent-light: #e8f0e7;
  --accent-hover: #234820;
  --danger: #c0392b;
  --danger-light: #fdf0ef;
  --out: #7c5c00;
  --out-light: #fdf6e3;
  --pending-light: #eef3ff;
  --pending: #2c4da0;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --font-mono: 'DM Mono', monospace;
  --font: 'DM Sans', sans-serif;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }
textarea, input, button { font-family: inherit; font-size: inherit; }

/* ── Nav ───────────────────────────────────────────────────── */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text);
  letter-spacing: -0.01em;
  text-decoration: none;
}
.nav-links { display: flex; gap: 0.25rem; }
.nav-links a {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-links a:hover { background: var(--bg); color: var(--text); }
.nav-links a.active { background: var(--accent-light); color: var(--accent); font-weight: 500; }

/* ── Community bar ────────────────────────────────────────── */
.community-bar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0.4rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.community-bar-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-right: 0.25rem;
}
.community-chip {
  font-size: 0.78rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.community-chip:hover { border-color: var(--accent); color: var(--accent); }
.community-chip--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: default;
}

/* ── Main ──────────────────────────────────────────────────── */
.main { max-width: 960px; margin: 0 auto; padding: 2rem 1.5rem; }

/* ── Flash ─────────────────────────────────────────────────── */
.flashes { margin-bottom: 1.5rem; }
.flash {
  background: var(--accent-light);
  border: 1px solid #c5d9c3;
  color: var(--accent);
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg); text-decoration: none; }
.btn-danger { background: transparent; border-color: #f5c6c2; color: var(--danger); }
.btn-danger:hover { background: var(--danger-light); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── Tags ──────────────────────────────────────────────────── */
.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.tag--free { background: var(--accent-light); border-color: #c5d9c3; color: var(--accent); }
.tag--out { background: var(--out-light); border-color: #e8d9a0; color: var(--out); }
.tag--pending { background: var(--pending-light); border-color: #c5d0ef; color: var(--pending); }
.tag--danger { background: var(--danger-light); border-color: #f5c6c2; color: var(--danger); }
.tag--you { background: var(--accent-light); border-color: #c5d9c3; color: var(--accent); }

/* ── Page header ───────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}
.page-header h1 {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.page-header-sub { color: var(--text-muted); font-size: 0.88rem; }

/* ── Search bar ────────────────────────────────────────────── */
.search-bar { margin-bottom: 1rem; }
.search-input {
  width: 100%;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color 0.15s;
}
.search-input:focus { outline: none; border-color: var(--accent); }

/* ── Filter bar ────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}
.filter-chip {
  font-size: 0.8rem;
  padding: 0.25rem 0.7rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s;
}
.filter-chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.filter-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── View toggle ───────────────────────────────────────────── */
.page-header-right { display: flex; align-items: center; gap: 0.75rem; }
.view-toggle { display: flex; gap: 0.2rem; }
.view-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.3rem 0.45rem;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center;
  transition: all 0.15s;
}
.view-btn:hover { border-color: var(--accent); color: var(--accent); }
.view-btn--active { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

/* ── Item grid ─────────────────────────────────────────────── */
.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}
.item-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.item-card--out { opacity: 0.75; }
.item-photo { aspect-ratio: 4/3; overflow: hidden; background: var(--bg); }
.item-photo img { width: 100%; height: 100%; object-fit: cover; }
.item-photo-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 2.5rem;
  color: var(--border);
}
.item-body { padding: 0.9rem; }
.item-info { margin-bottom: 0.75rem; }
.item-meta { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.item-name { font-size: 1rem; font-weight: 600; margin-bottom: 0.25rem; }
.item-desc { font-size: 0.83rem; color: var(--text-muted); margin-bottom: 0.4rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-cost { font-size: 0.8rem; color: var(--out); margin-bottom: 0.4rem; font-family: var(--font-mono); }
.item-owner { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.item-yours, .item-unavail { font-size: 0.82rem; color: var(--text-muted); font-style: italic; }

/* ── List view overrides ───────────────────────────────────── */
#item-container[data-view="list"] {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
#item-container[data-view="list"] .item-card {
  display: flex;
  flex-direction: row;
  overflow: visible;
}
#item-container[data-view="list"] .item-photo {
  width: 72px;
  min-width: 72px;
  aspect-ratio: unset;
  height: auto;
  min-height: 72px;
}
#item-container[data-view="list"] .item-body {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1rem;
  flex: 1;
  padding: 0.65rem 0.9rem;
  flex-wrap: wrap;
}
#item-container[data-view="list"] .item-info {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}
#item-container[data-view="list"] .item-actions {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
}
#item-container[data-view="list"] .item-desc,
#item-container[data-view="list"] .item-cost { display: none; }
#item-container[data-view="list"] .item-owner { margin-bottom: 0; }
#item-container[data-view="list"] .item-meta { margin-bottom: 0.25rem; }
#item-container[data-view="list"] .item-name { margin-bottom: 0; }

/* ── Borrow form (details/summary) ────────────────────────── */
.borrow-form summary {
  cursor: pointer;
  list-style: none;
  margin-bottom: 0;
}
.borrow-form summary::-webkit-details-marker { display: none; }
.borrow-form[open] summary { margin-bottom: 0.75rem; }
.borrow-form form { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; }

/* ── Section ───────────────────────────────────────────────── */
.section { margin-bottom: 2.5rem; }
.section-title {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: lowercase;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* ── List ──────────────────────────────────────────────────── */
.list { display: flex; flex-direction: column; gap: 0.5rem; }
.list-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow);
}
.list-row--sm { padding: 0.55rem 0.9rem; }
.list-thumb {
  width: 52px; height: 52px;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg);
}
.list-thumb img { width: 100%; height: 100%; object-fit: cover; }
.list-thumb-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 1.2rem; color: var(--border);
}
.list-body { flex: 1; display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.list-name { font-weight: 600; font-size: 0.95rem; }
.list-actions { display: flex; gap: 0.4rem; align-items: center; flex-shrink: 0; }
.member-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.85rem; flex-shrink: 0;
}

/* ── Forms ─────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.field--sm { margin-bottom: 0; }
label { font-size: 0.82rem; font-weight: 500; color: var(--text-muted); }
input[type="text"], input[type="date"], input[type="file"], textarea {
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s;
  width: 100%;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}
textarea { resize: vertical; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 0.5rem; }
.current-photo { margin-bottom: 0.5rem; }
.current-photo img { width: 80px; height: 80px; object-fit: cover; border-radius: 4px; margin-bottom: 0.25rem; }
.checkbox-label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.82rem; color: var(--text-muted); cursor: pointer; margin-bottom: 0.35rem; }
.checkbox-label input { width: auto; }

/* ── Form page (centred) ───────────────────────────────────── */
.form-page {
  display: flex; justify-content: center;
  padding: 2rem 0;
}
.form-page--inline { justify-content: flex-start; }
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.form-card h1 {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}
.form-card p { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 1.25rem; }
.form-card-icon { font-size: 2rem; margin-bottom: 0.75rem; }

/* ── Landing ───────────────────────────────────────────────── */
.landing { display: flex; justify-content: center; align-items: center; min-height: 60vh; }
.landing-inner { text-align: center; max-width: 360px; }
.landing-actions { display: flex; gap: 0.75rem; justify-content: center; margin-bottom: 1rem; }
.landing-inner h1 {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
}
.landing-sub { color: var(--text-muted); margin-bottom: 1rem; line-height: 1.6; }
.landing-hint { font-size: 0.85rem; color: var(--text-muted); font-style: italic; }

/* ── Copy box ──────────────────────────────────────────────── */
.copy-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.9rem;
  margin-top: 0.5rem;
}
.copy-box code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Misc ──────────────────────────────────────────────────── */
.muted { font-size: 0.82rem; color: var(--text-muted); }
.empty { text-align: center; padding: 3rem; color: var(--text-muted); }
.empty p { margin-bottom: 1rem; }
.empty-inline { color: var(--text-muted); font-size: 0.9rem; padding: 0.5rem 0; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 600px) {
  .main { padding: 1.25rem 1rem; }
  .nav { padding: 0 1rem; }
  .nav-links a { padding: 0.3rem 0.5rem; font-size: 0.8rem; }
  .list-actions { flex-direction: column; align-items: flex-end; }
  .item-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 400px) {
  .item-grid { grid-template-columns: 1fr; }
}
