/* =========================
   GLOBAL
========================= */
body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: #111;
  color: #eee;
  line-height: 1.45;
}

a {
  color: #aaa;
  text-decoration: none;
}

/* =========================
   NAV
========================= */
nav {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  background: #000;
  border-bottom: 1px solid #333;
  align-items: center;
  flex-wrap: wrap;
}

/* =========================
   LAYOUT
========================= */
.main {
  padding: 16px;
}

.card-detail-page {
  max-width: 760px;
  margin: 0 auto;
}

.section {
  margin-bottom: 20px;
}

/* =========================
   DASHBOARD
========================= */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.stat {
  background: #1f1f1f;
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,.4);
}

.stat h2 {
  margin: 0 0 6px 0;
  font-size: 16px;
  color: #aaa;
}

.stat .value {
  font-size: 28px;
  font-weight: 700;
}

.dashboard-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin: 16px 0;
}

.dashboard-panels.two-col {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.dash-panel {
  background: #1f1f1f;
  border: 1px solid #2b2b2b;
  border-radius: 8px;
  padding: 12px;
}

.dash-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.dash-panel-head h2 {
  margin: 0;
  font-size: 16px;
}

.dash-panel-head span {
  color: #111;
  background: #2ecc71;
  border-radius: 999px;
  min-width: 28px;
  padding: 3px 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.dash-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  width: 100%;
  padding: 4px;
  margin-bottom: 10px;
  border: 1px solid #303030;
  border-radius: 8px;
  background: #111;
}

.dash-toggle button {
  width: 100%;
  margin: 0;
  padding: 7px 8px;
  border-radius: 6px;
  background: transparent;
  color: #ccc;
  font-size: 13px;
}

.dash-toggle button.active {
  background: #2ecc71;
  color: #071108;
}

.pill-list,
.token-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dash-link-pill,
.token-list span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #111;
  border: 1px solid #333;
  color: #eee;
  font-size: 13px;
  font-weight: 700;
}

.dash-link-pill:hover {
  border-color: #2ecc71;
  color: #fff;
}

.audit-list {
  display: grid;
  gap: 6px;
}

.audit-list a {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  padding: 7px 8px;
  border-radius: 6px;
  background: #151515;
  border: 1px solid #303030;
}

.audit-list span {
  color: #aaa;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.duplicate-list {
  display: grid;
  gap: 10px;
}

.duplicate-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.duplicate-row > strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 6px;
  background: #2f2110;
  color: #f4d35e;
  border: 1px solid #6d5015;
}

.empty-state {
  color: #888;
  font-size: 13px;
}

.conversion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.conversion-panel {
  background: #1f1f1f;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #2b2b2b;
}

.conversion-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid #333;
  font-family: monospace;
}

/* =========================
   DECK GRID
========================= */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
  padding: 14px;
}

.card {
  text-decoration: none;
}

.card.solved .card-face,
.card.solved .card-photo {
  outline: 3px solid #2ecc71;
}

/* =========================
   CARD VISUALS
========================= */
.card-container {
  position: relative;
  width: 100%;
}

.card-face,
.card-photo {
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,.4);
}

.card-photo {
  object-fit: cover;
  display: block;
}

.red { color: #c0392b; }
.black { color: #111; }

.corner {
  position: absolute;
  font-size: 14px;
  font-weight: 600;
}

.corner.top {
  top: 8px;
  left: 8px;
}

.corner.bottom {
  bottom: 8px;
  right: 8px;
  transform: rotate(180deg);
}

.center-suit {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 36px;
}

/* =========================
   ANSWER BADGE
========================= */
.answer-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 42px;
  height: 42px;
  padding: 6px;
  background: #fff;
  color: #000;
  border: 2px solid #000;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  pointer-events: none;
}

/* =========================
   FORMS
========================= */
input,
textarea {
  width: 100%;
  margin-top: 6px;
  padding: 8px;
  border-radius: 6px;
  border: none;
  font-size: 14px;
  box-sizing: border-box;
}

textarea {
  min-height: 96px;
}

button {
  margin-top: 10px;
  padding: 10px;
  width: 100%;
  border: none;
  border-radius: 8px;
  background: #2ecc71;
  font-weight: 600;
  cursor: pointer;
}
/* Fix: prevent global input styles from breaking checkboxes */
input[type="checkbox"] {
  width: auto;
  padding: 0;
  margin: 0;
}

/* =========================
   NOTES
========================= */
.note {
  background: #1f1f1f;
  padding: 8px;
  border-radius: 6px;
  margin-top: 6px;
  font-size: 13px;
}

/* =========================
   LIGHTBOX
========================= */
#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

#lightbox img {
  max-width: 95%;
  max-height: 95%;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.8);
}
/* Leaflet popup cleanup */
.leaflet-popup-content {
  margin: 0;
}
.leaflet-popup-content-wrapper {
  border-radius: 16px;
  padding: 12px;
}

/* Popup layout */
.card-popup {
  width: 280px;
  font-family: system-ui, -apple-system, sans-serif;
}

/* Title */
.popup-title {
  font-size: 20px;
  font-weight: 700;
  color: #3f51f5;
  margin-bottom: 4px;
}

/* Location line */
.popup-location {
  font-size: 14px;
  margin-bottom: 10px;
}

/* Blue card panel */
.popup-card-frame {
  background: #4b5cff;
  border-radius: 18px;
  height: 140px;
  margin-bottom: 12px;

  display: flex;
  align-items: center;
  justify-content: center;
}

/* Card image inside blue panel */
.popup-card-frame img {
  width: 80px;
  height: 120px;
  object-fit: cover;
  object-position: center top;
  border-radius: 6px;
}

/* Placeholder if no image */
.popup-card-placeholder {
  color: white;
  font-size: 32px;
  font-weight: 700;
}

/* Clue block */
.popup-clue {
  background: #f4f5f7;
  border-radius: 10px;
  padding: 10px;
  font-size: 14px;
  margin-bottom: 10px;
}

.popup-clue-text {
  margin-top: 4px;
  line-height: 1.4;
}

/* Open card button */
.popup-open-btn {
  width: 100%;
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: #3f51f5;
  color: white;
  font-weight: 600;
  cursor: pointer;
}
/* Force Leaflet popups to not center content */
/* Leaflet popup: force left alignment and full width */
.leaflet-popup-content {
  
  text-align: left !important;
}
.popup-title {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: #3f51f5;
  margin-bottom: 6px;
}


/* Keep checkbox + label tight and left */
.trip-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0px;

  width: 100%;
  margin: 8px 0;
}

.trip-check {
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
}

.trip-label {
  margin: 0;
  flex: 0 0 auto;
  white-space: nowrap;
}
.route-export {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.map-tool-section {
  border-top: 1px solid #333;
  border-bottom: 1px solid #333;
  margin: 10px 0;
  padding: 10px 0;
}

.map-tool-title {
  color: #eee;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.map-tool-status {
  color: #aaa;
  font-size: 12px;
  line-height: 1.35;
  margin-bottom: 4px;
}

.map-tool-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}

.map-tool-buttons button {
  width: 100%;
  margin-top: 0;
  padding: 7px 8px;
  font-size: 12px;
}

.map-tool-buttons button:first-child {
  grid-column: 1 / -1;
}

.muted-tool-btn {
  background: #333;
  color: #eee;
}

.map-dot-marker {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid #fff;
  color: #111;
  font-size: 14px;
  font-weight: 900;
  line-height: 30px;
  text-align: center;
  box-shadow: 0 3px 10px rgba(0,0,0,.45);
}

.map-click-popup button {
  width: auto;
  margin-top: 0;
  padding: 7px 10px;
}

.export-btn {
  width: 100%;
  min-width: 0;
  height: 36px;
  border-radius: 8px;
  border: 1px solid #ccc;
  background: #fff;
  color: #111;
  font-size: 0;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0 10px;
  margin-top: 0;
}

.export-btn::after {
  font-size: 12px;
}

.route-optimize-btn::after {
  content: "Optimize";
}

.route-clear-btn::after {
  content: "Clear";
}

.route-google-btn::after {
  content: "Google";
}

.route-apple-btn::after {
  content: "Apple";
}

@media (max-width: 640px) {
  #trip-panel {
    left: 10px !important;
    right: 10px !important;
    bottom: 10px !important;
    min-width: 0 !important;
    max-width: none;
  }

  .map-tool-buttons {
    grid-template-columns: repeat(3, 1fr);
  }

  .map-tool-buttons button:first-child {
    grid-column: auto;
  }

  .map-tool-buttons button,
  .export-btn {
    height: 38px;
    padding: 0;
    font-size: 0;
  }

  .map-tool-buttons button::after,
  .export-btn::after {
    font-size: 13px;
    font-weight: 800;
  }

  .map-tool-buttons button:nth-child(1)::after {
    content: "GPS";
  }

  .map-tool-buttons button:nth-child(2)::after {
    content: "LOC";
  }

  .map-tool-buttons button.tracking:nth-child(2)::after {
    content: "STOP";
  }

  .map-tool-buttons button:nth-child(3)::after {
    content: "X";
  }

  .route-optimize-btn::after {
    content: "OPT";
  }

  .route-clear-btn::after {
    content: "CLR";
  }

  .route-google-btn::after {
    content: "G";
  }

  .route-apple-btn::after {
    content: "A";
  }
}

.export-btn:hover {
  background: #f0f0f0;
}

.export-btn:active {
  transform: scale(0.95);
}
.custom-pin {
  position: relative;
  width: 25px;
  height: 41px;
}

.custom-pin img {
  width: 25px;
  height: 41px;
  display: block;
}

/* covers the white dot */
.pin-cover {
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  z-index: 2;
}

/* label on top of cover */
.pin-label {
  position: absolute;
  top: 9px;
  left: 0;
  width: 100%;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  color: #000;
  z-index: 3;
  line-height: 14px;
  pointer-events: none;
}
.icon-btn {
  width: auto;
  min-width: 48px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: #2c2c2c;
  color: #fff;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0 10px;
  margin-top: 6px;
}

.geocode-btn,
.gps-btn {
  font-size: 0;
}

.geocode-btn:not(.loading)::after,
.gps-btn:not(.loading)::after {
  font-size: 13px;
  font-weight: 700;
}

.geocode-btn:not(.loading)::after {
  content: "Find";
}

.gps-btn:not(.loading)::after {
  content: "GPS";
}

.icon-btn:hover {
  background: #3a3a3a;
}
.icon-btn.loading {
  pointer-events: none;
  background: #555;
}

.icon-btn.loading::after {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =========================
   Top Navigation - Button Feel
========================= */

.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #0b0b0b;
  border-bottom: 1px solid #222;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.nav-left,
.nav-right {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Button base */
.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;

  padding: 10px 14px;
  border-radius: 10px;

  background: linear-gradient(#1b1b1b, #141414);
  border: 1px solid #2a2a2a;

  color: #ddd;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;

  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.05),
    0 2px 6px rgba(0,0,0,0.6);

  transition:
    transform 0.08s ease,
    box-shadow 0.08s ease,
    background 0.12s ease,
    border-color 0.12s ease;
}

/* Hover = lift */
.nav-item:hover {
  background: linear-gradient(#222, #1a1a1a);
  border-color: #3a3a3a;
  color: #fff;

  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 4px 10px rgba(0,0,0,0.8);
}

/* Active press */
.nav-item:active {
  transform: translateY(1px);
  box-shadow:
    inset 0 2px 6px rgba(0,0,0,0.8);
}

/* Current page = latched down */
.nav-item.active {
  background: linear-gradient(#2ecc71, #25b863);
  border-color: #2ecc71;
  color: #000;
  font-weight: 700;

  transform: translateY(1px);
  box-shadow:
    inset 0 2px 6px rgba(0,0,0,0.35);
}

/* Logout danger tone */
.nav-item.logout {
  background: linear-gradient(#2a1616, #1e0f0f);
  border-color: #402020;
}

.nav-item.logout:hover {
  background: linear-gradient(#402020, #2a1414);
  border-color: #ff6b6b;
  color: #ffdede;
}

/* Icon sizing */
.nav-icon {
  font-size: 16px;
  line-height: 1;
}

/* Mobile: icon-only buttons */
@media (max-width: 600px) {
  .nav-label {
    display: none;
  }

  .nav-item {
    padding: 10px;
  }
}

/* ---- GRID ---- */
.cipher-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), 44px);
  grid-auto-rows: 44px;
  gap: 6px;
  background: #111;
  padding: 16px;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
}

/* ---- CELLS ---- */
.cipher-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;

  background: #fff;
  border: 1px solid #999;
  border-radius: 8px;

  font-size: 18px;
  font-weight: 600;
  color: #000;

  box-shadow:
    inset 0 0 0 1px #e0e0e0,
    0 2px 4px rgba(0,0,0,.25);

  user-select: none;
}


/* formatting flags */
.cipher-cell.bold { font-weight: 700; }
.cipher-cell.italic { font-style: italic; }
.cipher-cell.underline { text-decoration: underline; }

/* special emphasis */
.cipher-cell.special {
  border-color: #f1c40f;
  box-shadow:
    inset 0 0 0 2px #f1c40f,
    0 2px 6px rgba(0,0,0,.35);
}


/* optional suit coloring (simple heuristic) */
.cipher-cell.red {
  color: #c0392b;
}

.cipher-cell.black {
  color: #111;
}


/* tooltip note */
.cipher-cell[data-note]:hover::after {
  content: attr(data-note);
  position: absolute;
  left: 50%;
  top: -10px;
  transform: translate(-50%, -100%);
  background: #000;
  color: #fff;
  border: 1px solid #333;
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 999;
}
.cipher-cell .glyph {
  z-index: 1;
}

.cipher-cell .decoded {
  position: absolute;
  bottom: 3px;
  right: 6px;
  font-size: 11px;
  font-weight: 700;
  opacity: 0.9;
  display: none;
  pointer-events: none;
}
.cipher-title {
  margin: 0 0 14px 0;
  font-weight: 700;
}
/* ---- MOBILE GRID HANDLING ---- */
.cipher-wrap {
  display: flex;
  justify-content: flex-start;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
}

/* Prevent grid from shrinking */
.cipher-grid {
  min-width: max-content;
}

/* Responsive cell sizing */
@media (max-width: 768px) {
  .cipher-grid {
    grid-auto-rows: 36px;
    gap: 4px;
    padding: 10px;
  }

  .cipher-cell {
    width: 36px;
    height: 36px;
    font-size: 15px;
  }
}

@media (max-width: 768px) {
  .cipher-grid {
    grid-auto-rows: 32px;
    gap: 4px;
  }

  .cipher-cell {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
}
/* Center title cleanly on mobile */
@media (max-width: 768px) {
  .cipher-title {
    font-size: 20px;
  }
}

/* Make decoded text slightly bolder for phones */
@media (max-width: 768px) {
  .cipher-cell .decoded {
    font-weight: 800;
  }
}
/* --- Granite page full-width override --- */
.granite-page {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 12px;
  box-sizing: border-box;
}
/* Ensure grid uses available width on mobile */
@media (max-width: 768px) {
  .cipher-wrap {
    width: 100%;
    justify-content: flex-start;
  }
}
.cipher-workspace {
  display: grid;
  grid-template-columns: minmax(210px, 250px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.cipher-stage {
  min-width: 0;
}

.cipher-toolbar {
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 12px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
  position: sticky;
  top: 72px;
}

.tool-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.key-tool-group {
  min-width: 0;
}

.cipher-tool-group {
  min-width: 0;
}

.tool-label {
  color: #aaa;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  padding: 4px;
  background: #101010;
  border: 1px solid #303030;
  border-radius: 9px;
}

.seg-btn {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 7px 10px;
  border-radius: 7px;
  background: transparent;
  color: #ccc;
  border: none;
}

.seg-btn.active {
  background: #2ecc71;
  color: #061108;
}

.cipher-toolbar select,
.cipher-toolbar input {
  width: 100%;
  margin-top: 0;
  min-height: 36px;
  padding: 7px 8px;
}

.inline-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tool-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tool-actions button {
  width: 100%;
  min-width: 0;
  margin-top: 0;
  padding: 8px 10px;
}

.secondary-btn {
  background: #333;
  color: #eee;
}

@media (max-width: 900px) {
  .cipher-workspace {
    grid-template-columns: 1fr;
  }

  .cipher-toolbar {
    position: static;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .segmented-control {
    grid-template-columns: repeat(3, 1fr);
  }
}

.hidden {
  display: none !important;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  box-sizing: border-box;
}

.login-panel {
  width: min(100%, 360px);
  background: #1f1f1f;
  border: 1px solid #2b2b2b;
  border-radius: 12px;
  padding: 22px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
}

.login-panel h1 {
  margin: 0 0 18px 0;
  font-size: 24px;
  text-align: center;
}
