* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: #f5f4ef;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#chrome { padding: 6px 8px 2px; }

#navrow {
  display: flex;
  align-items: center;
  gap: 4px;
}

button.icon {
  width: 42px;
  height: 42px;
  flex: none;
  border: none;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
}
button.icon:disabled { opacity: 0.3; cursor: default; }
button.icon:not(:disabled):active { background: rgba(0,0,0,0.08); }
button.icon svg { width: 24px; height: 24px; fill: currentColor; }
button.icon.quick { color: #d32f2f; }
button.icon.speak { background: rgba(30,136,229,0.12); }

#strip {
  flex: 1;
  min-width: 60px;
  height: 44px;
  background: rgba(0,0,0,0.05);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  overflow-x: auto;
  cursor: pointer;
  scrollbar-width: none;
}
#strip::-webkit-scrollbar { display: none; }
#strip-hint { color: #888; font-size: 14px; white-space: nowrap; }
.strip-word {
  background: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
}

#set-picker {
  height: 36px;
  border-radius: 8px;
  border: 1px solid #ccc;
  background: #fff;
  font-size: 13px;
  max-width: 110px;
}

#board {
  flex: 1;
  display: grid;
  gap: 6px;
  padding: 6px;
  min-height: 0;
}

.cell {
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 4px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  font-family: inherit;
}
.cell:active { filter: brightness(0.85); }
.cell img {
  flex: 1;
  min-height: 0;
  max-width: 100%;
  object-fit: contain;
}
.cell .lbl {
  font-size: clamp(9px, 1.6vw, 15px);
  font-weight: 600;
  color: rgba(0,0,0,0.82);
  text-align: center;
  line-height: 1.15;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}
.cell.folder { border: 2px solid #3c3c43; }

button.icon.heart { color: #1e88e5; }

#edit-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #d6e6f5;
  border-radius: 8px;
  padding: 6px 12px;
  margin-top: 4px;
  font-size: 13px;
  font-weight: 500;
}
#edit-banner span { flex: 1; }
.banner-done {
  background: #5e35b1;
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 6px 16px;
  font-weight: 600;
  cursor: pointer;
}

.cell.empty {
  background: transparent;
  border: 2px dashed rgba(0,0,0,0.25);
  align-items: center;
  justify-content: center;
}
.cell.empty .plus { width: 22px; height: 22px; fill: #999; }
.cell.move-source { outline: 3px solid #1e88e5; }
.cell.holding { opacity: 0.55; }

/* ---- modals ---- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.modal {
  background: #fdfcfa;
  border-radius: 16px;
  width: min(640px, 100%);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.modal-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.modal-title { flex: 1; font-size: 17px; font-weight: 600; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-body h4 {
  margin: 18px 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  color: #888;
  letter-spacing: 0.04em;
}
.modal-body h4:first-child { margin-top: 0; }

.text-btn {
  background: none;
  border: none;
  color: #5e35b1;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 8px;
}
.text-btn.danger { color: #c62828; }
.primary-btn {
  background: #5e35b1;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.field, .search-input, .pin-input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 15px;
  margin: 4px 0;
  background: #fff;
}
.pin-input { max-width: 200px; font-size: 20px; letter-spacing: 4px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.muted { color: #777; font-size: 13px; }
.muted.small { font-size: 12px; }
.error { color: #c62828; font-size: 13px; min-height: 18px; }
.slider-lbl { width: 120px; font-size: 14px; flex: none; }
.row input[type="range"] { flex: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}
.chip.active { background: #e3f2fd; border-color: #1e88e5; }
.swatch { width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(0,0,0,0.15); }

.preview { display: flex; justify-content: center; margin: 8px 0; }
.preview img { max-height: 100px; max-width: 160px; object-fit: contain; }

.tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.tab {
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}
.tab.active { background: #5e35b1; color: #fff; border-color: #5e35b1; }

.pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.pick-cell {
  border: none;
  background: #fff;
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.pick-cell img { width: 80px; height: 80px; object-fit: contain; }
.pick-lbl {
  font-size: 10px;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-row { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.bar-lbl { width: 110px; font-size: 12px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 14px; }
.bar-fill { display: block; height: 100%; background: #1e88e5; border-radius: 4px; }
.bar-count { font-size: 12px; color: #777; min-width: 24px; text-align: right; }
.word-row { display: flex; justify-content: space-between; font-size: 14px; padding: 2px 0; }

@media (max-width: 640px) {
  #navrow { flex-wrap: wrap; }
  #strip { order: 10; flex-basis: 100%; margin-top: 4px; }
}
