:root {
  --bg: #f6f4ef; --surface: #fff; --ink: #1f2a24; --muted: #6b756f;
  --accent: #2f6b4f; --accent-ink: #fff; --line: #e2ded5;
  --warn: #c98a12; --crit: #b3402f; --ok: #2f6b4f;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #131814; --surface: #1c231e; --ink: #ece9e1; --muted: #98a39c;
    --accent: #5fb98c; --accent-ink: #0d1510; --line: #2b352f; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 0 16px calc(76px + env(safe-area-inset-bottom)); max-width: 720px; margin-inline: auto; }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0 8px; }
h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 8px 0 12px; }
.muted { color: var(--muted); font-size: .85rem; }
.center { text-align: center; }
[hidden] { display: none !important; }

.meter { min-width: 120px; text-align: right; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--ok); transition: width .3s; }
.meter.alerta .bar span { background: var(--warn); }
.meter.critico .bar span { background: var(--crit); }
.meter small { font-size: .72rem; color: var(--muted); }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card-item { background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; cursor: pointer; text-align: left; padding: 0; color: inherit; }
.card-item img, .card-item .noimg { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--line); }
.card-item .meta { padding: 8px 10px 10px; }
.card-item b { display: block; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-item span { font-size: .78rem; color: var(--muted); }

form, fieldset { display: flex; flex-direction: column; gap: 12px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 0 0 14px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px; width: 100%; }
button { font: inherit; border: 0; border-radius: 10px; padding: 12px 16px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; }
button:disabled { opacity: .5; }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.danger { background: var(--crit); color: #fff; }

.photo-pick { position: relative; display: grid; place-items: center; min-height: 180px; margin-bottom: 8px;
  border: 2px dashed var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; cursor: pointer; }
.photo-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-pick img { width: 100%; max-height: 320px; object-fit: contain; }
.photo-pick span { color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font-weight: 500; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-top: 14px; font-size: .9rem; }

nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; justify-content: center;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
nav button { flex: 1; max-width: 220px; background: transparent; color: var(--muted); }
nav button.active { background: var(--accent); color: var(--accent-ink); }

dialog { border: 0; border-radius: 16px; padding: 0; width: min(92vw, 460px); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgb(0 0 0 / .5); }
dialog .body { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
dialog img { width: 100%; max-height: 300px; object-fit: contain; background: var(--line); }
dialog dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: .9rem; }
dialog dt { color: var(--muted); }
dialog dd { margin: 0; }
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; }
#toast.show { opacity: 1; }

#view-outfit { display: flex; flex-direction: column; gap: 12px; }
#view-outfit[hidden] { display: none; }
.chips.quick .chip { font-size: .8rem; padding: 6px 12px; }
.outfit { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.outfit h3 { margin: 0 0 8px; font-size: 1rem; }
.outfit .pieces { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 10px; }
.piece { flex: 0 0 84px; text-align: center; font-size: .72rem; color: var(--muted); }
.piece img, .piece .noimg { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; background: var(--line); display: block; margin-bottom: 4px; }
.outfit p { margin: 6px 0; font-size: .9rem; }
.outfit .falta { color: var(--warn); }

.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.sw { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; padding: 3px 8px 3px 4px; border: 1px solid var(--line); border-radius: 999px; }
.sw i { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--line); display: inline-block; }
.verdict { font-size: .75rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); }
.verdict.conservar { color: var(--ok); }
.verdict.reparar { color: var(--warn); }
.verdict.reemplazar { color: var(--crit); }
.photo-pick.small { min-height: 70px; }
#view-analysis { display: flex; flex-direction: column; gap: 10px; }
#view-analysis[hidden] { display: none; }
nav button { padding-inline: 8px; font-size: .9rem; }
