:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --border: #2a2f3a;
  --text: #f2f3f5;
  --muted: #9aa1ad;
  --accent: #d9a441;
  --accent-2: #7c9cff;
  --danger: #e0645a;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(24px + var(--safe-bottom));
  position: relative;
}

.loading {
  padding: 40vh 20px;
  text-align: center;
  color: var(--muted);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + var(--safe-top)) 16px 12px;
  background: rgba(15, 17, 21, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.6px;
}

/* The real logo (js/app.js's Home header) — a transparent PNG derived from
   the actual TECA wordmark, recolored to var(--text) so it reads cleanly
   against the dark topbar. Every other header still uses plain .brand text
   (collection names, "Add item", etc.) — only Home gets the logo. */
.brand-logo {
  display: block;
  height: 24px;
  width: auto;
}

.tagline {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.2px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  width: 38px;
  height: 38px;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#addBtn {
  font-size: 22px;
  font-weight: 600;
  color: var(--accent);
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  white-space: nowrap;
}
.tab.active {
  background: var(--accent);
  color: #1a1200;
  border-color: var(--accent);
  font-weight: 600;
}
.tab-manage {
  border-style: dashed;
  color: var(--accent-2);
}

.chooser-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}
.chooser-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: left;
  color: var(--text);
}
.chooser-icon { font-size: 22px; }
.chooser-name { flex: 1; font-weight: 600; font-size: 15px; color: var(--text); }
.chooser-count { font-size: 12px; color: var(--muted); }

.library-card { padding: 0; overflow: hidden; }
.library-card-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: none;
  color: var(--text);
  padding: 14px;
  text-align: left;
}
.library-edit-btn { flex: none; margin: 8px 10px 8px 0; }

.profile-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  padding: 8px 16px;
  text-align: left;
}
.profile-strip strong { color: var(--accent-2); font-weight: 600; }

.top-collections-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 14px 16px 4px;
  scrollbar-width: none;
}
.top-collections-row::-webkit-scrollbar { display: none; }
.top-collection-card {
  flex: none;
  min-width: 128px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  text-align: left;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.top-collection-card.pinned { border-color: var(--accent); }
.top-collection-icon { font-size: 20px; }
.top-collection-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-collection-count { font-size: 12px; color: var(--muted); }

.home-results { padding: 4px 16px 20px; }

.search-results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.search-result-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  text-align: left;
  color: var(--text);
  width: 100%;
}
.result-photo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background-color: var(--surface-2);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.result-photo .photo-placeholder { font-size: 18px; opacity: 0.5; }
.result-info { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.result-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result-meta { font-size: 12px; color: var(--muted); }

.controls {
  padding: 12px 16px 4px;
}

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.search-row input[type="search"] {
  flex: 1;
}

.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
}

.field-filters {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.field-filters-title {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.field-filters-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.filter-item label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  display: block;
}
.filter-item input,
.filter-item select {
  font-size: 13px;
  padding: 8px 10px;
}
.range-row {
  display: flex;
  gap: 6px;
}
.range-row input {
  min-width: 0;
}

.search-banner {
  margin-top: 10px;
  font-size: 13px;
  color: var(--accent-2);
}

input, select, textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  width: 100%;
  font-family: inherit;
}
input[type="range"] { padding: 0; }

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}
label > input, label > select, label > textarea {
  margin-top: 6px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.checkbox-row input { width: auto; }

.gallery-wrap {
  padding: 8px 16px 20px;
}

.group-heading {
  margin: 18px 4px 8px;
  font-size: 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-photo {
  aspect-ratio: 1 / 1;
  background-color: var(--surface-2);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-placeholder {
  font-size: 32px;
  opacity: 0.4;
}

.card-body { padding: 10px 12px 12px; }
.card-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-rating {
  font-size: 12px;
  color: var(--accent);
}
.badge {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  background: var(--surface-2);
  color: var(--accent-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
}
.card-date {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.form {
  padding: 16px;
}

.photo-capture { margin-bottom: 16px; }

.suggestion-banner {
  background: var(--surface-2);
  border: 1px solid var(--accent-2);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.4;
}
.suggestion-banner strong { color: var(--accent-2); }

/* Home's "resume an unfinished entry" prompt — see the draft helpers in
   js/app.js. Reuses .suggestion-banner's look but sits in the Home wrap's
   own 16px gutter instead of the form's padded container. */
.draft-banner {
  margin: 12px 16px 0;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
}
.draft-banner p { margin: 0 0 8px; }
.draft-banner strong { color: var(--accent); }
.draft-banner-actions { display: flex; gap: 16px; }
.photo-preview {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  border: 1.5px dashed var(--border);
  background-color: var(--surface);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  transition: border-color 0.15s, background-color 0.15s;
}
.photo-capture.dragging .photo-preview {
  border-color: var(--accent);
  background-color: var(--surface-2);
  color: var(--accent);
}

.detail-photo {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  background-color: var(--surface);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.detail { padding: 16px; }
.detail h2 { margin: 0 0 6px; }
.detail-rating { color: var(--accent); font-size: 15px; margin-bottom: 8px; }
.detail-date { margin-top: 4px; }
.detail-notes { line-height: 1.5; color: var(--text); margin: 14px 0; white-space: pre-wrap; }

.detail-fields { margin: 14px 0; }
.detail-field {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.fld-name { color: var(--muted); }

.danger-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 10px;
  padding: 12px;
  margin-top: 20px;
  font-size: 15px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent-2);
  font-size: 13px;
  padding: 0;
}
.link-btn.danger { color: var(--danger); }

.repost-btn {
  width: 100%;
  background: var(--accent);
  border: none;
  color: #1a1200;
  border-radius: 10px;
  padding: 12px;
  margin-top: 12px;
  font-size: 15px;
  font-weight: 600;
}
.repost-btn:disabled { opacity: 0.6; }

.repost-note { margin-top: 6px; }
.repost-note .link-btn { font-size: inherit; }

.manage-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.manage-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 15px;
}
.manage-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.field-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.field-chip em { color: var(--muted); font-style: normal; }
.chip-x {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  padding: 0 2px;
}

.add-field-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.add-field-row input { flex: 2; }
.add-field-row select { flex: 1.4; }
.add-field-row button { flex: none; white-space: nowrap; }

.new-collection h3 { margin: 0 0 12px; font-size: 15px; }
.template-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.template-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 14px 6px;
  font-size: 12px;
  line-height: 1.6;
}

.muted { color: var(--muted); font-size: 13px; }

/* Collection icon: photo variant. Applied on top of whatever size class the
   context already uses (.chooser-icon, .top-collection-icon, .header-icon)
   — those keep setting font-size for the plain-emoji case, this just adds a
   fixed image box when a photo is active. */
.icon-photo {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background-color: var(--surface-2);
  background-size: cover;
  background-position: center;
  vertical-align: middle;
  flex: none;
}
.header-icon { margin-right: 4px; vertical-align: middle; }
.header-icon.icon-photo { width: 20px; height: 20px; }

/* Profile avatars use the same .icon-photo photo box, but circular. */
.profile-strip-avatar.icon-photo { width: 16px; height: 16px; border-radius: 50%; }
.profile-header-avatar.icon-photo { width: 28px; height: 28px; border-radius: 50%; }
.manage-card-header .profile-header-avatar { margin-right: 2px; vertical-align: middle; }

/* Taste Ledger — Home's cross-profile activity feed. Each row is a plain
   div (not a button) wrapping two separate buttons — the avatar (view that
   person's collections) and everything else (open the item) — since a
   button can't validly contain another button. */
.ledger-list { display: flex; flex-direction: column; gap: 8px; }
.ledger-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text);
  width: 100%;
}
.ledger-avatar-btn {
  background: none;
  border: none;
  padding: 0;
  flex: none;
  cursor: pointer;
}
.ledger-item-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  color: var(--text);
  cursor: pointer;
}
.ledger-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--surface-2);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex: none;
}
.ledger-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.ledger-line {
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ledger-meta { font-size: 12px; color: var(--muted); }

/* The item's own photo (what they added), distinct from the .ledger-avatar
   (who added it) on the other side of the row. */
.ledger-photo {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background-color: var(--surface-2);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ledger-photo .photo-placeholder { font-size: 20px; opacity: 0.4; }

/* People list (Profile screen) — view-only browsing of someone else's
   collections. Reuses .ledger-avatar's photo-box look via ledgerAvatarSpan(). */
.people-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.people-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  text-align: left;
  color: var(--text);
  font-size: 14px;
  width: 100%;
}

/* Item detail's owner attribution ("· Jordan's") — tappable, jumps to that
   person's collections (see openProfileBrowse). */
.owner-link {
  font-size: 12px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Shown instead of the Delete button on someone else's item. */
.view-only-note { margin-top: 16px; }

.icon-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 6px;
}
.icon-picker-preview {
  align-self: flex-start;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  background-size: cover;
  background-position: center;
  color: var(--text);
}
.icon-emoji-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.icon-emoji-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 18px;
  padding: 6px 8px;
  line-height: 1;
}
.icon-emoji-input { width: 100%; }
.icon-photo-capture .icon-photo-upload-preview {
  aspect-ratio: unset;
  height: 60px;
  font-size: 12px;
}
