:root {
  --bg-a: #101812;
  --bg-b: #1d291f;
  --panel: rgba(19, 28, 21, 0.76);
  --panel-solid: #17221a;
  --line: rgba(171, 210, 138, 0.25);
  --line-strong: rgba(171, 210, 138, 0.45);
  --text: #eef8e6;
  --soft: #b8d0b2;
  --accent: #6fae4f;
  --accent-strong: #86c968;
  --warn: #f7b267;
  --danger: #e2665c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-height: 100vh;
  font-family: "Plus Jakarta Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 20%, rgba(199, 138, 69, 0.18), transparent 42%),
    radial-gradient(circle at 82% 18%, rgba(118, 192, 110, 0.18), transparent 40%),
    linear-gradient(165deg, var(--bg-a), var(--bg-b));
}

a { color: inherit; }

/* ---------- Header / nav ---------- */

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand {
  font-family: "Bebas Neue", sans-serif;
  font-size: 1.4rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
}

nav.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

nav.tabs a {
  text-decoration: none;
  color: var(--soft);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.84rem;
  letter-spacing: 0.04em;
}

nav.tabs a.active,
nav.tabs a:hover {
  background: var(--panel);
  color: var(--text);
}

.tab-form { display: inline; margin: 0; }

.tab-button,
.tab-button-link {
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.84rem;
  letter-spacing: 0.04em;
  background: rgba(25, 36, 27, 0.6);
  cursor: pointer;
  font-family: inherit;
}

/* ---------- Layout ---------- */

main.wrap {
  width: min(1060px, 100%);
  margin: 0 auto;
  padding: 40px 20px 60px;
}

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

h1 {
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(2rem, 5vw, 3.6rem);
  letter-spacing: 0.04em;
  line-height: 0.95;
  text-transform: uppercase;
}

.sub {
  color: var(--soft);
  margin-top: 8px;
  max-width: 620px;
  line-height: 1.5;
}

.back {
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  align-self: flex-start;
  background: rgba(25, 36, 27, 0.6);
}

.kicker {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--soft);
  margin-bottom: 8px;
}

/* ---------- Range cards (home page) ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.item {
  display: block;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: var(--panel);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.item:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
}

.title {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.desc {
  color: var(--soft);
  font-size: 0.92rem;
  line-height: 1.5;
}

/* ---------- Search ---------- */

.search-wrap {
  position: relative;
  margin-bottom: 28px;
}

.search-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
}

.search-input:focus {
  outline: none;
  border-color: var(--line-strong);
}

.search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 12px;
  max-height: 340px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.search-result-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  cursor: pointer;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  min-height: 44px;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: rgba(171, 210, 138, 0.08); }

.search-result-name { font-weight: 700; }
.search-result-meta { color: var(--soft); font-size: 0.82rem; margin-top: 2px; }

/* ---------- Marker drawer grid ---------- */

.layer { margin-bottom: 36px; }

.layer-title {
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.trays {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.tray {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: var(--panel);
}

.tray-title {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--soft);
  margin-bottom: 12px;
}

.markers {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.markers li { border-radius: 8px; }

.markers li button {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  text-decoration: none;
  color: var(--text);
  padding: 10px 8px;
  border-radius: 8px;
  min-height: 44px;
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.markers li button:hover { background: rgba(171, 210, 138, 0.08); }

.markers li.is-highlighted button {
  background: rgba(247, 178, 103, 0.16);
  box-shadow: inset 3px 0 0 var(--warn);
  font-weight: 700;
}

.pos {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-size: 0.7rem;
  color: var(--soft);
}

/* ---------- Tessellating honeycomb (Fanatic racks, Speedpaint 2.0 categories) ---------- */

.honeycomb {
  --seam: 3px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0 4.545%;
}

.honeycomb-row {
  display: flex;
  gap: var(--seam);
  width: fit-content;
}

.honeycomb-row:not(:first-child) {
  margin-top: var(--row-overlap, calc(-2.63% + var(--seam) * 0.5));
}

.honeycomb-row.offset {
  margin-left: var(--row-offset, calc(4.545% + var(--seam) * 0.5));
}

/* Outline, filter/drop-shadow AND box-shadow are all, in one browser or
   another, unreliable at following an element's own clip-path — instead of
   fighting that for a highlight ring, .honeycomb-cell is just an unfilled hex
   hit-area/positioner, and the actual swatch colour lives on a nested
   .honeycomb-cell-fill hex sized to match it exactly. Highlighting shrinks
   the inner hex inward, revealing the outer hex's own colour as a ring — two
   real nested shapes, no cross-effect clipping quirks possible. */
.honeycomb-cell {
  flex: 0 0 var(--cell-w, calc(9.0909% - (var(--seam) * 10 / 11)));
  min-width: 0;
  aspect-ratio: 0.866;
  /* now that the swatch colour lives on .honeycomb-cell-fill, not here, this
     needs its own background reset — otherwise the browser's default button
     chrome shows through in the un-clipped notches between hexes */
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  position: relative;
  font-family: inherit;
  transition: transform 0.08s ease;
}

.honeycomb-cell:hover .honeycomb-cell-fill {
  filter: brightness(1.12);
}

.honeycomb-cell:hover {
  transform: translateY(-2px);
  z-index: 2;
}

.honeycomb-cell:focus {
  /* the default browser focus ring is a plain rectangle and — like outline
     in general — isn't clipped to the hex shape by clip-path, so it shows as
     a square. Tapping on touch triggers plain :focus, not :focus-visible. */
  outline: none;
}

.honeycomb-cell:focus-visible {
  transform: translateY(-2px) scale(1.04);
  z-index: 3;
}

.honeycomb-cell-fill {
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: clamp(2px, 1vw, 7px) clamp(3px, 1.4vw, 10px);
  transition: inset 0.1s ease, filter 0.12s ease;
}

.honeycomb-cell.is-highlighted {
  background: var(--warn);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  z-index: 3;
}

.honeycomb-cell.is-highlighted .honeycomb-cell-fill {
  inset: 4px;
}

.honeycomb-cell-name {
  /* set from actual cell width in layoutHoneycombs(), not viewport width —
     inside a narrower modal the cells are smaller than a vw-based size would
     assume, which was overflowing/mis-wrapping names in the popup */
  font-size: var(--cell-font, clamp(0.5rem, 1.05vw, 0.78rem));
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  word-break: normal;
  overflow-wrap: anywhere;
  max-width: 94%;
}

.honeycomb-cell-warn {
  position: absolute;
  bottom: 10%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  font-size: 0.72rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.55);
}

.note {
  color: var(--soft);
  font-size: 0.85rem;
  margin-top: 14px;
  line-height: 1.5;
}

/* ---------- Category groups (non-marker ranges) ---------- */

.category-section { margin-bottom: 28px; }

.category-title {
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}


.empty-note {
  color: var(--soft);
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: 14px;
}

/* ---------- Panels / forms ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 20px;
}

.panel-title {
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(1.1rem, 2.6vw, 1.4rem);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.field { margin-bottom: 14px; }

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--soft);
  font-size: 0.85rem;
}

.field input, .field select {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--line-strong);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.location-text {
  font-size: 1.3rem;
  font-weight: 700;
}

.low-stock-badge {
  display: inline-block;
  margin-top: 10px;
  background: rgba(247, 178, 103, 0.15);
  color: var(--warn);
  border: 1px solid rgba(247, 178, 103, 0.4);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.actions-panel {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- Buttons ---------- */

.btn {
  background: var(--accent);
  color: #0c1409;
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.btn:hover { background: var(--accent-strong); }

.btn.secondary {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
}

.btn.danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}

/* ---------- Shopping list ---------- */

.shopping-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 8px;
  background: var(--panel);
}

.shopping-item input[type="checkbox"] {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.shopping-item-name { flex: 1; font-weight: 600; }
.shopping-item-note { color: var(--soft); font-size: 0.85rem; }

.shopping-item.is-done .shopping-item-name {
  text-decoration: line-through;
  color: var(--soft);
  font-weight: 400;
}

.shopping-item .btn.danger {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* ---------- Paint popup (tap a paint anywhere, see it without navigating away) ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 5, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  position: relative;
  /* wide enough that an 11-across rack honeycomb gets real room to breathe —
     narrow phones still fall back to the 94vw cap */
  width: min(720px, 94vw);
  max-height: 85vh;
  overflow-y: auto;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px 20px 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(25, 36, 27, 0.6);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.modal-content .kicker { margin-top: 4px; }
.modal-content h2 { font-family: "Bebas Neue", sans-serif; font-size: 1.6rem; letter-spacing: 0.03em; text-transform: uppercase; margin: 4px 0 10px; padding-right: 36px; }
.modal-content .location-text { font-size: 1.1rem; font-weight: 700; margin-bottom: 14px; }
.modal-content .actions-panel { padding: 0; border: none; background: none; margin-bottom: 4px; }
.modal-content .view-full-link { display: inline-block; margin-top: 10px; color: var(--soft); font-size: 0.85rem; text-decoration: underline; }

/* ---------- Location visual (full rack honeycomb, highlighted, used in the popup) ---------- */

.location-visual {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 16px;
  background: rgba(0, 0, 0, 0.15);
}

.loc-tray-label {
  font-size: 0.85rem;
  color: var(--soft);
  margin-bottom: 10px;
}

.triad-strip-wrap {
  margin-bottom: 16px;
}

.triad-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--soft);
  margin-bottom: 6px;
}

.triad-name {
  color: var(--accent);
  font-weight: 700;
}

.triad-strip {
  display: flex;
  gap: 3px;
}

.triad-cell {
  flex: 1 1 0;
  height: 30px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  outline: 2px solid transparent;
  outline-offset: 2px;
}

.triad-cell.active {
  outline-color: var(--text);
}

.swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  vertical-align: middle;
  margin-right: 4px;
}

.modal-content h2 .swatch {
  width: 22px;
  height: 22px;
}

/* ---------- Responsive ---------- */

@media (max-width: 950px) {
  .grid, .trays { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-row { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .grid, .trays { grid-template-columns: 1fr; }
}
