/* ============ Reset & Tokens ============ */
*,
*::before,
*::after { box-sizing: border-box; }

:root {
  --bg: #0f1115;
  --bg-elev: #171a21;
  --bg-elev-2: #1f232c;
  --bg-hover: #242935;
  --border: #2a2f3a;
  --border-strong: #3a4150;
  --text: #e6e9ef;
  --text-dim: #9aa3b2;
  --text-muted: #6b7280;
  --accent: #8b9dff;
  --accent-hover: #a4b3ff;
  --accent-text: #0f1115;
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #f87171;
  --drag-line: #8b9dff;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 6px rgba(0,0,0,0.25);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7fa;
    --bg-elev: #ffffff;
    --bg-elev-2: #fafbfd;
    --bg-hover: #eef0f5;
    --border: #e2e5eb;
    --border-strong: #c9cfd9;
    --text: #1a1d23;
    --text-dim: #5b6270;
    --text-muted: #8a92a1;
    --accent: #4c5fd5;
    --accent-hover: #3a4bc0;
    --accent-text: #ffffff;
    --shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
  }
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.muted { color: var(--text-muted); font-size: 12px; }
.spacer { flex: 1; }

/* Lock background scroll while a modal is open — prevents iOS Safari from
   pushing the modal up when the on-screen keyboard appears. */
body.modal-open { overflow: hidden; }
body.modal-open #main-view { overflow: hidden; }

/* ============ Auth view ============ */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 60% 50% at 28% 22%, rgba(139, 157, 255, 0.16), transparent 65%),
    radial-gradient(ellipse 55% 45% at 78% 82%, rgba(74, 222, 128, 0.10), transparent 60%),
    radial-gradient(ellipse 80% 70% at 50% 110%, rgba(251, 191, 36, 0.06), transparent 70%),
    var(--bg);
}
.auth-decor {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.auth-decor-item {
  position: absolute;
  opacity: 0.14;
  user-select: none;
  filter: grayscale(0.2);
  animation: auth-drift 16s ease-in-out infinite alternate;
  will-change: transform;
}
.auth-decor-item:nth-child(2) { animation-duration: 19s; animation-delay: -2s; }
.auth-decor-item:nth-child(3) { animation-duration: 14s; animation-delay: -4s; }
.auth-decor-item:nth-child(4) { animation-duration: 21s; animation-delay: -1s; }
.auth-decor-item:nth-child(5) { animation-duration: 17s; animation-delay: -6s; }
.auth-decor-item:nth-child(6) { animation-duration: 23s; animation-delay: -3s; }
@keyframes auth-drift {
  0%   { transform: translate(0, 0)      rotate(-3deg); }
  100% { transform: translate(10px, -12px) rotate(3deg); }
}
@media (prefers-reduced-motion: reduce) {
  .auth-decor-item { animation: none; }
}

.auth-stack {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 420px;
}
.auth-hero {
  margin: 0;
  text-align: center;
  font-size: clamp(44px, 9vw, 72px);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.02;
  color: var(--text);
  opacity: 0.78;
  pointer-events: none;
}
.auth-subhero {
  margin: 0 0 14px;
  text-align: center;
  font-size: clamp(15px, 1.8vw, 17px);
  font-weight: 400;
  line-height: 1.4;
  color: var(--text-dim);
  max-width: 34ch;
}
.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.auth-card h1 { font-size: 22px; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: -4px;
}
.auth-form input[type="email"],
.auth-form input[type="text"] {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
}
.auth-form input[type="email"]:focus,
.auth-form input[type="text"]:focus { border-color: var(--accent); }
.auth-status { margin-top: 10px; text-align: center; }
.auth-status.error { color: var(--danger); }
.auth-status.ok { color: var(--success); }

.auth-tagline { text-align: center; margin: 8px 0 16px; }
.auth-cta { width: 100%; padding: 12px; font-size: 15px; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 12px;
  color: var(--text-muted);
  font-size: 12px;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-subtitle { font-size: 18px; text-align: center; margin-top: 4px; }
.auth-back {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  padding: 0;
  margin-bottom: 8px;
  cursor: pointer;
}
.auth-back:hover { color: var(--text); }

@media (max-width: 600px) {
  .auth-wrap { padding: 16px; }
  .auth-stack { gap: 10px; max-width: 100%; }
  .auth-hero {
    font-size: clamp(40px, 13vw, 56px);
    letter-spacing: -0.03em;
  }
  .auth-subhero {
    font-size: 14px;
    max-width: 30ch;
    margin-bottom: 8px;
  }
  .auth-card { padding: 24px 20px; }
  .auth-decor-item { opacity: 0.09; }
  /* Shrink the bigger decor emojis so they don't overpower the card on phones.
     Inline font-size styles on individual items are overridden here. */
  .auth-decor-item[style*="56px"] { font-size: 36px !important; }
  .auth-decor-item[style*="50px"] { font-size: 32px !important; }
  .auth-decor-item[style*="46px"] { font-size: 30px !important; }
  .auth-decor-item[style*="44px"] { font-size: 28px !important; }
  .auth-decor-item[style*="38px"] { font-size: 24px !important; }
  .auth-decor-item[style*="34px"] { font-size: 22px !important; }
}

/* ============ Status line ============ */
.status {
  position: fixed;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  pointer-events: none;
}
.status.error { color: var(--danger); }
.status.ok { color: var(--success); }

/* ============ Header ============ */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 22px; }
.brand h1 { font-size: 18px; letter-spacing: -0.01em; }
.header-actions { display: flex; gap: 8px; align-items: center; }

/* ============ Buttons ============ */
.btn {
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent); color: var(--accent-text); border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary { background: var(--bg-elev-2); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-danger {
  background: transparent; color: var(--danger); border-color: var(--border);
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.1); border-color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.icon-btn {
  background: transparent; border: none; color: var(--text-dim);
  font-size: 20px; line-height: 1; padding: 4px 8px; border-radius: var(--radius-sm);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ============ Main layout ============ */
.app-main {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 0;
  height: calc(100vh - 57px);
}
/* Mobile layout is handled in the touch/mobile block at the bottom */

/* ============ Gear Library ============ */
.gear-library {
  border-right: 1px solid var(--border);
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.library-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 14px 16px 8px;
}
.library-header h2 { font-size: 14px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.library-header-right { display: flex; align-items: center; gap: 8px; }
#library-edit-toggle[aria-pressed="true"] { background: var(--bg-hover); color: var(--accent); }

.gear-card-actions {
  display: none;
  grid-column: 1 / -1;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  margin-top: 2px;
}
.gear-list.edit-mode .gear-card { cursor: default; grid-template-columns: 48px 1fr auto; }
.gear-list.edit-mode .gear-card-actions { display: flex; }
.gear-list.edit-mode .gear-card:hover { background: var(--bg-elev-2); }
.gear-search {
  margin: 0 16px 10px;
  padding: 8px 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  outline: none;
}
.gear-search:focus { border-color: var(--accent); }
.gear-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gear-card {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  align-items: center;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  cursor: grab;
  transition: border-color 0.12s, transform 0.08s, background 0.12s;
}
.gear-card:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.gear-card:active { cursor: grabbing; }
.gear-card.dragging { opacity: 0.4; }
.gear-card img {
  width: 48px; height: 48px; object-fit: cover; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--border);
}
.gear-card .placeholder-img {
  width: 48px; height: 48px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--bg-hover), var(--bg));
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: var(--text-muted);
}
.gear-card .gear-meta { min-width: 0; }
.gear-card .gear-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gear-card .gear-sub { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gear-card .gear-image-link {
  display: inline-flex;
  line-height: 0;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: zoom-in;
  transition: transform 0.12s, box-shadow 0.12s;
}
.gear-card .gear-image-link:hover { transform: scale(1.04); box-shadow: 0 0 0 2px var(--accent); }
.gear-card .gear-image-link:active { transform: scale(0.96); }
.gear-card .gear-weight {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text-dim);
  padding: 2px 6px;
  background: var(--bg);
  border-radius: 4px;
  white-space: nowrap;
}
.gear-card .gear-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.brand-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1.2;
  min-width: 22px;
  text-align: center;
  border: 1px solid rgba(0, 0, 0, 0.15);
  white-space: nowrap;
}
img.brand-badge-logo {
  display: inline-block;
  height: 20px;
  width: 20px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  object-fit: contain;
  vertical-align: middle;
  /* hide alt text while the browser is loading / errored but before the
     error handler swaps in the abbreviation fallback */
  font-size: 0;
  color: transparent;
}

/* Brand filter pill row */
.brand-filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 10px;
}
.brand-filter-pills.hidden { display: none; }

/* Mobile-only toggle that collapses/expands the brand pill strip.
   Hidden on desktop — the strip shows unconditionally there. */
.brand-filter-toggle {
  display: none;
  align-self: flex-start;
  margin: 0 12px 8px;
  padding: 4px 0;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.01em;
}
.brand-filter-toggle:hover { color: var(--accent); }
.brand-filter-toggle[aria-expanded="true"] { color: var(--text); }
.brand-filter-toggle.hidden { display: none; }
@media (max-width: 820px) {
  .brand-filter-toggle:not(.hidden) { display: inline-flex; }
}
.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.brand-pill:hover { border-color: var(--border-strong); color: var(--text); }
.brand-pill.active { border-color: var(--accent); color: var(--text); background: var(--bg-hover); }
.brand-pill .brand-badge { font-size: 10px; }
.brand-pill-count { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ============ Activity panel ============ */
.activity-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--bg);
}
.activity-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 16px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  overflow-x: auto;
  scrollbar-width: thin;
}
.activity-tab {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-bottom: none;
  background: var(--bg-elev-2);
  color: var(--text-dim);
  border-radius: 8px 8px 0 0;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  margin-bottom: -1px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.activity-tab:hover { background: var(--bg-hover); color: var(--text); }
.activity-tab.active {
  color: var(--accent);
  font-weight: 700;
}
.activity-tab.drop-target {
  border-color: var(--accent);
  background: rgba(139, 157, 255, 0.1);
  color: var(--accent);
}
.activity-tab-emoji { font-size: 14px; }
.activity-tab-add {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-dim);
}
.activity-tab-add:hover { color: var(--accent); border-color: var(--accent); }

/* ============ Weather filter ============ */
.custom-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  flex-wrap: wrap;
}
.custom-filter.hidden { display: none; }
.custom-filter-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.custom-filter-hint {
  margin-left: auto;
  font-size: 12px;
}
.custom-filter-pills { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.custom-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s, transform 0.08s;
}
.custom-filter-pill:hover { background: var(--bg-hover); color: var(--text); }
.custom-filter-pill.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}
.custom-filter-pill-add {
  background: transparent;
  color: var(--text-dim);
  border-style: dashed;
  padding: 5px 10px;
  font-weight: 600;
}
.custom-filter-pill-add:hover { color: var(--accent); border-color: var(--accent); }

/* Per-row custom-filter chip cluster */
.custom-chips {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-right: 4px;
  margin-top: 2px;
}
.custom-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1.4;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.12s, background 0.12s, border-color 0.12s, color 0.12s, transform 0.08s;
}
.custom-chip:hover { opacity: 1; background: var(--bg-hover); }
.custom-chip.active {
  opacity: 1;
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}
.custom-chip:active { transform: scale(0.95); }

.weather-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  flex-wrap: wrap;
}
.weather-filter.hidden { display: none; }
.weather-filter-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.weather-filter-hint {
  margin-left: auto;
  font-size: 12px;
}
.weather-toggles { display: flex; gap: 6px; flex-wrap: wrap; }
.weather-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s, transform 0.08s;
}
.weather-toggle:hover { background: var(--bg-hover); color: var(--text); }
.weather-toggle.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}
.weather-toggle .weather-emoji { font-size: 14px; line-height: 1; }

/* Per-row weather chip cluster */
.weather-chips {
  display: inline-flex;
  gap: 3px;
  margin-right: 4px;
}
.weather-chip {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.25;
  transition: opacity 0.12s, background 0.12s, border-color 0.12s, transform 0.08s;
}
.weather-chip:hover { opacity: 0.7; background: var(--bg-hover); }
.weather-chip.active {
  opacity: 1;
  background: var(--bg-elev-2);
  border-color: var(--accent);
}
.weather-chip:active { transform: scale(0.9); }

.activity-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
  padding: 16px 20px;
  position: relative;
}
.activity-body.drop-target {
  box-shadow: inset 0 0 0 2px var(--accent);
  background: rgba(139, 157, 255, 0.04);
}

.activity-list { display: flex; flex-direction: column; gap: 6px; }

.activity-item {
  display: grid;
  grid-template-columns: 22px 40px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background 0.12s, border-color 0.12s;
  position: relative;
  cursor: grab;
}
.activity-item:hover { background: var(--bg-elev-2); }
.activity-item.dragging { opacity: 0.3; }

/* Packed visual treatment — consistent on desktop and mobile. */
.activity-item.packed {
  background: color-mix(in srgb, var(--success) 8%, var(--bg-elev));
  border-color: color-mix(in srgb, var(--success) 40%, var(--border));
}
.activity-item.packed .gear-name-row { text-decoration: line-through; color: var(--text-muted); }
.activity-item.packed .activity-item-meta,
.activity-item.packed .item-weight,
.activity-item.packed img,
.activity-item.packed .placeholder-img { opacity: 0.55; }

/* Corner "earmark" check — mobile-only. On desktop the checkbox itself
   (tinted with --success) signals the packed state; the badge would be
   redundant. Mobile hides the checkbox, so it gets the badge instead. */
.activity-item .item-check-badge { display: none; }

.activity-item input.item-checkbox { width: 18px; height: 18px; accent-color: var(--success); cursor: pointer; }
.activity-item img,
.activity-item .placeholder-img {
  width: 36px; height: 36px; object-fit: cover; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--border);
}
.activity-item-image-link {
  display: inline-flex;
  line-height: 0;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: zoom-in;
  transition: transform 0.12s, box-shadow 0.12s;
}
.activity-item-image-link:hover { transform: scale(1.1); box-shadow: 0 0 0 2px var(--accent); }
.activity-item-image-link:active { transform: scale(0.94); }
.activity-item .placeholder-img { display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--text-muted); }
.activity-item-meta { min-width: 0; }
.activity-item .gear-name-row { font-weight: 500; overflow-wrap: anywhere; }
.activity-item .gear-sub-row {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.activity-item .item-weight {
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  font-size: 13px;
  text-align: right;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}
.activity-item .item-weight-breakdown { font-size: 11px; color: var(--text-muted); }
.activity-item .item-remove {
  background: transparent; border: none; color: var(--text-muted); font-size: 18px;
  padding: 2px 6px; border-radius: var(--radius-sm); cursor: pointer;
}
.activity-item .item-remove:hover { background: var(--bg-hover); color: var(--danger); }

.activity-item.drop-above::before,
.activity-item.drop-below::after {
  content: ""; position: absolute; left: 0; right: 0; height: 2px;
  background: var(--drag-line); border-radius: 2px;
}
.activity-item.drop-above::before { top: -4px; }
.activity-item.drop-below::after { bottom: -4px; }

.activity-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.totals { display: flex; flex-direction: column; gap: 2px; }
#activity-total { font-weight: 600; font-variant-numeric: tabular-nums; }
.activity-actions { display: flex; gap: 6px; }

/* ============ Empty state ============ */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}
.empty-state p { margin: 4px 0; }
.empty-state-icon { font-size: 44px; line-height: 1; margin-bottom: 8px; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--text); }
.empty-state .btn { margin-top: 14px; }

/* ============ Remove dropzone ============ */
.remove-dropzone {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  background: var(--bg-elev);
  border: 2px dashed var(--danger);
  color: var(--danger);
  border-radius: 999px;
  font-weight: 500;
  z-index: 100;
  pointer-events: all;
  transition: background 0.12s, transform 0.12s;
}
.remove-dropzone.active {
  background: rgba(248, 113, 113, 0.15);
  transform: translateX(-50%) scale(1.05);
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  top: 70px;
  right: 20px;
  padding: 10px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 200;
  max-width: 400px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.success { border-color: var(--success); color: var(--success); }

/* ============ Modals ============ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}
.modal-panel {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-narrow { max-width: 380px; }

/* Image preview lightbox — no panel chrome, just the image over a scrim. */
.image-preview-modal { padding: 24px; }
.image-preview-modal .modal-backdrop { background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(4px); }
.image-preview-body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  max-height: 100%;
}
.image-preview-body img {
  max-width: min(90vw, 900px);
  max-height: 80vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  background: var(--bg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.image-preview-caption {
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  max-width: 90vw;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}
.image-preview-caption:empty { display: none; }
.image-preview-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  font-size: 24px;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  z-index: 2;
}
.image-preview-close:hover { background: rgba(0, 0, 0, 0.7); }
.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 { font-size: 16px; }
.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
}
.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--bg-elev-2);
}

/* ============ Form ============ */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field.full { grid-column: 1 / -1; }
.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input[type="text"],
.field input[type="url"],
.field input[type="number"],
.field input[type="password"],
.field input[type="search"],
.field textarea,
.field select {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  outline: none;
  font-size: 13px;
  width: 100%;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
}
.field-hint { margin: 2px 0 0; font-size: 12px; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}
.divider { border: none; border-top: 1px solid var(--border); margin: 8px 0 14px; }

/* ============ Color selector (in Add Gear modal) ============ */
.color-field { display: flex; flex-direction: column; gap: 6px; }
.color-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  min-height: 6px;
}
.color-chips:empty { display: none; }
.color-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.color-chip:hover { background: var(--bg-hover); }
.color-chip.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}
.color-chip:active { transform: scale(0.97); }
.color-swatch {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.25);
  background: #ccc;
  flex-shrink: 0;
}
.color-row { display: flex; gap: 8px; }
.color-row input { flex: 1; }

.gear-preview {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 56px;
}
.gear-preview-img-wrap {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}
.gear-preview-img-wrap.loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  z-index: 1;
}
.gear-preview-img-wrap.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px; height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  z-index: 2;
}
.gear-preview img {
  width: 56px; height: 56px; object-fit: cover; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--border);
  display: block;
}
.gear-preview img:not([src]),
.gear-preview img[src=""] { display: none; }
.gear-preview-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 14px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.gear-preview-remove:hover {
  background: var(--danger, #c0392b);
  color: #fff;
  border-color: transparent;
}

/* ============ Screenshot drop zone ============ */
.section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 14px 0 8px;
}
.section-label:first-child { margin-top: 0; }

.screenshot-dropzone {
  position: relative;
  min-height: 180px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-elev-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, transform 0.08s;
  outline: none;
  padding: 20px;
}
.screenshot-dropzone:hover,
.screenshot-dropzone:focus {
  border-color: var(--accent);
  background: var(--bg-hover);
}
.screenshot-dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(139, 157, 255, 0.08);
  transform: scale(1.01);
}
.dropzone-idle {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.dropzone-icon { font-size: 36px; line-height: 1; }
.dropzone-title { font-size: 15px; font-weight: 500; color: var(--text); }
.dropzone-sub { font-size: 12px; }
.dropzone-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.dropzone-preview img {
  max-width: 100%;
  max-height: 220px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  object-fit: contain;
  background: var(--bg);
}
.dropzone-preview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 28px;
}
.dropzone-bg-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}
.dropzone-bg-status .spinner-sm {
  width: 12px; height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.dropzone-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 13px;
}
.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Gear search (autocomplete) ---------- */
.gear-search-field { position: relative; }
.gear-search-row { position: relative; align-items: center; }
.gear-search-row input[type="search"] { padding-right: 32px; }
.gear-search-row input[type="search"]::-webkit-search-cancel-button,
.gear-search-row input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}
.gear-search-row .spinner-sm {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  pointer-events: none;
}
.gear-search-suggestions {
  margin-top: 6px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-y: auto;
  max-height: 168px;
}
.gear-suggestion {
  display: block;
  padding: 8px 12px;
  cursor: pointer;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  width: 100%;
  text-align: left;
}
.gear-suggestion:last-child { border-bottom: none; }
.gear-suggestion:hover,
.gear-suggestion:focus-visible {
  background: var(--bg-hover);
  outline: none;
}
.gear-suggestion-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.gear-suggestion-name {
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gear-suggestion-meta {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gear-search-empty {
  padding: 12px;
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
}
#gear-preview-meta { flex: 1; font-size: 12px; line-height: 1.5; }

/* ============ Quantity (library badge + packing-list stepper) ============ */
.gear-qty-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.item-qty {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}
.item-qty-btn {
  width: 22px; height: 22px;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.item-qty-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.item-qty-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.item-qty-input {
  width: 40px;
  height: 22px;
  text-align: center;
  padding: 0 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 6px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.item-qty-input::-webkit-outer-spin-button,
.item-qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.item-qty-owned { font-size: 11px; margin-left: 2px; margin-right: 10px; }

/* ============ Global drop overlay ============ */
.global-drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 20, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
  animation: global-drop-fade 0.12s ease-out;
}
.global-drop-overlay.active { display: flex; }
.global-drop-card {
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  padding: 40px 56px;
  background: var(--bg-elev-2);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.global-drop-icon { font-size: 56px; line-height: 1; }
.global-drop-title { font-size: 20px; font-weight: 600; color: var(--text); }
.global-drop-sub { font-size: 13px; color: var(--text-dim); }
@keyframes global-drop-fade { from { opacity: 0; } to { opacity: 1; } }

/* ============ Scrollbars ============ */
.gear-list::-webkit-scrollbar,
.activity-body::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.activity-tabs::-webkit-scrollbar { width: 8px; height: 8px; }
.gear-list::-webkit-scrollbar-thumb,
.activity-body::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.activity-tabs::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 4px;
}
.gear-list::-webkit-scrollbar-thumb:hover,
.activity-body::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover,
.activity-tabs::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ============ Touch / mobile ============ */

/* Hidden on desktop */
.mobile-tab-bar { display: none; }
.btn-text-mobile { display: none; }
.take-photo-section { display: none; }
.identify-photo-section { display: none; }

/* Take a photo (touch devices only, when no image yet) */
@media (hover: none) and (pointer: coarse) {
  .take-photo-section:not(.hidden) {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    padding: 12px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: var(--bg-elev-2);
  }
  .take-photo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 14px;
    font-size: 14px;
  }
  .take-photo-icon { font-size: 18px; line-height: 1; }

  /* Identify gear from a photo (touch devices only) — top of add-gear modal */
  .identify-photo-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0 0 16px;
  }
  .identify-photo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 600;
  }
  .identify-photo-icon { font-size: 20px; line-height: 1; }
  .identify-photo-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    font-size: 14px;
    line-height: 1.4;
  }
  .identify-photo-status.loading {
    border-color: var(--accent);
    color: var(--text);
  }
  .identify-photo-status.error {
    border-color: var(--danger, #c2410c);
    color: var(--danger, #c2410c);
  }
  .identify-photo-status .spinner-sm {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
  .identify-photo-status-text { flex: 1 1 auto; min-width: 0; }
  .identify-photo-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }
  .identify-photo-divider::before,
  .identify-photo-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
  }
}

/* Photo explainer modal — first-time tips before the camera opens */
.photo-explainer-panel { max-width: 380px; }
.photo-explainer-lede {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.45;
}
.photo-tips-diagram {
  display: flex;
  justify-content: center;
  margin: 4px 0 16px;
}
.photo-tips-frame {
  position: relative;
  width: 220px;
  height: 150px;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.06), transparent 60%),
    var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  overflow: hidden;
}
.photo-tips-corner {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid var(--accent);
}
.photo-tips-corner.tl { top: 8px;    left: 8px;    border-right: 0; border-bottom: 0; border-top-left-radius: 4px; }
.photo-tips-corner.tr { top: 8px;    right: 8px;   border-left: 0;  border-bottom: 0; border-top-right-radius: 4px; }
.photo-tips-corner.bl { bottom: 8px; left: 8px;    border-right: 0; border-top: 0;    border-bottom-left-radius: 4px; }
.photo-tips-corner.br { bottom: 8px; right: 8px;   border-left: 0;  border-top: 0;    border-bottom-right-radius: 4px; }
.photo-tips-sun {
  position: absolute;
  top: 6px;
  right: 30px;
  font-size: 18px;
  filter: drop-shadow(0 1px 2px rgba(251, 191, 36, 0.4));
}
.photo-tips-gear {
  font-size: 56px;
  line-height: 1;
}
.photo-tips-brand {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 3px;
}
.photo-tips-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.photo-tips-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  line-height: 1.4;
}
.photo-tip-icon {
  flex: 0 0 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--bg-elev-2);
  border-radius: 50%;
  font-size: 16px;
}

/* ============ Photo workflow (queue, picker, multi-upload) ============ */

/* Workflow region — visible when one or more photos are being processed. */
.photo-workflow {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 16px;
}
.photo-workflow-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
.photo-workflow-progress-dots {
  display: flex;
  gap: 4px;
}
.photo-progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
  transition: background 120ms ease;
}
.photo-progress-dot.current { background: var(--accent); transform: scale(1.2); }
.photo-progress-dot.saved { background: #4ade80; }
.photo-progress-dot.skipped { background: var(--muted); opacity: 0.5; }
.photo-progress-dot.error { background: var(--danger, #f87171); }

.photo-workflow-card {
  display: flex;
  gap: 12px;
  align-items: stretch;
}
.photo-workflow-preview-wrap {
  flex: 0 0 96px;
  width: 96px;
  height: 96px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
}
.photo-workflow-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-workflow-meta {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.photo-workflow-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  line-height: 1.35;
}
.photo-workflow-status .spinner-sm {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.photo-workflow-status.error { color: var(--danger, #f87171); }
.photo-workflow-status.success { color: #4ade80; }
.photo-workflow-status-text { flex: 1 1 auto; min-width: 0; }
.photo-workflow-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.photo-workflow-actions .btn {
  padding: 4px 10px;
  font-size: 12px;
}

/* Candidate picker — shown when there are 2+ candidates. */
.photo-candidates {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.photo-candidates-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}
.photo-candidates-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
.photo-candidate-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.photo-candidate-card:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.photo-candidate-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent) inset, 0 4px 12px -6px var(--accent);
  background: var(--bg-hover);
}
.photo-candidate-img-wrap {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-elev-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-candidate-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: white;
}
.photo-candidate-img-placeholder {
  font-size: 20px;
  color: var(--muted);
}
.photo-candidate-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.photo-candidate-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.photo-candidate-meta {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
}
.photo-candidate-check {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
}
.photo-candidate-card.selected .photo-candidate-check { display: inline-flex; }

/* Desktop multi-photo dropzone (shown only on hover/pointer-fine devices). */
.upload-photos-section-wrap { margin-top: 14px; }
.upload-photos-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 18px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 12px;
  background: var(--bg-elev);
  cursor: pointer;
  text-align: center;
  transition: border-color 120ms ease, background 120ms ease;
}
.upload-photos-dropzone:hover,
.upload-photos-dropzone:focus,
.upload-photos-dropzone.drag-over {
  border-color: var(--accent);
  background: var(--bg-hover);
  outline: none;
}
.upload-photos-icon { font-size: 24px; }
.upload-photos-title { font-weight: 600; font-size: 13px; }
.upload-photos-sub { font-size: 12px; }

/* On touch devices: hide the desktop-only screenshot dropzone, and make the
   primary save button big and inviting. */
@media (hover: none) and (pointer: coarse) {
  .screenshot-section-wrap { display: none; }
  .upload-photos-section-wrap { display: none; }
  .photo-workflow-card { gap: 10px; }
  .photo-workflow-preview-wrap { flex: 0 0 80px; width: 80px; height: 80px; }
  .photo-candidates-list { grid-template-columns: 1fr; }

  #gear-modal .modal-footer {
    gap: 10px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  }
  #gear-modal .modal-footer .spacer { display: none; }
  #gear-modal #gear-save-btn {
    flex: 1 1 auto;
    min-height: 56px;
    padding: 14px 22px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.01em;
    border-radius: 14px;
    box-shadow: 0 6px 20px -6px var(--accent), 0 1px 0 rgba(255,255,255,0.1) inset;
    transition: transform 80ms ease, box-shadow 120ms ease;
  }
  #gear-modal #gear-save-btn:not(:disabled):active {
    transform: scale(0.98);
    box-shadow: 0 3px 10px -4px var(--accent);
  }
  #gear-modal #gear-save-btn:disabled {
    box-shadow: none;
    opacity: 0.55;
  }
  #gear-modal .modal-footer .btn-ghost {
    flex: 0 0 auto;
    padding: 10px 14px;
  }
  #gear-modal #gear-delete-btn {
    flex: 0 0 auto;
    padding: 10px 14px;
  }
}

/* ============ Activity picker ============ */
.activity-picker-panel { max-width: 380px; }
.activity-picker-gear {
  margin: 0 0 12px;
  padding: 8px 10px;
  background: var(--bg-elev-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
}
.activity-picker-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.activity-picker-empty {
  padding: 16px 10px;
  text-align: center;
  font-size: 13px;
}
.activity-picker-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
  width: 100%;
}
.activity-picker-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.activity-picker-main:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.activity-picker-main:active { transform: scale(0.98); }
.activity-picker-main.in-list { opacity: 0.7; cursor: default; }
.activity-picker-main.in-list:hover { background: var(--bg-elev-2); border-color: var(--border); }
.activity-picker-main.in-list:active { transform: none; }
.activity-picker-remove {
  flex-shrink: 0;
  width: 44px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text-dim);
  border-radius: var(--radius);
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.activity-picker-remove:hover {
  background: var(--bg-hover);
  color: var(--danger);
  border-color: var(--danger);
}
.activity-picker-remove:active { transform: scale(0.94); }
.activity-picker-emoji { font-size: 22px; line-height: 1; }
.activity-picker-name { flex: 1; font-weight: 500; }
.activity-picker-add {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
}
.activity-picker-badge {
  font-size: 11px;
  color: var(--success);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.activity-picker-new {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  justify-content: center;
}
.activity-picker-new:hover { color: var(--accent); border-color: var(--accent); }
.apn-icon { font-size: 16px; line-height: 1; }

/* Touch devices: card is tap-to-add (drag is unreliable) */
@media (hover: none) and (pointer: coarse) {
  .gear-card, .gear-card:active { cursor: pointer; }
}

/* ============ Mobile mode (≤ 820px) ============ */
@media (max-width: 820px) {
  /* Header collapses */
  .app-header { padding: 10px 12px; gap: 8px; }
  .header-actions { gap: 6px; }
  #user-email { display: none; }
  #sign-out-btn { display: none; }
  #unit-toggle { padding: 6px 10px; font-size: 12px; }
  .brand h1 { font-size: 17px; }
  .btn-text-full { display: none; }
  .btn-text-mobile {
    display: inline;
    font-size: 20px;
    line-height: 1;
    font-weight: 600;
    padding: 0 6px;
  }

  /* Single-panel layout — pick which based on data-mobile-mode on body.
     Use dvh so the height shrinks when iOS Safari's chrome is visible,
     keeping the activity footer above the bottom tab bar. */
  .app-main {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    height: calc(100dvh - 53px - 56px - env(safe-area-inset-bottom, 0px));
  }
  body[data-mobile-mode="library"] .activity-panel { display: none; }
  body[data-mobile-mode="packing"] .gear-library { display: none; }
  .gear-library { border-right: none; }

  /* Bottom tab bar */
  .mobile-tab-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg-elev);
    border-top: 1px solid var(--border);
    padding: 4px 0 env(safe-area-inset-bottom, 0px);
    justify-content: space-around;
    align-items: stretch;
  }
  .mobile-tab {
    flex: 1;
    background: transparent;
    border: none;
    padding: 6px 4px 4px;
    color: var(--text-dim);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 10px;
    line-height: 1;
    cursor: pointer;
    min-height: 52px;
    transition: color 0.12s;
  }
  .mobile-tab:active { transform: scale(0.96); }
  .mobile-tab.active { color: var(--accent); }
  .mobile-tab-icon { font-size: 22px; line-height: 1; }
  .mobile-tab-label { font-weight: 500; letter-spacing: 0.02em; }

  /* Tighter content padding */
  .library-header { padding: 10px 12px 6px; }
  .gear-search { margin: 0 12px 8px; }
  .gear-list { padding: 4px 12px 16px; }
  /* The pill strip stays collapsed on phones until the user taps the
     "Filter by brand" toggle (or a filter is already active). */
  .brand-filter-pills:not(.expanded):not(.hidden) { display: none; }
  .activity-tabs {
    padding: 10px 12px;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    touch-action: pan-x;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    border-bottom: 1px solid var(--border);
  }
  .activity-tab {
    padding: 12px 18px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-elev-2);
    margin-bottom: 0;
    flex-shrink: 0;
    min-height: 44px;
  }
  .activity-tab.active {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
  }
  .activity-tab-emoji { font-size: 18px; }
  .activity-tab-add { padding: 12px 16px; }
  .custom-filter, .weather-filter { padding: 8px 12px; }
  /* On phones the hint wraps onto its own row, wasting vertical space.
     Pin it to the top-right next to the label, and push toggles to row 2. */
  .weather-filter .weather-filter-label { order: 1; }
  .weather-filter .weather-filter-hint { order: 2; margin-left: auto; }
  .weather-filter .weather-toggles { order: 3; width: 100%; }
  /* Filter row keeps label + pills (incl. + button) inline. The hint is
     pushed to the end so it fills remaining space or wraps cleanly if
     there are enough pills to push it off. */
  .custom-filter { gap: 8px; }
  .custom-filter .custom-filter-pills { order: 2; }
  .custom-filter .custom-filter-hint {
    order: 3;
    margin-left: auto;
    font-size: 12px;
    text-align: right;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .activity-footer { padding: 12px 12px 16px; flex-wrap: wrap; gap: 8px; }

  /* On mobile the checkbox is too small to tap reliably. Hide it and let a
     tap anywhere on the card toggle packed state; the corner earmark badge
     indicates the packed state visually. */
  .activity-item { grid-template-columns: 40px 1fr auto auto; }
  .activity-item input.item-checkbox { display: none; }
  .activity-item .item-check-badge {
    position: absolute;
    top: -6px;
    left: -6px;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: var(--success);
    color: #0f1115;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: none;
    z-index: 2;
  }
  .activity-item.packed .item-check-badge {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 600px) {
  /* Modal goes full-screen on phones; dvh shrinks when the keyboard opens
     so the header stays anchored at the top instead of being pushed off. */
  .modal { padding: 0; align-items: stretch; }
  .modal-panel {
    max-width: none;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
    border: none;
  }
  .modal-narrow { max-width: none; }
  .modal-header {
    padding: 12px 14px;
    flex-shrink: 0;
    background: var(--bg-elev);
  }
  .modal-body { padding: 12px 14px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  .modal-footer { padding: 10px 14px; flex-wrap: wrap; flex-shrink: 0; }

  /* Compact screenshot dropzone — less common on phones */
  .screenshot-dropzone-compact { min-height: 100px; padding: 14px; }
  .screenshot-dropzone-compact .dropzone-icon { font-size: 26px; }
  .screenshot-dropzone-compact .dropzone-title { font-size: 13px; }
  .screenshot-dropzone-compact .dropzone-sub { font-size: 11px; }
  /* 16px inputs prevent iOS zoom-on-focus */
  .field input[type="text"],
  .field input[type="url"],
  .field input[type="number"],
  .field input[type="password"],
  .field input[type="search"],
  .field input[type="email"],
  .field textarea,
  .field select,
  .gear-search,
  .auth-form input { font-size: 16px; }
}

/* ============ Share (members, invites, owner chips) ============ */

/* Share button in the activity footer */
.share-activity-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
}
.share-activity-btn .share-icon {
  flex-shrink: 0;
  color: var(--text-dim);
}
.share-activity-btn:hover .share-icon { color: var(--text); }
.share-activity-btn .share-activity-label { display: inline; }
.share-activity-count {
  display: none;
  min-width: 18px;
  padding: 0 6px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 999px;
}
.share-activity-count.visible { display: inline-block; }

/* Stack the header icons in the activity modal */
.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.activity-modal-share-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Share modal */
.share-modal-panel .modal-body { padding-bottom: 20px; }
.share-modal-subtitle {
  margin: 0 0 14px 0;
  font-size: 13px;
  color: var(--text-dim);
}
.share-section { margin-bottom: 18px; }
.share-section:last-child { margin-bottom: 0; }
.share-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

/* Invite form inside share modal */
.share-invite-form {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.share-invite-form input[type="email"] {
  flex: 1;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  outline: none;
  font-size: 13px;
  min-width: 0;
}
.share-invite-form input[type="email"]:focus {
  border-color: var(--accent);
}
.share-invite-status {
  min-height: 16px;
  margin-top: 6px;
}
.share-invite-status.success { color: var(--success); }
.share-invite-status.error { color: var(--danger); }

/* Member + pending-invite lists */
.share-members-list,
.share-invites-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.share-member-row,
.share-invite-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.share-member-main,
.share-invite-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.share-member-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.share-member-sub,
.share-invite-sub {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.share-role-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-hover);
  color: var(--text-dim);
  flex-shrink: 0;
}
.share-role-badge.role-owner {
  background: rgba(139, 157, 255, 0.18);
  color: var(--accent);
}
.share-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Avatar chip — a circle with an initial, color seeded from user id */
.owner-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--bg-hover);
  flex-shrink: 0;
  user-select: none;
  letter-spacing: 0;
  line-height: 1;
  text-transform: uppercase;
}
.owner-chip-sm { width: 20px; height: 20px; font-size: 10px; }
.owner-chip-lg { width: 32px; height: 32px; font-size: 13px; }

/* Owner chip shown at the start of each item row in a shared list */
.activity-item .owner-chip {
  margin-right: 4px;
}

/* Invite banner on top of main view, shown right after consuming ?invite= */
.invite-banner {
  position: fixed;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  z-index: 200;
  max-width: calc(100vw - 24px);
  padding: 10px 14px;
  background: rgba(139, 157, 255, 0.14);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
}
.invite-banner.error {
  background: rgba(248, 113, 113, 0.12);
  border-color: var(--danger);
}
.invite-banner .invite-banner-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.invite-banner .invite-banner-close:hover { color: var(--text); }

/* Mobile: give share modal roomy touch targets */
@media (max-width: 600px) {
  .share-activity-btn {
    min-height: 44px;
    padding: 8px 12px;
  }
  .activity-modal-share-btn {
    width: 44px;
    height: 44px;
  }
  .share-invite-form { flex-direction: column; gap: 8px; }
  .share-invite-form .btn { width: 100%; min-height: 44px; }
  .share-invite-form input[type="email"] { font-size: 16px; min-height: 44px; }
  .share-member-row,
  .share-invite-row {
    padding: 10px 12px;
  }
  .share-row-actions .btn { min-height: 36px; }
}

/* Hide the invite-count badge until someone is actually there — prevents a
   lone inviter from seeing "1" on their own list. */
.share-activity-count:empty { display: none; }
