:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --primary: #722f37;
  --primary-soft: #f7eef1;
  --text: #111827;
  --muted: #667085;
  --border: #d0d5dd;
  --green: #15803d;
  --red: #be123c;
  --amber: #b45309;
  --blue: #2563eb;
  --shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
html { max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.4;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.app-header {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 18px 16px 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.brand-lockup {
  flex: 1 1 auto;
  max-width: none;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-height: 92px;
}
.brand-logo-frame {
  flex: 0 0 auto;
  width: 86px;
  height: 86px;
  overflow: hidden;
  border: 1px solid rgba(114, 47, 55, 0.18);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(39, 18, 18, 0.10);
}
.brand-logo-frame img {
  width: 123px;
  height: 123px;
  max-width: none;
  display: block;
  transform: translate(-19px, -8px);
}
.brand-copy {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-width: 0;
}
.app-header h1 {
  flex: 0 0 auto;
  margin: 0;
  min-width: max-content;
  font-size: 31px;
  line-height: 1.06;
  color: var(--primary);
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}
.app-header p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.title-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: nowrap;
}
.language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}
.language-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}
.language-option:hover {
  background: #f8fafc;
  border-color: #eef2f6;
}
.language-option.active {
  background: var(--primary-soft);
  border-color: rgba(114, 47, 55, 0.35);
  box-shadow: inset 0 0 0 1px rgba(114, 47, 55, 0.18);
}
.header-stack {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  justify-content: flex-end;
  margin-left: auto;
}
.header-stat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  min-height: 38px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
  box-shadow: var(--shadow);
}
.header-stat.subtle { color: var(--muted); }

.container {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
}
.app-header > *,
.hero > *,
.card-head > *,
.quiz-layout > *,
.results-grid > *,
.controls-grid > *,
.profile-kpis > *,
.recs-row > *,
.rec-card > * {
  min-width: 0;
}
.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
h2 { margin: 0; font-size: 15px; color: var(--primary); }
h3 { margin: 16px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
h1, h2, h3, p, .header-stat, .badge, .answer-title, .answer-subtitle {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f2f4f7;
  color: #475467;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.badge.good { background: #ecfdf3; color: var(--green); }
.badge.warn { background: #fffaeb; color: var(--amber); }
.badge.bad { background: #fff1f3; color: var(--red); }

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  background: linear-gradient(135deg, #ffffff, #fff7f8);
}
.hero h2 { font-size: 20px; }
.hero p { margin: 6px 0 0; max-width: 760px; color: var(--muted); font-size: 13px; }
.hero-actions {
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 210px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(10px);
}

.btn-generate, .btn-secondary {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.18;
}
.hero-actions .btn-generate,
.hero-actions .btn-secondary {
  width: 100%;
  min-height: 40px;
}
.hero-actions .btn-generate { min-height: 48px; }
.hero-actions .action-quiz-stat {
  width: 100%;
  border-radius: 10px;
  padding: 8px 10px;
  text-align: center;
  line-height: 1.2;
  white-space: normal;
}
.btn-generate { background: var(--primary); color: #fff; }
.btn-secondary { background: #f2f4f7; color: #344054; border: 1px solid var(--border); }
.btn-generate:hover, .btn-secondary:hover { filter: brightness(0.97); }

.quiz-layout {
  display: contents;
}
.quiz-panel {
  order: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.quiz-question {
  padding: 14px;
  background: var(--quiz-bg, var(--card));
  border-color: var(--quiz-border, var(--border));
}
.quiz-panel > .quiz-question:nth-child(1) { --quiz-bg: #fff1f2; --quiz-border: #fecdd3; }
.quiz-panel > .quiz-question:nth-child(2) { --quiz-bg: #fff4ed; --quiz-border: #fed7aa; }
.quiz-panel > .quiz-question:nth-child(3) { --quiz-bg: #fffbeb; --quiz-border: #fde68a; }
.quiz-panel > .quiz-question:nth-child(4) { --quiz-bg: #f7fee7; --quiz-border: #d9f99d; }
.quiz-panel > .quiz-question:nth-child(5) { --quiz-bg: #ecfdf5; --quiz-border: #bbf7d0; }
.quiz-panel > .quiz-question:nth-child(6) { --quiz-bg: #ecfeff; --quiz-border: #a5f3fc; }
.quiz-panel > .quiz-question:nth-child(7) { --quiz-bg: #eff6ff; --quiz-border: #bfdbfe; }
.quiz-panel > .quiz-question:nth-child(8) { --quiz-bg: #f5f3ff; --quiz-border: #ddd6fe; }
.quiz-panel > .quiz-question:nth-child(9) { --quiz-bg: #fdf2f8; --quiz-border: #fbcfe8; }
.quiz-panel > .quiz-question:nth-child(10) { --quiz-bg: #f0fdfa; --quiz-border: #99f6e4; }
.quiz-question-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}
.quiz-question h2 { font-size: 16px; }
.quiz-question p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.question-weight {
  font-size: 11px;
  color: var(--primary);
  font-weight: 900;
  background: var(--primary-soft);
  border-radius: 999px;
  padding: 5px 8px;
}
.answer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}
.answer-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fcfcfd;
  min-height: 118px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: .15s ease;
}
.answer-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.answer-card.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.answer-title { font-size: 14px; font-weight: 900; color: #1d2939; }
.answer-subtitle { color: var(--muted); font-size: 12px; }
.answer-image {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(208, 213, 221, 0.85);
  background: #f8fafc;
  margin-top: auto;
}
.answer-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: auto; }
.tag-pill {
  font-size: 10px;
  color: #344054;
  background: #eef2f6;
  border-radius: 999px;
  padding: 3px 6px;
  font-weight: 700;
}
.answer-card.selected .tag-pill { background: #fff; color: var(--primary); }

.expert-card { order: 2; }
.sticky-summary {
  order: 3;
  position: static;
  top: auto;
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(360px, 1.2fr) minmax(300px, 0.95fr);
  gap: 14px;
  align-items: start;
}
.sticky-summary > * { min-width: 0; }
.sticky-summary > .card-head {
  grid-column: 1;
  grid-row: 1;
}
.sticky-summary > .profile-kpis {
  grid-column: 1;
  grid-row: 2;
}
.sticky-summary > h3:nth-of-type(1) {
  grid-column: 1;
  grid-row: 3;
}
.sticky-summary > .bars {
  grid-column: 1;
  grid-row: 4;
}
.sticky-summary > h3:nth-of-type(2) {
  grid-column: 1;
  grid-row: 5;
}
.sticky-summary > .prob-list {
  grid-column: 1;
  grid-row: 6;
}
.sticky-summary > h3:nth-of-type(3) {
  grid-column: 1;
  grid-row: 7;
}
.sticky-summary > .tag-cloud {
  grid-column: 1;
  grid-row: 8;
}
.sticky-summary > .calc-details {
  grid-column: 2;
  grid-row: 1 / span 8;
  margin-top: 0;
}
.sticky-summary > .profile-radar-block {
  grid-column: 3;
  grid-row: 1 / span 8;
  margin-top: 0;
}
.sticky-summary > h3 { margin-top: 0; }
.profile-kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.profile-kpis div {
  background: #f8fafc;
  border: 1px solid #eef2f6;
  border-radius: 10px;
  padding: 10px;
}
.profile-kpis span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; font-weight: 800; }
.profile-kpis strong { display: block; font-size: 14px; margin-top: 4px; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 95px 1fr 44px; align-items: center; gap: 8px; font-size: 11px; }
.bar-track { height: 9px; border-radius: 999px; background: #eef2f6; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.prob-list { display: flex; flex-direction: column; gap: 7px; }
.prob-group { border: 1px solid #eef2f6; border-radius: 10px; padding: 8px; background: #fcfcfd; }
.prob-group strong { display: block; margin-bottom: 5px; font-size: 11px; color: var(--primary); }
.prob-items { display: flex; flex-wrap: wrap; gap: 5px; }
.prob-item { font-size: 10px; background: #f2f4f7; border-radius: 999px; padding: 3px 6px; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-cloud .tag-pill { background: var(--primary-soft); color: var(--primary); }
.calc-details {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fcfcfd;
  padding: 12px;
}
.calc-details h3 { margin-top: 0; }
.calc-table-wrap {
  overflow-x: auto;
  border: 1px solid #eef2f6;
  border-radius: 10px;
}
.calc-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
  font-size: 10px;
}
.calc-table th,
.calc-table td {
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #eef2f6;
  padding: 7px 8px;
}
.calc-table th {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 9px;
  font-weight: 900;
  background: #f8fafc;
}
.calc-table tr:last-child td { border-bottom: 0; }
.calc-table td:first-child { color: var(--primary); font-weight: 800; }
.calc-table td:nth-child(3) { white-space: nowrap; color: #101828; }

.expert-card { padding: 0; overflow: hidden; }
details summary {
  list-style: none;
  cursor: pointer;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-weight: 900;
  color: var(--primary);
}
details summary::-webkit-details-marker { display: none; }
details summary small { color: var(--muted); font-weight: 600; }
details[open] summary { border-bottom: 1px solid var(--border); }
.controls-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(260px, 1fr);
  gap: 16px;
}
.control-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.control-row label { width: 132px; flex: 0 0 132px; font-size: 11px; color: var(--muted); font-weight: 800; }
.control-row input[type="range"] { flex: 1; accent-color: var(--primary); }
.control-row span { width: 38px; text-align: right; font-size: 11px; color: var(--primary); font-weight: 900; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.field label { font-size: 10px; text-transform: uppercase; color: var(--muted); font-weight: 900; }
input[type="number"], select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px;
  font-size: 12px;
  background: #fff;
}
.form-grid.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sub-panel { background: #f8fafc; border: 1px solid #eef2f6; border-radius: 10px; padding: 10px; margin-top: 8px; }
.hidden { display: none !important; }

.filter-note {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.alert-banner {
  margin: 0 16px 0;
  background: #fffaeb;
  border: 1px solid #fedf89;
  color: #92400e;
  border-radius: 10px;
  padding: 10px;
  font-size: 12px;
  display: none;
}

.results-grid {
  order: 4;
  display: block;
}
.recs-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.rec-card {
  border: 1px solid var(--border);
  border-top: 5px solid var(--primary);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}
.rec-card.exploration { border-top-color: var(--blue); }
.rec-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.rec-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  font-weight: 900;
  color: var(--primary);
  min-height: 36px;
  overflow-wrap: anywhere;
}
.rec-role-badge {
  flex: 0 1 128px;
  justify-content: center;
  max-width: 128px;
  min-height: 0;
  border-radius: 10px;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
}
.rec-card.exploration .rec-name { color: var(--blue); }
.rec-score { font-size: 24px; font-weight: 950; }
.rec-meta { color: var(--muted); font-size: 10px; margin: 6px 0 8px; }
.wine-sensory-profile {
  border: 1px solid #eef2f6;
  border-radius: 10px;
  background: #fcfcfd;
  padding: 8px;
  margin: 8px 0;
}
.wine-sensory-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 900;
  color: var(--primary);
  text-transform: uppercase;
}
.wine-sensory-title small {
  font-size: 9px;
  color: var(--muted);
  text-transform: none;
  font-weight: 700;
}

.legend-target,
.legend-wine {
  display: inline-block;
  vertical-align: middle;
  position: relative;
}
.legend-target {
  width: 2px;
  height: 14px;
  border-radius: 2px;
  background: #111827;
  margin: 0 4px 0 2px;
  transform: translateY(-1px);
}
.legend-wine {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--primary);
  border: 1px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(114,47,55,.25);
  margin: 0 4px 0 2px;
}
.sensory-legend-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin: -1px 0 7px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}
.sensory-legend-row span {
  white-space: normal;
  overflow-wrap: anywhere;
}
.sensory-scale-list { display: flex; flex-direction: column; gap: 5px; }
.sensory-row {
  display: grid;
  grid-template-columns: 62px minmax(72px, 1fr) 70px;
  gap: 6px;
  align-items: center;
  font-size: 10px;
}
.sensory-label { color: #344054; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sensory-scale {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: visible;
}
.sensory-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 999px;
  background: rgba(114, 47, 55, 0.28);
}
.target-marker {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 16px;
  border-radius: 2px;
  background: #111827;
  transform: translateX(-1px);
}
.wine-marker {
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--primary);
  border: 1px solid #ffffff;
  transform: translate(-4px, -50%);
  box-shadow: 0 0 0 1px rgba(114,47,55,.25);
}
.sensory-value {
  color: var(--muted);
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}
.rec-reasons { display: flex; flex-direction: column; gap: 4px; font-size: 11px; }
.reason-line { background: #f8fafc; border-radius: 8px; padding: 5px 7px; display: flex; justify-content: space-between; gap: 10px; }
.reason-line span,
.reason-line strong { min-width: 0; overflow-wrap: anywhere; }
.signature-line {
  align-items: center;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  padding: 7px 8px;
}
.signature-title {
  flex: 0 0 auto;
  color: #344054;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.signature-chips {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 12px;
  line-height: 1;
}
.signature-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 950;
  white-space: nowrap;
}
.signature-chip--color {
  background: #e0f2fe;
  border-color: #38bdf8;
  color: #075985;
}
.signature-chip--sweetness {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #78350f;
}
.signature-chip--acidity {
  background: #dcfce7;
  border-color: #22c55e;
  color: #14532d;
}
.signature-chip--body {
  background: #fce7f3;
  border-color: #ec4899;
  color: #831843;
}
.signature-chip--extra {
  background: #ede9fe;
  border-color: #8b5cf6;
  color: #4c1d95;
}
.wine-data-quality {
  margin-top: 10px;
  padding: 8px 9px;
  border: 1px solid #eef2f6;
  border-left: 4px solid #94a3b8;
  border-radius: 9px;
  background: #fcfcfd;
  color: #344054;
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.wine-data-quality--a { border-left-color: #15803d; }
.wine-data-quality--aminus { border-left-color: #16a34a; }
.wine-data-quality--b { border-left-color: #2563eb; }
.wine-data-quality--cplus { border-left-color: #b45309; }
.wine-data-quality__label {
  font-weight: 800;
  margin-right: 4px;
  color: var(--muted);
}
.wine-data-quality__tier {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #f2f4f7;
  color: #101828;
  font-weight: 900;
  margin-right: 6px;
}
.wine-data-quality__score {
  color: var(--muted);
  margin-left: 4px;
  font-weight: 800;
}
.wine-data-quality__review {
  display: block;
  margin-top: 4px;
  color: var(--amber);
  font-weight: 800;
}
.empty-state { color: var(--muted); padding: 18px; text-align: center; border: 1px dashed var(--border); border-radius: 12px; }
.table-container { overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.contribution-table-wrap { overflow: visible; }
.contribution-card .table-container { overflow: visible; }
.contribution-card table { table-layout: auto; }
.debug-scroll { max-height: 520px; }
.debug-card { order: 5; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th, td { padding: 8px 10px; border-bottom: 1px solid #eef2f6; text-align: left; vertical-align: top; }
th { background: #f8fafc; color: var(--muted); text-transform: uppercase; font-size: 10px; white-space: nowrap; }
tr.selected { background: #f0fdf4; }
tr.exploration-row { background: #eff6ff; }
tr.skipped { opacity: .55; }

@media (max-width: 1180px) {
  .hero-actions {
    top: 18px;
    right: 16px;
    bottom: auto;
    width: 210px;
    flex-direction: column;
  }
  .hero-actions .btn-generate,
  .hero-actions .btn-secondary {
    width: 100%;
  }
  .hero-actions .action-quiz-stat {
    width: 100%;
    flex: 0 0 auto;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  body { padding-bottom: 0; }
}

@media (max-width: 1180px) {
  .results-grid { grid-template-columns: 1fr; }
  .sticky-summary {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 0.95fr);
  }
  .sticky-summary > .card-head,
  .sticky-summary > .profile-kpis,
  .sticky-summary > h3:nth-of-type(1),
  .sticky-summary > .bars,
  .sticky-summary > h3:nth-of-type(2),
  .sticky-summary > .prob-list,
  .sticky-summary > h3:nth-of-type(3),
  .sticky-summary > .tag-cloud {
    grid-column: 1;
  }
  .sticky-summary > .profile-radar-block {
    grid-column: 2;
    grid-row: 1 / span 7;
  }
  .sticky-summary > .calc-details {
    grid-column: 1 / -1;
    grid-row: auto;
  }
  .controls-grid { grid-template-columns: repeat(2, 1fr); }
  .recs-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .app-header {
    max-width: 100%;
    padding: 12px 10px 8px;
    gap: 10px;
  }
  .app-header, .hero, details summary { flex-direction: column; align-items: stretch; }
  .app-header > div,
  .hero > div {
    width: 100%;
    max-width: 100%;
  }
  .brand-lockup {
    flex: 1 1 auto;
    min-height: 66px;
    gap: 10px;
    align-items: center;
  }
  .brand-logo-frame {
    width: 60px;
    height: 60px;
    border-radius: 14px;
  }
  .brand-logo-frame img {
    width: 86px;
    height: 86px;
    transform: translate(-13px, -6px);
  }
  .app-header p,
  .hero p {
    max-width: calc(100dvw - 20px);
  }
  .app-header h1 { font-size: 20px; line-height: 1.15; }
  .app-header p { font-size: 12px; }
  .title-row {
    align-items: center;
    flex-wrap: wrap;
  }
  .language-switcher {
    flex: 0 0 auto;
  }
  .header-stack {
    width: 100%;
    margin-left: 0;
    flex: 1 1 100%;
    flex-wrap: wrap;
    justify-content: stretch;
  }
  .header-stat {
    flex: 1 1 100%;
    width: 100%;
    border-radius: 10px;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .container {
    padding: 0 10px 18px;
    gap: 10px;
  }
  .card {
    border-radius: 12px;
    padding: 12px;
  }
  .hero {
    gap: 10px;
  }
  .hero h2 { font-size: 17px; }
  .hero p { font-size: 12px; }
  .hero-actions {
    top: auto;
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: calc(100dvw - 20px);
    max-width: calc(100dvw - 20px);
    flex-direction: row;
    gap: 8px;
    padding: 8px;
    border-radius: 12px;
  }
  .hero-actions .btn-generate,
  .hero-actions .btn-secondary {
    flex: 1 1 0;
    min-width: 0;
    white-space: normal;
    padding: 10px 8px;
    font-size: 11px;
    min-height: 44px;
  }
  .hero-actions .action-quiz-stat {
    flex: 1.35 1 0;
    min-width: 0;
    padding: 8px 6px;
    font-size: 10px;
  }
  body { padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
  .controls-grid { grid-template-columns: 1fr; }
  .answer-grid { grid-template-columns: 1fr; }
  .sticky-summary {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .sticky-summary > .card-head,
  .sticky-summary > .profile-kpis,
  .sticky-summary > h3,
  .sticky-summary > .bars,
  .sticky-summary > .prob-list,
  .sticky-summary > .tag-cloud,
  .sticky-summary > .calc-details,
  .sticky-summary > .profile-radar-block {
    grid-column: auto;
    grid-row: auto;
  }
  .profile-kpis { grid-template-columns: 1fr; }
  .quiz-layout,
  .results-grid {
    gap: 10px;
  }
  .quiz-question {
    padding: 12px;
  }
  .quiz-question h2 { font-size: 15px; }
  .answer-card {
    min-height: 96px;
    padding: 11px;
  }
  .card-head {
    flex-direction: column;
    align-items: stretch;
  }
  .card-head .badge {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: center;
  }
  .bar-row {
    grid-template-columns: 74px minmax(0, 1fr) 40px;
    gap: 6px;
  }
  .calc-details,
  .profile-radar-block {
    padding: 10px;
  }
  .calc-table-wrap {
    overflow: visible;
    border: 0;
  }
  .calc-table {
    min-width: 0;
    font-size: 10px;
  }
  .calc-table thead {
    display: none;
  }
  .calc-table,
  .calc-table tbody,
  .calc-table tr,
  .calc-table td {
    display: block;
    width: 100%;
  }
  .calc-table tr {
    border: 1px solid #eef2f6;
    border-radius: 10px;
    background: #fff;
    margin-bottom: 8px;
    overflow: hidden;
  }
  .calc-table td {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 8px;
    border-bottom: 1px solid #eef2f6;
    padding: 7px 8px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .calc-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
  }
  .calc-table td:last-child { border-bottom: 0; }
  .radar-chart {
    min-height: 300px;
    padding: 0;
  }
  .radar-chart svg {
    max-width: 330px;
  }
  .recs-row {
    grid-template-columns: 1fr;
  }
  .rec-head {
    flex-direction: column;
  }
  .rec-name {
    min-height: 0;
  }
  .rec-role-badge {
    flex: 0 1 auto;
    max-width: 100%;
    width: 100%;
  }
  .reason-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }
  .signature-line {
    grid-template-columns: 1fr;
  }
  .signature-chips {
    justify-content: flex-start;
  }
  .sensory-row {
    grid-template-columns: 58px minmax(0, 1fr) 64px;
  }
  .calibration-actions {
    align-items: stretch;
    flex-direction: column;
  }
  .calibration-save {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .container { padding-left: 8px; padding-right: 8px; }
  .app-header { padding-left: 8px; padding-right: 8px; }
  .card { padding: 10px; }
  .hero-actions {
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: calc(100dvw - 16px);
    max-width: calc(100dvw - 16px);
  }
  .btn-generate,
  .btn-secondary {
    border-radius: 9px;
  }
  .answer-title { font-size: 13px; }
  .answer-subtitle { font-size: 11px; }
  .profile-kpis div { padding: 9px; }
  .bar-row {
    grid-template-columns: 70px minmax(0, 1fr) 38px;
    font-size: 10px;
  }
  .prob-item,
  .tag-pill {
    font-size: 9px;
  }
  .calc-table td {
    grid-template-columns: 78px minmax(0, 1fr);
  }
  .radar-chart {
    min-height: 276px;
  }
  .radar-chart svg {
    max-width: 292px;
  }
  .sensory-row {
    grid-template-columns: 54px minmax(0, 1fr);
  }
  .calibration-row {
    grid-template-columns: 60px minmax(0, 1fr) 40px;
  }
  .sensory-value {
    grid-column: 2;
    text-align: left;
    white-space: normal;
  }
}


.profile-radar-block {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fcfcfd;
  padding: 12px;
}
.profile-radar-block h3 { margin-top: 0; }
.radar-chart {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 380px;
  overflow: visible;
  padding: 6px 0;
}
.radar-chart svg { width: 100%; max-width: 460px; height: auto; display: block; overflow: visible; }
.radar-ring { fill: none; stroke: #e5e7eb; stroke-width: 1; }
.radar-axis { stroke: #cbd5e1; stroke-width: 1; }
.radar-profile { fill: rgba(114, 47, 55, 0.18); stroke: var(--primary); stroke-width: 2.5; }
.radar-point { fill: var(--primary); stroke: #ffffff; stroke-width: 1.5; }
.radar-label { font-size: 10px; font-weight: 800; fill: #475467; }
.radar-value { font-size: 9px; font-weight: 700; fill: var(--primary); }
.radar-note { margin-top: 6px; color: var(--muted); font-size: 11px; text-align: center; }

@media (max-width: 720px) {
  .profile-radar-block { padding: 10px; }
  .radar-chart {
    min-height: 300px;
    padding: 0;
  }
  .radar-chart svg {
    max-width: 330px;
  }
}

@media (max-width: 430px) {
  .radar-chart {
    min-height: 276px;
  }
  .radar-chart svg {
    max-width: 292px;
  }
}

/* V5.6 layout adjustment: wider debug table and fixed radar label space */
.debug-card {
  overflow: hidden;
}
.debug-card .table-container {
  width: 100%;
  overflow-x: auto;
}
.debug-card table {
  min-width: 1180px;
}
.debug-wine-name {
  min-width: 260px;
}

@media (max-width: 720px) {
  .debug-card {
    padding: 10px;
  }
  .debug-card .card-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
  .debug-scroll {
    max-height: 460px;
  }
}


/* V5.8 price corridor step */
.price-question {
  border-top: 3px solid rgba(114, 47, 55, 0.25);
}
.price-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}
.price-card .price-range {
  display: inline-block;
  margin: 4px 0 6px 0;
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
}
.price-card.selected .price-range {
  color: #ffffff;
}


/* V5.9 feedback and LocalStorage session log */
.feedback-panel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.calibration-panel {
  padding-top: 0;
  border-top: 0;
}
.calibration-panel[open] {
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.calibration-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid rgba(21, 128, 61, 0.28);
  border-radius: 10px;
  background: linear-gradient(180deg, #dcfce7 0%, #bbf7d0 100%);
  color: #14532d;
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-align: center;
  text-transform: uppercase;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72), 0 2px 6px rgba(21, 128, 61, 0.12);
  list-style: none;
}
.calibration-toggle::-webkit-details-marker { display: none; }
.calibration-toggle::after {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 8px;
  border-radius: 999px;
  background: rgba(20, 83, 45, 0.12);
  font-size: 15px;
  line-height: 1;
}
.calibration-panel[open] .calibration-toggle::after {
  content: "–";
}
.calibration-content {
  padding-top: 10px;
}
.feedback-title {
  font-size: 10px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.calibration-note {
  margin: -2px 0 8px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}
.calibration-sliders {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.calibration-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 42px;
  gap: 7px;
  align-items: center;
  font-size: 10px;
}
.calibration-label {
  color: #344054;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.calibration-row input[type="range"] {
  min-width: 0;
  accent-color: var(--primary);
}
.calibration-row strong {
  color: var(--primary);
  font-size: 10px;
  text-align: right;
  white-space: nowrap;
}
.calibration-comment {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 10px;
}
.calibration-comment span {
  color: #344054;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.calibration-comment textarea {
  width: 100%;
  min-height: 74px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  color: var(--text);
  background: #ffffff;
  font: inherit;
  font-size: 12px;
  line-height: 1.35;
}
.calibration-comment textarea:focus {
  outline: 2px solid rgba(21, 128, 61, 0.22);
  border-color: rgba(21, 128, 61, 0.48);
}
.calibration-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.calibration-save {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 8px 10px;
  font-size: 11px;
}
.calibration-save:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.calibration-status {
  min-width: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.feedback-log-card { margin-top: 0; }
.log-note {
  color: var(--muted);
  font-size: 12px;
  margin-top: 0;
}
.log-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.btn-secondary.danger {
  border-color: #fecaca;
  color: #991b1b;
}
.log-preview {
  min-height: 70px;
  max-height: 180px;
  overflow: auto;
  background: #0f172a;
  color: #e5e7eb;
  border-radius: 10px;
  padding: 10px;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
}


/* V5.10 imported JSON log reader */
.log-reader-block {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.log-reader-block h3 {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--primary);
}
.file-input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  font-size: 12px;
  color: #344054;
}
.log-reader-summary {
  margin: 8px 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  font-size: 12px;
  color: #344054;
}
.log-reader-table-wrap {
  max-height: 340px;
}
.log-reader-table {
  min-width: 1120px;
}
.log-reader-table td, .log-reader-table th {
  font-size: 11px;
}
.feedback-positive { color: #027a48; font-weight: 800; }
.feedback-neutral { color: #b54708; font-weight: 800; }
.feedback-negative { color: #b42318; font-weight: 800; }
.feedback-missing { color: #667085; font-weight: 800; }

.btn-generate:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}
