/* ── Variables: Light Mode ───────────────────────────────────── */
:root {
  --bg: #fefeff;
  --surface: #ffffff;
  --surface-2: #eef4f7;
  --border: #c8dde6;
  --text: #114b5f;
  --muted: #537e8f;
  --accent: #1a936f;
  --accent-light: #dff2ec;
  --accent-mid: #147a5a;
  --green: #1a936f;
  --green-bg: #dff2ec;
  --amber: #c47a00;
  --amber-bg: #fff3cc;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 8px rgba(17,75,95,0.07), 0 8px 24px rgba(17,75,95,0.05);
  --shadow-lg: 0 8px 32px rgba(17,75,95,0.13), 0 2px 8px rgba(17,75,95,0.07);
  --shadow-accent: 0 4px 20px rgba(26,147,111,0.35);
  --nav-h: 56px;
  --bottom-h: 72px;
  --font-display: 'Caudex', Georgia, serif;
  --font-body: 'Noto Serif', Georgia, serif;
}

/* ── Variables: Dark Mode (manual) ──────────────────────────── */
[data-theme="dark"] {
  --bg: #114b5f;
  --surface: #1a5f76;
  --surface-2: #1f6d87;
  --border: #2a7d97;
  --text: #fefeff;
  --muted: #8bbfcc;
  --accent: #22bb84;
  --accent-light: #0d3a2e;
  --accent-mid: #1a936f;
  --green: #22bb84;
  --green-bg: #0d3a2e;
  --amber: #fbbf24;
  --amber-bg: #3d2e00;
  --red: #f87171;
  --red-bg: #3d0a0a;
  --shadow: 0 2px 8px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.2);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.3);
  --shadow-accent: 0 4px 20px rgba(34,187,132,0.3);
}

/* ── Variables: Dark Mode (system preference) ───────────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #114b5f;
    --surface: #1a5f76;
    --surface-2: #1f6d87;
    --border: #2a7d97;
    --text: #fefeff;
    --muted: #8bbfcc;
    --accent: #22bb84;
    --accent-light: #0d3a2e;
    --accent-mid: #1a936f;
    --green: #22bb84;
    --green-bg: #0d3a2e;
    --amber: #fbbf24;
    --amber-bg: #3d2e00;
    --red: #f87171;
    --red-bg: #3d0a0a;
    --shadow: 0 2px 8px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.2);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.3);
    --shadow-accent: 0 4px 20px rgba(34,187,132,0.3);
  }
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
  transition: background 0.3s, color 0.3s;
}
#app { height: 100dvh; overflow: hidden; }
.screen { display: none; height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }

/* ── Accessibility: Focus styles ─────────────────────────────── */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ── Auth ────────────────────────────────────────────────────── */
.auth-hero {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background: #114b5f;
}
.auth-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='52' height='52' viewBox='0 0 52 52'%3E%3Cpath d='M26 44C26 44 8 33 8 20a11 11 0 0 1 18-8.5A11 11 0 0 1 44 20c0 13-18 24-18 24z' fill='%23FED99B' fill-opacity='0.32'/%3E%3C/svg%3E");
  background-size: 52px 52px;
  pointer-events: none;
}
.auth-blob { display: none; }
.auth-content { width: 100%; max-width: 380px; z-index: 1; }
.brand-mark {
  width: 52px;
  height: 52px;
  background: rgba(254,217,155,0.2);
  border: 1.5px solid rgba(254,217,155,0.55);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  backdrop-filter: blur(8px);
}
.brand-name {
  font-family: var(--font-display);
  font-size: 41px;
  font-weight: 800;
  color: #fefeff;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.brand-tagline {
  font-size: 17px;
  color: rgba(254,254,255,0.72);
  margin: 6px 0 28px;
  font-weight: 400;
  letter-spacing: 0.01em;
}
.auth-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.22);
}
.auth-tabs {
  display: flex;
  margin-bottom: 20px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.auth-tab {
  flex: 1;
  padding: 8px;
  font-size: 17px;
  font-family: var(--font-body);
  font-weight: 400;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.2s;
}
.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.auth-form { display: none; flex-direction: column; gap: 10px; }
.auth-form.active { display: flex; }
.auth-message { font-size: 16px; margin-top: 8px; min-height: 18px; text-align: center; }
.auth-message.error { color: var(--red); }
.auth-message.success { color: var(--green); }

/* ── Inputs ──────────────────────────────────────────────────── */
.input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 17px;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
.input:focus { border-color: var(--accent); background: var(--surface); }
.input::placeholder { color: var(--muted); }
select.input { cursor: pointer; }
.fof-label { display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--text); cursor: pointer; padding: 4px 0; }
.fof-label input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 12px 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 17px;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.btn-primary:hover { background: var(--accent-mid); box-shadow: var(--shadow-accent); }
.btn-primary:active { transform: scale(0.98); }
.btn-ghost {
  padding: 7px 14px;
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.3);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.2s;
}
.btn-ghost:hover { background: rgba(255,255,255,0.25); }
.btn-ghost-dark {
  padding: 7px 14px;
  background: none;
  border: 1.5px solid var(--border);
  color: var(--muted);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: var(--font-body);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.2s, color 0.2s;
}
.btn-ghost-dark:hover { border-color: var(--text); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 14px; width: auto; }

/* ── Top Nav ─────────────────────────────────────────────────── */
.topnav {
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}
.topnav-brand { display: flex; align-items: center; gap: 10px; }
.topnav-logo {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.topnav-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}
.topnav-actions { display: flex; align-items: center; gap: 8px; }
.theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  flex-shrink: 0;
}
.theme-toggle:hover { color: var(--text); border-color: var(--text); background: var(--border); }
.theme-toggle svg { width: 16px; height: 16px; }
/* Light mode: show moon (click to go dark) */
.sun-icon { display: none; }
.moon-icon { display: block; }
/* Dark mode (manual): show sun (click to go light) */
[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }
/* Dark mode (system, no manual override): show sun */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sun-icon { display: block; }
  :root:not([data-theme="light"]) .moon-icon { display: none; }
}
.nav-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-light);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  border: 2px solid var(--accent);
  transition: opacity 0.2s;
}
.nav-avatar:hover { opacity: 0.82; }
.nav-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ── Notification Bell ───────────────────────────────────────── */
.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  background: #fe654f;
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  pointer-events: none;
  font-family: var(--font-body);
}
.notif-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: -8px;
  width: 320px;
  max-width: 92vw;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 400;
  overflow: hidden;
  animation: fadeUp 0.18s ease;
}
.notif-panel.open { display: block; }
.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.notif-panel-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.notif-clear-btn {
  background: none;
  border: none;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-body);
  padding: 2px 6px;
  border-radius: 6px;
  transition: color 0.15s;
}
.notif-clear-btn:hover { color: var(--accent); }
#notif-list { max-height: 360px; overflow-y: auto; }
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: var(--accent-light); }
.notif-item.unread:hover { background: var(--accent-light); filter: brightness(0.97); }
.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-top: 6px;
}
.notif-dot.read { background: transparent; }
.notif-text { flex: 1; }
.notif-msg { font-size: 14px; color: var(--text); line-height: 1.4; }
.notif-time { font-size: 12px; color: var(--muted); margin-top: 2px; }
.notif-empty { font-size: 14px; color: var(--muted); padding: 20px 16px; text-align: center; margin: 0; }

/* ── Nav Dropdown ────────────────────────────────────────────── */
.nav-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 300;
  overflow: hidden;
  animation: fadeUp 0.18s ease;
}
.nav-dropdown.open { display: block; }
.nav-dropdown-item {
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  text-align: left;
  font-size: 17px;
  font-family: var(--font-body);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
  display: block;
}
.nav-dropdown-item:hover { background: var(--surface-2); }
.nav-dropdown-item + .nav-dropdown-item { border-top: 1px solid var(--border); }

/* ── Info Modals ─────────────────────────────────────────────── */
.info-modal { gap: 0; }
.info-body { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.info-body p { font-size: 17px; line-height: 1.65; color: var(--text); }
.info-intro { color: var(--muted) !important; font-style: italic; }
.info-heading {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  margin-top: 4px;
}
.info-link { color: var(--accent); text-decoration: underline; }
.welcome-emoji { font-size: 43px; margin-bottom: 4px; }
.welcome-list { padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.welcome-list li { font-size: 17px; line-height: 1.5; color: var(--text); }

/* ── Bottom Nav ──────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: none; /* shown via JS when main screen is active */
  align-items: center;
  justify-content: space-around;
  padding: 0 8px;
  z-index: 100;
}
#main-screen.active .bottom-nav { display: flex; }
.bn-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 0.2s;
  position: relative;
}
.bn-btn svg { width: 20px; height: 20px; transition: transform 0.2s; }
.bn-btn:hover svg { transform: translateY(-1px); }
.bn-btn.active { color: var(--accent); }
.bn-btn.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  background: var(--accent);
  border-radius: 0 0 4px 4px;
}
.bn-btn.add-btn {
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  background: #fe654f;
  color: #ffffff;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(254,101,79,0.45);
  margin-bottom: 8px;
  font-size: 0;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
}
.bn-btn.add-btn::before { display: none; }
.bn-btn.add-btn:hover { transform: scale(1.08) rotate(8deg); }
.bn-btn.add-btn svg { width: 24px; height: 24px; transition: none; }
.bn-btn.add-btn:hover svg { transform: none; }

/* ── Views ───────────────────────────────────────────────────── */
.view-container { flex: 1; overflow-y: auto; padding-bottom: calc(var(--bottom-h) + 16px); }
.view { display: none; padding: 16px; }
.view.active { display: block; }
.view-header { margin-bottom: 16px; }
.view-header h2 {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.view-sub { font-size: 16px; color: var(--muted); margin-top: 2px; }
.section-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* ── Filters ─────────────────────────────────────────────────── */
.filter-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 12px; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.chip.active, .chip:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ── Item Cards ──────────────────────────────────────────────── */
.item-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.item-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.25s, transform 0.2s;
  animation: fadeUp 0.3s ease both;
}
.item-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.item-card-img {
  width: 100%;
  height: 120px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  overflow: hidden;
}
.item-card-img img { width: 100%; height: 100%; object-fit: contain; }
.item-card-body { padding: 10px 12px 12px; }
.item-card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-card-owner { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.item-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 4px; flex-wrap: wrap; }
.fof-tag { font-size: 12px; color: var(--muted); font-style: italic; margin-top: 3px; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge { font-size: 12px; padding: 3px 8px; border-radius: 20px; font-weight: 600; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-cat {
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

/* ── Network / Friends ───────────────────────────────────────── */
.friend-search-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.friend-search-row { display: flex; gap: 8px; }
.invite-row { display: flex; gap: 8px; margin-bottom: 20px; }
.recruit-banner {
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 24px;
  margin-bottom: 8px;
}
.recruit-banner h4 { font-family: var(--font-display); font-size: 17px; color: var(--accent); margin-bottom: 6px; }
.recruit-banner p { font-size: 15px; color: var(--text); line-height: 1.55; margin-bottom: 8px; }
.recruit-copy {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 10px;
  font-style: italic;
}
.recruit-links { display: flex; gap: 8px; flex-wrap: wrap; }
.recruit-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-body);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s;
}
.recruit-link:hover { opacity: 0.82; }
.recruit-link-copy { background: var(--accent); color: white; }
.recruit-link-ig { background: #E1306C; color: white; }
.friend-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.friend-av {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--accent-light);
  color: var(--accent);
  overflow: hidden;
}
.friend-av img { width: 100%; height: 100%; object-fit: cover; }
.friend-info { flex: 1; }
.friend-name { font-size: 17px; font-weight: 600; }
.friend-meta { font-size: 14px; color: var(--muted); }
.friend-actions { display: flex; gap: 6px; }
.btn-accept { padding: 5px 12px; background: var(--green-bg); color: var(--green); border: none; border-radius: 8px; font-size: 14px; font-family: var(--font-body); cursor: pointer; font-weight: 600; transition: opacity 0.2s; }
.btn-decline { padding: 5px 12px; background: var(--red-bg); color: var(--red); border: none; border-radius: 8px; font-size: 14px; font-family: var(--font-body); cursor: pointer; transition: opacity 0.2s; }

/* ── Wish List ───────────────────────────────────────────────── */
.wishlist-collapsible { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.wishlist-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: none;
  border: none;
  font-size: 17px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  color: var(--text);
  transition: background 0.2s;
}
.wishlist-toggle:hover { background: var(--surface-2); }
.wishlist-body { padding: 0 16px 16px; display: none; }
.wishlist-body.open { display: block; }
.wish-add-row { display: flex; gap: 8px; margin-bottom: 12px; }
.wish-item { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px; }
.wish-item-name { font-size: 16px; font-weight: 600; }
.wish-item-meta { font-size: 14px; color: var(--muted); margin-top: 2px; }

/* ── Borrow Log ──────────────────────────────────────────────── */
.borrow-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.borrow-info { flex: 1; }
.borrow-item-name { font-size: 16px; font-weight: 600; }
.borrow-meta { font-size: 14px; color: var(--muted); margin-top: 2px; }
.btn-return { padding: 5px 10px; font-size: 13px; background: var(--green-bg); color: var(--green); border: none; border-radius: 8px; cursor: pointer; font-weight: 600; font-family: var(--font-body); white-space: nowrap; }

/* ── Feed ────────────────────────────────────────────────────── */
.post-composer { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.post-composer-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.photo-upload-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
}
.photo-upload-label:hover { background: var(--surface-2); color: var(--text); }
.feed-post {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
  animation: fadeUp 0.3s ease both;
}
.feed-post-header { display: flex; align-items: center; gap: 10px; padding: 14px 16px 8px; }
.feed-post-av {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
}
.feed-post-av img { width: 100%; height: 100%; object-fit: cover; }
.feed-post-name { font-size: 16px; font-weight: 600; }
.feed-post-time { font-size: 13px; color: var(--muted); }
.feed-post-img { width: 100%; max-height: 300px; object-fit: cover; display: block; }
.feed-post-text { padding: 10px 16px 4px; font-size: 17px; line-height: 1.55; }
.feed-post-actions { padding: 8px 16px 12px; display: flex; align-items: center; gap: 16px; border-top: 1px solid var(--border); margin-top: 8px; }
.heart-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 16px;
  color: var(--muted);
  font-family: var(--font-body);
  font-weight: 500;
  padding: 4px 0;
  transition: color 0.2s;
}
.heart-btn.liked { color: #e74c3c; }
.heart-btn svg { width: 18px; height: 18px; transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); }
.heart-btn:active svg { transform: scale(1.4); }
.comment-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--muted);
  font-family: var(--font-body);
  font-weight: 500;
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color 0.2s;
}
.comment-toggle:hover { color: var(--text); }
.comment-toggle svg { width: 16px; height: 16px; }
.comments-section { padding: 0 16px 12px; border-top: 1px solid var(--border); }
.comment-item { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 16px; line-height: 1.45; }
.comment-item:last-child { border-bottom: none; }
.comment-author { font-weight: 600; margin-right: 6px; }
.comment-add-row { display: flex; gap: 8px; margin-top: 8px; }
.comment-add-row input {
  flex: 1;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 16px;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}
.comment-add-row input:focus { border-color: var(--accent); }
.comment-send {
  padding: 8px 14px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
.comment-send:hover { background: var(--accent-mid); }

/* ── Profile ─────────────────────────────────────────────────── */
.profile-header-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.profile-pic-wrap {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  background: var(--accent-light);
  border: 2px solid var(--accent);
}
.profile-pic-initials {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
}
.profile-pic-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s;
}
.profile-pic-wrap:hover .profile-pic-overlay { opacity: 1; }
.profile-info { flex: 1; }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
.stats-row-2 { grid-template-columns: repeat(2, 1fr); }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  text-align: center;
}
.stat-num {
  font-size: 29px;
  font-weight: 800;
  color: var(--accent);
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}
.stat-label { font-size: 13px; color: var(--muted); margin-top: 2px; font-weight: 500; }

/* ── Modals ──────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  border-radius: 24px 24px 0 0;
  padding: 24px;
  max-height: 92dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: slideUp 0.32s cubic-bezier(0.34, 1.1, 0.64, 1);
  position: relative;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.modal-close {
  position: absolute;
  right: 20px;
  top: 20px;
  background: var(--surface-2);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 17px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.photo-upload-area {
  width: 100%;
  height: 150px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  color: var(--muted);
  font-size: 16px;
  transition: border-color 0.2s, background 0.2s;
  overflow: hidden;
  position: relative;
}
.photo-upload-area:hover { border-color: var(--accent); background: var(--accent-light); }

/* ── Item Detail ─────────────────────────────────────────────── */
.detail-img-wrap {
  width: 100%;
  height: 200px;
  background: var(--surface-2);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  margin-bottom: 12px;
}
.detail-img-wrap img { width: 100%; height: 100%; object-fit: cover; }
.detail-title { font-family: var(--font-display); font-size: 26px; font-weight: 800; margin-bottom: 4px; letter-spacing: -0.01em; }
.detail-row { display: flex; justify-content: space-between; font-size: 16px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.detail-row-label { color: var(--muted); font-weight: 500; }
.detail-desc { font-size: 17px; color: var(--text); line-height: 1.6; margin: 12px 0; }
.borrow-request-row { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }

/* ── Borrow Log Sections ─────────────────────────────────────── */
.borrow-section-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin: 20px 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.borrow-section-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.loan-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.btn-loan-action {
  padding: 4px 10px;
  font-size: 12px;
  font-family: var(--font-body);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-loan-action:hover { border-color: var(--text); color: var(--text); }
.btn-loan-return {
  padding: 4px 10px;
  font-size: 12px;
  font-family: var(--font-body);
  background: var(--green-bg);
  color: var(--green);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}
.btn-loan-delete {
  padding: 4px 10px;
  font-size: 12px;
  font-family: var(--font-body);
  background: none;
  color: var(--muted);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.15s;
}
.btn-loan-delete:hover { color: var(--red); }

/* ── Lend-to user search ─────────────────────────────────────── */
.lend-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
  max-height: 220px;
  overflow-y: auto;
}
.lend-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.lend-result-item:last-child { border-bottom: none; }
.lend-result-item:hover, .lend-result-item:active { background: var(--surface-2); }
.lend-result-av {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.lend-result-av img { width: 100%; height: 100%; object-fit: cover; }
.lend-result-name { font-size: 14px; font-weight: 600; color: var(--text); }
.lend-result-username { font-size: 12px; color: var(--muted); }
.lend-result-empty { padding: 12px 14px; font-size: 14px; color: var(--muted); }
.lend-selected-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 600;
}
.lend-selected-chip button {
  background: none; border: none; cursor: pointer;
  color: var(--accent); font-size: 15px; line-height: 1; padding: 0 0 0 4px;
}

/* ── Image Crop Modal ────────────────────────────────────────── */
.crop-container {
  position: relative;
  width: 100%;
  max-height: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
#crop-canvas { display: block; max-width: 100%; }
.crop-overlay {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
}
.crop-box {
  position: absolute;
  border: 2px solid white;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
  cursor: move;
  pointer-events: all;
  box-sizing: border-box;
}
.crop-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 2px;
  pointer-events: all;
}
.crop-handle-tl { top: -7px; left: -7px; cursor: nw-resize; }
.crop-handle-tr { top: -7px; right: -7px; cursor: ne-resize; }
.crop-handle-bl { bottom: -7px; left: -7px; cursor: sw-resize; }
.crop-handle-br { bottom: -7px; right: -7px; cursor: se-resize; }

/* ── Delete Post Button ──────────────────────────────────────── */
.delete-post-btn {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  font-family: var(--font-body);
}
.delete-post-btn:hover { background: var(--red-bg); color: var(--red); }

/* ── Empty States ────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; }
.empty-icon { font-size: 44px; margin-bottom: 14px; }
.empty-state p { font-size: 17px; color: var(--muted); line-height: 1.6; }

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--bottom-h) + 20px);
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--text);
  color: var(--surface);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 16px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.1, 0.64, 1);
  z-index: 999;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Animations ──────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { transform: translateY(50px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (min-width: 600px) {
  .item-grid { grid-template-columns: repeat(3, 1fr); }
  .modal { border-radius: 24px; margin-bottom: 24px; }
  .modal-overlay { align-items: center; }
}
