:root {
  color-scheme: light;
  --ink: #2d1a20;
  --muted: #8a7566;
  --line: #e6dccd;
  --surface: #ffffff;
  --canvas: #faf5ec;
  --wine: #7c2141;
  --wine-deep: #571731;
  --gold: #c99b3f;
  --green: #3f8f5f;
  --blue: #315c82;
  --shadow: 0 14px 40px rgba(87, 23, 49, 0.10);
  --shadow-soft: 0 6px 18px rgba(87, 23, 49, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

body.modal-open { overflow: hidden; }

button, input, select { font: inherit; }

/* ------------------------------------------------------------------ hero */

.hero {
  background:
    radial-gradient(1100px 320px at 15% -60%, rgba(255, 255, 255, 0.16), transparent),
    radial-gradient(900px 420px at 90% 140%, rgba(201, 155, 63, 0.25), transparent),
    linear-gradient(120deg, var(--wine-deep), var(--wine) 55%, #93395a);
  color: #fdf6ee;
  padding: 26px 30px;
}

.hero-inner {
  display: flex;
  align-items: center;
  gap: 26px;
  flex-wrap: wrap;
  max-width: 1460px;
  margin: 0 auto;
}

.brand { display: flex; align-items: center; gap: 15px; }

.brand-logo {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  font-size: 30px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 16px;
}

.brand h1 { margin: 0; font-size: 1.6rem; letter-spacing: 0.2px; }
.brand p { margin: 4px 0 0; color: #ecd3c2; font-size: 0.95rem; }

.hero-fruit {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-left: auto;
  padding: 10px 20px 10px 12px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  backdrop-filter: blur(4px);
}

.hero-emoji {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  font-size: 26px;
  background: #fdf6ee;
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px var(--fruit, #c99b3f);
}

.hero-fruit-text { display: grid; line-height: 1.25; }
.hero-fruit-text strong { font-size: 1.05rem; }
.hero-fruit-text em { font-style: normal; color: #ecd3c2; font-size: 0.85rem; }

.source-pill {
  padding: 9px 16px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.14);
  color: #ecd3c2;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* ------------------------------------------------------------- workspace */

.workspace {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 26px;
  padding: 26px;
  max-width: 1460px;
  margin: 0 auto;
}

.controls {
  position: sticky;
  top: 20px;
  align-self: start;
  display: grid;
  gap: 15px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-title {
  margin: 0 0 2px;
  font-size: 1.05rem;
  color: var(--wine);
}

.field { display: grid; gap: 7px; min-width: 0; position: relative; }

.field span,
.segmented legend,
.profile-chip span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--wine);
  box-shadow: 0 0 0 3px rgba(124, 33, 65, 0.14);
}

.field small {
  position: absolute;
  right: 12px;
  bottom: 12px;
  color: var(--muted);
  pointer-events: none;
}

.fruit-profile { display: grid; gap: 8px; }

.profile-chip {
  display: grid;
  gap: 2px;
  padding: 9px 13px;
  background: #fbf3e6;
  border: 1px solid #f0e2c9;
  border-radius: 12px;
}

.profile-chip strong { font-size: 0.9rem; font-weight: 650; }

.input-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.segmented {
  border: 0;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segmented legend { grid-column: 1 / -1; margin-bottom: 2px; }

.segmented label { display: contents; }

.segmented input { position: absolute; opacity: 0; pointer-events: none; }

.segmented span {
  display: grid;
  place-items: center;
  min-height: 40px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.2s ease;
}

.segmented input:checked + span {
  background: var(--wine);
  border-color: var(--wine);
  color: #fff;
}

.primary-button {
  min-height: 48px;
  border: 0;
  border-radius: 13px;
  background: linear-gradient(120deg, var(--wine-deep), var(--wine));
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(124, 33, 65, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.primary-button:hover { transform: translateY(-1px); box-shadow: 0 11px 24px rgba(124, 33, 65, 0.36); }
.primary-button:disabled { opacity: 0.6; cursor: wait; transform: none; }

.status { margin: 0; min-height: 1.2em; color: #b3452f; font-size: 0.88rem; }

/* --------------------------------------------------------------- results */

.results { display: grid; gap: 22px; align-content: start; }

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.title-row h2 { margin: 0; font-size: 1.7rem; color: var(--wine-deep); }
.title-row p { margin: 6px 0 0; color: var(--muted); }

.volume-badge {
  display: grid;
  justify-items: end;
  gap: 2px;
  padding: 13px 22px;
  border-radius: 16px;
  background: linear-gradient(120deg, var(--wine-deep), var(--wine));
  color: #fff;
  box-shadow: var(--shadow-soft);
  text-align: right;
}

.volume-badge span { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.6px; color: #ecd3c2; }
.volume-badge strong { font-size: 1.5rem; line-height: 1; }
.volume-badge small { color: #ecd3c2; font-size: 0.8rem; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.metric-card {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
}

.metric-icon { font-size: 1.25rem; }
.metric-label { color: var(--muted); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
.metric-card strong { font-size: 1.12rem; }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.section-heading h3 { margin: 0; font-size: 1.2rem; color: var(--wine-deep); }
.section-heading span { color: var(--muted); font-size: 0.85rem; }

/* --------------------------------------------------------------- journey */

.journey-section {
  padding: 22px;
  background:
    radial-gradient(700px 200px at 100% 0%, rgba(201, 155, 63, 0.10), transparent),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.play-all {
  border: 0;
  border-radius: 999px;
  padding: 11px 22px;
  background: linear-gradient(120deg, var(--wine-deep), var(--wine));
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(124, 33, 65, 0.28);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.play-all:hover { transform: translateY(-1px); box-shadow: 0 11px 24px rgba(124, 33, 65, 0.36); }

.journey {
  --track: #ecdfc8;
  list-style: none;
  margin: 0;
  padding: 6px 0 2px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 14px;
}

.journey-card {
  position: relative;
  display: grid;
  justify-items: start;
  gap: 6px;
  width: 100%;
  padding: 15px 15px 13px;
  text-align: left;
  background: #fffdf8;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.journey-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent, var(--wine));
  box-shadow: 0 14px 26px rgba(87, 23, 49, 0.14);
}

.journey-num {
  position: absolute;
  top: -9px;
  left: -7px;
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: var(--accent, var(--wine));
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  box-shadow: 0 4px 9px rgba(87, 23, 49, 0.3);
}

.journey-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  color: var(--accent, var(--wine));
  background: color-mix(in srgb, var(--accent-soft, #f2ddc9) 34%, #ffffff);
  border: 1px solid color-mix(in srgb, var(--accent, #7c2141) 25%, #ffffff);
}

.journey-icon svg { width: 30px; height: 30px; }

.journey-title { font-weight: 750; font-size: 0.95rem; line-height: 1.2; }
.journey-sub { color: var(--muted); font-size: 0.78rem; }

.journey-play {
  margin-top: 3px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent, var(--wine));
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.journey-card:hover .journey-play { opacity: 1; transform: none; }

.process-balance {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding: 13px 16px;
  background: #fbf3e6;
  border: 1px dashed #e3cfa8;
  border-radius: 14px;
}

.balance-item { display: grid; justify-items: center; gap: 1px; }
.balance-item span { color: var(--muted); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
.balance-item strong { font-size: 1rem; }
.balance-arrow { color: #cdb488; font-weight: 800; }

/* ------------------------------------------------------------ book notes */

.book-notes {
  padding: 18px 22px;
  background: #fdf9ef;
  border: 1px solid #eadfc4;
  border-left: 5px solid var(--gold);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
}

.book-head { display: flex; gap: 12px; align-items: center; }
.book-icon { font-size: 1.5rem; }
.book-head strong { display: block; }
.book-head small { color: var(--muted); }

.book-notes ul { margin: 12px 0 0; padding-left: 20px; display: grid; gap: 5px; }
.book-notes li { color: #5c4a3a; font-size: 0.92rem; }
.book-standard { margin: 10px 0 0; color: var(--muted); font-size: 0.92rem; }

/* ----------------------------------------------------------------- bands */

.band {
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }

thead th {
  text-align: left;
  padding: 9px 12px;
  color: var(--muted);
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--line);
}

tbody td { padding: 11px 12px; border-bottom: 1px solid #f1e8d8; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fdf8ee; }

/* ----------------------------------------------------------------- modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(45, 26, 32, 0.55);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.25s ease;
}

.modal-card {
  width: min(1120px, 100%);
  max-height: min(94vh, 860px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  background: #fdfaf4;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 40px 90px rgba(20, 8, 12, 0.45);
  transform: translateY(14px) scale(0.98);
  transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

.modal-backdrop.open .modal-card { transform: none; }

.modal-head {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 24px;
  background: linear-gradient(120deg, var(--wine-deep), var(--accent, var(--wine)));
  color: #fdf6ee;
}

.modal-step-num {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #ecd3c2;
}

.modal-head h2 { margin: 2px 0 0; font-size: 1.35rem; }
.modal-head p { margin: 3px 0 0; color: #ecd3c2; font-size: 0.88rem; }

.modal-fruit-chip {
  margin-left: auto;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.92rem;
  white-space: nowrap;
}

.modal-close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.modal-close:hover { background: rgba(255, 255, 255, 0.3); }

.modal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr);
  gap: 0;
  min-height: 0;
  overflow: auto;
}

.modal-grid > * { min-width: 0; }

.scene-holder {
  display: grid;
  grid-template-rows: 1fr auto;
  min-width: 0;
  overflow: hidden;
  padding: 18px 10px 14px 20px;
}

.scene-box {
  /* Llena su celda del grid (1fr) sin forzar un alto minimo: en ventanas bajas se
     achica en vez de desbordar sobre los controles. El SVG (preserveAspectRatio
     "meet") se escala solo dentro sin deformarse. */
  min-height: 0;
  height: 100%;
  width: 100%;
  max-height: 480px;
}

.scene-controls {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 6px 0;
}

.ctl {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--wine-deep);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.18s ease;
}

.ctl:hover { border-color: var(--wine); background: #fdf3f0; }

.ctl-play {
  width: 48px;
  height: 48px;
  background: var(--wine);
  border-color: var(--wine);
  color: #fff;
  font-size: 1.05rem;
}

.ctl-play:hover { background: var(--wine-deep); color: #fff; }

.beat-dots { display: flex; gap: 7px; margin: 0 4px; }

.beat-dots i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #e3d5bd;
  cursor: pointer;
  transition: all 0.2s ease;
}

.beat-dots i.on { background: var(--wine); transform: scale(1.15); }

.modal-aside {
  position: relative;
  background: #fdfaf4;
  display: grid;
  gap: 15px;
  align-content: start;
  padding: 20px 22px 18px 16px;
  border-left: 1px solid #f0e6d2;
  overflow-y: auto;
}

.step-summary { margin: 0; color: #5c4a3a; font-size: 0.93rem; line-height: 1.5; overflow-wrap: anywhere; }

.substeps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 3px;
}

.substeps li {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 8px 11px;
  border-radius: 11px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
  transition: all 0.25s ease;
}

.substeps li:hover { background: #f6eeda; }

.substeps li i {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 50%;
  border: 2px solid #d8c8a8;
  position: relative;
  transition: all 0.25s ease;
}

.substeps li.now {
  background: #fbeee6;
  color: var(--ink);
  font-weight: 600;
}

.substeps li.now i { border-color: var(--wine); box-shadow: inset 0 0 0 4px #fff, inset 0 0 0 12px var(--wine); }

.substeps li.done { color: #6d5c4c; }

.substeps li.done i {
  border-color: var(--green);
  background: var(--green);
}

.substeps li.done i::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
}

.step-data {
  margin: 0;
  display: grid;
  gap: 7px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 13px;
}

.step-data div { display: flex; justify-content: space-between; gap: 12px; }
.step-data dt { color: var(--muted); font-size: 0.83rem; }
.step-data dd { margin: 0; font-weight: 700; font-size: 0.86rem; text-align: right; }

.modal-foot {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 13px 22px;
  border-top: 1px solid #f0e6d2;
  background: #fbf6ec;
}

.step-nav {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  background: #fff;
  color: var(--wine-deep);
  font-weight: 650;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.18s ease;
}

.step-nav:hover:not(:disabled) { border-color: var(--wine); background: #fdf3f0; }
.step-nav:disabled { opacity: 0.35; cursor: default; }
.step-nav.next { margin-left: auto; }

.step-progress { display: flex; gap: 5px; margin: 0 auto; flex-wrap: wrap; justify-content: center; min-width: 0; }

.step-progress i {
  width: 20px;
  height: 6px;
  border-radius: 3px;
  background: #e3d5bd;
  transition: background 0.2s ease;
}

.step-progress i.done { background: #c9a86a; }
.step-progress i.now { background: var(--wine); }

/* ------------------------------------------------------------ responsive */

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 1fr; }
  .controls { position: static; }
  .modal-grid { grid-template-columns: 1fr; }
  .modal-aside { border-left: 0; border-top: 1px solid #f0e6d2; }
  .scene-holder { padding: 14px 14px 8px; }
}

@media (max-width: 720px) {
  .hero { padding: 20px 18px; }
  .hero-fruit { margin-left: 0; }
  .source-pill { display: none; }
  .workspace { padding: 16px; gap: 16px; }
  .journey { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .modal-backdrop { padding: 0; }
  .modal-card { max-height: 100vh; height: 100%; border-radius: 0; }
  .modal-head { flex-wrap: wrap; gap: 10px; }
  .modal-fruit-chip { order: 3; }
  .step-nav { max-width: 130px; }
  .step-progress i { width: 12px; height: 5px; }
  .scene-box { min-height: 230px; }
}
