:root {
  --bg: #FAF7F1;
  --bg2: #F1EAE0;
  --text: #2E2A25;
  --accent: #C0653B;
  --accent-dark: #A85430;
  --muted: #7d756b;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: 4rem;
}

h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; letter-spacing: -0.3px; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.7rem 1rem; gap: 0.5rem; flex-wrap: wrap;
}
.top h1 { font-size: 1.45rem; margin: 0; }
nav { display: flex; gap: 0.4rem; }
.navbtn {
  border: 0; background: transparent; padding: 0.45rem 0.9rem;
  border-radius: 999px; font-size: 0.95rem; color: var(--text); cursor: pointer;
}
.navbtn.active { background: var(--bg2); font-weight: 600; }

.scene { max-width: 640px; margin: 0 auto; padding: 0.5rem 1rem; }
.hidden { display: none !important; }

.card {
  background: var(--bg2); border-radius: var(--radius);
  padding: 1.2rem; display: flex; flex-direction: column; gap: 0.8rem;
  margin-top: 2rem;
}

input[type="text"], input[type="password"], select {
  width: 100%; padding: 0.7rem 0.9rem; border: 1px solid #ddd2c2;
  border-radius: 10px; background: #fff; font-size: 1rem; color: var(--text);
}

button { font-size: 1rem; cursor: pointer; }
.primary {
  background: var(--accent); color: #fff; border: 0;
  padding: 0.8rem 1.2rem; border-radius: 12px; font-weight: 600;
}
.primary:active { background: var(--accent-dark); }
.primary:disabled { opacity: 0.45; cursor: default; }
.primary.big { width: 100%; padding: 1rem; font-size: 1.1rem; margin-top: 0.8rem; }
.ghost {
  background: var(--bg2); border: 0; color: var(--text);
  padding: 0.6rem 1rem; border-radius: 10px;
}

.photobox {
  display: block; background: var(--bg2); border: 2px dashed #d8c9b4;
  border-radius: var(--radius); min-height: 11rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative; margin-top: 0.4rem;
}
#photoPlaceholder { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; padding: 1.5rem; text-align: center; }
#photoPlaceholder .big { font-size: 2.2rem; }
#photoPreview { width: 100%; display: block; }

.field { margin-top: 1rem; }
.label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.4rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.pills { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.pill {
  border: 1px solid #ddd2c2; background: #fff; color: var(--text);
  border-radius: 999px; padding: 0.45rem 0.95rem; font-size: 0.95rem;
}
.pill.sel { background: var(--accent); border-color: var(--accent); color: #fff; }

.advanced { margin-top: 1.2rem; background: var(--bg2); border-radius: var(--radius); padding: 0.8rem 1rem; }
.advanced summary { cursor: pointer; font-weight: 600; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.error { color: #a33; background: #fae8e4; padding: 0.7rem 1rem; border-radius: 10px; }

.status { background: var(--bg2); border-radius: 10px; padding: 0.6rem 1rem; margin: 0.8rem 0; font-size: 0.95rem; }

.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; margin-top: 1rem; }
.duo figure { margin: 0; }
.duo figcaption { font-weight: 600; margin-bottom: 0.3rem; }
.duo img { width: 100%; border-radius: 10px; display: block; }
@media (max-width: 480px) { .duo { grid-template-columns: 1fr; } }

/* Comparador */
#compareWrap { margin-top: 1.4rem; }
#ba { position: relative; width: 100%; overflow: hidden; border-radius: 12px; user-select: none; line-height: 0; }
#ba > img { display: block; width: 100%; }
#baTop { position: absolute; top: 0; left: 0; height: 100%; width: 50%; overflow: hidden; }
#baTop img { display: block; height: 100%; max-width: none; }
#baBar { position: absolute; top: 0; left: 50%; width: 3px; height: 100%; background: #fff; box-shadow: 0 0 6px rgba(0,0,0,.45); }
#baKnob {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 36px; height: 36px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 6px rgba(0,0,0,.4); display: flex; align-items: center;
  justify-content: center; font-size: 15px; color: var(--text); line-height: 1;
}
#ba .tag {
  position: absolute; top: 10px; background: rgba(46,42,37,.8); color: var(--bg);
  padding: 3px 9px; border-radius: 6px; font-size: 12px; line-height: 1.4;
}
#ba .tag.left { left: 10px; }
#ba .tag.right { right: 10px; }
#baRange { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: ew-resize; margin: 0; }

.row { display: flex; gap: 0.6rem; margin-top: 0.7rem; flex-wrap: wrap; }
#refineBox { display: flex; gap: 0.5rem; margin-top: 0.6rem; }
#refineBox input { flex: 1; }

.analysis { margin-top: 1.2rem; overflow-x: auto; }
.analysis h2 { font-size: 1.25rem; margin: 1.2rem 0 0.4rem; }
.analysis table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.analysis th, .analysis td { border: 1px solid #e4dacb; padding: 0.45rem 0.6rem; text-align: left; }
.analysis th { background: var(--bg2); }
.analysis a { color: var(--accent); }
.cursor::after { content: '▋'; animation: blink 1s infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }

#histList { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 1rem; }
.histItem {
  display: flex; gap: 0.8rem; background: var(--bg2); border-radius: var(--radius);
  padding: 0.6rem; align-items: center; cursor: pointer; border: 0; text-align: left;
}
.histItem img { width: 72px; height: 54px; object-fit: cover; border-radius: 8px; }
.histItem .when { font-weight: 600; }
