:root {
  color-scheme: light;
  --bg: #f4efe8;
  --panel: #fffaf4;
  --panel-2: #f8f1e7;
  --text: #1d1a17;
  --muted: #6f6258;
  --accent: #8d4f28;
  --accent-2: #164e63;
  --border: rgba(29, 26, 23, 0.12);
  --shadow: 0 14px 40px rgba(70, 45, 20, 0.12);
  --radius: 18px;
  --good: #2e6b3e;
  --bad: #8d2828;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(141, 79, 40, 0.1), transparent 32%),
    radial-gradient(circle at top right, rgba(22, 78, 99, 0.08), transparent 28%),
    linear-gradient(180deg, #fcf8f2 0%, var(--bg) 100%);
  min-height: 100vh;
}
/* Lock the body from scrolling behind the modal */
body.modal-open {
  overflow: hidden;
}
/* Muted hint text within a field label (e.g. "(optional)") */
.field-label-optional {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  margin-left: 4px;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  margin: 0;
  font-size: 1.9rem;
  letter-spacing: -0.02em;
}
header.top {
  padding: 22px 28px 14px;
  max-width: 1300px;
  margin: 0 auto;
}
.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.actor-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}
.actor-field input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  font: inherit;
  background: white;
  width: 160px;
}
.stats {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
}
.stats .badge {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
}
main {
  max-width: 1300px;
  margin: 0 auto;
  padding: 8px 28px 60px;
}
.filter-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 16px;
  margin-bottom: 18px;
}
.tabs { display: flex; gap: 6px; }
.tab {
  border: 1px solid var(--border);
  background: white;
  border-radius: 999px;
  padding: 6px 14px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--muted);
}
.tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.source-filters {
  display: flex;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--muted);
}
.source-filters label { display: flex; align-items: center; gap: 4px; }
#searchBox {
  flex: 1;
  min-width: 200px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.card-tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform 0.08s ease;
}
.card-tile:hover { transform: translateY(-2px); }
.card-tile img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: #111;
}
.card-tile .no-image {
  width: 100%;
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.card-tile .tile-body { padding: 12px 14px 14px; }
.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.pill.instagram { background: #fde8d7; color: var(--accent); }
.pill.news { background: #dbeefb; color: var(--accent-2); }
.pill.blog { background: #e7e2f7; color: #4a3a8d; }
.tile-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin: 0 0 4px;
  line-height: 1.3;
}
.tile-company { font-size: 0.82rem; color: var(--muted); }
.tile-blurb {
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile-snippet {
  font-size: 0.82rem;
  margin: 6px 0 0;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile-suggestion {
  font-size: 0.8rem;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile-suggestion-label {
  font-weight: 600;
  color: var(--accent);
}
.tile-status {
  margin-top: 8px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tile-status.done { color: var(--good); }
.tile-status.skipped { color: var(--bad); }
.empty-state { color: var(--muted); text-align: center; padding: 40px 0; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 15, 10, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
  /* Prevent the overlay itself from scrolling — only the modal inside scrolls */
  overflow: hidden;
}
.modal-overlay[hidden] {
  display: none;
}
.modal {
  position: relative;  /* anchor for the absolute close button */
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: min(1040px, 95vw);  /* slightly wider to comfortably fit 2 columns */
  width: 100%;
  max-height: min(800px, 85vh);  /* keep modal strictly within viewport, fixed height */
  display: flex;
  flex-direction: column;
  overflow: hidden; /* disable container scrollbar, we scroll the body instead */
}
@media (max-width: 767px) {
  .modal {
    max-height: 95vh;
  }
}
.modal-header {
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--border);
  padding-right: 40px; /* reserve space for close button */
  flex-shrink: 0; /* do not shrink */
}
.modal-header h2 {
  font-family: Georgia, serif;
  margin: 8px 0 0;
  font-size: 1.5rem;
}
.modal-body {
  flex: 1;
  min-height: 0; /* important for flex child scrolling */
  overflow-y: auto;
  padding: 20px 24px;
}
/* Style the custom scrollbar inside modal body */
.modal-body::-webkit-scrollbar {
  width: 8px;
}
.modal-body::-webkit-scrollbar-track {
  background: transparent;
}
.modal-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

.modal-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.modal-left-col,
.modal-right-col {
  min-width: 0;
}
@media (min-width: 768px) {
  .modal-grid {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 28px;
    align-items: start;
  }
}
.modal .company-summary {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 14px;
  line-height: 1.5;
}
.modal .field-group { margin-bottom: 18px; }
.modal .field-label {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}
.modal .caption-text {
  white-space: pre-line;
  font-size: 0.92rem;
  line-height: 1.5;
  margin-bottom: 8px;
}
textarea#messageBox {
  width: 100%;
  min-height: 110px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  resize: vertical;
}
select, input[type="text"], input[type="email"] {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 10px;
  background: white;
  max-width: 100%;
  min-width: 0;
}
#contactSelect {
  max-width: 300px;
  text-overflow: ellipsis;
}
.contact-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.add-contact-form {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.add-contact-form.open { display: grid; }
.skip-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
  flex-shrink: 0; /* do not shrink */
}
.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
button.btn {
  font: inherit;
  font-size: 0.88rem;
  border-radius: 999px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
}
button.btn.primary { background: var(--accent); color: white; border-color: var(--accent); }
button.btn.accent { background: var(--accent-2); color: white; border-color: var(--accent-2); }
button.btn.danger { background: white; color: var(--bad); border-color: var(--bad); }
button.btn:disabled { opacity: 0.45; cursor: not-allowed; }
button.btn.small { padding: 5px 11px; font-size: 0.78rem; }
.modal-close {
  /* Absolute so it doesn't affect document flow or cause layout overflow.
     Previously sticky+float which caused horizontal scroll artifacts. */
  position: absolute;
  top: 10px;
  right: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--muted);
  z-index: 10;
  flex-shrink: 0;
}
.modal-close:hover {
  background: var(--panel);
  color: var(--text);
}
.hint { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  z-index: 100;
}

/* Card tile image wrapper for better scaling and rounded corners */
.tile-media-wrapper {
  width: 100%;
  height: 160px;
  overflow: hidden;
  position: relative;
  background: #111;
}
.tile-media-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Card Header inside tile body */
.tile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

/* Small source indicator badge */
.source-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: -0.02em;
}
.source-badge.instagram { background: #fde8d7; color: var(--accent); }
.source-badge.news { background: #dbeefb; color: var(--accent-2); }
.source-badge.blog { background: #e7e2f7; color: #4a3a8d; }

/* Status styling on tiles */
.tile-status {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.tile-status.done { background: rgba(46, 107, 62, 0.08); color: var(--good); border-color: rgba(46, 107, 62, 0.18); }
.tile-status.skipped { background: rgba(141, 40, 40, 0.08); color: var(--bad); border-color: rgba(141, 40, 40, 0.18); }

/* Company summary/description toggle area */
.company-blurb-container {
  margin-bottom: 18px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.company-blurb-text {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text);
  overflow: hidden;
  transition: max-height 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}
.company-blurb-text.collapsed {
  max-height: 4.65em; /* exactly 3 lines at 1.55 line-height */
  mask-image: linear-gradient(to bottom, black 40%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 40%, transparent 100%);
}
.company-blurb-toggle {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 0 0;
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
}
.company-blurb-toggle:hover {
  color: #703816;
}

/* Relevant items/products carousel */
.relevant-items-carousel {
  display: flex;
  overflow-x: auto;
  gap: 12px;
  margin-top: 6px;
  padding-bottom: 8px; /* space for scrollbar */
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}
/* Custom scrollbar styling for the carousel */
.relevant-items-carousel::-webkit-scrollbar {
  height: 6px;
}
.relevant-items-carousel::-webkit-scrollbar-track {
  background: var(--panel-2);
  border-radius: 3px;
}
.relevant-items-carousel::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.relevant-items-carousel::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}
.relevant-items-carousel .item-thumb-card {
  flex: 0 0 180px;
  scroll-snap-align: start;
}

/* No items placeholder styling */
.no-items-placeholder {
  background: var(--panel-2);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 14px;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
  text-align: center;
}

/* Suggestion tabs */
.sugg-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.sugg-tab {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.sugg-tab:hover {
  background: white;
  color: var(--text);
  border-color: rgba(141, 79, 40, 0.3);
}
.sugg-tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.item-thumb-card {
  display: flex;
  flex-direction: column;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.item-thumb-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(70, 45, 20, 0.08);
  border-color: rgba(141, 79, 40, 0.25);
}
.item-thumb-gem {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  position: relative;
  text-align: center;
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.gem-label {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  padding: 2px 8px;
  border-radius: 999px;
  color: #333;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  max-width: 90%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-thumb-info {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.item-thumb-name {
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 2.5em; /* space for 2 lines */
}
.item-thumb-price {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
}

/* Gemstone themed color gradients for items */
.item-thumb-gem.tanzanite {
  background: linear-gradient(135deg, #4f46e5 0%, #818cf8 100%);
}
.item-thumb-gem.tsavorite {
  background: linear-gradient(135deg, #047857 0%, #10b981 100%);
}
.item-thumb-gem.tourmaline {
  background: linear-gradient(135deg, #ec4899 0%, #f472b6 100%);
}
.item-thumb-gem.aquamarine {
  background: linear-gradient(135deg, #0891b2 0%, #06b6d4 100%);
}
.item-thumb-gem.morganite {
  background: linear-gradient(135deg, #fb923c 0%, #ffedd5 100%);
}
.item-thumb-gem.spinel {
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
}
.item-thumb-gem.garnet {
  background: linear-gradient(135deg, #7f1d1d 0%, #dc2626 100%);
}
.item-thumb-gem.rubellite {
  background: linear-gradient(135deg, #be185d 0%, #f472b6 100%);
}
.item-thumb-gem.sphene {
  background: linear-gradient(135deg, #854d0e 0%, #eab308 100%);
}
.item-thumb-gem.rhodolite {
  background: linear-gradient(135deg, #9d174d 0%, #db2777 100%);
}
.item-thumb-gem.spessartite {
  background: linear-gradient(135deg, #c2410c 0%, #f97316 100%);
}
.item-thumb-gem.default {
  background: linear-gradient(135deg, #6b7280 0%, #9ca3af 100%);
}

/* News/Blog Summary styling */
.summary-text-block {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}
.summary-text-block strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 6px;
  line-height: 1.35;
  color: var(--text);
}
.summary-text-block p {
  margin: 0;
  color: var(--muted);
}
