/* Phone-first: everything sized for thumbs on an iPhone. */
* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 16px;
  font-family: -apple-system, system-ui, sans-serif;
  background: #f4f2ef;
  color: #222;
  max-width: 600px;
  margin-inline: auto;
}

header { display: flex; justify-content: space-between; align-items: center; }
h1 { font-size: 1.5rem; margin: 0; }

button {
  font: inherit;
  min-height: 44px; /* Apple's minimum comfortable tap size */
  padding: 0 16px;
  border: 1px solid #ccc;
  border-radius: 10px;
  background: white;
}
button.primary { background: #222; color: white; border-color: #222; }
button.danger { color: #b00020; border-color: #b00020; }
h2 { font-size: 1.2rem; margin: 0 0 12px; }

/* Add form */
#add-form {
  background: white;
  border-radius: 14px;
  padding: 16px;
  margin-top: 16px;
}
fieldset { border: none; padding: 0; margin: 0 0 14px; }
legend { font-weight: 600; margin-bottom: 6px; }

.photo-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  border: 2px dashed #bbb;
  border-radius: 12px;
  margin-bottom: 16px;
  color: #666;
}
.photo-pick input { display: none; }
#preview { max-height: 200px; max-width: 100%; }

/* Tag chips: radio/checkbox hidden, the pill shows the state */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { display: none; }
.chip span {
  display: inline-block;
  padding: 10px 14px;
  border: 1px solid #ccc;
  border-radius: 999px;
}
.chip input:checked + span { background: #222; color: white; border-color: #222; }

.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.row input {
  width: 100%;
  font-size: 16px; /* 16px stops iPhone Safari from zooming in on tap */
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  margin-top: 4px;
}
.row + .row { margin-top: 16px; }
.error { color: #b00020; min-height: 1em; }

/* Filter bar: 2 x 2 dropdowns */
#filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
#filters select {
  font-size: 16px; /* stops iPhone zoom */
  min-height: 44px;
  padding: 0 8px;
  border: 1px solid #ccc;
  border-radius: 10px;
  background: white;
}
#filters select.active { border-color: #222; border-width: 2px; }
#clear-filters { margin-top: 8px; width: 100%; }

/* Closet grid: 3 tiles across */
#count { color: #666; }
#grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  height: auto;
  font-size: 0.8rem;
}
.tile img { width: 100%; aspect-ratio: 1; object-fit: contain; }

/* Details popup */
dialog { border: none; border-radius: 14px; width: min(90vw, 400px); }
#details-photo { width: 100%; max-height: 300px; object-fit: contain; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; }
dt { font-weight: 600; }
dd { margin: 0; }

#outfits-section { margin-top: 32px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading h2 { margin: 0; }
#outfit-form, .outfit-card { background: white; border-radius: 14px; padding: 16px; margin-top: 16px; }
#outfit-name { width: 100%; font: inherit; font-size: 16px; padding: 12px; border: 1px solid #ccc; border-radius: 8px; margin-top: 6px; }
.piece-row { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 12px; }
.piece-choice { flex: 0 0 104px; }
.piece-choice[aria-pressed="true"] { outline: 3px solid #222; outline-offset: -3px; background: #eae7e1; }
.outfit-card h3 { margin: 0 0 12px; overflow-wrap: anywhere; }
.outfit-photos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.outfit-photos img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.missing-piece { font-size: 0.85rem; color: #b00020; align-self: center; }
.slot-empty { margin: 4px 0 12px; color: #666; }
button:disabled { opacity: 0.6; }

#backup-section { margin-top: 32px; }
#backup-section p { line-height: 1.5; }
#backup-status { overflow-wrap: anywhere; }

#install-section { margin-top: 32px; }
#install-section p { line-height: 1.5; }
