/* ---------- Modal ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 45, 51, 0.45);
  backdrop-filter: blur(3px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.overlay[hidden] { display: none; }

.modal {
  background: #fff;
  border-radius: 18px;
  padding: 24px;
  width: 100%;
  max-width: 460px;
  max-height: 92vh;    /* fallback */
  max-height: 92dvh;   /* fits within iOS Safari's visible area, toolbars included */
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal h2 { margin: 0 0 16px; font-size: 21px; font-weight: 900; }

.field { display: block; margin-bottom: 14px; }
.field[hidden] { display: none; }

.field > span {
  display: block;
  font-size: 12.5px;
  font-weight: 800;
  margin-bottom: 5px;
  color: var(--ink);
}

.field small { font-weight: 600; color: var(--ink-soft); }

.field input,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  outline: none;
  background: #fff;
  transition: border-color 0.15s;
  resize: vertical;
}

.field input:focus,
.field textarea:focus { border-color: var(--accent); }

.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 42px; }
.pass-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  border: none;
  background: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 6px;
  border-radius: 8px;
}

.addr-field { position: relative; }

#addrResults {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 10;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 180px;
  overflow-y: auto;
}

#addrResults .addr-option {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: 9px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}

#addrResults .addr-option:last-child { border-bottom: none; }
#addrResults .addr-option:hover { background: var(--bg-soft); }

.loc-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -4px 0 14px;
}

.coords { font-size: 12px; color: var(--ink-soft); font-weight: 700; }
.coords.set { color: #16a34a; }

.cat-picker { display: flex; flex-wrap: wrap; gap: 6px; }

.cat-option {
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s;
}

.cat-option.active {
  border-color: var(--c, var(--accent));
  background: var(--c, var(--accent));
  color: #fff;
}

.field-row { display: flex; gap: 20px; }
.field-row .field { flex: 1; min-width: 0; }

.price-picker { display: flex; gap: 6px; }

.price-option {
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 7px 13px;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s;
}

.price-option:hover { border-color: #16a34a; color: #16a34a; }

.price-option.active {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}

.price { color: #16a34a; font-weight: 800; }

.stars { display: flex; gap: 2px; }

.stars button {
  border: none;
  background: none;
  font-size: 26px;
  cursor: pointer;
  color: #d6d3d1;
  padding: 0 2px;
  transition: transform 0.1s;
}

.stars button:hover { transform: scale(1.15); }
.stars button.lit { color: #f5a623; }

.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
}

.modal-actions .spacer { flex: 1; }

/* ---------- Category manager ---------- */

.chip-manage { border-style: dashed; }

#catList {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  max-height: 290px;
  overflow-y: auto;
}

.cat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
}

.cat-row:last-child { border-bottom: none; }

.cat-swatch {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  background: var(--c, var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5);
}

.cat-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  white-space: nowrap;
}

.cat-icon-btn,
.cat-del {
  border: none;
  background: none;
  width: 28px;
  min-width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 15px;
  color: var(--ink-soft);
  cursor: pointer;
}

.cat-del:hover { background: #fef2f2; color: #dc2626; }
.cat-edit:hover { background: var(--bg-soft); color: var(--accent); }
.cat-save { color: #16a34a; font-weight: 800; }
.cat-save:hover { background: #f0fdf4; }
.cat-cancel:hover { background: var(--bg-soft); color: var(--ink); }

.cat-row-editing .cat-edit-name {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  outline: none;
}

.cat-row-editing .cat-edit-name:focus { border-color: var(--accent); }

.cat-row-editing input[type="color"] {
  width: 36px;
  min-width: 36px;
  height: 34px;
  padding: 3px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.cat-add-row { display: flex; align-items: center; gap: 8px; }

.cat-add-row input {
  padding: 9px 10px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  outline: none;
  background: #fff;
}

.cat-add-row input:focus { border-color: var(--accent); }
.cat-add-row #cLabel { flex: 1; min-width: 0; }

.emoji-wrap { position: relative; }

#cEmojiBtn {
  width: 44px;
  height: 40px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 18px;
  cursor: pointer;
  transition: border-color 0.15s;
}

#cEmojiBtn:hover { border-color: var(--accent); }

#emojiPop {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 30;
  width: 272px;
  max-height: 250px;
  overflow-y: auto;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px;
}

#emojiPop[hidden] { display: none; }

.emoji-sec {
  font-size: 11px;
  font-weight: 800;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 8px 0 4px;
}

.emoji-sec:first-child { margin-top: 0; }

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

.emoji-grid button {
  border: none;
  background: none;
  font-size: 18px;
  padding: 4px 0;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1.2;
}

.emoji-grid button:hover { background: var(--bg-soft); }

.cat-add-row input[type="color"] {
  width: 44px;
  height: 40px;
  padding: 4px;
  cursor: pointer;
}

